]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 17:40:28 +0000 (18:40 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 27 Mar 2021 17:40:28 +0000 (18:40 +0100)
Crow/src/Text/TextSpan.cs
Crow/src/Widgets/Label.cs
Samples/common/ui/Interfaces/Container/3.crow
Samples/common/ui/Interfaces/Divers/testTextBox.crow
Samples/common/ui/Interfaces/TemplatedContainer/testPopper.crow

index 0ea0a6381cb737e3dce20149bcde9957532658d6..ca1f34742b24dd81cab1deace27e8aa14e7893d4 100644 (file)
@@ -29,6 +29,7 @@ namespace Crow.Text
                public static bool operator ==(TextSpan left, TextSpan right)
                        => left.Equals (right);         
                public static bool operator !=(TextSpan left, TextSpan right)
-                       => !left.Equals (right);                
+                       => !left.Equals (right);
+               public override string ToString() => $"{Start},{End}";
        }
 }
index 066793d08e096424dc28976a677e32ffd31e90f8..00788de40041fcb1236be4dc537df2f7545c76d2 100644 (file)
@@ -290,7 +290,9 @@ namespace Crow
                /// Current Selected text span.
                /// </summary>
                public TextSpan Selection {
-                       get {                           
+                       get {
+                               if (CurrentLoc == null)
+                                       return default;
                                CharLocation selStart = CurrentLoc.Value, selEnd = CurrentLoc.Value;
                                if (selectionStart.HasValue) {
                                        if (CurrentLoc.Value.Line < selectionStart.Value.Line) {
index 5ca515a86066a368c4f454d716112b153322463b..4d6d1ec3734c6cb513449f202a50b078f5c87518 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
 <Container Background="Blue" Margin="10" Fit="true">
-       <Label Text="tes" Margin="10" Fit="true" Background="SeaGreen"/>
+       <Label Text="test" Margin="10" Fit="true" Background="SeaGreen"/>
 </Container>
\ No newline at end of file
index f58e800e4bcfbdb558ad50c08cfd8453cf722253..266eeebbb5fc77ead26ef9e7c373ca3c812b9286 100644 (file)
@@ -1,22 +1,20 @@
 <?xml version="1.0"?>
 <VerticalStack Background="SteelBlue" Fit="true">
        <HorizontalStack Fit="true">
-               <TextBox Background="DarkGrey" Height="30" Width="50" TextAlignment="Left"/>
-               <TextBox Background="DarkGrey" Height="30" Width="50" TextAlignment="Center"/>
-               <TextBox Background="DarkGrey" Height="30" Width="50" TextAlignment="Right"/>
+               <TextBox Background="DarkGrey" Width="50" TextAlignment="Left" Foreground="White"/>
+               <TextBox Background="DarkGrey" Width="50" TextAlignment="Center" Foreground="White"/>
+               <TextBox Background="DarkGrey" Width="50" TextAlignment="Right" Foreground="White"/>
        </HorizontalStack>
        
-       <TextBox Name="tb" Multiline="true" Font="droid,16" Margin="5" Text="A\nBB\nCCC\nDDDD"/>
-       <TextBox Multiline="true" Font="droid,16" Name="tb5" Margin="5" Text="{../tb.SelectedText}"/>
-<!--   <TextBox Font="droid,10" Name="tb1" Margin="5" Text="this is a test of a text box"/>
-       <TextBox Width="300" Height="35" Text="this is a test of a text box"/>-->
+       <TextBox Text="A\nBB\nCCC\nDDDD" Focused="true" Name="tb" Multiline="true" Font="droid,16" Margin="5" />
+       <TextBox Multiline="true" Font="droid,16" Name="tb5" Margin="5" Text="{../tb.Selection}"/>
        <TextBox Font="droid,10" Name="tb2" Margin="0" Text="this is a test of a text box"/>
        <TextBox Font="droid,10" Name="tb3" Margin="5" Text="this is a test of a text box"/>
        <TextBox Font="droid,10" Name="tb4" Margin="5" Text="this is a test of a text box"/>
        <TextBox Font="droid,10" Name="tb5" Margin="20" Text="this is a test of a text box"/>
        <TextBox Multiline="true" Font="droid,10" Name="tb6" Margin="5" Text="this is a test of a text box\nthis is a test of a text box"/>
        <TextBox Multiline="true" Font="droid,10" Name="tb7" Margin="1" TextAlignment="Center"
-               Text="this is a test of a text box\nthis is a test\nthis is a test when line are centered"/>
+               Text="this is a test of a text boxthis is a test\nthis is a test when line are centered"/>
        <TextBox Multiline="true" Font="droid,10" Name="tb8" Margin="1" TextAlignment="Center"
                Text="this is a test of a text box\n\n\nthis is a test\nthis is a test when line are centered"/>
 </VerticalStack>
\ No newline at end of file
index beac87341307b003aec6d1ba205b22d1e5f246b6..15de8eff5ab3a1b48fc5cdbafedc713ecfa8d2eb 100644 (file)
@@ -1,18 +1,11 @@
 <?xml version="1.0"?>
-<VerticalStack>
-       <Border Fit="true" Margin="10">
-               <VerticalStack Width="150" Height="Fit">
-                       <RadioButton Caption="Left" IsChecked="true" Checked="change_alignment"/>
-                       <RadioButton Caption="Right" Checked="change_alignment"/>
-                       <RadioButton Caption="Top" Checked="change_alignment"/>
-                       <RadioButton Caption="Bottom" Checked="change_alignment"/>
-               </VerticalStack>
-       </Border>
-       <Widget Height="200"/>
-       <Popper Caption="TestPopper" Width="100" Background="DimGrey" PopDirection="{alignment}">
+<Group Margin="10">
+       <EnumSelector Caption="Pop Direction" RadioButtonStyle="CheckBox2" HorizontalAlignment="Left" VerticalAlignment="Top" EnumValue="{²../popper.PopDirection}"/>
+       <Popper Name="popper" Caption="Popping Widget" Width="Fit" Background="DimGrey" PopDirection="Right"
+               MouseEnter="{IsPopped='true'}">
                <Border Fit="True" Background="SteelBlue">
-                       <Image Fit="true" Path="#Crow.Icons.crow.svg" Margin="10"/>
                        <VerticalStack Fit="true" Margin="10" Background="CornflowerBlue">
+                               <Image Width="64" Height="64" Path="#Crow.Icons.crow.svg" Margin="1" />
                                <CheckBox Name="chk1" Background="Red"/>
                                <CheckBox Name="chk2" IsChecked="true"/>
                                <CheckBox Name="chk3"/>
@@ -24,4 +17,5 @@
                        </VerticalStack>
                </Border>
        </Popper>
-</VerticalStack>
+       <Label Multiline="true" VerticalAlignment="Bottom" Text="Popping Direction is overriden if space not sufficient."/>
+</Group>