Skip to content

Commit

Permalink
Use command icons in main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
CPKreu committed Apr 28, 2023
1 parent 6d1bbc7 commit c09c493
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/PixiEditor/Models/Commands/XAML/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,23 @@ public static void CommandChanged(object sender, DependencyPropertyChangedEventA

var command = CommandController.Current.Commands[value];

var icon = new Image
{
Source = command.GetIcon(),
Width = 20, Height = 20,
Opacity = command.CanExecute() ? 1 : 0.75
};

icon.IsVisibleChanged += (_, v) =>
{
if ((bool)v.NewValue)
{
icon.Opacity = command.CanExecute() ? 1 : 0.75;
}
};

item.Command = Command.GetICommand(command, false);
item.Icon = icon;
item.SetBinding(MenuItem.InputGestureTextProperty, ShortcutBinding.GetBinding(command));
}

Expand Down
4 changes: 2 additions & 2 deletions src/PixiEditor/Styles/MenuButtonStyle.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<Border x:Name="Border" Padding="2.5"
<Border x:Name="Border" Padding="2.5,1,2.5,1"
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="Col0" MinWidth="17" Width="Auto"
<ColumnDefinition x:Name="Col0" Width="Auto" MinWidth="5"
SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuTextColumnGroup" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
Expand Down

0 comments on commit c09c493

Please sign in to comment.