Skip to content

Commit

Permalink
Context menu styling
Browse files Browse the repository at this point in the history
  • Loading branch information
xoascf committed Jun 21, 2023
1 parent 5310862 commit dbebdc1
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 44 deletions.
42 changes: 30 additions & 12 deletions RetroBar/Controls/TaskButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,50 +108,68 @@ private void AppButton_OnContextMenuOpening(object sender, ContextMenuEventArgs
int ws = Window.WindowStyles;

// disable window operations depending on current window state. originally tried implementing via bindings but found there is no notification we get regarding maximized state
MaximizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MinimizeMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0);
if (RestoreMenuItem.IsEnabled = (wss != NativeMethods.WindowShowStyle.ShowNormal))
MaximizeMenuItem.StaysOpenOnClick = !(wss != NativeMethods.WindowShowStyle.ShowMaximized && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MinimizeMenuItem.StaysOpenOnClick = !(wss != NativeMethods.WindowShowStyle.ShowMinimized && (ws & (int)NativeMethods.WindowStyles.WS_MINIMIZEBOX) != 0);
if (!(RestoreMenuItem.StaysOpenOnClick = wss == NativeMethods.WindowShowStyle.ShowNormal))
{
CloseMenuItem.FontWeight = FontWeights.Normal;
RestoreMenuItem.FontWeight = FontWeights.Bold;
}
if (!RestoreMenuItem.IsEnabled || RestoreMenuItem.IsEnabled && !MaximizeMenuItem.IsEnabled)
if (RestoreMenuItem.StaysOpenOnClick || !RestoreMenuItem.StaysOpenOnClick && MaximizeMenuItem.StaysOpenOnClick)
{
CloseMenuItem.FontWeight = FontWeights.Bold;
RestoreMenuItem.FontWeight = FontWeights.Normal;
}
MoveMenuItem.IsEnabled = wss == NativeMethods.WindowShowStyle.ShowNormal;
SizeMenuItem.IsEnabled = (wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
MoveMenuItem.StaysOpenOnClick = wss != NativeMethods.WindowShowStyle.ShowNormal;
SizeMenuItem.StaysOpenOnClick = !(wss == NativeMethods.WindowShowStyle.ShowNormal && (ws & (int)NativeMethods.WindowStyles.WS_MAXIMIZEBOX) != 0);
}

private void CloseMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Close();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Close();
}
}

private void RestoreMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Restore();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Restore();
}
}

private void MoveMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Move();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Move();
}
}

private void SizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Size();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Size();
}
}

private void MinimizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Minimize();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Minimize();
}
}

private void MaximizeMenuItem_OnClick(object sender, RoutedEventArgs e)
{
Window?.Maximize();
if (!((MenuItem)sender).StaysOpenOnClick)
{
Window?.Maximize();
}
}

private void AppButton_OnClick(object sender, RoutedEventArgs e)
Expand Down
10 changes: 8 additions & 2 deletions RetroBar/Controls/TaskList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ private void SetScrollable(bool canScroll)

private void TasksScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
if (!isScrollable)
if (e.Delta > 0)
{
e.Handled = true;
TasksScrollViewer.PageUp();
}
if (e.Delta < 0)
{
TasksScrollViewer.PageDown();
}

e.Handled = true;
}
}
}
15 changes: 14 additions & 1 deletion RetroBar/Themes/System XP.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,20 @@
</Style>

<Style TargetType="MenuItem"
x:Key="TaskManMenuItem">
x:Key="{x:Type MenuItem}"
BasedOn="{StaticResource {x:Type MenuItem}}">
<Style.Triggers>
<Trigger Property="Role"
Value="SubmenuItem">
<Setter Property="Padding"
Value="4,1,1,3" />
</Trigger>
</Style.Triggers>
</Style>

<Style TargetType="MenuItem"
x:Key="TaskManMenuItem"
BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header"
Value="{DynamicResource show_taskman}" />
</Style>
Expand Down
Loading

0 comments on commit dbebdc1

Please sign in to comment.