]> O.S.I.I.S - jp/crow.git/commitdiff
focusParent
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 17 Feb 2018 02:18:23 +0000 (03:18 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 17 Feb 2018 02:18:23 +0000 (03:18 +0100)
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Popper.cs
src/Interface.cs

index dd7efbe25526106a099fef00742acaccb98e31fe..15730905e6193e8eb7d86edebbded0283e32c9a3 100644 (file)
@@ -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; }
+               }
+
                /// <summary>
                /// interface this widget is bound to, this should not be changed once the instance is created
                /// </summary>
@@ -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);
 
index ea7b635a967efab2eb94c0a78705bad406a2b35c..70804bda2df9428dcaf6277290111fa9219d022b 100644 (file)
@@ -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);
index b044e132f42f71b83d50ab8343153e2163e6ac63..c573164ff5ea5154de1952b13e9d58e676ce7612 100644 (file)
@@ -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;