Browse Source

Fixed opacity scroll and Focusables

flabbet 3 years ago
parent
commit
e272a058cb

+ 1 - 0
PixiEditor/Styles/ListSwitchButtonStyle.xaml

@@ -7,6 +7,7 @@
         <Setter Property="BorderThickness" Value="1"/>
         <Setter Property="BorderThickness" Value="1"/>
         <Setter Property="FontSize" Value="12"/>
         <Setter Property="FontSize" Value="12"/>
         <Setter Property="Cursor" Value="Hand"/>
         <Setter Property="Cursor" Value="Hand"/>
+        <Setter Property="Focusable" Value="False"/>
         <Setter Property="Padding" Value="2, 0"/>
         <Setter Property="Padding" Value="2, 0"/>
         <Setter Property="Foreground" Value="White"/>
         <Setter Property="Foreground" Value="White"/>
         <Setter Property="Template">
         <Setter Property="Template">

+ 4 - 0
PixiEditor/Styles/ThemeStyle.xaml

@@ -13,6 +13,10 @@
         <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
         <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
     </Style>
     </Style>
 
 
+    <Style TargetType="ToggleButton">
+        <Setter Property="Focusable" Value="False"/>
+    </Style>
+    
     <Style TargetType="Button" x:Key="BaseDarkButton">
     <Style TargetType="Button" x:Key="BaseDarkButton">
         <Setter Property="Background" Value="#404040" />
         <Setter Property="Background" Value="#404040" />
         <Setter Property="Foreground" Value="White" />
         <Setter Property="Foreground" Value="White" />

+ 4 - 4
PixiEditor/Views/MainWindow.xaml

@@ -203,7 +203,7 @@
             <Button Command="{Binding UndoSubViewModel.RedoCommand}" ToolTip="Redo"
             <Button Command="{Binding UndoSubViewModel.RedoCommand}" ToolTip="Redo"
                     Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A6;"/>
                     Style="{StaticResource ToolSettingsGlyphButton}" Content="&#xE7A6;"/>
             <ToggleButton Width="30" BorderThickness="0"
             <ToggleButton Width="30" BorderThickness="0"
-                          ToolTip="Pen Mode"
+                          ToolTip="Pen Mode" Focusable="False"
                           IsChecked="{Binding StylusSubViewModel.IsPenModeEnabled}">
                           IsChecked="{Binding StylusSubViewModel.IsPenModeEnabled}">
                 <ToggleButton.Style>
                 <ToggleButton.Style>
                     <Style TargetType="ToggleButton">
                     <Style TargetType="ToggleButton">
@@ -211,9 +211,9 @@
                             <Setter.Value>
                             <Setter.Value>
                                 <ControlTemplate TargetType="ToggleButton">
                                 <ControlTemplate TargetType="ToggleButton">
                                     <Border BorderBrush="{TemplateBinding BorderBrush}" 
                                     <Border BorderBrush="{TemplateBinding BorderBrush}" 
-                                            Background="{TemplateBinding Background}">
+                                            Background="{TemplateBinding Background}" Focusable="False">
                                         <ContentPresenter HorizontalAlignment="Center"
                                         <ContentPresenter HorizontalAlignment="Center"
-                                              VerticalAlignment="Center"/>
+                                              VerticalAlignment="Center" Focusable="False"/>
                                     </Border>
                                     </Border>
                                 </ControlTemplate>
                                 </ControlTemplate>
                             </Setter.Value>
                             </Setter.Value>
@@ -223,7 +223,7 @@
                                 <Setter Property="Background" Value="Transparent"/>
                                 <Setter Property="Background" Value="Transparent"/>
                             </Trigger>
                             </Trigger>
                             <Trigger Property="IsMouseOver" Value="True">
                             <Trigger Property="IsMouseOver" Value="True">
-                                <Setter Property="Background" Value="#606060"/>
+                                <Setter Property="Background" Value="#404040"/>
                             </Trigger>
                             </Trigger>
                             <Trigger Property="IsChecked" Value="True">
                             <Trigger Property="IsChecked" Value="True">
                                 <Setter Property="Background" Value="#707070"/>
                                 <Setter Property="Background" Value="#707070"/>

+ 1 - 1
PixiEditor/Views/UserControls/Layers/LayersManager.xaml

@@ -53,7 +53,7 @@
                         IsEnabled="{Binding Path=OpacityInputEnabled, ElementName=layersManager}" 
                         IsEnabled="{Binding Path=OpacityInputEnabled, ElementName=layersManager}" 
                         Width="40" Height="20"
                         Width="40" Height="20"
                         VerticalAlignment="Center"
                         VerticalAlignment="Center"
-                        Value="{Binding OpacityValue, ElementName=layersManager, Mode=TwoWay}"/>
+                        LostFocus="NumberInput_LostFocus"/>
                 <Label Content="%" Foreground="White" VerticalAlignment="Center"/>
                 <Label Content="%" Foreground="White" VerticalAlignment="Center"/>
             </StackPanel>
             </StackPanel>
         </DockPanel>
         </DockPanel>

+ 4 - 22
PixiEditor/Views/UserControls/Layers/LayersManager.xaml.cs

@@ -71,21 +71,10 @@ namespace PixiEditor.Views.UserControls.Layers
         public static readonly DependencyProperty OpacityInputEnabledProperty =
         public static readonly DependencyProperty OpacityInputEnabledProperty =
             DependencyProperty.Register(nameof(OpacityInputEnabled), typeof(bool), typeof(LayersManager), new PropertyMetadata(false));
             DependencyProperty.Register(nameof(OpacityInputEnabled), typeof(bool), typeof(LayersManager), new PropertyMetadata(false));
 
 
-
-        public float OpacityValue
-        {
-            get { return (float)GetValue(OpacityValueProperty); }
-            set { SetValue(OpacityValueProperty, value); }
-        }
-
-        // Using a DependencyProperty as the backing store for OpacityValue.  This enables animation, styling, binding, etc...
-        public static readonly DependencyProperty OpacityValueProperty =
-            DependencyProperty.Register("OpacityValue", typeof(float), typeof(LayersManager), new PropertyMetadata(100f, OpacityChanged));
-
-
         public LayersManager()
         public LayersManager()
         {
         {
             InitializeComponent();
             InitializeComponent();
+            numberInput.OnScrollAction = () => NumberInput_LostFocus(null, null);
         }
         }
 
 
         private static void LayerTreeRootChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         private static void LayerTreeRootChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -352,21 +341,14 @@ namespace PixiEditor.Views.UserControls.Layers
             }
             }
         }
         }
 
 
-        private static void OpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        private void NumberInput_LostFocus(object sender, RoutedEventArgs e)
         {
         {
-            LayersManager layersManager = d as LayersManager;
-            layersManager.HandleOpacityChanged((float)e.NewValue);
-        }
-
-        private void HandleOpacityChanged(float newVal)
-        {
-            float val = newVal / 100f;
+            float val = numberInput.Value / 100f;
 
 
             object item = SelectedItem;
             object item = SelectedItem;
 
 
             if (item is Layer || item is LayerStructureItemContainer)
             if (item is Layer || item is LayerStructureItemContainer)
             {
             {
-
                 Layer layer = null;
                 Layer layer = null;
 
 
                 if (item is Layer lr)
                 if (item is Layer lr)
@@ -481,4 +463,4 @@ namespace PixiEditor.Views.UserControls.Layers
             SelectedItem = sender;
             SelectedItem = sender;
         }
         }
     }
     }
-}
+}

+ 4 - 4
PixiEditor/Views/UserControls/Layers/ReferenceLayer.xaml

@@ -51,7 +51,7 @@
                         </Button.Background>
                         </Button.Background>
                     </Button>
                     </Button>
                 </StackPanel>
                 </StackPanel>
-                <CheckBox Panel.ZIndex="10" Name="visibilityCheckbox" Grid.Column="1" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
+                <CheckBox Focusable="False" Panel.ZIndex="10" Name="visibilityCheckbox" Grid.Column="1" Margin="0,0,5,0" Height="16" HorizontalAlignment="Right">
                     <CheckBox.Triggers>
                     <CheckBox.Triggers>
                         <EventTrigger RoutedEvent="CheckBox.Checked">
                         <EventTrigger RoutedEvent="CheckBox.Checked">
                             <BeginStoryboard>
                             <BeginStoryboard>
@@ -73,13 +73,13 @@
                     </CheckBox.Triggers>
                     </CheckBox.Triggers>
                     <CheckBox.Template>
                     <CheckBox.Template>
                         <ControlTemplate TargetType="{x:Type CheckBox}">
                         <ControlTemplate TargetType="{x:Type CheckBox}">
-                            <StackPanel Orientation="Horizontal">
-                                <Image Width="14" Cursor="Hand" x:Name="checkboxImage" Source="/Images/ChevronDown.png">
+                            <StackPanel Orientation="Horizontal" Focusable="False">
+                                <Image Focusable="False" Width="14" Cursor="Hand" x:Name="checkboxImage" Source="/Images/ChevronDown.png">
                                     <Image.RenderTransform>
                                     <Image.RenderTransform>
                                         <RotateTransform Angle="0"/>
                                         <RotateTransform Angle="0"/>
                                     </Image.RenderTransform>
                                     </Image.RenderTransform>
                                 </Image>
                                 </Image>
-                                <ContentPresenter/>
+                                <ContentPresenter Focusable="False"/>
                             </StackPanel>
                             </StackPanel>
                             <ControlTemplate.Triggers>
                             <ControlTemplate.Triggers>
                                 <Trigger Property="IsChecked" Value="True">
                                 <Trigger Property="IsChecked" Value="True">

+ 14 - 0
PixiEditor/Views/UserControls/NumberInput.xaml.cs

@@ -50,6 +50,18 @@ namespace PixiEditor.Views
             DependencyProperty.Register("Decimals", typeof(int), typeof(NumberInput), new PropertyMetadata(2));
             DependencyProperty.Register("Decimals", typeof(int), typeof(NumberInput), new PropertyMetadata(2));
 
 
 
 
+        public Action OnScrollAction
+        {
+            get { return (Action)GetValue(OnScrollActionProperty); }
+            set { SetValue(OnScrollActionProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for OnScrollAction.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty OnScrollActionProperty =
+            DependencyProperty.Register("OnScrollAction", typeof(Action), typeof(NumberInput), new PropertyMetadata(null));
+
+
+
         public NumberInput()
         public NumberInput()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -101,6 +113,8 @@ namespace PixiEditor.Views
             {
             {
                 Value += step;
                 Value += step;
             }
             }
+
+            OnScrollAction?.Invoke();
         }
         }
     }
     }
 }
 }