aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-02-15 15:39:16 +0100
committerjpbruyere <jp.bruyere@hotmail.com>2016-02-15 15:39:16 +0100
commit0bba9f0c7fb86e3af67f7ce8a0f42f87b914976c (patch)
tree2dec4541ef1dc2c37baf99da77dd088a15d04826 /src
parent1a1b87d5505bd98321dfcab4fb00da3ee5767a1c (diff)
Added Hoverable prop to GraphicObject, still have problem in tabview when hover another tab, content is also hover
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs16
-rw-r--r--src/GraphicObjects/Group.cs10
-rw-r--r--src/GraphicObjects/PrivateContainer.cs10
-rw-r--r--src/GraphicObjects/TabItem.cs38
-rw-r--r--src/GraphicObjects/TabView.cs2
5 files changed, 53 insertions, 23 deletions
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;
}
}
+ /// <summary>
+ /// used to handle mouse hover in children instead of the whole container
+ /// </summary>
+ [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 ());
}
}
}