Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-row functionality #928

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
12 changes: 11 additions & 1 deletion RetroBar/Controls/NotifyIconList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<UserControl.Resources>
<ResourceDictionary>
<converters:EdgeOrientationConverter x:Key="edgeOrientationConverter" />
<converters:NotifyIconListOrientation x:Key="notificationIconsOrientation" />
</ResourceDictionary>
</UserControl.Resources>
<StackPanel>
Expand All @@ -26,7 +27,16 @@
VerticalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
<WrapPanel>
<WrapPanel.Orientation>
<MultiBinding Converter="{StaticResource notificationIconsOrientation}">
<Binding Path="Orientation"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Window}" />
<Binding Path="Rows"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Window}" />
</MultiBinding>
</WrapPanel.Orientation>
</WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
Expand Down
10 changes: 9 additions & 1 deletion RetroBar/Controls/TaskList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,23 @@ private void TaskList_OnSizeChanged(object sender, SizeChangedEventArgs e)

private void SetTaskButtonWidth()
{
if (Host is null)
return; // The state is trashed, but presumably it's just a transition

if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
ButtonWidth = ActualWidth;
SetScrollable(true); // while technically not always scrollable, we don't run into DPI-specific issues with it enabled while vertical
return;
}

double height = ActualHeight;
int rows = (int)Math.Round(height / Host.DesiredRowHeight);
rows = Math.Max(rows, 1);

int taskCount = TasksList.Items.Count;
double margin = TaskButtonLeftMargin + TaskButtonRightMargin;
double maxWidth = TasksList.ActualWidth / TasksList.Items.Count;
double maxWidth = TasksList.ActualWidth * rows / (taskCount + (taskCount % rows));
double defaultWidth = DefaultButtonWidth + margin;
double minWidth = MinButtonWidth + margin;

Expand Down
21 changes: 21 additions & 0 deletions RetroBar/Converters/EdgeIsHorizontalConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using ManagedShell.AppBar;
using RetroBar.Utilities;
using System.Windows.Data;
using System;

namespace RetroBar.Converters
{
[ValueConversion(typeof(AppBarEdge), typeof(bool))]
public class EdgeIsHorizontalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Settings.Instance.Edge is AppBarEdge.Top or AppBarEdge.Bottom;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
30 changes: 30 additions & 0 deletions RetroBar/Converters/NotifyIconListOrientation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using ManagedShell.AppBar;
using RetroBar.Utilities;
using System.Windows.Controls;
using System;
using System.Windows.Data;
using System.Globalization;

namespace RetroBar.Converters
{
public class NotifyIconListOrientation : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
bool horizontal = Settings.Instance.Edge is AppBarEdge.Top or AppBarEdge.Bottom;
int rows = Settings.Instance.RowCount;

if (horizontal && rows > 1)
{
return Orientation.Vertical;
}

return Orientation.Horizontal;
}

public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
9 changes: 9 additions & 0 deletions RetroBar/Languages/English.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
<s:String>Right</s:String>
<s:String>Bottom</s:String>
</x:Array>
<s:String x:Key="rowcount_text">Row Count:</s:String>
<s:String x:Key="rowcount_tip">The number of rows on the taskbar when on top or bottom.</s:String>
<x:Array x:Key="rowcount_options" Type="s:Int32">
<s:Int32>1</s:Int32>
<s:Int32>2</s:Int32>
<s:Int32>3</s:Int32>
<s:Int32>4</s:Int32>
<s:Int32>5</s:Int32>
</x:Array>
<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
2 changes: 2 additions & 0 deletions RetroBar/Languages/עברית.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<s:String>ימין</s:String>
<s:String>ישבן</s:String>
</x:Array>
<s:String x:Key="rowcount_text">מספר שורות:</s:String>
<s:String x:Key="rowcount_tip">מספר השורות בשורת המשימות כאשר למעלה או למטה.</s:String>
<s:String x:Key="allow_font_smoothing">_אפשר החלקת גופנים</s:String>
<s:String x:Key="collapse_tray_icons">סמלי אזור הודעה מכווץ</s:String>
<s:String x:Key="customize">התא_מה אישית...</s:String>
Expand Down
10 changes: 10 additions & 0 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<converters:BoolToInvertedVisibilityConverter x:Key="boolToInvertedVisibilityConverter" />
<converters:DoubleToPercentConverter x:Key="doubleToPercentConverter" />
<converters:EnumConverter x:Key="enumConverter" />
<converters:EdgeIsHorizontalConverter x:Key="isHorizontalConverter" />
<Style TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment"
Value="Center" />
Expand Down Expand Up @@ -203,6 +204,15 @@
SelectedIndex="{Binding Source={x:Static Settings:Settings.Instance}, Path=Edge, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource enumConverter}}"
SelectionChanged="cboEdgeSelect_SelectionChanged" />
</DockPanel>
<DockPanel IsEnabled="{Binding Source={x:Static Settings:Settings.Instance}, Path=Edge, Converter={StaticResource isHorizontalConverter}}">
<Label VerticalAlignment="Center"
Target="{Binding ElementName=cboEdgeSelect}">
<AccessText Text="{DynamicResource rowcount_text}"
ToolTip="{DynamicResource rowcount_tip}" />
</Label>
<ComboBox ItemsSource="{DynamicResource rowcount_options}"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=RowCount, UpdateSourceTrigger=PropertyChanged}" />
</DockPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=AllowFontSmoothing, UpdateSourceTrigger=PropertyChanged}">
<Label Content="{DynamicResource allow_font_smoothing}" />
</CheckBox>
Expand Down
62 changes: 53 additions & 9 deletions RetroBar/Taskbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ public bool IsScaled
}
}

private double _unlockedMargin;
public double DesiredRowHeight { get; private set; }

public int Rows
{
get => Settings.Instance.RowCount;
set => Settings.Instance.RowCount = value;
}

private bool _clockRightClicked;
private bool _notifyAreaRightClicked;
private bool _startMenuOpen;
Expand All @@ -58,14 +67,16 @@ public Taskbar(WindowManager windowManager, ShellManager shellManager, StartMenu
DataContext = _shellManager;
StartButton.StartMenuMonitor = startMenuMonitor;

DesiredHeight = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarHeight") as double? ?? 0);

_unlockedMargin = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarUnlockedSize") as double? ?? 0);
DesiredRowHeight = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarHeight") as double? ?? 0);
DesiredWidth = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarWidth") as double? ?? 0);
DesiredHeight = DesiredRowHeight * Rows;

if (AppBarMode == AppBarMode.AutoHide || !Settings.Instance.LockTaskbar)
{
double unlockedSize = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarUnlockedSize") as double? ?? 0);
DesiredHeight += unlockedSize;
DesiredWidth += unlockedSize;
DesiredHeight += _unlockedMargin;
DesiredWidth += _unlockedMargin;
}

AllowsTransparency = mode == AppBarMode.AutoHide || (Application.Current.FindResource("AllowsTransparency") as bool? ?? false);
Expand Down Expand Up @@ -94,7 +105,7 @@ public Taskbar(WindowManager windowManager, ShellManager shellManager, StartMenu

PropertyChanged += Taskbar_PropertyChanged;
}

private void Taskbar_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(DpiScale))
Expand Down Expand Up @@ -152,14 +163,16 @@ private void UpdateTrayPosition()

private void RecalculateSize()
{
double newHeight = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarHeight") as double? ?? 0);
_unlockedMargin = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarUnlockedSize") as double? ?? 0);
DesiredRowHeight = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarHeight") as double? ?? 0);
double newWidth = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarWidth") as double? ?? 0);

double newHeight = DesiredRowHeight * Rows;

if (AppBarMode == AppBarMode.AutoHide || !Settings.Instance.LockTaskbar)
{
double unlockedSize = Settings.Instance.TaskbarScale * (Application.Current.FindResource("TaskbarUnlockedSize") as double? ?? 0);
newHeight += unlockedSize;
newWidth += unlockedSize;
newHeight += _unlockedMargin;
newWidth += _unlockedMargin;
}

bool heightChanged = newHeight != DesiredHeight;
Expand Down Expand Up @@ -263,6 +276,11 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
PeekDuringAutoHide();
RecalculateSize();
}
else if (e.PropertyName == nameof(Settings.RowCount))
{
RecalculateSize();
OnPropertyChanged(nameof(Rows));
}
}

private void Taskbar_OnLocationChanged(object sender, EventArgs e)
Expand All @@ -275,6 +293,32 @@ private void Taskbar_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
UpdateTrayPosition();
StartButton?.UpdateFloatingStartCoordinates();



/*
This code is for drag resizing the taskbar. It's a work in progress
if (e.HeightChanged && !e.WidthChanged)
{
double extraMargin = !Settings.Instance.LockTaskbar ? _unlockedMargin : 0;

if ((Height - extraMargin) % DesiredRowHeight != 0)
{
var screenSize = Top + Height;
Height = (Math.Round(e.NewSize.Height / DesiredRowHeight) * DesiredRowHeight) + extraMargin;
Top = screenSize - Height;
}
else if (Screen.Primary)
{
int rows = (int)(e.NewSize.Height / DesiredRowHeight);
rows = Math.Min(rows, 5); // Max count of 5 rows
Rows = rows;

RecalculateSize();
}

e.Handled = true;
}*/
}

private void Taskbar_Deactivated(object sender, EventArgs e)
Expand Down
23 changes: 14 additions & 9 deletions RetroBar/Themes/System XP.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,31 @@
<TextBlock Text="{Binding Path=Now, StringFormat=dddd, Mode=OneWay}"
Style="{DynamicResource Clock}"
Name="ClockVerticalDayOfWeek"
Visibility="Collapsed">
Visibility="Visible">
</TextBlock>
<TextBlock Text="{Binding Path=Now, StringFormat=d, Mode=OneWay}"
Style="{DynamicResource Clock}"
Name="ClockVerticalDate"
Visibility="Collapsed">
Visibility="Visible">
</TextBlock>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="Vertical">
<DataTrigger.Setters>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="Horizontal"/>
<Condition Binding="{Binding Path=Rows, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="1"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter TargetName="ClockVerticalDayOfWeek"
Property="Visibility"
Value="Visible" />
Value="Collapsed" />
<Setter TargetName="ClockVerticalDate"
Property="Visibility"
Value="Visible" />
</DataTrigger.Setters>
</DataTrigger>
Value="Collapsed" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

Expand Down
4 changes: 4 additions & 0 deletions RetroBar/Themes/System.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@
Value="{DynamicResource ButtonForeground}" />
<Setter Property="HorizontalAlignment"
Value="Left" />
<Setter Property="VerticalAlignment"
Value="Top" />
<Setter Property="BorderThickness"
Value="0,0,1,1" />
<Setter Property="FocusVisualStyle"
Expand Down Expand Up @@ -963,6 +965,8 @@
Value="Stretch" />
<Setter Property="Margin"
Value="4,0,0,0" />
<Setter Property="VerticalAlignment"
Value="Top"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
Expand Down
23 changes: 14 additions & 9 deletions RetroBar/Themes/Windows Longhorn Aero.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,26 +1237,31 @@
<TextBlock Text="{Binding Path=Now, StringFormat=dddd, Mode=OneWay}"
Style="{DynamicResource Clock}"
Name="ClockVerticalDayOfWeek"
Visibility="Collapsed">
Visibility="Visible">
</TextBlock>
<TextBlock Text="{Binding Path=Now, StringFormat=d, Mode=OneWay}"
Style="{DynamicResource Clock}"
Name="ClockVerticalDate"
Visibility="Collapsed">
Visibility="Visible">
</TextBlock>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="Vertical">
<DataTrigger.Setters>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=Orientation, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="Horizontal"/>
<Condition Binding="{Binding Path=Rows, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"
Value="1"/>
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter TargetName="ClockVerticalDayOfWeek"
Property="Visibility"
Value="Visible" />
Value="Collapsed" />
<Setter TargetName="ClockVerticalDate"
Property="Visibility"
Value="Visible" />
</DataTrigger.Setters>
</DataTrigger>
Value="Collapsed" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

Expand Down
Loading