]> O.S.I.I.S - jp/crow.git/commitdiff
embedded mouse cursors
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 13 May 2020 08:35:36 +0000 (10:35 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 13 May 2020 08:35:36 +0000 (10:35 +0200)
76 files changed:
Crow.sln
Crow/Crow.csproj
Crow/Cursors/08e8e1c95fe2fc01f976f1e063a24ccd [new file with mode: 0644]
Crow/Cursors/X_cursor [new file with mode: 0644]
Crow/Cursors/arrow
Crow/Cursors/base_arrow_down [new file with mode: 0644]
Crow/Cursors/base_arrow_up [new file with mode: 0644]
Crow/Cursors/boat [new file with mode: 0644]
Crow/Cursors/bottom_left_corner
Crow/Cursors/bottom_right_corner
Crow/Cursors/bottom_side [new file with mode: 0644]
Crow/Cursors/bottom_tee [new file with mode: 0644]
Crow/Cursors/center_ptr [new file with mode: 0644]
Crow/Cursors/circle [new file with mode: 0644]
Crow/Cursors/cross
Crow/Cursors/cross_reverse [new file with mode: 0644]
Crow/Cursors/crosshair [new file with mode: 0644]
Crow/Cursors/dot [new file with mode: 0644]
Crow/Cursors/dot_box_mask [new file with mode: 0644]
Crow/Cursors/double_arrow [new file with mode: 0644]
Crow/Cursors/draft_large [new file with mode: 0644]
Crow/Cursors/draft_small [new file with mode: 0644]
Crow/Cursors/draped_box [new file with mode: 0644]
Crow/Cursors/exchange [new file with mode: 0644]
Crow/Cursors/fleur [new file with mode: 0644]
Crow/Cursors/gumby [new file with mode: 0644]
Crow/Cursors/hand1 [new file with mode: 0644]
Crow/Cursors/hand2 [new file with mode: 0644]
Crow/Cursors/left_ptr [new file with mode: 0644]
Crow/Cursors/left_ptr_watch [new file with mode: 0644]
Crow/Cursors/left_side [new file with mode: 0644]
Crow/Cursors/left_tee [new file with mode: 0644]
Crow/Cursors/ll_angle [new file with mode: 0644]
Crow/Cursors/lr_angle [new file with mode: 0644]
Crow/Cursors/pencil [new file with mode: 0644]
Crow/Cursors/pirate [new file with mode: 0644]
Crow/Cursors/plus [new file with mode: 0644]
Crow/Cursors/question_arrow [new file with mode: 0644]
Crow/Cursors/right_ptr [new file with mode: 0644]
Crow/Cursors/right_side [new file with mode: 0644]
Crow/Cursors/right_tee [new file with mode: 0644]
Crow/Cursors/sailboat [new file with mode: 0644]
Crow/Cursors/sb_down_arrow [new file with mode: 0644]
Crow/Cursors/sb_h_double_arrow
Crow/Cursors/sb_left_arrow [new file with mode: 0644]
Crow/Cursors/sb_right_arrow [new file with mode: 0644]
Crow/Cursors/sb_up_arrow [new file with mode: 0644]
Crow/Cursors/sb_v_double_arrow
Crow/Cursors/shuttle [new file with mode: 0644]
Crow/Cursors/sizing [new file with mode: 0644]
Crow/Cursors/target [new file with mode: 0644]
Crow/Cursors/tcross [new file with mode: 0644]
Crow/Cursors/top_left_arrow [new file with mode: 0644]
Crow/Cursors/top_left_corner
Crow/Cursors/top_right_corner
Crow/Cursors/top_side [new file with mode: 0644]
Crow/Cursors/top_tee [new file with mode: 0644]
Crow/Cursors/trek [new file with mode: 0644]
Crow/Cursors/ul_angle [new file with mode: 0644]
Crow/Cursors/ur_angle [new file with mode: 0644]
Crow/Cursors/watch [new file with mode: 0644]
Crow/Cursors/xterm [new file with mode: 0644]
Crow/src/Colors.cs
Crow/src/Enums.cs
Crow/src/Interface.cs
Crow/src/Widgets/Splitter.cs
Crow/src/Widgets/TextBox.cs
Crow/src/Widgets/Widget.cs
Crow/src/Widgets/Window.cs
Crow/src/XCursor.cs
Directory.Build.props
README.md
Samples/BasicTests/BasicTests.cs
Samples/HelloWorld/main.cs
Samples/HelloWorld/ui/helloworld.crow
Samples/ShowCase/main.cs

index 71f8d0460756071fc43c2f2ee1b15f508c6f02d5..b7b5f9b494e64551df39d86b53d62beb25fde1df 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unitTests", "unitTests\unit
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTests", "Samples\BasicTests\BasicTests.csproj", "{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "glfw-sharp", "..\..\glfw-sharp\glfw-sharp.csproj", "{A07754EB-1CAF-4D2D-8247-A3B6A46FB943}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -49,6 +51,10 @@ Global
                {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.Build.0 = Release|Any CPU
+               {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(MonoDevelopProperties) = preSolution
                Policies = $0
index 0094690cadc670d383ee425dd62adf025ed26b35..fdf4f29dda212278402ef1e4ed51a622dc6e3b1b 100644 (file)
@@ -39,7 +39,7 @@
                <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.6.0" />
                <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
                <!--<PackageReference Include="glfw-sharp" Version="0.2.0" />-->
-               <PackageReference Include="glfw-sharp" Version="0.2.4" />
+<!--           <PackageReference Include="glfw-sharp" Version="0.2.5" />-->
        </ItemGroup>
        <PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
                <DefineConstants>$(DefineConstants);STB_SHARP</DefineConstants>
                </EmbeddedResource>
                <EmbeddedResource Include="Default.style" />
                <EmbeddedResource Include="Icons\*.*" />
+               <EmbeddedResource Include="Cursors\*.*">
+                       <LogicalName>Crow.Cursors.%(Filename)</LogicalName>
+               </EmbeddedResource>
+       </ItemGroup>
+       <ItemGroup>
+         <ProjectReference Include="..\..\..\glfw-sharp\glfw-sharp.csproj" />
        </ItemGroup>
 </Project>
diff --git a/Crow/Cursors/08e8e1c95fe2fc01f976f1e063a24ccd b/Crow/Cursors/08e8e1c95fe2fc01f976f1e063a24ccd
new file mode 100644 (file)
index 0000000..583a6b4
Binary files /dev/null and b/Crow/Cursors/08e8e1c95fe2fc01f976f1e063a24ccd differ
diff --git a/Crow/Cursors/X_cursor b/Crow/Cursors/X_cursor
new file mode 100644 (file)
index 0000000..f93833b
Binary files /dev/null and b/Crow/Cursors/X_cursor differ
index 61f968efb0951f51adcd2215e54cec28fa914cb3..ef1398ad065a24247f7a4f66ea40ed6f6de4509d 100644 (file)
Binary files a/Crow/Cursors/arrow and b/Crow/Cursors/arrow differ
diff --git a/Crow/Cursors/base_arrow_down b/Crow/Cursors/base_arrow_down
new file mode 100644 (file)
index 0000000..371d652
Binary files /dev/null and b/Crow/Cursors/base_arrow_down differ
diff --git a/Crow/Cursors/base_arrow_up b/Crow/Cursors/base_arrow_up
new file mode 100644 (file)
index 0000000..1ed6036
Binary files /dev/null and b/Crow/Cursors/base_arrow_up differ
diff --git a/Crow/Cursors/boat b/Crow/Cursors/boat
new file mode 100644 (file)
index 0000000..1e512bf
Binary files /dev/null and b/Crow/Cursors/boat differ
index e9a41a20794e2c224346615c10412d600effb016..45f0bb0752c1284cafd98ceac7d3b6ef64b232b0 100644 (file)
Binary files a/Crow/Cursors/bottom_left_corner and b/Crow/Cursors/bottom_left_corner differ
index 208faf489081b710133e30e7f0f7352d6eb84b8a..d051cdedc569396ea17eba172fb5763141e8148e 100644 (file)
Binary files a/Crow/Cursors/bottom_right_corner and b/Crow/Cursors/bottom_right_corner differ
diff --git a/Crow/Cursors/bottom_side b/Crow/Cursors/bottom_side
new file mode 100644 (file)
index 0000000..ab1a917
Binary files /dev/null and b/Crow/Cursors/bottom_side differ
diff --git a/Crow/Cursors/bottom_tee b/Crow/Cursors/bottom_tee
new file mode 100644 (file)
index 0000000..4b10d72
Binary files /dev/null and b/Crow/Cursors/bottom_tee differ
diff --git a/Crow/Cursors/center_ptr b/Crow/Cursors/center_ptr
new file mode 100644 (file)
index 0000000..9a087da
Binary files /dev/null and b/Crow/Cursors/center_ptr differ
diff --git a/Crow/Cursors/circle b/Crow/Cursors/circle
new file mode 100644 (file)
index 0000000..bdcfdd3
Binary files /dev/null and b/Crow/Cursors/circle differ
index 4596b48078a48c6e076693a8afc582eddc393d5f..5d51f8aea342b4fae226953d394a2e1b2c144df7 100644 (file)
Binary files a/Crow/Cursors/cross and b/Crow/Cursors/cross differ
diff --git a/Crow/Cursors/cross_reverse b/Crow/Cursors/cross_reverse
new file mode 100644 (file)
index 0000000..5d51f8a
Binary files /dev/null and b/Crow/Cursors/cross_reverse differ
diff --git a/Crow/Cursors/crosshair b/Crow/Cursors/crosshair
new file mode 100644 (file)
index 0000000..5d51f8a
Binary files /dev/null and b/Crow/Cursors/crosshair differ
diff --git a/Crow/Cursors/dot b/Crow/Cursors/dot
new file mode 100644 (file)
index 0000000..fd20291
Binary files /dev/null and b/Crow/Cursors/dot differ
diff --git a/Crow/Cursors/dot_box_mask b/Crow/Cursors/dot_box_mask
new file mode 100644 (file)
index 0000000..f9ae0a9
Binary files /dev/null and b/Crow/Cursors/dot_box_mask differ
diff --git a/Crow/Cursors/double_arrow b/Crow/Cursors/double_arrow
new file mode 100644 (file)
index 0000000..2bc2a31
Binary files /dev/null and b/Crow/Cursors/double_arrow differ
diff --git a/Crow/Cursors/draft_large b/Crow/Cursors/draft_large
new file mode 100644 (file)
index 0000000..ef1398a
Binary files /dev/null and b/Crow/Cursors/draft_large differ
diff --git a/Crow/Cursors/draft_small b/Crow/Cursors/draft_small
new file mode 100644 (file)
index 0000000..ef1398a
Binary files /dev/null and b/Crow/Cursors/draft_small differ
diff --git a/Crow/Cursors/draped_box b/Crow/Cursors/draped_box
new file mode 100644 (file)
index 0000000..cf082fa
Binary files /dev/null and b/Crow/Cursors/draped_box differ
diff --git a/Crow/Cursors/exchange b/Crow/Cursors/exchange
new file mode 100644 (file)
index 0000000..2499208
Binary files /dev/null and b/Crow/Cursors/exchange differ
diff --git a/Crow/Cursors/fleur b/Crow/Cursors/fleur
new file mode 100644 (file)
index 0000000..efebc42
Binary files /dev/null and b/Crow/Cursors/fleur differ
diff --git a/Crow/Cursors/gumby b/Crow/Cursors/gumby
new file mode 100644 (file)
index 0000000..f50a94f
Binary files /dev/null and b/Crow/Cursors/gumby differ
diff --git a/Crow/Cursors/hand1 b/Crow/Cursors/hand1
new file mode 100644 (file)
index 0000000..338a54a
Binary files /dev/null and b/Crow/Cursors/hand1 differ
diff --git a/Crow/Cursors/hand2 b/Crow/Cursors/hand2
new file mode 100644 (file)
index 0000000..c517ac4
Binary files /dev/null and b/Crow/Cursors/hand2 differ
diff --git a/Crow/Cursors/left_ptr b/Crow/Cursors/left_ptr
new file mode 100644 (file)
index 0000000..2d7b8d6
Binary files /dev/null and b/Crow/Cursors/left_ptr differ
diff --git a/Crow/Cursors/left_ptr_watch b/Crow/Cursors/left_ptr_watch
new file mode 100644 (file)
index 0000000..583a6b4
Binary files /dev/null and b/Crow/Cursors/left_ptr_watch differ
diff --git a/Crow/Cursors/left_side b/Crow/Cursors/left_side
new file mode 100644 (file)
index 0000000..00947a6
Binary files /dev/null and b/Crow/Cursors/left_side differ
diff --git a/Crow/Cursors/left_tee b/Crow/Cursors/left_tee
new file mode 100644 (file)
index 0000000..2aa29cd
Binary files /dev/null and b/Crow/Cursors/left_tee differ
diff --git a/Crow/Cursors/ll_angle b/Crow/Cursors/ll_angle
new file mode 100644 (file)
index 0000000..d94e152
Binary files /dev/null and b/Crow/Cursors/ll_angle differ
diff --git a/Crow/Cursors/lr_angle b/Crow/Cursors/lr_angle
new file mode 100644 (file)
index 0000000..2ccae16
Binary files /dev/null and b/Crow/Cursors/lr_angle differ
diff --git a/Crow/Cursors/pencil b/Crow/Cursors/pencil
new file mode 100644 (file)
index 0000000..b246fe4
Binary files /dev/null and b/Crow/Cursors/pencil differ
diff --git a/Crow/Cursors/pirate b/Crow/Cursors/pirate
new file mode 100644 (file)
index 0000000..21dca82
Binary files /dev/null and b/Crow/Cursors/pirate differ
diff --git a/Crow/Cursors/plus b/Crow/Cursors/plus
new file mode 100644 (file)
index 0000000..5d51f8a
Binary files /dev/null and b/Crow/Cursors/plus differ
diff --git a/Crow/Cursors/question_arrow b/Crow/Cursors/question_arrow
new file mode 100644 (file)
index 0000000..e82d7e7
Binary files /dev/null and b/Crow/Cursors/question_arrow differ
diff --git a/Crow/Cursors/right_ptr b/Crow/Cursors/right_ptr
new file mode 100644 (file)
index 0000000..ef1398a
Binary files /dev/null and b/Crow/Cursors/right_ptr differ
diff --git a/Crow/Cursors/right_side b/Crow/Cursors/right_side
new file mode 100644 (file)
index 0000000..f7efcb2
Binary files /dev/null and b/Crow/Cursors/right_side differ
diff --git a/Crow/Cursors/right_tee b/Crow/Cursors/right_tee
new file mode 100644 (file)
index 0000000..108c4a5
Binary files /dev/null and b/Crow/Cursors/right_tee differ
diff --git a/Crow/Cursors/sailboat b/Crow/Cursors/sailboat
new file mode 100644 (file)
index 0000000..d028ded
Binary files /dev/null and b/Crow/Cursors/sailboat differ
diff --git a/Crow/Cursors/sb_down_arrow b/Crow/Cursors/sb_down_arrow
new file mode 100644 (file)
index 0000000..d4712c7
Binary files /dev/null and b/Crow/Cursors/sb_down_arrow differ
index 1768b6a0b633b7ba231c1f7a3478b2d7c8dd4155..04fac633eac249c9e94f1165795bd4654d214e73 100644 (file)
Binary files a/Crow/Cursors/sb_h_double_arrow and b/Crow/Cursors/sb_h_double_arrow differ
diff --git a/Crow/Cursors/sb_left_arrow b/Crow/Cursors/sb_left_arrow
new file mode 100644 (file)
index 0000000..27b321b
Binary files /dev/null and b/Crow/Cursors/sb_left_arrow differ
diff --git a/Crow/Cursors/sb_right_arrow b/Crow/Cursors/sb_right_arrow
new file mode 100644 (file)
index 0000000..8aa7ba3
Binary files /dev/null and b/Crow/Cursors/sb_right_arrow differ
diff --git a/Crow/Cursors/sb_up_arrow b/Crow/Cursors/sb_up_arrow
new file mode 100644 (file)
index 0000000..101cb92
Binary files /dev/null and b/Crow/Cursors/sb_up_arrow differ
index a36abd4b104d9b3cd0fb24ce5e1cc8f3e71ce530..a10e4a45ff58e564c757f055735f643fc02d627d 100644 (file)
Binary files a/Crow/Cursors/sb_v_double_arrow and b/Crow/Cursors/sb_v_double_arrow differ
diff --git a/Crow/Cursors/shuttle b/Crow/Cursors/shuttle
new file mode 100644 (file)
index 0000000..34e2913
Binary files /dev/null and b/Crow/Cursors/shuttle differ
diff --git a/Crow/Cursors/sizing b/Crow/Cursors/sizing
new file mode 100644 (file)
index 0000000..0116b65
Binary files /dev/null and b/Crow/Cursors/sizing differ
diff --git a/Crow/Cursors/target b/Crow/Cursors/target
new file mode 100644 (file)
index 0000000..e9eeb59
Binary files /dev/null and b/Crow/Cursors/target differ
diff --git a/Crow/Cursors/tcross b/Crow/Cursors/tcross
new file mode 100644 (file)
index 0000000..5d51f8a
Binary files /dev/null and b/Crow/Cursors/tcross differ
diff --git a/Crow/Cursors/top_left_arrow b/Crow/Cursors/top_left_arrow
new file mode 100644 (file)
index 0000000..2d7b8d6
Binary files /dev/null and b/Crow/Cursors/top_left_arrow differ
index 3493adc65014db24ddd2be45b844128f780e1666..e418bf468b614d5665619d77e5b49d4b44e44626 100644 (file)
Binary files a/Crow/Cursors/top_left_corner and b/Crow/Cursors/top_left_corner differ
index 264cc577246d767b44a657a7c95d0d8a82fa8e5f..68f04948602c52e3c1250e3c08346ec176a94ccd 100644 (file)
Binary files a/Crow/Cursors/top_right_corner and b/Crow/Cursors/top_right_corner differ
diff --git a/Crow/Cursors/top_side b/Crow/Cursors/top_side
new file mode 100644 (file)
index 0000000..ed5b07e
Binary files /dev/null and b/Crow/Cursors/top_side differ
diff --git a/Crow/Cursors/top_tee b/Crow/Cursors/top_tee
new file mode 100644 (file)
index 0000000..8a31eb0
Binary files /dev/null and b/Crow/Cursors/top_tee differ
diff --git a/Crow/Cursors/trek b/Crow/Cursors/trek
new file mode 100644 (file)
index 0000000..46f63f3
Binary files /dev/null and b/Crow/Cursors/trek differ
diff --git a/Crow/Cursors/ul_angle b/Crow/Cursors/ul_angle
new file mode 100644 (file)
index 0000000..ec2eb56
Binary files /dev/null and b/Crow/Cursors/ul_angle differ
diff --git a/Crow/Cursors/ur_angle b/Crow/Cursors/ur_angle
new file mode 100644 (file)
index 0000000..4ef9fc4
Binary files /dev/null and b/Crow/Cursors/ur_angle differ
diff --git a/Crow/Cursors/watch b/Crow/Cursors/watch
new file mode 100644 (file)
index 0000000..61c039f
Binary files /dev/null and b/Crow/Cursors/watch differ
diff --git a/Crow/Cursors/xterm b/Crow/Cursors/xterm
new file mode 100644 (file)
index 0000000..6e6d0b1
Binary files /dev/null and b/Crow/Cursors/xterm differ
index 8af93517f9117070f06e87cd601332f55ef2a533..21165cde5f4156c083f1a07f8bf877f900d95285 100644 (file)
@@ -11,7 +11,7 @@ namespace Crow
        /// <summary>
        /// Universal Color structure
        /// </summary>
-       public struct Color
+       public struct Color : IEquatable<Color>
     {
                #region CTOR
                public Color(double _R, double _G, double _B, double _A)
@@ -100,25 +100,6 @@ namespace Crow
                                double.Parse(c[3]));
                }
 
-               public static bool operator ==(Color left, Color right)
-               {
-                       if (left.predefinied & right.predefinied)
-                               return left.htmlCode == right.htmlCode;
-                       return left.A != right.A ? false :
-                               left.R != right.R ? false :
-                               left.G != right.G ? false :
-                               left.B != right.B ? false : true;
-               }
-               public static bool operator !=(Color left, Color right)
-               {
-                       if (left.predefinied & right.predefinied)
-                               return left.htmlCode != right.htmlCode;
-                       return left.A == right.A ? false :
-                               left.R == right.R ? false :
-                               left.G == right.G ? false :
-                               left.B == right.B ? false : true;
-
-               }
                public static bool operator ==(Color c, string n)
                {
                        return n.StartsWith("#", StringComparison.Ordinal) ?
@@ -382,25 +363,29 @@ namespace Crow
 
                #endregion
 
+               public override bool Equals (object obj)
+                       => obj is Color c && Equals(c);
+               public bool Equals (Color other)
+               {
+                       if (predefinied & other.predefinied)
+                               return htmlCode == other.htmlCode;
+                       return A == other.A && R == other.R && G == other.G && B == other.B;
+               }
+
                public override int GetHashCode ()
                {
                        unchecked // Overflow is fine, just wrap
                        {
                                int hash = 17;
                                // Suitable nullity checks etc, of course :)
-                               hash = hash * 23 + A.GetHashCode();
-                               hash = hash * 23 + R.GetHashCode();
-                               hash = hash * 23 + G.GetHashCode();
-                               hash = hash * 23 + B.GetHashCode();
+                               hash = hash * 23 + A.GetHashCode ();
+                               hash = hash * 23 + R.GetHashCode ();
+                               hash = hash * 23 + G.GetHashCode ();
+                               hash = hash * 23 + B.GetHashCode ();
                                return hash;
                        }
                }
-               public override bool Equals (object obj)
-               {
-                       return (obj == null || obj.GetType() != typeof(Color)) ?
-                               false :
-                               this == (Color)obj;
-               }
+
                public override string ToString()
                {
                        if (!string.IsNullOrEmpty(Name))
@@ -416,36 +401,6 @@ namespace Crow
         {
             return (Color)s;
         }
-               //public static Color FromHSV(double _h, double _v = 1.0, double _s = 1.0, double _alpha = 1.0){
-               //      Color c = Color.Black;
-               //      c.ResetName ();
-               //      c.A = _alpha;
-               //      if (_s == 0) {//HSV from 0 to 1
-               //              c.R = _v;
-               //              c.G = _v;
-               //              c.B = _v;
-               //      }else{
-               //              double var_h = _h * 6.0;
-
-               //              if (var_h == 6.0)
-               //                      var_h = 0;      //H must be < 1
-               //              double var_i = Math.Floor( var_h );     //Or ... var_i = floor( var_h )
-               //              double var_1 = _v * ( 1.0 - _s );
-               //              double var_2 = _v * (1.0 - _s * (var_h - var_i));
-               //              double var_3 = _v * (1.0 - _s * (1.0 - (var_h - var_i)));
-
-               //              if (var_i == 0.0) {
-               //                      c.R = _v;
-               //                      c.G = var_3;
-               //                      c.B = var_1;
-               //              }else if ( var_i == 1.0 ) { c.R = var_2 ; c.G = _v     ; c.B = var_1; }
-               //              else if ( var_i == 2 ) { c.R = var_1 ; c.G = _v     ; c.B = var_3; }
-               //              else if ( var_i == 3 ) { c.R = var_1 ; c.G = var_2 ; c.B = _v;     }
-               //              else if ( var_i == 4 ) { c.R = var_3 ; c.G = var_1 ; c.B = _v;    }
-               //              else                   { c.R = _v     ; c.G = var_1 ; c.B = var_2; }
-               //      }
-               //      return c;
-               //}
                public static Color FromHSV (double _h, double _v = 1.0, double _s = 1.0, double _alpha = 1.0) {
                        double H = _h * 360;
                        double C = _v * _s;
@@ -466,5 +421,6 @@ namespace Crow
 
                        return new Color (C + m, X + m, m, _alpha);
                }
+
        }
 }
index df741d5042bde9af858764f3a534bd9e5f6bad7a..55e3bfcbe8182af8b1d85f3572a5a99227b35477 100644 (file)
@@ -37,27 +37,69 @@ namespace Crow
     }
        public enum MouseCursor
        {
-               Arrow,
-               IBeam,
-               Crosshair,
-               Circle,
-               Hand,
-               Move,
-               Wait,
-               H,
-               V,
-               Top,
-               TopLeft,
-               TopRight,
-               Left,
-               Right,
-               BottomLeft,
-               Bottom,
-               BottomRight,
-               NW,
-               NE,
-               SW,
-               SE,
+               arrow,
+               base_arrow_down,
+               base_arrow_up,
+               boat,
+               bottom_left_corner,
+               bottom_right_corner,
+               bottom_side,
+               bottom_tee,
+               center_ptr,
+               circle,
+               cross,
+               cross_reverse,
+               crosshair,
+               dot,
+               dot_box_mask,
+               double_arrow,
+               draft_large,
+               draft_small,
+               draped_box,
+               exchange,
+               fleur,
+               gumby,
+               hand,
+               hand1,
+               hand2,
+               help,
+               ibeam,
+               left_ptr,
+               left_ptr_watch,
+               left_side,
+               left_tee,
+               ll_angle,
+               lr_angle,
+               move,
+               pencil,
+               pirate,
+               plus,
+               question_arrow,
+               right_ptr,
+               right_side,
+               right_tee,
+               sailboat,
+               sb_down_arrow,
+               sb_h_double_arrow,
+               sb_left_arrow,
+               sb_right_arrow,
+               sb_up_arrow,
+               sb_v_double_arrow,
+               shuttle,
+               sizing,
+               target,
+               tcross,
+               top_left_arrow,
+               top_left_corner,
+               top_right_corner,
+               top_side,
+               top_tee,
+               trek,
+               ul_angle,
+               ur_angle,
+               watch,
+               X_cursor,
+               xterm,                  
        }
        /// <summary>
        /// Cursor shape use in Sliders
index 6d795f664523f8958aad77cb6ea6a21196d1dcb9..b94458356fd2b41660ea13fb5a5feeb74e59915d 100644 (file)
@@ -9,6 +9,7 @@ using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Reflection;
+using System.Runtime.InteropServices;
 using System.Threading;
 using Crow.Cairo;
 using Crow.IML;
@@ -51,11 +52,74 @@ namespace Crow
                }
                #endregion
 
+               #region CTOR
+               static Interface ()
+               {
+                       /*if (Type.GetType ("Mono.Runtime") == null) {
+                               throw new Exception (@"C.R.O.W. run only on Mono, download latest version at: http://www.mono-project.com/download/stable/");
+                       }*/
+
+                       CROW_CONFIG_ROOT =
+                               System.IO.Path.Combine (
+                                       Environment.GetFolderPath (Environment.SpecialFolder.UserProfile),
+                                       ".config");
+                       CROW_CONFIG_ROOT = System.IO.Path.Combine (CROW_CONFIG_ROOT, "crow");
+                       if (!Directory.Exists (CROW_CONFIG_ROOT))
+                               Directory.CreateDirectory (CROW_CONFIG_ROOT);
+
+                       //ensure all assemblies are loaded, because IML could contains classes not instanciated in source
+                       foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
+                               try {
+                                       Assembly.LoadFrom (af);
+                               } catch {
+                                       Console.WriteLine ("{0} not loaded as assembly.", af);
+                               }
+                       }
+
+                       FontRenderingOptions = new FontOptions ();
+                       FontRenderingOptions.Antialias = Antialias.Subpixel;
+                       FontRenderingOptions.HintMetrics = HintMetrics.On;
+                       FontRenderingOptions.HintStyle = HintStyle.Full;
+                       FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
+
+                       loadCursors ();
+               }
+               public Interface (int width, int height, IntPtr glfwWindowHandle) : this (width, height, false, false)
+               {
+                       hWin = glfwWindowHandle;
+               }
+               public Interface (int width = 800, int height = 600, bool startUIThread = true, bool createSurface = true)
+               {
+                       CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
+                       CurrentInterface = this;
+                       clientRectangle = new Rectangle (0, 0, width, height);
+
+                       if (createSurface)
+                               initSurface ();
+
+                       if (startUIThread) {
+                               Thread t = new Thread (InterfaceThread) {
+                                       IsBackground = true
+                               };
+                               t.Start ();
+                       }
+
+#if MEASURE_TIME
+                       PerfMeasures.Add (updateMeasure);
+                       PerfMeasures.Add (drawingMeasure);
+                       PerfMeasures.Add (layoutingMeasure);
+                       PerfMeasures.Add (clippingMeasure);
+#endif
+               }
+               #endregion
+
                /** GLFW callback may return a custom pointer, this list makes the link between the GLFW window pointer and the
                        manage VkWindow instance. */
                static Dictionary<IntPtr, Interface> windows = new Dictionary<IntPtr, Interface> ();
                /** GLFW window native pointer and current native handle for mouse cursor */
-               IntPtr hWin, currentCursor;
+               IntPtr hWin;
+               Cursor currentCursor;
+               bool ownWindow;
 
                void initSurface ()
                {
@@ -63,11 +127,12 @@ namespace Crow
 
                        Glfw3.WindowHint (WindowAttribute.ClientApi, 0);
                        Glfw3.WindowHint (WindowAttribute.Resizable, 1);
+                       Glfw3.WindowHint (WindowAttribute.Decorated, 1);
 
                        hWin = Glfw3.CreateWindow (clientRectangle.Width, clientRectangle.Height, "win name", MonitorHandle.Zero, IntPtr.Zero);
-
                        if (hWin == IntPtr.Zero)
                                throw new Exception ("[GLFW3] Unable to create vulkan Window");
+                       ownWindow = true;
 
                        Glfw3.SetKeyCallback (hWin, HandleKeyDelegate);
                        Glfw3.SetMouseButtonPosCallback (hWin, HandleMouseButtonDelegate);
@@ -132,65 +197,10 @@ namespace Crow
 
                #endregion
 
-               #region CTOR
-               static Interface () {
-                       /*if (Type.GetType ("Mono.Runtime") == null) {
-                               throw new Exception (@"C.R.O.W. run only on Mono, download latest version at: http://www.mono-project.com/download/stable/");
-                       }*/
-
-                       CROW_CONFIG_ROOT =
-                               System.IO.Path.Combine (
-                                       Environment.GetFolderPath (Environment.SpecialFolder.UserProfile),
-                                       ".config");
-                       CROW_CONFIG_ROOT = System.IO.Path.Combine (CROW_CONFIG_ROOT, "crow");
-                       if (!Directory.Exists (CROW_CONFIG_ROOT))
-                               Directory.CreateDirectory (CROW_CONFIG_ROOT);
 
-                       //ensure all assemblies are loaded, because IML could contains classes not instanciated in source
-                       foreach (string af in Directory.GetFiles (AppDomain.CurrentDomain.BaseDirectory, "*.dll")) {
-                               try {
-                                       Assembly.LoadFrom (af);
-                               } catch {
-                                       Console.WriteLine ("{0} not loaded as assembly.", af);
-                               }
-                       }
-
-                       FontRenderingOptions = new FontOptions ();
-                       FontRenderingOptions.Antialias = Antialias.Subpixel;
-                       FontRenderingOptions.HintMetrics = HintMetrics.On;
-                       FontRenderingOptions.HintStyle = HintStyle.Full;
-                       FontRenderingOptions.SubpixelOrder = SubpixelOrder.Default;
-               }
-               public Interface (int width, int height, IntPtr glfwWindowHandle) : this(width, height, false, false)
-               { 
-                       hWin = glfwWindowHandle;
-               }
-               public Interface(int width=800, int height=600, bool startUIThread = true, bool createSurface = true)  {
-                       CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
-                       CurrentInterface = this;
-                       clientRectangle = new Rectangle (0, 0, width, height);
-
-                       if (createSurface)
-                               initSurface ();
-
-                       if (startUIThread) {
-                               Thread t = new Thread (InterfaceThread) {
-                                       IsBackground = true
-                               };
-                               t.Start ();
-                       }
-
-#if MEASURE_TIME
-                       PerfMeasures.Add (updateMeasure);
-                       PerfMeasures.Add (drawingMeasure);
-                       PerfMeasures.Add (layoutingMeasure);
-                       PerfMeasures.Add (clippingMeasure);
-#endif
-               }
-               #endregion
                public bool Running {
                        get => !Glfw3.WindowShouldClose (hWin);
-                       set => Glfw3.SetWindowShouldClose (hWin, 1);
+                       set => Glfw3.SetWindowShouldClose (hWin, value == true ? 0 : 1);
                }
                public virtual void InterfaceThread ()
                {
@@ -204,11 +214,12 @@ namespace Crow
 #endif
                        }
                }
-               protected virtual void Startup ()
+               protected virtual void OnInitialized ()
                {
                        try {
                                Load ("#main.crow").DataSource = this;
                        } catch { }
+                       Initialized.Raise (this, null);
                }
                /// <summary>
                /// load styling, init default tooltips and context menus, load main.crow resource if exists.
@@ -217,7 +228,7 @@ namespace Crow
                        loadStyling ();
                        initTooltip ();
                        initContextMenus ();
-                       Startup ();
+                       OnInitialized ();
                }
                /// <summary>
                /// call Init() then enter the running loop performing ProcessEvents until running==false.
@@ -249,11 +260,11 @@ namespace Crow
                                        // TODO: dispose managed state (managed objects).
                                }
 
-                               if (currentCursor != IntPtr.Zero)
-                                       Glfw3.DestroyCursor (currentCursor);
-
-                               Glfw3.DestroyWindow (hWin);
-                               Glfw3.Terminate ();
+                               currentCursor?.Dispose ();
+                               if (ownWindow) {
+                                       Glfw3.DestroyWindow (hWin);
+                                       Glfw3.Terminate ();
+                               }
 
                                disposedValue = true;
                        }
@@ -296,7 +307,7 @@ namespace Crow
                /// <summary> delay before tooltip appears </summary>
                public static int TOOLTIP_DELAY = 500;
                /// <summary>Double click threshold in milisecond</summary>
-               public static int DOUBLECLICK_TRESHOLD = 240;//max duration between two mouse_down evt for a dbl clk in milisec.
+               public static int DOUBLECLICK_TRESHOLD = 320;//max duration between two mouse_down evt for a dbl clk in milisec.
                /// <summary> Time to wait in millisecond before starting repeat loop</summary>
                public static int DEVICE_REPEAT_DELAY = 700;
                /// <summary> Time interval in millisecond between device event repeat</summary>
@@ -330,7 +341,7 @@ namespace Crow
                #region Events
                //public event EventHandler<MouseCursorChangedEventArgs> MouseCursorChanged;
                ////public event EventHandler Quit;
-
+               public event EventHandler Initialized;
                //public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
                //public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
                //public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
@@ -1048,7 +1059,76 @@ namespace Crow
                }
 
                #region Mouse and Keyboard Handling
-               MouseCursor cursor = MouseCursor.Arrow;
+               MouseCursor cursor = MouseCursor.top_left_arrow;
+               static void loadCursors ()
+               {
+                       const int minimumSize = 32;
+                       //Load cursors
+                       XCursor.Cursors [MouseCursor.arrow] = XCursorFile.Load ("#Crow.Cursors.arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.base_arrow_down] = XCursorFile.Load ("#Crow.Cursors.base_arrow_down").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.base_arrow_up] = XCursorFile.Load ("#Crow.Cursors.base_arrow_up").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.boat] = XCursorFile.Load ("#Crow.Cursors.boat").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.bottom_left_corner] = XCursorFile.Load ("#Crow.Cursors.bottom_left_corner").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.bottom_right_corner] = XCursorFile.Load ("#Crow.Cursors.bottom_right_corner").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.bottom_side] = XCursorFile.Load ("#Crow.Cursors.bottom_side").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.bottom_tee] = XCursorFile.Load ("#Crow.Cursors.bottom_tee").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.center_ptr] = XCursorFile.Load ("#Crow.Cursors.center_ptr").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.circle] = XCursorFile.Load ("#Crow.Cursors.circle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.cross] = XCursorFile.Load ("#Crow.Cursors.cross").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.cross_reverse] = XCursorFile.Load ("#Crow.Cursors.cross_reverse").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.crosshair] = XCursorFile.Load ("#Crow.Cursors.crosshair").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.dot] = XCursorFile.Load ("#Crow.Cursors.dot").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.dot_box_mask] = XCursorFile.Load ("#Crow.Cursors.dot_box_mask").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.double_arrow] = XCursorFile.Load ("#Crow.Cursors.double_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.draft_large] = XCursorFile.Load ("#Crow.Cursors.draft_large").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.draft_small] = XCursorFile.Load ("#Crow.Cursors.draft_small").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.draped_box] = XCursorFile.Load ("#Crow.Cursors.draped_box").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.exchange] = XCursorFile.Load ("#Crow.Cursors.exchange").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.fleur] = XCursorFile.Load ("#Crow.Cursors.fleur").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.gumby] = XCursorFile.Load ("#Crow.Cursors.gumby").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.hand] = XCursorFile.Load ("#Crow.Cursors.hand").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.hand1] = XCursorFile.Load ("#Crow.Cursors.hand1").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.hand2] = XCursorFile.Load ("#Crow.Cursors.hand2").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.help] = XCursorFile.Load ("#Crow.Cursors.help").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.ibeam] = XCursorFile.Load ("#Crow.Cursors.ibeam").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.left_ptr] = XCursorFile.Load ("#Crow.Cursors.left_ptr").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.left_ptr_watch] = XCursorFile.Load ("#Crow.Cursors.left_ptr_watch").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.left_side] = XCursorFile.Load ("#Crow.Cursors.left_side").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.left_tee] = XCursorFile.Load ("#Crow.Cursors.left_tee").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.ll_angle] = XCursorFile.Load ("#Crow.Cursors.ll_angle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.lr_angle] = XCursorFile.Load ("#Crow.Cursors.lr_angle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.move] = XCursorFile.Load ("#Crow.Cursors.move").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.pencil] = XCursorFile.Load ("#Crow.Cursors.pencil").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.pirate] = XCursorFile.Load ("#Crow.Cursors.pirate").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.plus] = XCursorFile.Load ("#Crow.Cursors.plus").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.question_arrow] = XCursorFile.Load ("#Crow.Cursors.question_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.right_ptr] = XCursorFile.Load ("#Crow.Cursors.right_ptr").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.right_side] = XCursorFile.Load ("#Crow.Cursors.right_side").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.right_tee] = XCursorFile.Load ("#Crow.Cursors.right_tee").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sailboat] = XCursorFile.Load ("#Crow.Cursors.sailboat").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_down_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_down_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_h_double_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_h_double_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_left_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_left_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_right_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_right_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_up_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_up_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sb_v_double_arrow] = XCursorFile.Load ("#Crow.Cursors.sb_v_double_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.shuttle] = XCursorFile.Load ("#Crow.Cursors.shuttle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.sizing] = XCursorFile.Load ("#Crow.Cursors.sizing").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.target] = XCursorFile.Load ("#Crow.Cursors.target").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.tcross] = XCursorFile.Load ("#Crow.Cursors.tcross").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.top_left_arrow] = XCursorFile.Load ("#Crow.Cursors.top_left_arrow").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.top_left_corner] = XCursorFile.Load ("#Crow.Cursors.top_left_corner").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.top_right_corner] = XCursorFile.Load ("#Crow.Cursors.top_right_corner").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.top_side] = XCursorFile.Load ("#Crow.Cursors.top_side").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.top_tee] = XCursorFile.Load ("#Crow.Cursors.top_tee").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.trek] = XCursorFile.Load ("#Crow.Cursors.trek").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.ul_angle] = XCursorFile.Load ("#Crow.Cursors.ul_angle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.ur_angle] = XCursorFile.Load ("#Crow.Cursors.ur_angle").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.watch] = XCursorFile.Load ("#Crow.Cursors.watch").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.X_cursor] = XCursorFile.Load ("#Crow.Cursors.X_cursor").Cursors.First (c => c.Width >= minimumSize);
+                       XCursor.Cursors [MouseCursor.xterm] = XCursorFile.Load ("#Crow.Cursors.xterm").Cursors.First (c => c.Width >= minimumSize);
+               }
+
 
                Stopwatch lastMouseDown = Stopwatch.StartNew (), mouseRepeatTimer = new Stopwatch ();
                bool doubleClickTriggered;      //next mouse up will trigger a double click
@@ -1058,57 +1138,25 @@ namespace Crow
                public Point MousePosition { get; set; } = default;
                public bool IsDown (MouseButton button) => Glfw3.GetMouseButton (hWin, button) != InputAction.Release;
 
+               Cursor createCursor (MouseCursor mc)
+               {
+                       XCursor c = XCursor.Cursors [mc];
+                       return new CustomCursor (c.Width, c.Height, c.data, c.Xhot, c.Yhot);
+               }
+
+
                public MouseCursor MouseCursor {
                        get => cursor;
                        set {
-
+                       
                                if (value == cursor)
                                        return;
                                cursor = value;
-                               if (currentCursor != IntPtr.Zero)
-                                       Glfw3.DestroyCursor (currentCursor);
-                               switch (MouseCursor) {
-                               case MouseCursor.Arrow:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.Arrow);
-                                       break;
-                               case MouseCursor.IBeam:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.IBeam);
-                                       break;
-                               case MouseCursor.Crosshair:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.Crosshair);
-                                       break;
-                               case MouseCursor.Circle:
-                                       break;
-                               case MouseCursor.Hand:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.Hand);
-                                       break;
-                               case MouseCursor.Wait:
-                                       break;
-                               case MouseCursor.H:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.HResize);
-                                       break;
-                               case MouseCursor.V:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.VResize);
-                                       break;
-                               case MouseCursor.Move:
-                               case MouseCursor.Top:
-                               case MouseCursor.TopLeft:
-                               case MouseCursor.TopRight:
-                               case MouseCursor.Left:
-                               case MouseCursor.Right:
-                               case MouseCursor.BottomLeft:
-                               case MouseCursor.Bottom:
-                               case MouseCursor.BottomRight:
-                               case MouseCursor.NW:
-                               case MouseCursor.NE:
-                               case MouseCursor.SW:
-                               case MouseCursor.SE:
-                               default:
-                                       currentCursor = Glfw3.CreateStandardCursor (CursorShape.Arrow);
-                                       break;
-                               }
 
-                               Glfw3.SetCursor (hWin, currentCursor);
+                               currentCursor?.Dispose ();
+                               currentCursor = createCursor (cursor);
+                               Console.WriteLine ($"cursor=>{cursor}");
+                               currentCursor.Set (hWin);
                                //MouseCursorChanged.Raise (this,new MouseCursorChangedEventArgs(cursor));
                        }
                }
index e3f2161b70bc32fc7f209f3d157c15cb1d329dae..40801160984b5e6a48c0c02f7100f5c7597693d5 100644 (file)
@@ -91,9 +91,9 @@ namespace Crow
                {
                        base.onMouseEnter (sender, e);
                        if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
-                               IFace.MouseCursor = MouseCursor.H;
+                               IFace.MouseCursor = MouseCursor.sb_h_double_arrow;
                        else
-                               IFace.MouseCursor = MouseCursor.V;
+                               IFace.MouseCursor = MouseCursor.sb_v_double_arrow;
                }
                public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
index 130848bb6a8ed4fd4d23c112a92097c2e097c40b..e3830cd005daf4203496a3f434b72a1b04b56c9e 100644 (file)
@@ -48,12 +48,8 @@ namespace Crow
                #region GraphicObject overrides
                [XmlIgnore]public override bool HasFocus   //trigger update when lost focus to errase text beam
         {
-            get
-            {
-                return base.HasFocus;
-            }
-            set
-            {
+            get => base.HasFocus;
+            set {
                 base.HasFocus = value;
                 RegisterForRedraw();
             }
index 98198d0538a7795912aada16fce2f7c12b5e96c2..418bb5b65db303dd4c5a112e1d2f539ba5df03e6 100644 (file)
@@ -268,7 +268,7 @@ namespace Crow
                bool isActive;
                bool isHover;
                bool mouseRepeat;
-               MouseCursor mouseCursor = MouseCursor.Arrow;
+               MouseCursor mouseCursor = MouseCursor.top_left_arrow;
                protected bool isVisible = true;
                bool isEnabled = true;
                VerticalAlignment verticalAlignment = VerticalAlignment.Center;
@@ -735,7 +735,7 @@ namespace Crow
                /// Determine Cursor when mouse is Hover.
                /// </summary>
                [DesignCategory ("Behaviour")]
-               [DefaultValue (MouseCursor.Arrow)]
+               [DefaultValue (MouseCursor.top_left_arrow)]
                public virtual MouseCursor MouseCursor {
                        get { return mouseCursor; }
                        set {
@@ -1943,7 +1943,7 @@ namespace Crow
                        Debug.WriteLine("MouseEnter => " + this.ToString());
 #endif
 
-                       IFace.MouseCursor = mouseCursor;
+                       IFace.MouseCursor = MouseCursor;
 
                        if (IFace.DragAndDropOperation != null) {
                                Widget g = this;
index 78f96153ce5a01c2330fc566bd4a7a21c895cc45..1952f972a6eb5c7f7632ef0254939250afe96f35 100644 (file)
@@ -315,31 +315,31 @@ namespace Crow
                                //if (currentDirection != lastDir) {
                                        switch (currentDirection) {
                                        case Direction.None:
-                                               otkgw.MouseCursor = MouseCursor.Move;
+                                               otkgw.MouseCursor = MouseCursor.move;
                                                break;
                                        case Direction.N:
-                                               otkgw.MouseCursor = MouseCursor.Top;
+                                               otkgw.MouseCursor = MouseCursor.top_side;
                                                break;
                                        case Direction.S:
-                                               otkgw.MouseCursor = MouseCursor.Bottom;
+                                               otkgw.MouseCursor = MouseCursor.bottom_side;
                                                break;
                                        case Direction.E:
-                                               otkgw.MouseCursor = MouseCursor.Right;
+                                               otkgw.MouseCursor = MouseCursor.right_side;
                                                break;
                                        case Direction.W:
-                                               otkgw.MouseCursor = MouseCursor.Left;
+                                               otkgw.MouseCursor = MouseCursor.left_side;
                                                break;
                                        case Direction.NW:
-                                               otkgw.MouseCursor = MouseCursor.TopLeft;
+                                               otkgw.MouseCursor = MouseCursor.top_left_corner;
                                                break;
                                        case Direction.NE:
-                                               otkgw.MouseCursor = MouseCursor.TopRight;
+                                               otkgw.MouseCursor = MouseCursor.top_right_corner;
                                                break;
                                        case Direction.SW:
-                                               otkgw.MouseCursor = MouseCursor.BottomLeft;
+                                               otkgw.MouseCursor = MouseCursor.bottom_left_corner;
                                                break;
                                        case Direction.SE:
-                                               otkgw.MouseCursor = MouseCursor.BottomRight;
+                                               otkgw.MouseCursor = MouseCursor.bottom_right_corner;
                                                break;
                                        }
                                //}                             
@@ -349,7 +349,7 @@ namespace Crow
                {
                        base.onMouseLeave (sender, e);
                        currentDirection = Direction.None;
-                       IFace.MouseCursor = MouseCursor.Arrow;
+                       IFace.MouseCursor = MouseCursor.top_left_arrow;
                }
                public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
@@ -410,7 +410,7 @@ namespace Crow
 
                protected void butQuitPress (object sender, MouseButtonEventArgs e)
                {
-                       IFace.MouseCursor = MouseCursor.Arrow;
+                       IFace.MouseCursor = MouseCursor.top_left_arrow;
                        close ();
                }
 
index 1cca510e61beb62f3b1d38fa9db8ac00b7b0e813..ddd3bca0407a614e0342f6d5916b06068283a05a 100644 (file)
@@ -86,52 +86,54 @@ namespace Crow
                        return tmp;
                }
 
-               public static XCursorFile Load(Interface iface, string path)
+               public static XCursorFile Load(string path)
                {
-                       return loadFromStream (iface.GetStreamFromPath (path));
+                       return loadFromStream (Interface.StaticGetStreamFromPath (path));
                }
 
-               static XCursor imageLoad(BinaryReader sr)
+               static XCursor imageLoad (BinaryReader sr)
                {
-                       XCursor tmp = new XCursor();
+                       XCursor tmp = new XCursor ();
                        //                      header: 36 Image headers are 36 bytes
-                       uint header = sr.ReadUInt32();
+                       uint header = sr.ReadUInt32 ();
                        //                      type: 0xfffd0002 Image type is 0xfffd0002
-                       uint type = sr.ReadUInt32();
+                       uint type = sr.ReadUInt32 ();
                        //                      subtype: CARD32 Image subtype is the nominal size
-                       uint subtype = sr.ReadUInt32();
+                       uint subtype = sr.ReadUInt32 ();
                        //                      version: 1
-                       uint version = sr.ReadUInt32();
+                       uint version = sr.ReadUInt32 ();
                        //                      width: CARD32 Must be less than or equal to 0x7fff
-                       tmp.Width = sr.ReadUInt32();
+                       tmp.Width = sr.ReadUInt32 ();
                        //                      height: CARD32 Must be less than or equal to 0x7fff
-                       tmp.Height = sr.ReadUInt32();
+                       tmp.Height = sr.ReadUInt32 ();
                        //                      xhot: CARD32 Must be less than or equal to width
-                       tmp.Xhot = sr.ReadUInt32();
+                       tmp.Xhot = sr.ReadUInt32 ();
                        //                      yhot: CARD32 Must be less than or equal to height
-                       tmp.Yhot = sr.ReadUInt32();
+                       tmp.Yhot = sr.ReadUInt32 ();
                        //                      delay: CARD32 Delay between animation frames in milliseconds
-                       tmp.Delay = sr.ReadUInt32();
+                       tmp.Delay = sr.ReadUInt32 ();
                        //                      pixels: LISTofCARD32 Packed ARGB format pixels
-                       tmp.data = sr.ReadBytes((int)(tmp.Width * tmp.Height * 4));
+                       tmp.data = new byte [tmp.Width * tmp.Height * 4];
+                       for (int i = 0; i < tmp.Width * tmp.Height; i++) {
+                               //unchecked { tmp.data [i * 4 + 3] = (byte)(2 * (int)sr.ReadByte ()); }
+                               tmp.data [i * 4 + 0] = sr.ReadByte ();
+                               tmp.data [i * 4 + 1] = sr.ReadByte ();
+                               tmp.data [i * 4 + 2] = sr.ReadByte ();
+                               tmp.data [i * 4 + 3] = sr.ReadByte ();
+
+                               //Console.WriteLine ($"{tmp.data [i * 4 + 3],2:X} {tmp.data [i * 4 + 0],2:X} {tmp.data [i * 4 + 1],2:X} {tmp.data [i * 4 + 2],2:X}");
+                       }
+                       //tmp.data = sr.ReadBytes((int)(tmp.Width * tmp.Height * 4));
+                       /*using(Stream fs = new FileStream($"/tmp/test.bin_{tmp.Width}", FileMode.Create))
+                       using (BinaryWriter sr2 = new BinaryWriter(fs)) {
+                               sr2.Write (tmp.data, 0, tmp.data.Length);
+                       }*/
                        return tmp;
                }
        }
        public class XCursor
        {
-               public static XCursor Default;
-               public static XCursor Cross;
-               public static XCursor Arrow;
-               public static XCursor Text;
-               public static XCursor SW;
-               public static XCursor SE;
-               public static XCursor NW;
-               public static XCursor NE;
-               public static XCursor N;
-               public static XCursor S;
-               public static XCursor V;
-               public static XCursor H;
-
+               public static readonly Dictionary<MouseCursor, XCursor> Cursors = new Dictionary<MouseCursor, XCursor>();
                public uint Width;
                public uint Height;
                public uint Xhot;
index 1e727169dd91410656ee5f7f083461e2faed3375..9e62cfede3f0f938d646793ab752db3346dffeae 100644 (file)
@@ -7,7 +7,7 @@
                <Authors>Jean-Philippe Bruyère</Authors>           
                <LangVersion>7.2</LangVersion>
                
-               <CrowVersion>0.8.12</CrowVersion>
+               <CrowVersion>0.9.1</CrowVersion>
                <CrowPackageVersion>$(CrowVersion)-beta</CrowPackageVersion>
                <CrowStbSharp>true</CrowStbSharp>
        </PropertyGroup>
index 530c76708a56786c794cefd6963e1177dc1acde6..28d28b50b0ce032ef53822a65c806bfada6bba6d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@
   C# Rapid Open Widgets
   <br>  
 <p align="center">
+  <a href="https://www.nuget.org/packages/Crow"><img src="https://buildstats.info/nuget/Crow"></a>
   <a href="https://travis-ci.org/jpbruyere/Crow">
       <img src="https://img.shields.io/travis/jpbruyere/Crow.svg?&logo=travis&logoColor=white">
   </a>
 </p>
 </h1>
 
-**C.R.O.W.** is an open source  [application framework](https://en.wikipedia.org/wiki/Application_framework) for building portable graphical interfaces in **C#**. It provides a declarative interface language with **styling** and **templates** called [IML](interface-markup-language) for **Interface Markup Language** similar to [XAML](https://en.wikipedia.org/wiki/Extensible_Application_Markup_Language) and a binding system for easy code linking.
+### Introduction
 
-C.R.O.W. is in **beta** development state, api could change.
-
-There's currently **3 main versions**, diverging on the way they handle OS integration. The last one replace [Cairo](https://www.cairographics.org/) with [vkvg](https://github.com/jpbruyere/vkvg).
+Open source  [application framework](https://en.wikipedia.org/wiki/Application_framework) for building portable graphical interfaces in **C#**, featuring a ***declarative language*** for ui with ***styling*** and ***templates*** called [IML](interface-markup-language) similar to [XAML](https://en.wikipedia.org/wiki/Extensible_Application_Markup_Language) and a ***binding system*** for easy code linking.
 
-| Package         | Description      | Link                             |
-|-------------------|--------------------|------------------------------|
-| Crow.OpenTK |OS layer handle with [OpenTK](https://github.com/opentk/opentk), fast implementation of 3D gui in OTK scenes |[![nuget](https://buildstats.info/nuget/Crow.OpenTK?includePreReleases=true&vWidth=100)](https://www.nuget.org/packages/Crow.OpenTK)    |
-| Crow               | `IBackend` interface for **xcb** and **win32** |[![nuget](https://buildstats.info/nuget/Crow?includePreReleases=true&vWidth=100)](https://www.nuget.org/packages/Crow)     |
-| Crow.Vk          | OS layer with [GLFW](https://www.glfw.org/), [vkvg](https://github.com/jpbruyere/vkvg) for accelerated 2d vectors and text.| [![nuget](https://buildstats.info/nuget/Crow.VK?includePreReleases=true&vWidth=100)](https://www.nuget.org/packages/Crow.Vk)     |
+C.R.O.W. is in **beta** development state, api could change.
 
-#### Features
+### Features
 - [Declarative interface definition](https://github.com/jpbruyere/Crow/wiki/interface-markup-language).
 - [Templates](https://github.com/jpbruyere/Crow/wiki/Templates)
 - [Styling](https://github.com/jpbruyere/Crow/wiki/Styling)
 - [Dynamic binding system](https://github.com/jpbruyere/Crow/wiki/The-binding-system)
 - SVG rendering (with [rsvg library](https://developer.gnome.org/rsvg/))
 
+### Requirements
+- [GLFW3](https://www.glfw.org/) for platform dependant integration.
+- [Cairo Graphic Library](https://cairographics.org/) >= 1.20, for 2d graphic rendering.
+- [rsvg library](https://developer.gnome.org/rsvg/) for svg rendering
+
+
 <p align="center">
   <a href="https://github.com/jpbruyere/Crow/blob/master/Images/screenshot.png">
        <kbd><img src="https://github.com/jpbruyere/Crow/blob/master/Images/screenshot.png" height="200"></kbd>
@@ -54,7 +55,7 @@ There's currently **3 main versions**, diverging on the way they handle OS integ
   </a>
 </p>
 
-#### Documentation
+### Documentation
 
 Due to the early state of this project and the frequent changes, some part of the docs may be outdated.
 
@@ -64,7 +65,3 @@ Due to the early state of this project and the frequent changes, some part of th
 
 Please report bugs and issues on [GitHub](https://github.com/jpbruyere/Crow/issues)
 
-### Requirements
-- [Cairo Graphic Library](https://cairographics.org/) >= 1.20 
-- [rsvg library](https://developer.gnome.org/rsvg/) for svg rendering
-
index 4e89ca79221fff35d8715599b37560ef339b8139..05bc0435a1c8d72badd2019c5899ca2a72f4aed9 100644 (file)
@@ -18,7 +18,7 @@ namespace tests
                        }
                }
 
-               protected override void Startup ()
+               protected override void OnInitialized ()
                {
                        Commands = new List<Crow.Command> (new Crow.Command [] {
                                new Crow.Command(new Action(() => command1())) { Caption = "command1"},
index 0089943e0851f815c57f8369fa16ee273a7ce91e..44ec3fb882dc7468852a8e94b546c17e66d9cbba 100644 (file)
@@ -3,40 +3,12 @@ using Crow;
 
 namespace HelloWorld
 {
-       class Program : Interface {
-               Command CMDQuit;
+       class Program {
                static void Main (string[] args) {
-                       using (Program vke = new Program ()) {
-                               vke.Run ();
+                       using (Interface app = new Interface ()) {
+                               app.Initialized += (sender, e) => (sender as Interface).Load ("#HelloWorld.helloworld.crow");
+                               app.Run ();
                        }
                }
-               protected override void Startup ()
-               {
-                       CMDQuit = new Command (new Action (Quit)) { Caption = "Quit", Icon = new SvgPicture ("#Crow.Icons.exit-symbol.svg") };
-
-                       Widget w = Load ("#HelloWorld.helloworld.crow");
-                       w.KeyPress += W_KeyPress;
-                       w.DataSource = this;
-               }
-
-               Color [] colors = { Color.Blue, Color.DarkGoldenRod, Color.Red, Color.Azure, Color.Brown, Color.Black, Color.White, Color.Pink };
-               int ptr = 0;
-
-               void W_KeyPress (object sender, KeyPressEventArgs e)
-               {
-                       switch (e.KeyChar) {
-                       case 'w':
-                               LoadIMLFragment ($"<DockWindow Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>");
-                               break;
-                       case 'x':
-                               LoadIMLFragment ($"<Window Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>");
-                               break;
-                       }
-
-                       ptr++;
-                       if (ptr == colors.Length)
-                               ptr = 0;
-               }
-
        }
 }
index cb1b8887b9e2ecfb8f37ab1679ac500abc305db5..2d7a3176d431025225cf74169ffa32772c0239df 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
-<Window>
-       <Label Text="Hello World"/>
+<Window Width="200" Height="200">
+       <TextBox Text="Hello World" Background="Blue"/>
 </Window>
 
 
index ac1032900850355d20f3bb3bca4ff9de49e64291..8a91a89437b2fe714134174d18c7dcc309eb1908 100644 (file)
@@ -28,7 +28,7 @@ namespace tests
                        }
                }
 
-               protected override void Startup ()
+               protected override void OnInitialized ()
                {
                        Widget g = Load ("#ShowCase.showcase.crow");
                        g.DataSource = this;
@@ -86,7 +86,7 @@ namespace tests
 
                void showError (Exception ex)
                {
-                       NotifyValueChanged ("ErrorMessage", ex.ToString());
+                       NotifyValueChanged ("ErrorMessage", ex.Message);
                        NotifyValueChanged ("ShowError", true);
                }
                void hideError ()