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 /Samples | |
| parent | bb9053da569aceaa3f58a97bfbc42c7a178cf9a1 (diff) | |
wip
Diffstat (limited to 'Samples')
| -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 |
4 files changed, 103 insertions, 59 deletions
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> + |