Skip to content

Commit

Permalink
[DYN-6370] Restore UI change in group context menu (#15898)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaylo-matov authored Mar 6, 2025
1 parent 792ab90 commit b4d0c0c
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 7 deletions.
108 changes: 108 additions & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4106,6 +4106,103 @@
</Border>
</Popup>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentPresenter" Property="TextBlock.Opacity" Value="0.5" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ContentPresenter" Property="TextBlock.Foreground" Value="White" />
<Setter TargetName="dockPanel" Property="Background" Value="{StaticResource GenericMouseOverBackgroundColorBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="dockPanel" Property="Background" Value="{StaticResource NodeContextMenuBackground}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="checkBox" Property="Visibility" Value="Visible" />
<Setter TargetName="ContentPresenter" Property="TextBlock.FontFamily" Value="{StaticResource ArtifaktElementBold}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!-- This context menu style is similar to the ContextMenuItemStyle and the only difference is the background at IsMouseOve = False -->
<Style x:Key="DarkContextMenuItemStyle" TargetType="{x:Type MenuItem}" BasedOn="{StaticResource ContextMenuItemStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MenuItem}">
<DockPanel x:Name="dockPanel"
HorizontalAlignment="Stretch"
Background="Transparent"
SnapsToDevicePixels="true">
<Label x:Name="checkBox"
Margin="0,0,-20,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content=""
DockPanel.Dock="Left"
FontSize="9px"
Foreground="{StaticResource PreferencesWindowButtonColor}"
Visibility="Collapsed" />
<ContentPresenter x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
ContentSource="Header"
DockPanel.Dock="Left"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextBlock.Foreground="{StaticResource NodeContextMenuForeground}" />
<Label x:Name="subMenuArrow"
Margin="0,0,15,7"
Padding="0"
VerticalAlignment="Center"
Content="&gt;"
DockPanel.Dock="Right"
FontFamily="{StaticResource ArtifaktElementRegular}"
FontSize="13px"
Foreground="{StaticResource Blue300Brush}">
<Label.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1.5" />
</Label.RenderTransform>
<Label.Style>
<Style TargetType="{x:Type Label}">
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type MenuItem}}, Path=HasItems}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Popup x:Name="PART_Popup"
AllowsTransparency="true"
Focusable="false"
HorizontalOffset="0"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
VerticalOffset="-2">
<Border Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0">
<ScrollViewer x:Name="SubMenuScrollViewer"
CanContentScroll="true"
Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer,
TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<ItemsPresenter x:Name="ItemsPresenter"
Grid.IsSharedSizeScope="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Popup>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentPresenter" Property="TextBlock.Opacity" Value="0.5" />
Expand Down Expand Up @@ -4274,6 +4371,17 @@
</Style.Resources>
</Style>

<Style x:Key="DarkContextMenuStyle" TargetType="{x:Type ContextMenu}" BasedOn="{StaticResource ContextMenuStyle}">
<Style.Resources>
<Style x:Key="{x:Static MenuItem.SeparatorStyleKey}"
BasedOn="{StaticResource ContextMenuSeparatorStyle}"
TargetType="Separator" />
<Style x:Key="{x:Type MenuItem}"
BasedOn="{StaticResource DarkContextMenuItemStyle}"
TargetType="MenuItem" />
</Style.Resources>
</Style>

<Style x:Key="MenuExpanderStyle" TargetType="Expander">
<Setter Property="Background" Value="{StaticResource SecondaryGray}" />
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void DropDownInstallButton_OnClick(object sender, RoutedEventArgs e)
commandParameterBinding.Source = button.DataContext;

var contextMenuStyle = new Style(typeof(ContextMenu));
contextMenuStyle.BasedOn = (Style)SharedDictionaryManager.DynamoModernDictionary["ContextMenuStyle"];
contextMenuStyle.BasedOn = (Style)SharedDictionaryManager.DynamoModernDictionary["DarkContextMenuStyle"];

//Apply the Style to the ContextMenu
contextMenu.Style = contextMenuStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<ContextMenu Width="Auto"
MinWidth="180"
Background="{StaticResource GenericBorderBackgroundColorBrush}"
Style="{StaticResource ContextMenuStyle}">
Style="{StaticResource DarkContextMenuStyle}">

<!-- Sub-Title 'SORT BY' -->
<Separator>
Expand All @@ -152,6 +152,7 @@
<!-- Sort By Package Name -->
<MenuItem Command="{Binding Path=SetSortingKeyCommand}"
CommandParameter="Name"
Style="{StaticResource DarkContextMenuItemStyle}"
Header="{x:Static p:Resources.PackageSearchViewContextMenuSortByName}"
IsCheckable="True"
IsChecked="{Binding Path=SortingKey, Converter={StaticResource EnumToBoolConverter}, ConverterParameter=Name, Mode=TwoWay}" />
Expand Down Expand Up @@ -254,9 +255,9 @@
DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Mode=Self}}"
DisplayMemberPath="FilterName"
StaysOpen="True"
Style="{StaticResource ContextMenuStyle}">
Style="{StaticResource DarkContextMenuStyle}">
<ContextMenu.Resources>
<Style BasedOn="{StaticResource ContextMenuItemStyle}" TargetType="{x:Type MenuItem}">
<Style BasedOn="{StaticResource DarkContextMenuItemStyle}" TargetType="{x:Type MenuItem}">
<Setter Property="IsCheckable" Value="True" />
<Setter Property="StaysOpenOnClick" Value="True" />
<Setter Property="Command" Value="{Binding FilterCommand}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
MinWidth="180"
Width="Auto"
Background="{StaticResource NodeContextMenuBackground}"
Style="{StaticResource ContextMenuStyle}">
Style="{StaticResource DarkContextMenuStyle}">

<!-- Sub-Title 'SORT BY' -->
<Separator>
Expand Down Expand Up @@ -315,9 +315,9 @@
DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Mode=Self}}"
DisplayMemberPath="FilterName"
ItemsSource="{Binding HostFilter}"
Style="{StaticResource ContextMenuStyle}">
Style="{StaticResource DarkContextMenuStyle}">
<ContextMenu.ItemContainerStyle>
<Style BasedOn="{StaticResource ContextMenuItemStyle}" TargetType="{x:Type MenuItem}">
<Style BasedOn="{StaticResource DarkContextMenuItemStyle}" TargetType="{x:Type MenuItem}">
<Setter Property="IsCheckable" Value="True" />
<Setter Property="Command" Value="{Binding FilterCommand}" />
<Setter Property="CommandParameter" Value="{Binding FilterName}" />
Expand Down

0 comments on commit b4d0c0c

Please sign in to comment.