flabbet 1 год назад
Родитель
Сommit
fa8b8b6bc5

+ 1 - 0
src/PixiEditor.AvaloniaUI/App.axaml

@@ -19,6 +19,7 @@
         <StyleInclude Source="/Styles/PixiEditor.Handles.axaml" />
         <StyleInclude Source="/Styles/PixiEditor.Layers.axaml" />
         <StyleInclude Source="/Styles/PixiEditorPopupTemplate.axaml" />
+        <StyleInclude Source="/Styles/Buttons/CaptionButtonsStyle.axaml" />
     </Application.Styles>
     <Application.Resources>
         <ResourceDictionary>

+ 23 - 0
src/PixiEditor.AvaloniaUI/Styles/Buttons/CaptionButtonsStyle.axaml

@@ -0,0 +1,23 @@
+<Styles xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:dialogs="clr-namespace:PixiEditor.AvaloniaUI.Views.Dialogs">
+    
+    <Style Selector="dialogs|DialogTitleBar CaptionButtons Button#PART_RestoreButton:disabled">
+        <Setter Property="IsVisible" Value="False"/>
+    </Style>
+    <Style Selector="dialogs|DialogTitleBar[CanMinimize=False] CaptionButtons Button#PART_MinimizeButton">
+        <Setter Property="IsVisible" Value="False"/>
+    </Style>
+    
+    <Style Selector="dialogs|DialogTitleBar[CanFullscreen=False] CaptionButtons Button#PART_FullScreenButton">
+        <Setter Property="IsVisible" Value="False"/>
+    </Style>
+    
+    <Style Selector="dialogs|DialogTitleBar[CanFullscreen=False] CaptionButtons Button#PART_RestoreButton">
+        <Setter Property="IsVisible" Value="False"/>
+    </Style>
+    
+    <Style Selector="CaptionButtons">
+        <Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush1}"/>
+    </Style>
+</Styles>

+ 1 - 39
src/PixiEditor.AvaloniaUI/Views/Dialogs/DialogTitleBar.axaml

@@ -21,45 +21,7 @@
             FontSize="13"
             Margin="5,0,0,0"/>
         <DockPanel IsHitTestVisible="True">
-            <Button 
-                DockPanel.Dock="Right" 
-                IsCancel="True"
-                Classes="close"
-                Theme="{StaticResource DialogButtonTheme}"
-                ui:Translator.TooltipKey="CLOSE"
-                Click="CloseWindow">
-                🗙
-            </Button>
-            <StackPanel DockPanel.Dock="Right" Orientation="Horizontal" IsVisible="{Binding ElementName=uc, Path=CanFullscreen}">
-                <Button
-                    IsVisible="{Binding !$parent[Window].WindowState, Converter={converters:IsEqualConverter}, ConverterParameter={x:Static WindowState.Maximized}}"
-                    DockPanel.Dock="Right"
-                    Theme="{StaticResource DialogButtonTheme}"
-                    ui:Translator.TooltipKey="MAXIMIZE"
-                    Name="maximizeButton"
-                    Click="MaximizeWindow">
-                    🗖
-                </Button>
-                <Button
-                    IsVisible="{Binding $parent[Window].WindowState, Converter={converters:IsEqualConverter}, ConverterParameter={x:Static WindowState.Maximized}}"
-                    DockPanel.Dock="Right"
-                    Name="restoreButton"
-                    Theme="{StaticResource DialogButtonTheme}"
-                    ui:Translator.TooltipKey="RESTORE"
-                    Click="RestoreWindow">
-                    🗗
-                </Button>
-            </StackPanel>
-            <Button 
-                DockPanel.Dock="Right"
-                Name="minimizeButton"
-                Theme="{StaticResource DialogButtonTheme}"
-                IsVisible="{Binding ElementName=uc, Path=CanMinimize}"
-                ui:Translator.TooltipKey="MINIMIZE"
-                Padding="0, 0, 0, 5"
-                Click="MinimizeWindow">
-                🗕
-            </Button>
+            <CaptionButtons Name="captionButtons" DockPanel.Dock="Right" />
             <Control /><!-- dummy control to occupy dockpanel center -->
         </DockPanel>
     </Grid>

+ 8 - 0
src/PixiEditor.AvaloniaUI/Views/Dialogs/DialogTitleBar.axaml.cs

@@ -1,6 +1,8 @@
 using System.Windows.Input;
 using Avalonia;
 using Avalonia.Controls;
+using Avalonia.Controls.Chrome;
+using Avalonia.Controls.Primitives;
 using Avalonia.Interactivity;
 using PixiEditor.Extensions.UI;
 
@@ -52,6 +54,12 @@ internal partial class DialogTitleBar : UserControl, ICustomTranslatorElement
         InitializeComponent();
     }
 
+    protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
+    {
+        base.OnApplyTemplate(e);
+        captionButtons.Attach(VisualRoot as Window);
+    }
+
     void ICustomTranslatorElement.SetTranslationBinding(AvaloniaProperty dependencyProperty, IObservable<string> binding)
     {
         Bind(dependencyProperty, binding);

+ 5 - 5
src/PixiEditor.UI.Common/Controls/CaptionButtons.axaml

@@ -11,10 +11,10 @@
 
   <ControlTheme x:Key="SimpleCaptionButton"
                 TargetType="Button">
-    <Setter Property="Background" Value="#ffe5e5e5" />
+    <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightBrush}" />
     <!--  Reusing BorderBrush to define pressed background color, as it's not used otherwise  -->
-    <Setter Property="BorderBrush" Value="#ffcacaca" />
-    <Setter Property="Foreground" Value="Black" />
+    <Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}" />
+    <Setter Property="Foreground" Value="{DynamicResource ThemeForegroundColor}" />
     <Setter Property="Width" Value="45" />
     <Setter Property="VerticalAlignment" Value="Stretch" />
     <Setter Property="Template">
@@ -36,7 +36,7 @@
 
   <ControlTheme x:Key="{x:Type CaptionButtons}"
                 TargetType="CaptionButtons">
-    <Setter Property="MaxHeight" Value="30" />
+    <Setter Property="MaxHeight" Value="40" />
     <Setter Property="Template">
       <ControlTemplate>
         <StackPanel VerticalAlignment="Stretch"
@@ -80,7 +80,7 @@
           </Button>
           <Button x:Name="PART_CloseButton"
                   Background="#ffe81123"
-                  BorderBrush="#fff1707a"
+                  BorderBrush="#FFBB0E1C"
                   Theme="{StaticResource SimpleCaptionButton}"
                   AutomationProperties.Name="Close">
             <Viewbox Width="11"