aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-31 12:26:16 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-09-01 12:44:39 +0200
commit8d1e0c98e1efac4f9ee133634251a48fa6547ce6 (patch)
tree3553d3999ae82e16936cbb07d51067559affc38c /src
parente68f66a334bd37c60416615d8314a62dd9d05740 (diff)
debug mouse leave, move recursive test back into interface instead of go.MouseLeave
Menu IsOpen handling MenuItem Open and Close events
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs11
-rw-r--r--src/GraphicObjects/Menu.cs16
-rw-r--r--src/GraphicObjects/MenuItem.cs43
-rw-r--r--src/GraphicObjects/Popper.cs36
-rw-r--r--src/GraphicObjects/TemplatedContainer.cs17
-rw-r--r--src/GraphicObjects/TemplatedGroup.cs2
-rw-r--r--src/Interface.cs22
7 files changed, 110 insertions, 37 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index f5b19bb0..6572ba52 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -1176,17 +1176,6 @@ namespace Crow
Debug.WriteLine("MouseLeave => " + this.ToString());
#endif
MouseLeave.Raise (this, e);
-
- GraphicObject p = Parent as GraphicObject;
- CurrentInterface.HoverWidget = p;
-
- if (p == null)
- return;
-
- if (p.MouseIsIn (e.Position)&&e!=null)
- p.checkHoverWidget (e);
- else
- p.onMouseLeave (sender, e);
}
#endregion
diff --git a/src/GraphicObjects/Menu.cs b/src/GraphicObjects/Menu.cs
index f3759c68..765925e9 100644
--- a/src/GraphicObjects/Menu.cs
+++ b/src/GraphicObjects/Menu.cs
@@ -38,6 +38,16 @@ namespace Crow
NotifyValueChanged ("Orientation", orientation);
}
}
+ bool isOpened = false;
+ public bool IsOpened
+ {
+ get { return isOpened; }
+ set
+ {
+ isOpened = value;
+ System.Diagnostics.Debug.WriteLine ("is opened = " + isOpened);
+ }
+ }
public Menu () : base()
{
@@ -52,5 +62,11 @@ namespace Crow
else
g.NotifyValueChanged ("PopDirection", Alignment.Right);
}
+ public override void onMouseLeave (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseLeave (sender, e);
+ IsOpened = false;
+ }
}
}
+
diff --git a/src/GraphicObjects/MenuItem.cs b/src/GraphicObjects/MenuItem.cs
index 9055fc5b..60233361 100644
--- a/src/GraphicObjects/MenuItem.cs
+++ b/src/GraphicObjects/MenuItem.cs
@@ -30,12 +30,34 @@ namespace Crow
public MenuItem () : base() {}
#endregion
+ public event EventHandler Open;
+ public event EventHandler Close;
public event EventHandler Execute;
string caption;
Command command;//TODO
+ bool isOpened;
- [XmlAttributeAttribute()][DefaultValue(null)]
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public bool IsOpened {
+ //get { return MenuRoot == null ? false : MenuRoot.IsOpened; }
+ get { return isOpened; }
+ set {
+ if (isOpened == value)
+ return;
+ isOpened = value;
+ NotifyValueChanged ("IsOpened", isOpened);
+
+ if (isOpened) {
+ onOpen (this, null);
+ if (MenuRoot != null)
+ MenuRoot.IsOpened = true;
+ }else
+ onClose (this, null);
+ }
+ }
+
+ [XmlAttributeAttribute][DefaultValue(null)]
public virtual Command Command {
get { return command; }
set {
@@ -59,11 +81,11 @@ namespace Crow
[XmlIgnore]Menu MenuRoot {
get {
- ILayoutable tmp = Parent;
+ ILayoutable tmp = LogicalParent;
while (tmp != null) {
if (tmp is Menu)
return tmp as Menu;
- tmp = tmp.Parent;
+ tmp = tmp.LogicalParent;
}
return null;
}
@@ -79,6 +101,21 @@ namespace Crow
{
Execute.Raise (this, null);
}
+ void onOpen (object sender, EventArgs e){
+ MenuRoot.IsOpened = true;
+ Open.Raise (this, null);
+ }
+ void onClose (object sender, EventArgs e){
+ //MenuRoot.IsOpened = true;
+ Close.Raise (this, null);
+ }
+ public override void onMouseEnter (object sender, MouseMoveEventArgs e)
+ {
+ base.onMouseEnter (sender, e);
+ if (MenuRoot == null || Items.Count == 0)
+ return;
+ IsOpened = MenuRoot.IsOpened;
+ }
}
}
diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs
index e0da0096..1bfdf19c 100644
--- a/src/GraphicObjects/Popper.cs
+++ b/src/GraphicObjects/Popper.cs
@@ -27,11 +27,11 @@ using OpenTK.Input;
namespace Crow
{
public class Popper : TemplatedContainer
- {
+ {
#region CTOR
public Popper() : base()
{
- }
+ }
#endregion
bool _isPopped, _canPop;
@@ -45,11 +45,11 @@ namespace Crow
#region Public Properties
[XmlAttributeAttribute()][DefaultValue("Popper")]
public string Caption {
- get { return caption; }
+ get { return caption; }
set {
if (caption == value)
return;
- caption = value;
+ caption = value;
NotifyValueChanged ("Caption", caption);
}
}
@@ -99,14 +99,13 @@ namespace Crow
public override GraphicObject Content {
get { return _content; }
- set {
+ set {
if (_content != null) {
_content.LogicalParent = null;
_content.LayoutChanged -= _content_LayoutChanged;
- _content.MouseLeave -= onMouseLeave;
}
-
- _content = value;
+
+ _content = value;
if (_content == null)
return;
@@ -115,7 +114,6 @@ namespace Crow
_content.HorizontalAlignment = HorizontalAlignment.Left;
_content.VerticalAlignment = VerticalAlignment.Top;
_content.LayoutChanged += _content_LayoutChanged;
- _content.MouseLeave += onMouseLeave;
}
}
@@ -172,9 +170,9 @@ namespace Crow
if (_content == null)
return;
-
+
if (layoutType == LayoutingType.Width)
- _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
+ _content.MinimumSize = new Size (this.Slot.Width, _content.MinimumSize.Height);
}
public override void ClearBinding ()
@@ -201,11 +199,21 @@ namespace Crow
}
public override void onMouseLeave (object sender, MouseMoveEventArgs e)
{
- base.onMouseLeave (sender, e);
- IsPopped = false;
+ if (!_isPopped || _content == null) {
+ base.onMouseLeave (sender, e);
+ System.Diagnostics.Debug.WriteLine ("NotPopped***popper mouse leave:"+ this.ToString());
+ return;
+ }
+
+ if (!_content.MouseIsIn (e.Position)) {
+ base.onMouseLeave (sender, e);
+ System.Diagnostics.Debug.WriteLine ("***popper mouse leave:"+ this.ToString());
+ IsPopped = false;
+ return;
+ }
}
#endregion
-
+
public virtual void onPop(object sender, EventArgs e)
{
if (Content != null) {
diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs
index 18977cf9..7a4649a4 100644
--- a/src/GraphicObjects/TemplatedContainer.cs
+++ b/src/GraphicObjects/TemplatedContainer.cs
@@ -54,6 +54,15 @@ namespace Crow
return Content == null ? null : Content.FindByName (nameToFind);
}
+ public override bool Contains (GraphicObject goToFind)
+ {
+ if (Content == null)
+ return base.Contains (goToFind);
+
+ if (Content == goToFind)
+ return true;
+ return Content.Contains (goToFind);
+ }
#endregion
#region IXmlSerialisation Overrides
@@ -66,7 +75,7 @@ namespace Crow
//seek for template tag
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
xr.Read ();
- base.ReadXml (xr);
+ base.ReadXml (xr);
}
//process content
using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
@@ -77,7 +86,7 @@ namespace Crow
if (!xr.IsStartElement ())
continue;
-
+
if (xr.Name == "Template"){
xr.Skip ();
if (!xr.IsStartElement ())
@@ -94,8 +103,8 @@ namespace Crow
}
if (t == null)
throw new Exception (xr.Name + " type not found");
-
- GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
+
+ GraphicObject go = (GraphicObject)Activator.CreateInstance (t);
(go as IXmlSerializable).ReadXml (xr);
diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs
index f7f849c0..0d48b9eb 100644
--- a/src/GraphicObjects/TemplatedGroup.cs
+++ b/src/GraphicObjects/TemplatedGroup.cs
@@ -87,7 +87,7 @@ namespace Crow
if (w.Contains (goToFind))
return true;
}
- return false;
+ return base.Contains(goToFind);
}
// public override void ClearBinding ()
// {
diff --git a/src/Interface.cs b/src/Interface.cs
index 73f44a6a..d01d2e8f 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -572,8 +572,15 @@ namespace Crow
int i = 0;
while (i < idxhw) {
if (GraphicTree [i].MouseIsIn (e.Position)) {
- //set evtarg to null to force mouseLeave without checking mouse pos
- HoverWidget.onMouseLeave (HoverWidget, null);
+ while (HoverWidget != null) {
+ if (HoverWidget is Popper) {
+ if ((HoverWidget as Popper).Content == GraphicTree[i])
+ break;
+ }
+ HoverWidget.onMouseLeave (HoverWidget, e);
+ HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ }
+
GraphicTree [i].checkHoverWidget (e);
return true;
}
@@ -587,8 +594,15 @@ namespace Crow
return true;
} else {
HoverWidget.onMouseLeave (HoverWidget, e);
- if (HoverWidget != null)
- return true;
+ //seek upward from last focused graph obj's
+ while (HoverWidget.LogicalParent as GraphicObject != null) {
+ HoverWidget = HoverWidget.LogicalParent as GraphicObject;
+ if (HoverWidget.MouseIsIn (e.Position)) {
+ HoverWidget.checkHoverWidget (e);
+ return true;
+ } else
+ HoverWidget.onMouseLeave (HoverWidget, e);
+ }
}
}