Skip to content

Commit

Permalink
Improve settings for vertical taskbar width
Browse files Browse the repository at this point in the history
  • Loading branch information
dremin committed Nov 26, 2024
1 parent 330e9e8 commit 0859264
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion RetroBar/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</x:Array>
<s:String x:Key="rowcount_text">Number of _rows:</s:String>
<s:String x:Key="rowcount_tip">The number of rows on the taskbar when on top or bottom.</s:String>
<s:String x:Key="rowcount_vertical_tip">The number of rows on the taskbar when on left or right.</s:String>
<s:String x:Key="taskbar_width">Taskba_r width:</s:String>
<s:String x:Key="allow_font_smoothing">_Allow font smoothing</s:String>
<s:String x:Key="collapse_tray_icons">Collapse _notification area icons</s:String>
<s:String x:Key="customize">_Customize...</s:String>
Expand Down
18 changes: 12 additions & 6 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,19 @@
</DockPanel>
<DockPanel Visibility="{Binding Source={x:Static Settings:Settings.Instance}, Path=Edge, Converter={StaticResource edgeOrientationVisibilityConverter}, ConverterParameter='vertical'}">
<Label VerticalAlignment="Center"
Target="{Binding ElementName=cboRowCountVertical}">
<AccessText Text="{DynamicResource rowcount_text}"
ToolTip="{DynamicResource rowcount_vertical_tip}" />
Target="{Binding ElementName=sldTaskbarWidth}">
<AccessText Text="{DynamicResource taskbar_width}" />
</Label>
<ComboBox x:Name="cboRowCountVertical"
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=RowCountVertical, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource countToIndexConverter}}"
SelectionChanged="cboRowCountVertical_SelectionChanged" />
<Slider Name="sldTaskbarWidth"
Orientation="Horizontal"
IsSnapToTickEnabled="True"
Value="{Binding Source={x:Static Settings:Settings.Instance}, Path=TaskbarWidth, UpdateSourceTrigger=PropertyChanged}"
Minimum="1"
TickFrequency="1"
TickPlacement="BottomRight"
HorizontalAlignment="Right"
Margin="0,3,0,4"
Width="200" />
</DockPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=AllowFontSmoothing, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource allow_font_smoothing}" />
Expand Down
18 changes: 6 additions & 12 deletions RetroBar/PropertiesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private PropertiesWindow(NotificationArea notificationArea, DictionaryManager di
LoadRows();
LoadThemes();
LoadVersion();
LoadWidth();

Settings.Instance.PropertyChanged += Settings_PropertyChanged;
}
Expand Down Expand Up @@ -170,10 +171,6 @@ private void LoadRows()
{
cboRowCount.Items.Add(i.ToString());
}
for (int i = 1; i <= Settings.Instance.RowLimitVertical; i++)
{
cboRowCountVertical.Items.Add(i.ToString());
}
}

private void LoadThemes()
Expand All @@ -189,6 +186,11 @@ private void LoadVersion()
txtVersion.Text = string.Format((string)FindResource("version"), System.Windows.Forms.Application.ProductVersion);
}

private void LoadWidth()
{
sldTaskbarWidth.Maximum = Settings.Instance.TaskbarWidthLimit;
}

private void UpdateWindowPosition()
{
switch (Settings.Instance.Edge)
Expand Down Expand Up @@ -317,14 +319,6 @@ private void cboRowCount_SelectionChanged(object sender, System.Windows.Controls
}
}

private void cboRowCountVertical_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
if (cboRowCountVertical.SelectedItem == null)
{
cboRowCountVertical.SelectedValue = cboRowCountVertical.Items[Settings.Instance.RowCountVertical - 1];
}
}

private void CustomizeNotifications_OnClick(object sender, RoutedEventArgs e)
{
OpenCustomizeNotifications();
Expand Down
12 changes: 6 additions & 6 deletions RetroBar/Taskbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private void RecalculateSize(bool performResize = true)
{
_unlockedMargin = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarUnlockedSize") as double? ?? 0);
DesiredRowHeight = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarRowHeight") as double? ?? 0);
double newWidth = (Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarWidth") as double? ?? 0)) + DesiredRowHeight * (Settings.Instance.RowCountVertical - 1);
double newWidth = (Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarWidth") as double? ?? 0)) + DesiredRowHeight * (Settings.Instance.TaskbarWidth - 1);
double newHeight = (Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarHeight") as double? ?? 0)) + DesiredRowHeight * (Rows - 1);

if (AppBarMode == AppBarMode.AutoHide || !Settings.Instance.LockTaskbar)
Expand Down Expand Up @@ -278,7 +278,7 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
RecalculateSize();
OnPropertyChanged(nameof(Rows));
}
else if (e.PropertyName == nameof(Settings.RowCountVertical))
else if (e.PropertyName == nameof(Settings.TaskbarWidth))
{
PeekDuringAutoHide();
RecalculateSize();
Expand Down Expand Up @@ -593,15 +593,15 @@ private void MouseDragHook_LowLevelMouseEvent(object sender, LowLevelMouseHook.L
double taskbarEdge = AppBarEdge == AppBarEdge.Left ? Screen.Bounds.Left + (DesiredWidth * DpiScale) : Screen.Bounds.Right - (DesiredWidth * DpiScale);
if ((AppBarEdge == AppBarEdge.Left && mouseX > taskbarEdge + scaledRowHeight ||
AppBarEdge == AppBarEdge.Right && mouseX < taskbarEdge - scaledRowHeight) &&
Settings.Instance.RowCountVertical < Settings.Instance.RowLimitVertical)
Settings.Instance.TaskbarWidth < Settings.Instance.TaskbarWidthLimit)
{
Settings.Instance.RowCountVertical += 1;
Settings.Instance.TaskbarWidth += 1;
}
else if ((AppBarEdge == AppBarEdge.Left && mouseX < taskbarEdge - SystemParameters.MinimumHorizontalDragDistance ||
AppBarEdge == AppBarEdge.Right && mouseX > taskbarEdge + SystemParameters.MinimumHorizontalDragDistance) &&
Settings.Instance.RowCountVertical > 1)
Settings.Instance.TaskbarWidth > 1)
{
Settings.Instance.RowCountVertical -= 1;
Settings.Instance.TaskbarWidth -= 1;
}
}
});
Expand Down
16 changes: 8 additions & 8 deletions RetroBar/Utilities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,18 @@ public int RowLimit
set => Set(ref _rowLimit, value);
}

private int _rowCountVertical = 1;
public int RowCountVertical
private int _taskbarWidth = 1;
public int TaskbarWidth
{
get => _rowCountVertical;
set => Set(ref _rowCountVertical, value);
get => _taskbarWidth;
set => Set(ref _taskbarWidth, value);
}

private int _rowLimitVertical = 7;
public int RowLimitVertical
private int _taskbarWidthLimit = 7;
public int TaskbarWidthLimit
{
get => _rowLimitVertical;
set => Set(ref _rowLimitVertical, value);
get => _taskbarWidthLimit;
set => Set(ref _taskbarWidthLimit, value);
}

private List<string> _quickLaunchOrder = [];
Expand Down

0 comments on commit 0859264

Please sign in to comment.