diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-03-27 14:12:47 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-03-27 14:12:47 +0100 |
| commit | 983371d5934520e5a29a105e88ce893eaeca3663 (patch) | |
| tree | ebfed89ac3c7dd4110a82adc06eac9a196e3810a | |
| parent | bb9053da569aceaa3f58a97bfbc42c7a178cf9a1 (diff) | |
wip
| -rw-r--r-- | Crow/Templates/ToolWindow.template | 4 | ||||
| -rw-r--r-- | Crow/Templates/Window.template | 2 | ||||
| -rw-r--r-- | Crow/src/IML/BindingMember.cs | 4 | ||||
| -rw-r--r-- | Crow/src/Widgets/ColorPicker.cs | 6 | ||||
| -rw-r--r-- | Crow/src/Widgets/Popper.cs | 4 | ||||
| -rw-r--r-- | Crow/src/Widgets/TabView2.cs | 17 | ||||
| -rw-r--r-- | Crow/src/Widgets/TextBox.cs | 2 | ||||
| -rw-r--r-- | Crow/src/Widgets/Window.cs | 38 | ||||
| -rw-r--r-- | Samples/ShowCase/Editor.cs | 44 | ||||
| -rw-r--r-- | Samples/ShowCase/ui/showcase.crow | 5 | ||||
| -rw-r--r-- | Samples/common/ui/templates/ColorPicker.template | 93 | ||||
| -rw-r--r-- | Samples/common/ui/templates/TabItem.template | 20 |
12 files changed, 146 insertions, 93 deletions
diff --git a/Crow/Templates/ToolWindow.template b/Crow/Templates/ToolWindow.template index 7840fb30..b0af1c5d 100644 --- a/Crow/Templates/ToolWindow.template +++ b/Crow/Templates/ToolWindow.template @@ -10,10 +10,10 @@ <Border CornerRadius="6" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Icons.exit2.svg" - MouseClick="./butQuitPress"/> + MouseClick="./onQuitPress"/> </Border> <Widget Width="5"/> </HorizontalStack> - <Container Name="Content" MinimumSize="50,50" Background="0.5,0.5,0.5,0.5"/> + <Container Name="Content" MinimumSize="50,50"/> </VerticalStack> </Border> diff --git a/Crow/Templates/Window.template b/Crow/Templates/Window.template index dee91bcd..a1de29de 100644 --- a/Crow/Templates/Window.template +++ b/Crow/Templates/Window.template @@ -19,7 +19,7 @@ </Border> <Border BorderWidth="1" Style="WindowIconBorder"> <Image Focusable="true" Path="#Crow.Icons.exit2.svg" - MouseClick="./butQuitPress"/> + MouseClick="./onQuitPress"/> </Border> <Widget Width="5"/> </HorizontalStack> diff --git a/Crow/src/IML/BindingMember.cs b/Crow/src/IML/BindingMember.cs index 0678fb32..2f96f131 100644 --- a/Crow/src/IML/BindingMember.cs +++ b/Crow/src/IML/BindingMember.cs @@ -56,7 +56,7 @@ namespace Crow.IML /// <summary> /// Target the template's root node, expression was in the form './name[.name[...]]' or '/name[.name[...]]' /// </summary> - public bool IsTemplateBinding { get { return LevelsUp < 0; }} + public bool IsTemplateBinding => LevelsUp < 0; /// <summary> /// No level change and expression was '.name' @@ -70,7 +70,7 @@ namespace Crow.IML /// <summary> /// no level change, and only a single name in Tokens[], that's dataSource member if property binding /// </summary> - public bool IsSingleName { get { return LevelsUp == 0 && Tokens.Length == 1; }} + public bool IsSingleName => LevelsUp == 0 && Tokens.Length == 1; #region CTOR /// <summary> diff --git a/Crow/src/Widgets/ColorPicker.cs b/Crow/src/Widgets/ColorPicker.cs index 4f5c0539..3ea8b547 100644 --- a/Crow/src/Widgets/ColorPicker.cs +++ b/Crow/src/Widgets/ColorPicker.cs @@ -33,8 +33,12 @@ namespace Crow NotifyValueChanged ("CurrentColor2", Color.FromHSV (currentColor.Hue, currentColor.Value, currentColor.Saturation, currentColor.A)); } } + public IList<Colors> AvailableColors => //Enum.GetValues (typeof (Color)).ToList<Color> ();// Colors. ColorDic.Values.OrderBy (c => c.Hue).ToList (); + FastEnumUtility.FastEnum.GetValues<Colors> ().ToList<Colors> (); - //public IList<Color> ColorList => Enum.GetValues (typeof (Color)).ToList<Color> ();// Colors. ColorDic.Values.OrderBy (c => c.Hue).ToList (); + public void onSelectedItemChanged(object sender, SelectionChangeEventArgs e) { + CurrentColor = (Color)(Colors)e.NewValue; + } } } diff --git a/Crow/src/Widgets/Popper.cs b/Crow/src/Widgets/Popper.cs index 99b3ef7d..e99bbcbc 100644 --- a/Crow/src/Widgets/Popper.cs +++ b/Crow/src/Widgets/Popper.cs @@ -193,7 +193,7 @@ namespace Crow public virtual void onPop(object sender, EventArgs e) { if (Content != null) { - Content.Visible = true; + Content.IsVisible = true; if (Content.Parent == null) IFace.AddWidget (Content); //if (Content.LogicalParent != this) @@ -206,7 +206,7 @@ namespace Crow public virtual void onUnpop(object sender, EventArgs e) { if (Content != null) { - Content.Visible = false; + Content.IsVisible = false; } Unpoped.Raise (this, e); } diff --git a/Crow/src/Widgets/TabView2.cs b/Crow/src/Widgets/TabView2.cs new file mode 100644 index 00000000..43c6f8c9 --- /dev/null +++ b/Crow/src/Widgets/TabView2.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com> +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +namespace Crow +{ + public class TabView2 : TemplatedGroup + { + #region CTOR + protected TabView2 () {} + public TabView2 (Interface iface, string style = null) : base (iface, style) { } + #endregion + + + } +} + diff --git a/Crow/src/Widgets/TextBox.cs b/Crow/src/Widgets/TextBox.cs index 68bcffca..dddcdfb1 100644 --- a/Crow/src/Widgets/TextBox.cs +++ b/Crow/src/Widgets/TextBox.cs @@ -312,7 +312,7 @@ namespace Crow } #endregion - void update (TextChange change) { + protected void update (TextChange change) { lock (linesMutex) { Span<char> tmp = stackalloc char[Text.Length + (change.ChangedText.Length - change.Length)]; //Console.WriteLine ($"{Text.Length,-4} {change.Start,-4} {change.Length,-4} {change.ChangedText.Length,-4} tmp:{tmp.Length,-4}"); diff --git a/Crow/src/Widgets/Window.cs b/Crow/src/Widgets/Window.cs index 374b67d2..e18c1d77 100644 --- a/Crow/src/Widgets/Window.cs +++ b/Crow/src/Widgets/Window.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2013-2019 Bruyère Jean-Philippe jp_bruyere@hotmail.com +// Copyright (c) 2013-2021 Bruyère Jean-Philippe jp_bruyere@hotmail.com // // This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) @@ -26,8 +26,7 @@ namespace Crow string _icon; bool resizable; bool movable; - bool modal; - protected bool hoverBorder = false; + bool modal; bool alwaysOnTop = false; Rectangle savedBounds; @@ -77,7 +76,7 @@ namespace Crow #region public properties [DefaultValue("#Crow.Icons.crow.svg")] public string Icon { - get { return _icon; } + get => _icon; set { if (_icon == value) return; @@ -87,9 +86,7 @@ namespace Crow } [DefaultValue(true)] public bool Resizable { - get { - return resizable; - } + get => resizable; set { if (resizable == value) return; @@ -99,9 +96,7 @@ namespace Crow } [DefaultValue(true)] public bool Movable { - get { - return movable; - } + get => movable; set { if (movable == value) return; @@ -111,9 +106,7 @@ namespace Crow } [DefaultValue(false)] public bool Modal { - get { - return modal; - } + get => modal; set { if (modal == value) return; @@ -123,28 +116,23 @@ namespace Crow } [DefaultValue(false)] public bool IsMinimized { - get { return _minimized; } + get => _minimized; set{ if (value == IsMinimized) return; _minimized = value; - _contentContainer.Visible = !_minimized; + _contentContainer.IsVisible = !_minimized; NotifyValueChangedAuto (_minimized); } } - [XmlIgnore]public bool IsMaximized { - get { return Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; } - } - [XmlIgnore]public bool IsNormal { - get { return !(IsMaximized|_minimized); } - } + [XmlIgnore]public bool IsMaximized => + Width == Measure.Stretched & Height == Measure.Stretched & !_minimized; + [XmlIgnore]public bool IsNormal => !(IsMaximized|_minimized); [DefaultValue(false)] public bool AlwaysOnTop { - get { - return modal ? true : alwaysOnTop; - } + get => modal ? true : alwaysOnTop; set { if (alwaysOnTop == value) return; @@ -385,7 +373,7 @@ namespace Crow Minimize.Raise (sender, e); } - protected void butQuitPress (object sender, MouseButtonEventArgs e) + public void onQuitPress (object sender, MouseButtonEventArgs e) { IFace.MouseCursor = MouseCursor.top_left_arrow; close (); diff --git a/Samples/ShowCase/Editor.cs b/Samples/ShowCase/Editor.cs new file mode 100644 index 00000000..315a5a9d --- /dev/null +++ b/Samples/ShowCase/Editor.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2013-2019 Bruyère Jean-Philippe <jp_bruyere@hotmail.com> +// +// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT) + +using System; +using Glfw; +using Crow.Text; + +namespace Crow +{ + public class Editor : TextBox { + public override void onKeyDown(object sender, KeyEventArgs e) + { + TextSpan selection = Selection; + if (e.Key == Key.Tab && !selection.IsEmpty) { + int lineStart = lines.GetLocation (selection.Start).Line; + int lineEnd = lines.GetLocation (selection.End).Line; + + if (IFace.Shift) { + for (int l = lineStart; l <= lineEnd; l++) { + if (Text[lines[l].Start] == '\t') + update (new TextChange (lines[l].Start, 1, "")); + else if (Char.IsWhiteSpace (Text[lines[l].Start])) { + int i = 1; + while (i < lines[l].Length && i < Interface.TAB_SIZE && Char.IsWhiteSpace (Text[i])) + i++; + update (new TextChange (lines[l].Start, i, "")); + } + } + + }else{ + for (int l = lineStart; l <= lineEnd; l++) + update (new TextChange (lines[l].Start, 0, "\t")); + } + + selectionStart = new CharLocation (lineStart, 0); + CurrentLoc = new CharLocation (lineEnd, lines[lineEnd].Length); + + return; + } + base.onKeyDown(sender, e); + } + } +}
\ No newline at end of file diff --git a/Samples/ShowCase/ui/showcase.crow b/Samples/ShowCase/ui/showcase.crow index 5b0e467c..3d589b3d 100644 --- a/Samples/ShowCase/ui/showcase.crow +++ b/Samples/ShowCase/ui/showcase.crow @@ -29,8 +29,9 @@ <Label Text="{../../tb.CurrentColumn}" Margin="2"/> </HorizontalStack> <HorizontalStack> - <TextBox Name="tb" Text="{Source}" Multiline="true" Font="consolas, 12" Focusable="true" Height="Stretched" Width="Stretched" - TextChanged="onTextChanged" KeyDown="textView_KeyDown" ContextCommands="{EditorCommands}"/> + <Editor Name="tb" Text="{Source}" Multiline="true" Font="consolas, 12" Focusable="true" Height="Stretched" Width="Stretched" + TextChanged="onTextChanged" KeyDown="textView_KeyDown" ContextCommands="{EditorCommands}" + Foreground="DarkGrey" Background="White"/> <!--SelectionChanged="onSelectedTextChanged"--> <ScrollBar Value="{²../tb.ScrollY}" LargeIncrement="{../tb.PageHeight}" SmallIncrement="1" diff --git a/Samples/common/ui/templates/ColorPicker.template b/Samples/common/ui/templates/ColorPicker.template index 7c5ff263..96d6edbd 100644 --- a/Samples/common/ui/templates/ColorPicker.template +++ b/Samples/common/ui/templates/ColorPicker.template @@ -1,60 +1,39 @@ <?xml version="1.0"?> -<TabView SelectedTab="0"> - <TabItem Caption="HSV"> - <Border Background="{./Background}" Foreground="{./Foreground}" Width="Stretched" - CornerRadius="{./CornerRadius}" BorderWidth="1"> - <VerticalStack Margin="2"> - <Widget Width="30" Height="16" Background="{./CurrentColor}"/> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="R:"/> - <ColorSlider Name="cs" Component="Red" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="G:"/> - <ColorSlider Name="cs" Component="Green" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="B:"/> - <ColorSlider Name="cs" Component="Blue" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="A:"/> - <ColorSlider Name="cs" Component="Alpha" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="H:"/> - <ColorSlider Name="cs" Component="Hue" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="S:"/> - <ColorSlider Name="cs" Component="Saturation" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - <HorizontalStack Height="Fit"> - <Label Style="labColor" Text="V:"/> - <ColorSlider Name="cs" Component="Value" CurrentColor="{²../../../../../../CurrentColor}"/> - <Label Style="labColorV" Text="{../cs.CurrentValue}" /> - </HorizontalStack> - </VerticalStack> - </Border> - </TabItem> - <TabItem Caption="List" Height="Stretched"> - <ListBox Data="{../../../ColorList}" SelectedItem="{²../../../CurrentColor}"> +<Popper Margin="0" Caption="{./CurrentColor}" Background="{./Background}" > + <Template> + <CheckBox Margin="0" Caption="{./Caption}" IsChecked="{²./IsPopped}" Background="{./Background}"> <Template> - <Scroller Name="scroller1" Margin="5"> - <Wrapper Name="ItemsContainer" Height="Fit" VerticalAlignment="Top"/> - </Scroller> + <HorizontalStack Margin="3" Spacing="3" Background="{./Background}"> + <Border Width="18" Height="12" CornerRadius="3" + Background="{../../../../CurrentColor}"> + </Border> + <Label Width="Stretched" Text="{./Caption}" /> + </HorizontalStack> </Template> - <ItemTemplate> - <Border Width="16" Height="16" Background="{}" Foreground="Transparent" Tooltip="{}" - MouseEnter="{Foreground=Black}" - MouseLeave="{Foreground=Transparent}"/> - </ItemTemplate> - </ListBox> - </TabItem> -</TabView>
\ No newline at end of file + </CheckBox> + </Template> + <TabView MinimumSize="{../../MinimumPopupSize}" Width="Fit" Height="Fit" ActivateNewTab="false"> + <TabItem Template="#ui.TabItem.template" Caption="HSV" Width="Fit" Height="Fit"> + <ColorPicker CurrentColor="{²../../../../CurrentColor}" /> + </TabItem> + <TabItem Template="#ui.TabItem.template" Caption="Colors names" SelectedBackground="Jet" Width="Stretched" Height="Stretched"> + <ColorPicker CurrentColor="{²../../../../CurrentColor}" > + <Template> + <ListBox Data="{./AvailableColors}" SelectedItem="{²./CurrentColor}" Width="200" Height="200"> + <!--<Template> + <Scroller Name="scroller1" Margin="5"> + <Wrapper Name="ItemsContainer" Height="Fit" VerticalAlignment="Top"/> + </Scroller> + </Template> + <ItemTemplate> + <Border Width="16" Height="16" Background="{}" Foreground="Transparent" Tooltip="{}" + MouseEnter="{Foreground=Black}" + MouseLeave="{Foreground=Transparent}"/> + </ItemTemplate>--> + </ListBox> + </Template> + </ColorPicker> + </TabItem> + </TabView> +</Popper> + diff --git a/Samples/common/ui/templates/TabItem.template b/Samples/common/ui/templates/TabItem.template new file mode 100644 index 00000000..a95b4dbe --- /dev/null +++ b/Samples/common/ui/templates/TabItem.template @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<GenericStack Orientation="Vertical" Spacing="0" + Background="{./Background}" + MouseEnter="{/caption.Foreground=White}" + MouseLeave="{/caption.Foreground=Grey}"> + <HorizontalStack Margin="2" Left="{./TabOffset}" + Name="TabTitle" + HorizontalAlignment="Left" + Height="{./TabHeight}" + Width="{./TabWidth}"> + <Label Name="caption" Text="{./Caption}" Foreground="Grey" Width="Stretched"/> + <Border CornerRadius="5" BorderWidth="1" Foreground="Transparent" Height="12" Width="12" + MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"> + <Image Focusable="true" Name="Image" Margin="0" Width="Stretched" Height="Stretched" Path="#Crow.Icons.exit2.svg" + MouseClick="./butCloseTabClick"/> + </Border> + </HorizontalStack> + <Container Name="Content"/> +</GenericStack> + |