Skip to content

Commit

Permalink
Fix RepeatButton and intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 2, 2024
1 parent 02e64a7 commit 9769f7a
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/PicView.Avalonia/CustomControls/IconButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public class IconButton : RepeatButton
AvaloniaProperty.Register<IconButton, double>(nameof(IconHeight));

/// <summary>
/// Overrides the default style key to <see cref="Button"/>.
/// Overrides the default style key to <see cref="RepeatButton"/>.
/// </summary>
protected override Type StyleKeyOverride => typeof(Button);
protected override Type StyleKeyOverride => typeof(RepeatButton);

/// <summary>
/// Gets or sets the <see cref="DrawingImage"/> displayed as the icon of the button.
Expand Down
2 changes: 1 addition & 1 deletion src/PicView.Avalonia/PicViewTheme/Classes.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Setter Property="CornerRadius" Value="2" />
</Style>

<Style Selector="Button.mainBtn, ToggleButton.mainBtn">
<Style Selector="Button.mainBtn, ToggleButton.mainBtn, RepeatButton.mainBtn">
<Setter Property="Width" Value="NaN" />
<Setter Property="Height" Value="35" />
<Setter Property="Padding" Value="10" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<ControlTheme TargetType="RepeatButton" x:Key="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False" />
<Setter Property="Interval" Value="-1" />

<Setter Property="RepeatButton.Template">
<ControlTemplate TargetType="RepeatButton">
Expand Down
76 changes: 37 additions & 39 deletions src/PicView.Avalonia/Views/BottomBar.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,56 @@ public BottomBar()
DragAndDropHelper.RemoveDragDropView();
};

if (!SettingsHelper.Settings.Theme.GlassTheme)
if (SettingsHelper.Settings.Theme.GlassTheme)
{
return;
}

MainBottomBorder.Background = Brushes.Transparent;
MainBottomBorder.BorderThickness = new Thickness(0);
MainBottomBorder.Background = Brushes.Transparent;
MainBottomBorder.BorderThickness = new Thickness(0);

FileMenuButton.Background = Brushes.Transparent;
FileMenuButton.Classes.Remove("noBorderHover");
FileMenuButton.Classes.Add("hover");
FileMenuButton.Background = Brushes.Transparent;
FileMenuButton.Classes.Remove("noBorderHover");
FileMenuButton.Classes.Add("hover");

ImageMenuButton.Background = Brushes.Transparent;
ImageMenuButton.Classes.Remove("noBorderHover");
ImageMenuButton.Classes.Add("hover");
ImageMenuButton.Background = Brushes.Transparent;
ImageMenuButton.Classes.Remove("noBorderHover");
ImageMenuButton.Classes.Add("hover");

ToolsMenuButton.Background = Brushes.Transparent;
ToolsMenuButton.Classes.Remove("noBorderHover");
ToolsMenuButton.Classes.Add("hover");
ToolsMenuButton.Background = Brushes.Transparent;
ToolsMenuButton.Classes.Remove("noBorderHover");
ToolsMenuButton.Classes.Add("hover");

SettingsMenuButton.Background = Brushes.Transparent;
SettingsMenuButton.Classes.Remove("noBorderHover");
SettingsMenuButton.Classes.Add("hover");
SettingsMenuButton.Background = Brushes.Transparent;
SettingsMenuButton.Classes.Remove("noBorderHover");
SettingsMenuButton.Classes.Add("hover");

NextButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
NextButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));

PreviousButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));
PreviousButton.Background = new SolidColorBrush(Color.FromArgb(15, 255, 255, 255));

if (!Application.Current.TryGetResource("SecondaryTextColor",
Application.Current.RequestedThemeVariant, out var textColor))
{
return;
}
if (!Application.Current.TryGetResource("SecondaryTextColor",
Application.Current.RequestedThemeVariant, out var textColor))
{
return;
}

if (textColor is not Color color)
{
return;
}
if (textColor is not Color color)
{
return;
}

FileMenuButton.Foreground = new SolidColorBrush(color);
ImageMenuButton.Foreground = new SolidColorBrush(color);
ToolsMenuButton.Foreground = new SolidColorBrush(color);
SettingsMenuButton.Foreground = new SolidColorBrush(color);
FileMenuButton.Foreground = new SolidColorBrush(color);
ImageMenuButton.Foreground = new SolidColorBrush(color);
ToolsMenuButton.Foreground = new SolidColorBrush(color);
SettingsMenuButton.Foreground = new SolidColorBrush(color);

NextButton.Foreground = new SolidColorBrush(color);
PreviousButton.Foreground = new SolidColorBrush(color);


NextButton.Delay =
NextButton.Foreground = new SolidColorBrush(color);
PreviousButton.Foreground = new SolidColorBrush(color);
}

// TODO add interval to mainviewmodel
NextButton.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;

PreviousButton.Delay =
PreviousButton.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;

};
Expand Down
5 changes: 5 additions & 0 deletions src/PicView.Avalonia/Views/UC/Buttons/ClickArrowLeft.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using PicView.Avalonia.UI;
using PicView.Avalonia.ViewModels;
using PicView.Core.Config;

namespace PicView.Avalonia.Views.UC.Buttons;
public partial class ClickArrowLeft : UserControl
Expand All @@ -16,6 +17,10 @@ public ClickArrowLeft()
}
HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);

// TODO add interval to mainviewmodel
PolyButton.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
};
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using PicView.Avalonia.UI;
using PicView.Avalonia.ViewModels;
using PicView.Core.Config;

namespace PicView.Avalonia.Views.UC.Buttons;
public partial class ClickArrowRight : UserControl
Expand All @@ -16,6 +17,10 @@ public ClickArrowRight()
}
HideInterfaceLogic.AddHoverButtonEvents(this, PolyButton, vm);
PointerWheelChanged += async (_, e) => await vm.ImageViewer.PreviewOnPointerWheelChanged(this, e);

// TODO add interval to mainviewmodel
PolyButton.Interval =
(int)TimeSpan.FromSeconds(SettingsHelper.Settings.UIProperties.NavSpeed).TotalMilliseconds;
};
}
}
2 changes: 1 addition & 1 deletion src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Foreground" Value="{DynamicResource MainTextColor}" />
</Style>
<Style Selector="Button.btn">
<Style Selector="Button.btn, RepeatButton.btn">
<Setter Property="Width" Value="45" />
<Setter Property="Height" Value="45" />
<Setter Property="Background" Value="Transparent" />
Expand Down

0 comments on commit 9769f7a

Please sign in to comment.