From: jpbruyere Date: Mon, 15 Feb 2016 14:39:16 +0000 (+0100) Subject: Added Hoverable prop to GraphicObject, still have problem in tabview when hover anoth... X-Git-Tag: v0.4~127^2~17 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0bba9f0c7fb86e3af67f7ce8a0f42f87b914976c;p=jp%2Fcrow.git Added Hoverable prop to GraphicObject, still have problem in tabview when hover another tab, content is also hover --- diff --git a/Templates/TabItem.crow b/Templates/TabItem.crow index 6f8bfe8e..8026c216 100644 --- a/Templates/TabItem.crow +++ b/Templates/TabItem.crow @@ -1,5 +1,5 @@  - diff --git a/Tests/Interfaces/testTabView.crow b/Tests/Interfaces/testTabView.crow index 0e2d5658..5edad7a2 100644 --- a/Tests/Interfaces/testTabView.crow +++ b/Tests/Interfaces/testTabView.crow @@ -1,15 +1,44 @@  - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 02e5c863..d7585d58 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -69,6 +69,7 @@ namespace Crow double _cornerRadius = 0; int _margin = 0; bool _focusable = false; + bool hoverable = true; bool _hasFocus = false; bool _isActive = false; bool _mouseRepeat; @@ -272,6 +273,19 @@ namespace Crow Bounds.Width = Bounds.Height = -1; } } + /// + /// used to handle mouse hover in children instead of the whole container + /// + [XmlAttributeAttribute()][DefaultValue(true)] + public virtual bool Hoverable { + get { return hoverable; } + set { + if (hoverable == value) + return; + hoverable = value; + NotifyValueChanged ("Hoverable", hoverable); + } + } [XmlAttributeAttribute()][DefaultValue(false)] public virtual bool Focusable { get { return _focusable; } @@ -916,7 +930,7 @@ namespace Crow if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) { Scroller scr = Parent as Scroller; if (scr == null) - return true; + return Hoverable; return scr.MouseIsIn (scr.savedMousePos); } return false; diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 12d8c705..68c92e2a 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -268,6 +268,16 @@ namespace Crow #region Mouse handling + public override bool MouseIsIn (Point m) + { + if (Hoverable) + return base.MouseIsIn (m); + for (int i = Children.Count - 1; i >= 0; i--) { + if (Children[i].MouseIsIn(m)) + return true; + } + return false; + } public override void checkHoverWidget (MouseMoveEventArgs e) { if (HostContainer.hoverWidget != this) { diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 5a680da0..7bc62cb8 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -225,12 +225,18 @@ namespace Crow #endregion #region Mouse handling + public override bool MouseIsIn (Point m) + { + if (Hoverable || child == null) + return base.MouseIsIn (m); + return child.MouseIsIn (m); + } public override void checkHoverWidget (MouseMoveEventArgs e) { base.checkHoverWidget (e); if (child != null) - if (child.MouseIsIn (e.Position)) - child.checkHoverWidget (e); + if (child.MouseIsIn (e.Position)) + child.checkHoverWidget (e); } #endregion diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 3ecce217..f54f4fc5 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -95,25 +95,25 @@ namespace Crow NotifyValueChanged ("Caption", caption); } } - public override bool MouseIsIn (Point m) - { - if (!Visible) - return false; - - Debug.WriteLine ("Mouse Testing " + this.ToString ()); - - if (TabTitle.MouseIsIn (m)){ - Debug.WriteLine ("Mouse is in title of " + this.ToString ()); - return true; - } - if (Content.MouseIsIn (m)){ - Debug.WriteLine ("Mouse is in content of " + this.ToString ()); - return true; - } - - Debug.WriteLine ("Mouse is not in " + this.ToString ()); - return false; - } +// public override bool MouseIsIn (Point m) +// { +// if (!Visible) +// return false; +// +// Debug.WriteLine ("Mouse Testing " + this.ToString ()); +// +// if (TabTitle.MouseIsIn (m)){ +// Debug.WriteLine ("Mouse is in title of " + this.ToString ()); +// return true; +// } +// if (Content.MouseIsIn (m)){ +// Debug.WriteLine ("Mouse is in content of " + this.ToString ()); +// return true; +// } +// +// Debug.WriteLine ("Mouse is not in " + this.ToString ()); +// return false; +// } protected override void onDraw (Cairo.Context gr) { int spacing = (Parent as TabView).Spacing; diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index ab780673..21247343 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -73,6 +73,7 @@ namespace Crow return; selectedTab = value; NotifyValueChanged ("SelectedTab", selectedTab); + Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ()); registerForGraphicUpdate (); } } @@ -187,7 +188,6 @@ namespace Crow void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e) { SelectedTab = Children.IndexOf (sender as GraphicObject); - Debug.WriteLine ("selected tab: " + (selectedTab + 1).ToString ()); } } }