Browse Source

collapse news now don't resize startup window

flabbet 1 year ago
parent
commit
e9c15396e5

+ 43 - 26
src/PixiEditor/Views/Windows/HelloTherePopup.axaml

@@ -35,7 +35,9 @@
                 <ColumnDefinition Width="300" />
             </Grid.ColumnDefinitions>
 
-            <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" IsVisible="{Binding !ShowAllBetaExamples, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" Margin="3,0">
+            <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto"
+                          IsVisible="{Binding !ShowAllBetaExamples, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}"
+                          Margin="3,0">
                 <Grid Grid.Row="1" Margin="0,30,0,0">
                     <Grid.RowDefinitions>
                         <RowDefinition Height="90" />
@@ -50,12 +52,13 @@
                             <CheckBox.Styles>
                                 <Style Selector="CheckBox:checked TextBlock#checkboxImage">
                                     <Setter Property="Text" Value="{DynamicResource icon-chevron-right}" />
-                                    <Setter Property="Margin" Value="2 0 0 0"/>
+                                    <Setter Property="Margin" Value="2 0 0 0" />
                                 </Style>
                             </CheckBox.Styles>
                             <CheckBox.Template>
                                 <ControlTemplate TargetType="{x:Type CheckBox}">
-                                    <Border CornerRadius="50" Width="40" Height="40" Background="{DynamicResource ThemeBackgroundBrush2}">
+                                    <Border CornerRadius="50" Width="40" Height="40"
+                                            Background="{DynamicResource ThemeBackgroundBrush2}">
                                         <TextBlock Focusable="False" x:Name="checkboxImage"
                                                    Classes="pixi-icon" FontSize="40" Margin="-2 0 0 0"
                                                    Text="{DynamicResource icon-chevron-left}" />
@@ -80,12 +83,15 @@
                     <StackPanel Grid.Row="2" HorizontalAlignment="Center" Margin="0,30,0,0">
                         <TextBlock FontSize="23" FontWeight="SemiBold" HorizontalAlignment="Center"
                                    ui:Translator.Key="BETA_EXAMPLE_FILES" />
-                        
+
                         <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
-                            <windows:BetaExampleButton FileName="Pond.pixi" DisplayName="POND_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            <windows:BetaExampleButton FileName="Tree.pixi" DisplayName="TREE_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            <windows:BetaExampleButton FileName="Stars.pixi" DisplayName="STARS_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            
+                            <windows:BetaExampleButton FileName="Pond.pixi" DisplayName="POND_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Tree.pixi" DisplayName="TREE_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Stars.pixi" DisplayName="STARS_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+
                             <StackPanel>
                                 <Button Margin="0,10,0,0" HorizontalAlignment="Center"
                                         Width="100" Height="100"
@@ -94,7 +100,8 @@
                                         Command="{Binding SetShowAllBetaExamplesCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}"
                                         CommandParameter="{x:True}">
                                     <Grid Width="100" Height="100">
-                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" ui:Translator.Key="SHOW_ALL_EXAMPLES"/>
+                                        <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"
+                                                   ui:Translator.Key="SHOW_ALL_EXAMPLES" />
                                     </Grid>
                                 </Button>
 
@@ -104,7 +111,7 @@
                                            FontSize="18" Margin="10,10,10,2" HorizontalAlignment="Center" />
                             </StackPanel>
                         </StackPanel>
-                        
+
                         <TextBlock Margin="0,8,0,0" FontSize="23" FontWeight="SemiBold" HorizontalAlignment="Center"
                                    ui:Translator.Key="RECENT_FILES" />
                         <TextBlock Margin="0,12.5,0,0" Foreground="LightGray" HorizontalAlignment="Center"
@@ -325,32 +332,42 @@
                     </panels:AlignableWrapPanel>
                 </Grid>
             </ScrollViewer>
-            
-            <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" IsVisible="{Binding ShowAllBetaExamples, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" Margin="3,0">
+
+            <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto"
+                          IsVisible="{Binding ShowAllBetaExamples, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}"
+                          Margin="3,0">
                 <StackPanel>
                     <Button Margin="6,8,0,0" HorizontalAlignment="Left"
                             Command="{Binding SetShowAllBetaExamplesCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}"
                             CommandParameter="{x:False}"
-                            Content="Go back" HorizontalContentAlignment="Left"/>
-                    
-                    <TextBlock ui:Translator.Key="BETA_EXAMPLE_FILES" Margin="0,-9,0,5" HorizontalAlignment="Center" TextAlignment="Center" FontSize="22" FontWeight="Bold" />
-                    
-                    <TextBlock ui:Translator.Key="BETA_PROCEDURAL_GENERATION" Margin="0,2" HorizontalAlignment="Center" TextAlignment="Center" FontSize="18" FontWeight="SemiBold" />
-                    
+                            Content="Go back" HorizontalContentAlignment="Left" />
+
+                    <TextBlock ui:Translator.Key="BETA_EXAMPLE_FILES" Margin="0,-9,0,5" HorizontalAlignment="Center"
+                               TextAlignment="Center" FontSize="22" FontWeight="Bold" />
+
+                    <TextBlock ui:Translator.Key="BETA_PROCEDURAL_GENERATION" Margin="0,2" HorizontalAlignment="Center"
+                               TextAlignment="Center" FontSize="18" FontWeight="SemiBold" />
+
                     <ScrollViewer HorizontalAlignment="Center" VerticalScrollBarVisibility="Auto">
                         <StackPanel Orientation="Horizontal">
-                            <windows:BetaExampleButton FileName="Pond.pixi" DisplayName="POND_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            <windows:BetaExampleButton FileName="Tree.pixi" DisplayName="TREE_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            <windows:BetaExampleButton FileName="Stars.pixi" DisplayName="STARS_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
-                            <windows:BetaExampleButton FileName="Outline.pixi" DisplayName="OUTLINE_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Pond.pixi" DisplayName="POND_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Tree.pixi" DisplayName="TREE_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Stars.pixi" DisplayName="STARS_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Outline.pixi" DisplayName="OUTLINE_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
                         </StackPanel>
                     </ScrollViewer>
-                    
-                    <TextBlock ui:Translator.Key="BETA_ANIMATIONS" Margin="0,8,0,2" HorizontalAlignment="Center" TextAlignment="Center" FontSize="18" FontWeight="SemiBold" />
-                    
+
+                    <TextBlock ui:Translator.Key="BETA_ANIMATIONS" Margin="0,8,0,2" HorizontalAlignment="Center"
+                               TextAlignment="Center" FontSize="18" FontWeight="SemiBold" />
+
                     <ScrollViewer HorizontalAlignment="Center" VerticalScrollBarVisibility="Auto">
                         <StackPanel Orientation="Horizontal">
-                            <windows:BetaExampleButton FileName="Slime.pixi" DisplayName="SLIME_EXAMPLE" CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
+                            <windows:BetaExampleButton FileName="Slime.pixi" DisplayName="SLIME_EXAMPLE"
+                                                       CloseCommand="{Binding CloseCommand, RelativeSource={RelativeSource AncestorType=windows:HelloTherePopup}}" />
                         </StackPanel>
                     </ScrollViewer>
                 </StackPanel>

+ 4 - 5
src/PixiEditor/Views/Windows/HelloTherePopup.axaml.cs

@@ -4,6 +4,7 @@ using System.Threading.Tasks;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Interactivity;
+using Avalonia.Threading;
 using CommunityToolkit.Mvvm.Input;
 using PixiEditor.Helpers.Extensions;
 using PixiEditor.Extensions.CommonApi.UserPreferences.Settings.PixiEditor;
@@ -132,7 +133,7 @@ internal partial class HelloTherePopup : PixiEditorPopup
 
         if (_newsDisabled || NewsPanelCollapsed)
         {
-            Enumerable.Last<ColumnDefinition>(grid.ColumnDefinitions).Width = new GridLength(0);
+            grid.ColumnDefinitions.Last<ColumnDefinition>().Width = new GridLength(0);
             newsWidth = 0;
         }
 
@@ -167,13 +168,11 @@ internal partial class HelloTherePopup : PixiEditorPopup
 
         if (e.NewValue.Value)
         {
-            helloTherePopup.Width -= 300;
-            Enumerable.Last<ColumnDefinition>(helloTherePopup.grid.ColumnDefinitions).Width = new GridLength(0);
+            helloTherePopup.grid.ColumnDefinitions.Last<ColumnDefinition>().Width = new GridLength(0);
         }
         else
         {
-            helloTherePopup.Width += 300;
-            Enumerable.Last<ColumnDefinition>(helloTherePopup.grid.ColumnDefinitions).Width = new GridLength(300);
+            helloTherePopup.grid.ColumnDefinitions.Last<ColumnDefinition>().Width = new GridLength(300);
         }
 
         PixiEditorSettings.StartupWindow.NewsPanelCollapsed.Value = e.NewValue.Value;