]> O.S.I.I.S - jp/crow.git/commitdiff
Debug
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 19 Oct 2015 14:49:05 +0000 (16:49 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 19 Oct 2015 14:49:05 +0000 (16:49 +0200)
* 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
Tests/image/folder0.svg [new file with mode: 0644]
Tests/image/folder1.svg [new file with mode: 0644]
src/GraphicObjects/Spinner.cs
src/OpenTKGameWindow.cs

index c1980eb780d0f28d0e60f8b4a6515c67eaac5781..48791ba5e13da3436a1148311ffab4d624adb848 100755 (executable)
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>\r
-<Container Name="TopContainer" Width="400" Height="350"\r
-       Margin="20" Focusable="True" Background="DarkGray">\r
+<VerticalStack Name="TopContainer" Width="400" Height="-1"\r
+       Margin="20" Background="DarkGray">\r
 \r
-       <Spinner Height="-1" Width="-1" Value="5"></Spinner>\r
-</Container>
\ No newline at end of file
+       <Spinner Value="5"/>\r
+       <Spinner Value="5"/>\r
+</VerticalStack>
\ No newline at end of file
diff --git a/Tests/image/folder0.svg b/Tests/image/folder0.svg
new file mode 100644 (file)
index 0000000..005f66f
--- /dev/null
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg
+    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+    xmlns="http://www.w3.org/2000/svg"
+    xmlns:cc="http://web.resource.org/cc/"
+    xmlns:xlink="http://www.w3.org/1999/xlink"
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:svg="http://www.w3.org/2000/svg"
+    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+    xmlns:ns1="http://sozi.baierouge.fr"
+    id="Layer_1"
+    enable-background="new 0 0 256 256"
+    xml:space="preserve"
+    viewBox="0 0 256 256"
+    version="1.1"
+    y="0px"
+    x="0px"
+  >
+<radialGradient
+      id="SVGID_1_"
+      gradientUnits="userSpaceOnUse"
+      cy="62.334"
+      cx="181"
+      r="208.44"
+    >
+       <stop
+        style="stop-color:#FFE0A2"
+        offset="0"
+    />
+       <stop
+        style="stop-color:#FCB447"
+        offset="1"
+    />
+</radialGradient
+  >
+<path
+      d="m86.089 63.528c2.655-0.805 5.306 1.066 5.896 4.161l0.58 3.044c0.588 3.085 3.239 4.956 5.885 4.153l88.174-26.738c2.654-0.805 5.307 1.066 5.896 4.161l21.189 111.14c0.588 3.085-1.098 6.271-3.754 7.076l-150.06 45.5c-2.654 0.805-5.306-1.065-5.894-4.15l-21.187-111.14c-0.59-3.094 1.097-6.281 3.751-7.085l3.071-0.931c2.646-0.803 4.332-3.989 3.744-7.074l-0.58-3.044c-0.59-3.095 1.097-6.281 3.751-7.086l39.533-11.992z"
+      fill="url(#SVGID_1_)"
+  />
+<defs
+    >
+       <filter
+        id="Adobe_OpacityMaskFilter"
+        height="132.64"
+        width="154.43"
+        y="83.58"
+        x="51.455"
+        filterUnits="userSpaceOnUse"
+      >
+               <feFlood
+          style="flood-color:white"
+          result="back"
+      />
+               <feBlend
+          mode="normal"
+          in2="back"
+          in="SourceGraphic"
+      />
+       </filter
+    >
+</defs
+  >
+<mask
+      id="SVGID_2_"
+      height="132.641"
+      width="154.43"
+      y="83.58"
+      x="51.455"
+      maskUnits="userSpaceOnUse"
+    >
+</mask
+  >
+<g
+      mask="url(#SVGID_2_)"
+    >
+       <path
+        d="m205.88 122.4l-7.402-38.824c-26.574 7.254-111.94 30.851-119.82 36.753-7.483 5.612-21.821 57.716-27.212 78.155l2.554 13.396c0.588 3.085 3.24 4.955 5.894 4.15l145.44-44.104 0.54-49.53z"
+    />
+</g
+  >
+<linearGradient
+      id="SVGID_3_"
+      y2="166.41"
+      gradientUnits="userSpaceOnUse"
+      x2="212.43"
+      y1="132.96"
+      x1="77.764"
+    >
+       <stop
+        style="stop-color:#FEE58A"
+        offset="0"
+    />
+       <stop
+        style="stop-color:#FCB461"
+        offset="1"
+    />
+</linearGradient
+  >
+<path
+      d="m233.7 82.767c2.654-0.805 4.299 0.371 3.658 2.609l-23.072 80.614c-0.643 2.244-3.336 4.736-5.99 5.542l-150.07 45.51c-2.646 0.803-4.29-0.373-3.647-2.618l23.072-80.613c0.64-2.237 3.334-4.729 5.98-5.532l150.06-45.513z"
+      fill="url(#SVGID_3_)"
+  />
+<metadata
+    ><rdf:RDF
+      ><cc:Work
+        ><dc:format
+          >image/svg+xml</dc:format
+        ><dc:type
+            rdf:resource="http://purl.org/dc/dcmitype/StillImage"
+        /><cc:license
+            rdf:resource="http://creativecommons.org/licenses/publicdomain/"
+        /><dc:publisher
+          ><cc:Agent
+              rdf:about="http://openclipart.org/"
+            ><dc:title
+              >Openclipart</dc:title
+            ></cc:Agent
+          ></dc:publisher
+        ><dc:title
+          >Folder icon</dc:title
+        ><dc:date
+          >2011-05-08T02:14:09</dc:date
+        ><dc:description
+          >A (somewhat) realistic folder icon.</dc:description
+        ><dc:source
+          >https://openclipart.org/detail/137155/folder-icon-by-jhnri4-137155</dc:source
+        ><dc:creator
+          ><cc:Agent
+            ><dc:title
+              >jhnri4</dc:title
+            ></cc:Agent
+          ></dc:creator
+        ><dc:subject
+          ><rdf:Bag
+            ><rdf:li
+              >folder</rdf:li
+            ><rdf:li
+              >how i did it</rdf:li
+            ><rdf:li
+              >icon</rdf:li
+            ></rdf:Bag
+          ></dc:subject
+        ></cc:Work
+      ><cc:License
+          rdf:about="http://creativecommons.org/licenses/publicdomain/"
+        ><cc:permits
+            rdf:resource="http://creativecommons.org/ns#Reproduction"
+        /><cc:permits
+            rdf:resource="http://creativecommons.org/ns#Distribution"
+        /><cc:permits
+            rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
+        /></cc:License
+      ></rdf:RDF
+    ></metadata
+  ></svg
+>
diff --git a/Tests/image/folder1.svg b/Tests/image/folder1.svg
new file mode 100644 (file)
index 0000000..d1a781f
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--part of the rodentia icon theme by sixsixfive released under CC0 (https://creativecommons.org/publicdomain/zero/1.0/) on openclipart-->
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48">
+ <defs id="0">
+  <linearGradient id="2">
+   <stop id="J" stop-color="#2e3436"/>
+   <stop id="K" offset="1" stop-color="#2e3436" stop-opacity="0"/>
+  </linearGradient>
+  <linearGradient id="3">
+   <stop id="L" stop-color="#fff" stop-opacity="0.4"/>
+   <stop id="M" offset="1" stop-color="#fff" stop-opacity="0"/>
+  </linearGradient>
+  <linearGradient id="4">
+   <stop id="N" stop-color="#8f5902"/>
+   <stop id="O" offset="1" stop-color="#683f00"/>
+  </linearGradient>
+  <linearGradient id="5">
+   <stop id="P" stop-color="#fff"/>
+   <stop id="Q" offset="1" stop-color="#fff" stop-opacity="0"/>
+  </linearGradient>
+  <linearGradient id="6">
+   <stop id="R" stop-color="#fff" stop-opacity="0.8"/>
+   <stop id="S" offset="1" stop-color="#fff" stop-opacity="0"/>
+  </linearGradient>
+  <linearGradient id="7">
+   <stop id="T" stop-color="#e9b96e"/>
+   <stop id="U" offset="1" stop-color="#c17d11"/>
+  </linearGradient>
+  <linearGradient id="8">
+   <stop id="V" stop-color="#2e3436"/>
+   <stop id="W" offset="1" stop-color="#555753"/>
+  </linearGradient>
+  <filter color-interpolation-filters="sRGB" id="9">
+   <feGaussianBlur stdDeviation="0.755" id="X"/>
+  </filter>
+  <radialGradient cx="35.488" cy="26.2" r="23" id="A" xlink:href="#8" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.0434444,-1.4643692,1.4020098,0.9990096,-62.776231,34.470805)"/>
+  <linearGradient y1="1.781" x2="0" y2="41.75" id="B" xlink:href="#3" gradientUnits="userSpaceOnUse"/>
+  <linearGradient y1="10.144" x2="0" y2="42.775" id="C" xlink:href="#7" gradientUnits="userSpaceOnUse"/>
+  <linearGradient y1="10.144" x2="0" y2="42.775" id="D" xlink:href="#4" gradientUnits="userSpaceOnUse"/>
+  <linearGradient y1="11.188" x2="0" y2="41.75" id="E" xlink:href="#6" gradientUnits="userSpaceOnUse"/>
+  <linearGradient x1="7.935" y1="-28.25" x2="20.05" y2="36.1" id="F" xlink:href="#5" gradientUnits="userSpaceOnUse"/>
+  <radialGradient cx="24.919" cy="48.2" r="25.941" id="G" xlink:href="#2" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1,0,0,0.1062992,0,43.080183)"/>
+ </defs>
+ <g id="1" opacity="0.6">
+  <path d="m 50.860289,48.204258 a 25.94079,2.7574856 0 1 1 -51.8815807,0 25.94079,2.7574856 0 1 1 51.8815807,0 z" transform="matrix(0.9652959,0,0,0.8148148,-0.05468968,4.2286171)" id="H" fill="url(#G)"/>
+  <g transform="matrix(0.9574469,0,0,0.9574469,1.0212744,3.1660267)" id="I">
+   <path d="m 1.5,1.2452202 0,41.0294108 45,0 0,-34.5135739 -18.834842,0 -5.497737,-6.5158369 -20.667421,0 z" id="Y" fill="url(#A)" stroke="#2e3436" stroke-linejoin="round" stroke-linecap="square"/>
+   <path d="m 2.53125,2.28125 0,38.96875 42.9375,0 0,-32.46875 -17.8125,0 A 1.0266953,1.0266953 0 0 1 26.875,8.40625 l -5.1875,-6.125 -19.15625,0 z" id="Z" opacity="0.8" fill="none" stroke="url(#B)" stroke-linejoin="round" stroke-linecap="square"/>
+   <path d="m 18.65625,11.1875 -2.875,6.34375 a 0.54138149,0.54138149 0 0 1 -0.5,0.3125 l -13.75,0 0.5,23.90625 43.9375,0 0.5,-30.5625 -27.8125,0 z" transform="translate(0,-1.7)" id="a" filter="url(#9)"/>
+   <path d="m 18.310273,10.643608 -3.037735,6.654088 -14.272535,0 0.4999972,24.976935 44.9999998,0 0.499997,-31.631023 -28.689724,0 z" id="b" fill="url(#C)" stroke="url(#D)" stroke-linejoin="round" stroke-linecap="square"/>
+   <path d="m 18.96875,11.6875 -2.75,6.0625 a 1.0266953,1.0266953 0 0 1 -0.9375,0.59375 l -13.21875,0 L 2.5,41.25 l 43,0 0.4375,-29.5625 -26.96875,0 z" id="c" opacity="0.8" fill="none" stroke="url(#E)" stroke-linejoin="round" stroke-linecap="square"/>
+   <path d="m 18.65625,11.15625 -2.90625,6.375 c -0.08919,0.176066 -0.271425,0.285406 -0.46875,0.28125 l -13.78125,0 0.3125,15.34375 c 12.189878,-5.184653 30.416986,-10.313955 44.53125,-12.75 l 0.15625,-9.25 -27.84375,0 z" id="d" opacity="0.8" fill="url(#F)"/>
+  </g>
+ </g>
+</svg>
index ea992b18786071ef0eb29f6b987ed5e017745ebc..5336a0bb7a3546912160a8293cc0254b0abe62b1 100644 (file)
@@ -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 ();
                }
 
        }
index 6b16f1576dd4eff79dac16e150c95a9dad99fbdc..7cc84bca6164eaa7f072036a851e82fd51ff4b6d 100755 (executable)
@@ -142,7 +142,8 @@ namespace go
                                if (_focusedWidget != null)\r
                                        _focusedWidget.onUnfocused (this, null);\r
                                _focusedWidget = value;\r
-                               _focusedWidget.onFocused (this, null);\r
+                               if (_focusedWidget != null)\r
+                                       _focusedWidget.onFocused (this, null);\r
                        }\r
                }\r
                #endregion\r
@@ -437,46 +438,57 @@ namespace go
         void Mouse_Move(object sender, MouseMoveEventArgs e)\r
         {\r
                        if (_activeWidget != null) {\r
-                               //send move evt even if mouse move outside bounds\r
-                               _activeWidget.onMouseMove (_activeWidget, e);\r
-                               return;\r
+                               //first, ensure object is still in the graphic tree\r
+                               if (_activeWidget.TopContainer == null) {\r
+                                       activeWidget = null;\r
+                               } else {\r
+                                       \r
+                                       //send move evt even if mouse move outside bounds\r
+                                       _activeWidget.onMouseMove (_activeWidget, e);\r
+                                       return;\r
+                               }\r
                        }\r
 \r
                        if (_hoverWidget != null) {\r
-                               //check topmost graphicobject first\r
-                               GraphicObject tmp = _hoverWidget;\r
-                               GraphicObject topc = null;\r
-                               while (tmp is GraphicObject) {\r
-                                       topc = tmp;\r
-                                       tmp = tmp.Parent as GraphicObject;\r
-                               }\r
-                               int idxhw = GraphicObjects.IndexOf (topc);\r
-                               if (idxhw != 0) {\r
-                                       int i = 0;\r
-                                       while (i < idxhw) {\r
-                                               if (GraphicObjects [i].MouseIsIn (e.Position)) {\r
-                                                       _hoverWidget.onMouseLeave (this, e);\r
-                                                       GraphicObjects [i].checkHoverWidget (e);\r
-                                                       return;\r
+                               //first, ensure object is still in the graphic tree\r
+                               if (_hoverWidget.TopContainer == null) {\r
+                                       hoverWidget = null;\r
+                               } else {\r
+                                       //check topmost graphicobject first\r
+                                       GraphicObject tmp = _hoverWidget;\r
+                                       GraphicObject topc = null;\r
+                                       while (tmp is GraphicObject) {\r
+                                               topc = tmp;\r
+                                               tmp = tmp.Parent as GraphicObject;\r
+                                       }\r
+                                       int idxhw = GraphicObjects.IndexOf (topc);\r
+                                       if (idxhw != 0) {\r
+                                               int i = 0;\r
+                                               while (i < idxhw) {\r
+                                                       if (GraphicObjects [i].MouseIsIn (e.Position)) {\r
+                                                               _hoverWidget.onMouseLeave (this, e);\r
+                                                               GraphicObjects [i].checkHoverWidget (e);\r
+                                                               return;\r
+                                                       }\r
+                                                       i++;\r
                                                }\r
-                                               i++;\r
                                        }\r
-                               }\r
                                        \r
                                        \r
-                               if (_hoverWidget.MouseIsIn (e.Position)) {\r
-                                       _hoverWidget.checkHoverWidget (e);\r
-                                       return;\r
-                               } else {\r
-                                       _hoverWidget.onMouseLeave (this, e);\r
-                                       //seek upward from last focused graph obj's\r
-                                       while (_hoverWidget.Parent as GraphicObject!=null) {\r
-                                               _hoverWidget = _hoverWidget.Parent as GraphicObject;\r
-                                               if (_hoverWidget.MouseIsIn (e.Position)) {\r
-                                                       _hoverWidget.checkHoverWidget (e);\r
-                                                       return;\r
-                                               } else\r
-                                                       _hoverWidget.onMouseLeave (this, e);\r
+                                       if (_hoverWidget.MouseIsIn (e.Position)) {\r
+                                               _hoverWidget.checkHoverWidget (e);\r
+                                               return;\r
+                                       } else {\r
+                                               _hoverWidget.onMouseLeave (this, e);\r
+                                               //seek upward from last focused graph obj's\r
+                                               while (_hoverWidget.Parent as GraphicObject != null) {\r
+                                                       _hoverWidget = _hoverWidget.Parent as GraphicObject;\r
+                                                       if (_hoverWidget.MouseIsIn (e.Position)) {\r
+                                                               _hoverWidget.checkHoverWidget (e);\r
+                                                               return;\r
+                                                       } else\r
+                                                               _hoverWidget.onMouseLeave (this, e);\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
@@ -495,12 +507,13 @@ namespace go
         }\r
         void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)\r
         {\r
-                       if (_activeWidget == null)\r
+                       if (_activeWidget == null) {\r
+                               MouseButtonUp.Raise (this, e);\r
                                return;\r
+                       }\r
 \r
                        _activeWidget.onMouseButtonUp (this, e);\r
                        _activeWidget = null;\r
-                       MouseButtonUp.Raise (this, e);\r
         }\r
         void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)\r
         {\r