From 5223bf7dc4f5f085d4bfde7c079a45adf5f344e7 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Mon, 19 Oct 2015 16:49:05 +0200 Subject: [PATCH] Debug * Spinner.cs: updated with binding system * OpenTKGameWindow.cs: ensure focused, active and hover widget were not removed from the graphic tree, fire MouseButtonUp special event only if threre's no actived widget * testSpinner.goml: updated to test focus --- Tests/Interfaces/testSpinner.goml | 9 +- Tests/image/folder0.svg | 158 ++++++++++++++++++++++++++++++ Tests/image/folder1.svg | 55 +++++++++++ src/GraphicObjects/Spinner.cs | 3 - src/OpenTKGameWindow.cs | 85 +++++++++------- 5 files changed, 267 insertions(+), 43 deletions(-) create mode 100644 Tests/image/folder0.svg create mode 100644 Tests/image/folder1.svg diff --git a/Tests/Interfaces/testSpinner.goml b/Tests/Interfaces/testSpinner.goml index c1980eb7..48791ba5 100755 --- a/Tests/Interfaces/testSpinner.goml +++ b/Tests/Interfaces/testSpinner.goml @@ -1,6 +1,7 @@  - + - - \ No newline at end of file + + + \ No newline at end of file diff --git a/Tests/image/folder0.svg b/Tests/image/folder0.svg new file mode 100644 index 00000000..005f66fc --- /dev/null +++ b/Tests/image/folder0.svg @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + +image/svg+xmlOpenclipartFolder icon2011-05-08T02:14:09A (somewhat) realistic folder icon.https://openclipart.org/detail/137155/folder-icon-by-jhnri4-137155jhnri4folderhow i did iticon diff --git a/Tests/image/folder1.svg b/Tests/image/folder1.svg new file mode 100644 index 00000000..d1a781ff --- /dev/null +++ b/Tests/image/folder1.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GraphicObjects/Spinner.cs b/src/GraphicObjects/Spinner.cs index ea992b18..5336a0bb 100644 --- a/src/GraphicObjects/Spinner.cs +++ b/src/GraphicObjects/Spinner.cs @@ -42,7 +42,6 @@ namespace go protected override void loadTemplate (GraphicObject template = null) { base.loadTemplate (template); - labCpt = this.child.FindByName ("labCpt") as Label; } #endregion @@ -54,7 +53,6 @@ namespace go // return; Value += this.SmallIncrement; - labCpt.Text = Value.ToString (); } void onDown (object sender, MouseButtonEventArgs e) { @@ -63,7 +61,6 @@ namespace go // return; Value -= this.SmallIncrement; - labCpt.Text = Value.ToString (); } } diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 6b16f157..7cc84bca 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -142,7 +142,8 @@ namespace go if (_focusedWidget != null) _focusedWidget.onUnfocused (this, null); _focusedWidget = value; - _focusedWidget.onFocused (this, null); + if (_focusedWidget != null) + _focusedWidget.onFocused (this, null); } } #endregion @@ -437,46 +438,57 @@ namespace go void Mouse_Move(object sender, MouseMoveEventArgs e) { if (_activeWidget != null) { - //send move evt even if mouse move outside bounds - _activeWidget.onMouseMove (_activeWidget, e); - return; + //first, ensure object is still in the graphic tree + if (_activeWidget.TopContainer == null) { + activeWidget = null; + } else { + + //send move evt even if mouse move outside bounds + _activeWidget.onMouseMove (_activeWidget, e); + return; + } } if (_hoverWidget != null) { - //check topmost graphicobject first - GraphicObject tmp = _hoverWidget; - GraphicObject topc = null; - while (tmp is GraphicObject) { - topc = tmp; - tmp = tmp.Parent as GraphicObject; - } - int idxhw = GraphicObjects.IndexOf (topc); - if (idxhw != 0) { - int i = 0; - while (i < idxhw) { - if (GraphicObjects [i].MouseIsIn (e.Position)) { - _hoverWidget.onMouseLeave (this, e); - GraphicObjects [i].checkHoverWidget (e); - return; + //first, ensure object is still in the graphic tree + if (_hoverWidget.TopContainer == null) { + hoverWidget = null; + } else { + //check topmost graphicobject first + GraphicObject tmp = _hoverWidget; + GraphicObject topc = null; + while (tmp is GraphicObject) { + topc = tmp; + tmp = tmp.Parent as GraphicObject; + } + int idxhw = GraphicObjects.IndexOf (topc); + if (idxhw != 0) { + int i = 0; + while (i < idxhw) { + if (GraphicObjects [i].MouseIsIn (e.Position)) { + _hoverWidget.onMouseLeave (this, e); + GraphicObjects [i].checkHoverWidget (e); + return; + } + i++; } - i++; } - } - if (_hoverWidget.MouseIsIn (e.Position)) { - _hoverWidget.checkHoverWidget (e); - return; - } else { - _hoverWidget.onMouseLeave (this, e); - //seek upward from last focused graph obj's - while (_hoverWidget.Parent as GraphicObject!=null) { - _hoverWidget = _hoverWidget.Parent as GraphicObject; - if (_hoverWidget.MouseIsIn (e.Position)) { - _hoverWidget.checkHoverWidget (e); - return; - } else - _hoverWidget.onMouseLeave (this, e); + if (_hoverWidget.MouseIsIn (e.Position)) { + _hoverWidget.checkHoverWidget (e); + return; + } else { + _hoverWidget.onMouseLeave (this, e); + //seek upward from last focused graph obj's + while (_hoverWidget.Parent as GraphicObject != null) { + _hoverWidget = _hoverWidget.Parent as GraphicObject; + if (_hoverWidget.MouseIsIn (e.Position)) { + _hoverWidget.checkHoverWidget (e); + return; + } else + _hoverWidget.onMouseLeave (this, e); + } } } } @@ -495,12 +507,13 @@ namespace go } void Mouse_ButtonUp(object sender, MouseButtonEventArgs e) { - if (_activeWidget == null) + if (_activeWidget == null) { + MouseButtonUp.Raise (this, e); return; + } _activeWidget.onMouseButtonUp (this, e); _activeWidget = null; - MouseButtonUp.Raise (this, e); } void Mouse_ButtonDown(object sender, MouseButtonEventArgs e) { -- 2.47.3