diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-10-19 16:49:05 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-10-19 16:49:05 +0200 |
| commit | 5223bf7dc4f5f085d4bfde7c079a45adf5f344e7 (patch) | |
| tree | 701566767b7a913e75f94d07709a8a4a7b1b0174 | |
| parent | d57ae20644694ed4862785be98d3ead18100315f (diff) | |
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
| -rwxr-xr-x | Tests/Interfaces/testSpinner.goml | 9 | ||||
| -rw-r--r-- | Tests/image/folder0.svg | 158 | ||||
| -rw-r--r-- | Tests/image/folder1.svg | 55 | ||||
| -rw-r--r-- | src/GraphicObjects/Spinner.cs | 3 | ||||
| -rwxr-xr-x | src/OpenTKGameWindow.cs | 85 |
5 files changed, 267 insertions, 43 deletions
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 @@ <?xml version="1.0"?>
-<Container Name="TopContainer" Width="400" Height="350"
- Margin="20" Focusable="True" Background="DarkGray">
+<VerticalStack Name="TopContainer" Width="400" Height="-1"
+ Margin="20" Background="DarkGray">
- <Spinner Height="-1" Width="-1" Value="5"></Spinner>
-</Container>
\ No newline at end of file + <Spinner Value="5"/>
+ <Spinner Value="5"/>
+</VerticalStack>
\ 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 @@ +<?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 index 00000000..d1a781ff --- /dev/null +++ b/Tests/image/folder1.svg @@ -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> 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)
{
|