aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2025-03-05 09:12:17 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2025-03-05 09:12:17 +0100
commitebb15c9f57cf0ccddcf1345648e9f2d031bae637 (patch)
treefdd5170c96eab6e6693ca6f9d55a5ff8e40514d7
parent232b019ff2e8ceeaef63c0fd9207a3d193d2046e (diff)
move other classes to Drawing2d
-rw-r--r--Crow/src/Enums.cs129
-rw-r--r--Crow/src/ItemTemplate.cs3
-rw-r--r--Crow/src/Widgets/GenericStack.cs3
-rw-r--r--Crow/src/Widgets/Grid.cs130
-rw-r--r--Crow/src/Widgets/HorizontalStack.cs1
-rw-r--r--Crow/src/Widgets/Wrapper.cs4
-rw-r--r--Crow/src/XCursor.cs1
-rw-r--r--Drawing2D/src/Enums copy.cs138
-rw-r--r--Drawing2D/src/Font.cs (renamed from Crow/src/Font.cs)0
-rw-r--r--Drawing2D/src/IMLAttributes.cs2
-rw-r--r--Drawing2D/src/IObservableList.cs (renamed from Crow/src/IObservableList.cs)0
-rw-r--r--Drawing2D/src/ISelectable.cs (renamed from Crow/src/ISelectable.cs)0
-rw-r--r--Drawing2D/src/IToggle.cs (renamed from Crow/src/IToggle.cs)0
-rw-r--r--Drawing2D/src/IValueChange.cs (renamed from Crow/src/IValueChange.cs)0
-rw-r--r--Drawing2D/src/ListChangedEventArg.cs (renamed from Crow/src/EventArgs/ListChangedEventArg.cs)0
-rw-r--r--Drawing2D/src/ObservableList.cs (renamed from Crow/src/ObservableList.cs)0
-rw-r--r--Drawing2D/src/ValueChangeEventArgs.cs (renamed from Crow/src/EventArgs/ValueChangeEventArgs.cs)0
-rw-r--r--Samples/common/ui/Interfaces/Experimental/testGrid.crow10
18 files changed, 207 insertions, 214 deletions
diff --git a/Crow/src/Enums.cs b/Crow/src/Enums.cs
index 866e32a9..ad113bec 100644
--- a/Crow/src/Enums.cs
+++ b/Crow/src/Enums.cs
@@ -4,132 +4,5 @@
namespace Crow
{
- public enum Orientation
- {
- Horizontal,
- Vertical
- }
-
- public enum Alignment
- {
- Top = 0x01,
- Left = 0x02,
- TopLeft = 0x03,
- Right = 0x04,
- TopRight = 0x05,
- Bottom = 0x08,
- BottomLeft = 0x0a,
- BottomRight = 0x0c,
- Center = 0x10,
- Undefined = 0x40
- }
- public enum TextAlignment
- {
- Left,
- Right,
- Center,
- Justify
- }
- public enum HorizontalAlignment
- {
- Left,
- Right,
- Center,
- }
- public enum VerticalAlignment
- {
- Top,
- Bottom,
- Center,
- }
- public enum MouseCursor
- {
- 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
- /// </summary>
- public enum CursorType
- {
- /// <summary>Only Background of cursor will be drawm, you may use a bmp, svg, or shape as background for custom shape.</summary>
- None,
- Rectangle,
- Circle,
- Pentagone
- }
- /// <summary>
- /// Color component used in color widgets
- /// </summary>
- public enum ColorComponent
- {
- Red,
- Green,
- Blue,
- Alpha,
- Hue,
- Saturation,
- Value
- }
+
}
diff --git a/Crow/src/ItemTemplate.cs b/Crow/src/ItemTemplate.cs
index cf5bcab3..6d922886 100644
--- a/Crow/src/ItemTemplate.cs
+++ b/Crow/src/ItemTemplate.cs
@@ -20,9 +20,6 @@ using System.Collections;
//at the root level of the item template if the dataTest is 'typeOf'...
namespace Crow
{
- /// <summary> Test func on data, return yes if there's children </summary>
- public delegate bool BooleanTestOnInstance(object instance);
-
/// <summary>
/// Derived from Instantiator with sub data fetching facilities for hierarchical data access.
///
diff --git a/Crow/src/Widgets/GenericStack.cs b/Crow/src/Widgets/GenericStack.cs
index 4c0a85d9..d5375c5f 100644
--- a/Crow/src/Widgets/GenericStack.cs
+++ b/Crow/src/Widgets/GenericStack.cs
@@ -109,9 +109,8 @@ namespace Crow {
}
Widget stretchedGO = null;
public override bool UpdateLayout (LayoutingType layoutType) {
- RegisteredLayoutings &= (~layoutType);
-
if (layoutType == LayoutingType.ArrangeChildren) {
+ RegisteredLayoutings &= (~layoutType);
//allow 1 child to have stretched size,
//this child will occupy remaining space
//if stack size policy is Fit, no child may have stretch enabled
diff --git a/Crow/src/Widgets/Grid.cs b/Crow/src/Widgets/Grid.cs
index 4d7edced..e5c0809f 100644
--- a/Crow/src/Widgets/Grid.cs
+++ b/Crow/src/Widgets/Grid.cs
@@ -1,35 +1,7 @@
-//
-// Grid.cs
+// Copyright (c) 2013-2025 Bruyère Jean-Philippe jp_bruyere@hotmail.com
//
-// Author:
-// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Xml.Serialization;
using System.ComponentModel;
namespace Crow
@@ -44,59 +16,57 @@ namespace Crow
{
#region CTOR
protected Grid () : base(){}
- public Grid(Interface iface) : base(iface)
- {
- }
+ public Grid(Interface iface, string style = null) : base (iface, style) { }
#endregion
#region Private fields
- int _spacing;
- int _columnCount;
- int _rowCount;
+ int spacing;
+ int columnCount;
+ int rowCount;
#endregion
#region Public Properties
- [DefaultValue(2)]
- public int Spacing
- {
- get { return _spacing; }
- set { _spacing = value; }
+ [DefaultValue (2)]
+ public int Spacing {
+ get => spacing;
+ set {
+ if (spacing == value)
+ return;
+ spacing = value;
+ NotifyValueChangedAuto (spacing);
+ RegisterForLayouting (LayoutingType.ArrangeChildren);
+ }
}
[DefaultValue(2)]
public virtual int ColumnCount
{
- get { return _columnCount; }
+ get { return columnCount; }
set {
- if (_columnCount == value)
+ if (columnCount == value)
return;
- _columnCount = value;
+ columnCount = value;
NotifyValueChangedAuto (ColumnCount);
- this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ RegisterForLayouting (LayoutingType.ArrangeChildren);
}
}
[DefaultValue(2)]
public virtual int RowCount
{
- get { return _rowCount; }
+ get { return rowCount; }
set {
- if (_rowCount == value)
+ if (rowCount == value)
return;
- _rowCount = value;
+ rowCount = value;
NotifyValueChangedAuto (RowCount);
- this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ RegisterForLayouting (LayoutingType.ArrangeChildren);
}
}
- public virtual int CaseWidth {
- get => (Slot.Width - (ColumnCount - 1) * Spacing) / ColumnCount;
- }
- public virtual int CaseHeight {
- get => (Slot.Height - (RowCount - 1) * Spacing) / RowCount;
- }
-
+ public virtual int CaseWidth => (Slot.Width - (ColumnCount - 1) * Spacing) / ColumnCount;
+ public virtual int CaseHeight => (Slot.Height - (RowCount - 1) * Spacing) / RowCount;
#endregion
#region Widget Overrides
@@ -119,9 +89,9 @@ namespace Crow
public override void ChildrenLayoutingConstraints (ILayoutable layoutable, ref LayoutingType layoutType)
{
//Prevent child repositionning
- layoutType &= (~LayoutingType.Positioning);
+ layoutType &= (~LayoutingType.Sizing);
}
- public override bool ArrangeChildren { get { return true; } }
+ public override bool ArrangeChildren => true;
public virtual void ComputeChildrenPositions()
{
int slotWidth = CaseWidth;
@@ -134,31 +104,43 @@ namespace Crow
Widget c = Children [idx];
if (!c.IsVisible)
continue;
- c.Slot.X = curX * (slotWidth + Spacing);
- c.Slot.Y = curY * (slotHeight + Spacing);
- //c.Slot.Width = slotWidth;
- //c.Slot.Height = slotHeight;
+ int x = curX * (slotWidth + Spacing);
+ if (c.Slot.X != x) {
+ c.Slot.X = x;
+ c.OnLayoutChanges (LayoutingType.X);
+ c.LastSlots.X = c.Slot.X;
+ IsDirty = true;
+ }
+ int y = curY * (slotHeight + Spacing);
+ if (c.Slot.Y != y) {
+ c.Slot.Y = y;
+ c.OnLayoutChanges (LayoutingType.Y);
+ c.LastSlots.Y = c.Slot.Y;
+ IsDirty = true;
+ }
}
}
IsDirty = true;
}
- public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
- {
- //base.OnChildLayoutChanges (sender, arg);
- }
+ public override void RegisterForLayouting(LayoutingType layoutType)
+ {
+ base.RegisterForLayouting(layoutType);
+ }
+ public override void OnLayoutChanges(LayoutingType layoutType)
+ {
+ base.OnLayoutChanges(layoutType);
+ }
+ public override void OnChildLayoutChanges(object sender, LayoutingEventArgs arg)
+ {
+ base.OnChildLayoutChanges(sender, arg);
+ }
- public override bool UpdateLayout (LayoutingType layoutType)
+ public override bool UpdateLayout (LayoutingType layoutType)
{
- RegisteredLayoutings &= (~layoutType);
-
if (layoutType == LayoutingType.ArrangeChildren) {
+ RegisteredLayoutings &= (~layoutType);
ComputeChildrenPositions ();
-
- //if no layouting remains in queue for item, registre for redraw
- if (RegisteredLayoutings == LayoutingType.None && IsDirty)
- IFace.EnqueueForRepaint (this);
-
return true;
}
diff --git a/Crow/src/Widgets/HorizontalStack.cs b/Crow/src/Widgets/HorizontalStack.cs
index 5e16c326..517f692e 100644
--- a/Crow/src/Widgets/HorizontalStack.cs
+++ b/Crow/src/Widgets/HorizontalStack.cs
@@ -2,6 +2,7 @@
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
namespace Crow
{
/// <summary>
diff --git a/Crow/src/Widgets/Wrapper.cs b/Crow/src/Widgets/Wrapper.cs
index ef7d627a..734227b7 100644
--- a/Crow/src/Widgets/Wrapper.cs
+++ b/Crow/src/Widgets/Wrapper.cs
@@ -2,6 +2,7 @@
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using static Crow.Logger;
+
namespace Crow
{
/// <summary>
@@ -180,9 +181,8 @@ namespace Crow
public override bool UpdateLayout (LayoutingType layoutType)
{
- RegisteredLayoutings &= (~layoutType);
-
if (layoutType == LayoutingType.ArrangeChildren) {
+ RegisteredLayoutings &= (~layoutType);
if ((RequiredLayoutings & LayoutingType.Sizing) != 0)
return false;
diff --git a/Crow/src/XCursor.cs b/Crow/src/XCursor.cs
index 2fdfa5a0..b74f7293 100644
--- a/Crow/src/XCursor.cs
+++ b/Crow/src/XCursor.cs
@@ -7,6 +7,7 @@ using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
+using Drawing2D;
namespace Crow
{
diff --git a/Drawing2D/src/Enums copy.cs b/Drawing2D/src/Enums copy.cs
new file mode 100644
index 00000000..d8a975ad
--- /dev/null
+++ b/Drawing2D/src/Enums copy.cs
@@ -0,0 +1,138 @@
+// Copyright (c) 2018-2022 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+
+using System;
+
+namespace Crow
+{
+
+ public enum Orientation
+ {
+ Horizontal,
+ Vertical
+ }
+
+ public enum Alignment
+ {
+ Top = 0x01,
+ Left = 0x02,
+ TopLeft = 0x03,
+ Right = 0x04,
+ TopRight = 0x05,
+ Bottom = 0x08,
+ BottomLeft = 0x0a,
+ BottomRight = 0x0c,
+ Center = 0x10,
+ Undefined = 0x40
+ }
+ public enum TextAlignment
+ {
+ Left,
+ Right,
+ Center,
+ Justify
+ }
+ public enum HorizontalAlignment
+ {
+ Left,
+ Right,
+ Center,
+ }
+ public enum VerticalAlignment
+ {
+ Top,
+ Bottom,
+ Center,
+ }
+ public enum MouseCursor
+ {
+ 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
+ /// </summary>
+ public enum CursorType
+ {
+ /// <summary>Only Background of cursor will be drawm, you may use a bmp, svg, or shape as background for custom shape.</summary>
+ None,
+ Rectangle,
+ Circle,
+ Pentagone
+ }
+ /// <summary>
+ /// Color component used in color widgets
+ /// </summary>
+ public enum ColorComponent
+ {
+ Red,
+ Green,
+ Blue,
+ Alpha,
+ Hue,
+ Saturation,
+ Value
+ }
+} \ No newline at end of file
diff --git a/Crow/src/Font.cs b/Drawing2D/src/Font.cs
index e39f9125..e39f9125 100644
--- a/Crow/src/Font.cs
+++ b/Drawing2D/src/Font.cs
diff --git a/Drawing2D/src/IMLAttributes.cs b/Drawing2D/src/IMLAttributes.cs
index 9a6d7dfb..0c7a07a5 100644
--- a/Drawing2D/src/IMLAttributes.cs
+++ b/Drawing2D/src/IMLAttributes.cs
@@ -6,6 +6,8 @@ using System;
namespace Crow
{
+ /// <summary> Test func on data, return yes if there's children </summary>
+ public delegate bool BooleanTestOnInstance(object instance);
public class XmlIgnoreAttribute : Attribute
{
}
diff --git a/Crow/src/IObservableList.cs b/Drawing2D/src/IObservableList.cs
index 4c8ae236..4c8ae236 100644
--- a/Crow/src/IObservableList.cs
+++ b/Drawing2D/src/IObservableList.cs
diff --git a/Crow/src/ISelectable.cs b/Drawing2D/src/ISelectable.cs
index 23fdcfd6..23fdcfd6 100644
--- a/Crow/src/ISelectable.cs
+++ b/Drawing2D/src/ISelectable.cs
diff --git a/Crow/src/IToggle.cs b/Drawing2D/src/IToggle.cs
index 6a47b404..6a47b404 100644
--- a/Crow/src/IToggle.cs
+++ b/Drawing2D/src/IToggle.cs
diff --git a/Crow/src/IValueChange.cs b/Drawing2D/src/IValueChange.cs
index b79c7fae..b79c7fae 100644
--- a/Crow/src/IValueChange.cs
+++ b/Drawing2D/src/IValueChange.cs
diff --git a/Crow/src/EventArgs/ListChangedEventArg.cs b/Drawing2D/src/ListChangedEventArg.cs
index 7f83cfaf..7f83cfaf 100644
--- a/Crow/src/EventArgs/ListChangedEventArg.cs
+++ b/Drawing2D/src/ListChangedEventArg.cs
diff --git a/Crow/src/ObservableList.cs b/Drawing2D/src/ObservableList.cs
index a62e7e3a..a62e7e3a 100644
--- a/Crow/src/ObservableList.cs
+++ b/Drawing2D/src/ObservableList.cs
diff --git a/Crow/src/EventArgs/ValueChangeEventArgs.cs b/Drawing2D/src/ValueChangeEventArgs.cs
index 854e2cd3..854e2cd3 100644
--- a/Crow/src/EventArgs/ValueChangeEventArgs.cs
+++ b/Drawing2D/src/ValueChangeEventArgs.cs
diff --git a/Samples/common/ui/Interfaces/Experimental/testGrid.crow b/Samples/common/ui/Interfaces/Experimental/testGrid.crow
index 1385acc4..2eaccda2 100644
--- a/Samples/common/ui/Interfaces/Experimental/testGrid.crow
+++ b/Samples/common/ui/Interfaces/Experimental/testGrid.crow
@@ -1,6 +1,6 @@
-<Grid ColumnCount="2" RowCount="2">
- <Label/>
- <Label/>
- <Label/>
- <Label/>
+<Grid ColumnCount="3" RowCount="3" Width="Stretched" Height="Stretched" Background="Green">
+ <Label HorizontalAlignment="Right"/>
+ <Label HorizontalAlignment="Right"/>
+ <Label VerticalAlignment="Top"/>
+ <Label Background="RebeccaPurple"/>
</Grid> \ No newline at end of file