aboutsummaryrefslogtreecommitdiffstatsci
path: root/Samples/common
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-10-30 19:38:50 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-10-30 19:38:50 +0200
commita4367fb29faf7ee987b937e2397359a6020f25b9 (patch)
treec4bda0d5d5b2cc73b11f38795d151fbaf2c0c9a7 /Samples/common
parentc706b713a716e8b7fd29508ccf88e5de5041d1d4 (diff)
update readme
Diffstat (limited to 'Samples/common')
-rw-r--r--Samples/common/src/MyNumericControl.cs46
-rw-r--r--Samples/common/src/TestWidget.cs26
-rw-r--r--Samples/common/ui/Interfaces/Divers/0.crow2
-rw-r--r--Samples/common/ui/Interfaces/Totorials/myNumericControlTest.crow16
-rw-r--r--Samples/common/ui/Interfaces/Totorials/testWidget.crow3
5 files changed, 92 insertions, 1 deletions
diff --git a/Samples/common/src/MyNumericControl.cs b/Samples/common/src/MyNumericControl.cs
new file mode 100644
index 00000000..38e162a3
--- /dev/null
+++ b/Samples/common/src/MyNumericControl.cs
@@ -0,0 +1,46 @@
+//Tutorial
+using Crow;
+
+namespace MyNumericControl {
+ public class MyNumericControl : TemplatedControl {
+ protected double actualValue, minValue, maxValue;
+ public double Minimum {
+ get => minValue;
+ set {
+ if (minValue == value)
+ return;
+ minValue = value;
+ if (Value < minValue)
+ Value = minValue;
+ NotifyValueChangedAuto (minValue);
+ }
+ }
+ public double Maximum {
+ get => maxValue;
+ set {
+ if (maxValue == value)
+ return;
+ maxValue = value;
+ NotifyValueChangedAuto (maxValue);
+
+ if (Value > maxValue)
+ Value = maxValue;
+
+ }
+ }
+ public virtual double Value {
+ get => actualValue;
+ set {
+ if (actualValue == value)
+ return;
+ if (value < minValue)
+ actualValue = minValue;
+ else if (value > maxValue)
+ actualValue = maxValue;
+ else
+ actualValue = value;
+ NotifyValueChangedAuto (actualValue);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Samples/common/src/TestWidget.cs b/Samples/common/src/TestWidget.cs
new file mode 100644
index 00000000..bf2f6bd0
--- /dev/null
+++ b/Samples/common/src/TestWidget.cs
@@ -0,0 +1,26 @@
+//Tutorial
+using Crow;
+using Crow.Drawing;
+using Glfw;
+
+namespace TestWidget {
+ public class TestWidget : Widget {
+ protected override void onDraw (Context gr) {
+ base.onDraw (gr);
+ gr.SetSource (myColor);
+ gr.Rectangle (ClientRectangle);
+ gr.Fill();
+ }
+ Color myColor = Colors.Green;
+ public override void onMouseEnter(object sender, MouseMoveEventArgs e) {
+ base.onMouseEnter (sender, e);
+ myColor = Colors.Chartreuse;
+ RegisterForRedraw ();
+ }
+ public override void onMouseLeave(object sender, MouseMoveEventArgs e) {
+ base.onMouseLeave (sender, e);
+ myColor = Colors.Green;
+ RegisterForRedraw ();
+ }
+ }
+} \ No newline at end of file
diff --git a/Samples/common/ui/Interfaces/Divers/0.crow b/Samples/common/ui/Interfaces/Divers/0.crow
index d9ba0161..d282fade 100644
--- a/Samples/common/ui/Interfaces/Divers/0.crow
+++ b/Samples/common/ui/Interfaces/Divers/0.crow
@@ -87,7 +87,7 @@
</VerticalStack>
<Splitter />
<VerticalStack Width="30%" Margin="5">
- <ListBox Focusable="true" Name="colorList" Data="{TestList}" Margin="5" ItemTemplate="Interfaces/colorItem.crow" />
+ <ListBox Focusable="true" Name="colorList" Data="{TestList}" Margin="5" ItemTemplate="#ui.colorItem.crow" />
</VerticalStack>
</HorizontalStack>
</Window> \ No newline at end of file
diff --git a/Samples/common/ui/Interfaces/Totorials/myNumericControlTest.crow b/Samples/common/ui/Interfaces/Totorials/myNumericControlTest.crow
new file mode 100644
index 00000000..fda9f400
--- /dev/null
+++ b/Samples/common/ui/Interfaces/Totorials/myNumericControlTest.crow
@@ -0,0 +1,16 @@
+<MyNumericControl Minimum="0" Maximum="100" Value="50" Background="Jet" >
+ <Template>
+ <VerticalStack Spacing="20" Height="Fit" Width="80%" Background="{./Background}" Margin="20">
+ <HorizontalStack Spacing="5" Fit="true">
+ <Label Text="min:"/>
+ <TextBox Text="{²./Minimum}" Width="60" TextAlignment="Right"/>
+ <Label Text="val:"/>
+ <TextBox Text="{²./Value}" Width="60" TextAlignment="Right"/>
+ <Label Text="max:"/>
+ <TextBox Text="{²./Maximum}" Width="60" TextAlignment="Right" />
+ </HorizontalStack>
+ <Gauge Height="20" Minimum="{./Minimum}" Maximum="{./Maximum}" Value="{²./Value}"
+ Background="DarkGrey" Margin="5" Foreground="CornflowerBlue"/>
+ </VerticalStack>
+ </Template>
+</MyNumericControl>
diff --git a/Samples/common/ui/Interfaces/Totorials/testWidget.crow b/Samples/common/ui/Interfaces/Totorials/testWidget.crow
new file mode 100644
index 00000000..2bd2c7ac
--- /dev/null
+++ b/Samples/common/ui/Interfaces/Totorials/testWidget.crow
@@ -0,0 +1,3 @@
+<Container Margin="50" Background="SteelBlue" >
+ <TestWidget Background="DarkGrey" Margin="20"/>
+</Container> \ No newline at end of file