]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 13:12:47 +0000 (14:12 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 13:12:47 +0000 (14:12 +0100)
12 files changed:
Crow/Templates/ToolWindow.template
Crow/Templates/Window.template
Crow/src/IML/BindingMember.cs
Crow/src/Widgets/ColorPicker.cs
Crow/src/Widgets/Popper.cs
Crow/src/Widgets/TabView2.cs [new file with mode: 0644]
Crow/src/Widgets/TextBox.cs
Crow/src/Widgets/Window.cs
Samples/ShowCase/Editor.cs [new file with mode: 0644]
Samples/ShowCase/ui/showcase.crow
Samples/common/ui/templates/ColorPicker.template
Samples/common/ui/templates/TabItem.template [new file with mode: 0644]

index 7840fb301e9a93456171da9f030bd7c2b3e7f213..b0af1c5d230fa1aa5d0c14e81771f94eaf7fd5ef 100644 (file)
                                <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>
index dee91bcd41403fe8233828e241bcbfe880d76d20..a1de29de3e10337e0310fa63668110f1d3cbb336 100644 (file)
@@ -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>
index 0678fb3228079e2b301a767000aa84a89c179600..2f96f131dc18f6c08d57dec8b590e7d039f3c6ef 100644 (file)
@@ -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>
index 4f5c0539c010f411e614185673b958c3fa64b3b3..3ea8b547538841465282c7276ade0afba31b57c5 100644 (file)
@@ -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;
+               }
        }
 }
 
index 99b3ef7d2c792274966872b7065c084c64a3fd70..e99bbcbc0304e4503b0e6a42600d2018c1897bcb 100644 (file)
@@ -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 (file)
index 0000000..43c6f8c
--- /dev/null
@@ -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
+
+               
+       }
+}
+
index 68bcffcac3cefbf4f5a8ada6b1bada59b83e0a00..dddcdfb1e2b625c0ed54203754acffe410177a93 100644 (file)
@@ -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}");
index 374b67d265646d553075a5bce110834e2952bff6..e18c1d772cf7c926f1a3725952ef22130a2d6bf5 100644 (file)
@@ -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 (file)
index 0000000..315a5a9
--- /dev/null
@@ -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
index 5b0e467c9db665de8e663245d6fda75e314dbaba..3d589b3db20fc9dfec6c6e3fb0de9077a2857c32 100644 (file)
@@ -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"
index 7c5ff263c2cc217228ffbf6766fba729cd58c525..96d6edbd5a4530734e6196e32b1a3aca48193032 100644 (file)
@@ -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 (file)
index 0000000..a95b4db
--- /dev/null
@@ -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>
+