From da3cb49100440029d1694e50800260d6286ccf8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 17 Feb 2018 03:18:23 +0100 Subject: [PATCH] focusParent --- src/GraphicObjects/GraphicObject.cs | 17 +++++++++++------ src/GraphicObjects/Popper.cs | 12 ++++++------ src/Interface.cs | 13 +++++++------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index dd7efbe2..15730905 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -93,6 +93,11 @@ namespace Crow internal static ulong currentUid = 0; internal ulong uid = 0; + internal bool isPopup = false; + internal GraphicObject focusParent { + get { return (isPopup ? LogicalParent : parent) as GraphicObject; } + } + /// /// interface this widget is bound to, this should not be changed once the instance is created /// @@ -1541,7 +1546,7 @@ namespace Crow IsDragged = true; //bubble event to the top - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseMove(sender,e); @@ -1566,7 +1571,7 @@ namespace Crow } } //bubble event to the top - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseDown(sender,e); @@ -1586,7 +1591,7 @@ namespace Crow } //bubble event to the top - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseUp(sender,e); @@ -1599,19 +1604,19 @@ namespace Crow } } public virtual void onMouseClick(object sender, MouseButtonEventArgs e){ - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseClick(sender,e); MouseClick.Raise (this, e); } public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){ - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseDoubleClick(sender,e); MouseDoubleClick.Raise (this, e); } public virtual void onMouseWheel(object sender, MouseWheelEventArgs e){ - GraphicObject p = Parent as GraphicObject; + GraphicObject p = focusParent; if (p != null) p.onMouseWheel(sender,e); diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index ea7b635a..70804bda 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -72,10 +72,14 @@ namespace Crow get { return _isPopped; } set { + if (!_canPop & value) + return; + if (value == _isPopped) return; _isPopped = value; + NotifyValueChanged ("IsPopped", _isPopped); if (_isPopped) @@ -115,6 +119,7 @@ namespace Crow set { if (_content != null) { _content.LogicalParent = null; + _content.isPopup = false; _content.LayoutChanged -= _content_LayoutChanged; } @@ -124,6 +129,7 @@ namespace Crow return; _content.LogicalParent = this; + _content.isPopup = true; _content.HorizontalAlignment = HorizontalAlignment.Left; _content.VerticalAlignment = VerticalAlignment.Top; _content.LayoutChanged += _content_LayoutChanged; @@ -181,12 +187,6 @@ namespace Crow } #region GraphicObject overrides - public override void onMouseClick (object sender, MouseButtonEventArgs e) - { - if (_canPop) - IsPopped = !IsPopped; - base.onMouseClick (this, e); - } public override void onMouseLeave (object sender, MouseMoveEventArgs e) { base.onMouseLeave (this, e); diff --git a/src/Interface.cs b/src/Interface.cs index b044e132..c573164f 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -90,7 +90,7 @@ namespace Crow FontRenderingOptions = new FontOptions (); FontRenderingOptions.Antialias = Antialias.Subpixel; FontRenderingOptions.HintMetrics = HintMetrics.On; - FontRenderingOptions.HintStyle = HintStyle.Medium; + FontRenderingOptions.HintStyle = HintStyle.Full; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } public Interface(){ @@ -822,11 +822,11 @@ namespace Crow if (idxhw != 0) { int i = 0; while (i < idxhw) { - if (GraphicTree [i].localLogicalParentIsNull) { + if (!GraphicTree [i].isPopup) { if (GraphicTree [i].MouseIsIn (e.Position)) { while (HoverWidget != null) { HoverWidget.onMouseLeave (HoverWidget, e); - HoverWidget = HoverWidget.LogicalParent as GraphicObject; + HoverWidget = HoverWidget.focusParent; } GraphicTree [i].checkHoverWidget (e); @@ -845,8 +845,8 @@ namespace Crow } else { HoverWidget.onMouseLeave (HoverWidget, e); //seek upward from last focused graph obj's - while (HoverWidget.LogicalParent as GraphicObject != null) { - HoverWidget = HoverWidget.LogicalParent as GraphicObject; + while (HoverWidget.focusParent != null) { + HoverWidget = HoverWidget.focusParent; if (HoverWidget.MouseIsIn (e.Position)) { HoverWidget.checkHoverWidget (e); HoverWidget.onMouseMove (this, e); @@ -1048,7 +1048,8 @@ namespace Crow this.AddWidget (ctxMenuContainer); else ctxMenuContainer.IsOpened = true; - + + ctxMenuContainer.isPopup = true; ctxMenuContainer.LogicalParent = go; ctxMenuContainer.DataSource = go; -- 2.47.3