Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4814,6 +4814,7 @@ private void AnimateFloatingBarHighlightTo(string mode)
System.Windows.Controls.Canvas.SetTop(indicatorBar, nextBarTop);

selectionBG.Visibility = Visibility.Visible;
targetButton.SetSelectedVisualOffset(true);
_lastHighlightButton = targetButton;
return;
}
Expand All @@ -4839,6 +4840,9 @@ private void AnimateFloatingBarHighlightTo(string mode)
if (double.IsNaN(prevBarLeft)) prevBarLeft = nextBarLeft;
}

if (_lastHighlightButton != null && _lastHighlightButton != targetButton)
_lastHighlightButton.SetSelectedVisualOffset(false);
targetButton.SetSelectedVisualOffset(true);
_lastHighlightButton = targetButton;

selectionBG.Width = nextWidth;
Expand Down Expand Up @@ -5094,6 +5098,10 @@ private void DeferFloatingBarHighlightIfLayoutPending(string mode)

private void HideAllSelectionHighlights()
{
if (_lastHighlightButton != null)
{
_lastHighlightButton.SetSelectedVisualOffset(false);
}
if (SelectionBGFloatingBar != null)
{
SelectionBGFloatingBar.Visibility = Visibility.Hidden;
Expand Down
8 changes: 7 additions & 1 deletion InkCanvas.Controls/ToolbarImageButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
mc:Ignorable="d">
<Border x:Name="ButtonBorder" CornerRadius="4" Background="Transparent" Margin="0,2,0,7">
<Border x:Name="ButtonBorder"
CornerRadius="4"
Background="Transparent"
Width="44"
Height="52">
<Grid Name="ButtonPanel" d:Background="Red"
MouseDown="ButtonPanel_MouseDown"
MouseLeave="ButtonPanel_MouseLeave"
MouseUp="ButtonPanel_MouseUp"
Background="Transparent"
VerticalAlignment="Center"
RenderTransformOrigin="0.5,0.5"
Width="44" Height="43">
<Image x:Name="ButtonImage" HorizontalAlignment="Center" VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="24" Width="24" Margin="0,1,0,0">
Expand Down
20 changes: 20 additions & 0 deletions InkCanvas.Controls/ToolbarImageButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace Ink_Canvas.Controls
{
Expand Down Expand Up @@ -87,6 +89,24 @@ public double IconHeight
set => ButtonImage.Height = value;
}

public void SetSelectedVisualOffset(bool isSelected)
{
var transform = ButtonPanel.RenderTransform as TranslateTransform;
if (transform == null)
{
transform = new TranslateTransform();
ButtonPanel.RenderTransform = transform;
}

var animation = new DoubleAnimation
{
To = isSelected ? -3 : 0,
Duration = TimeSpan.FromMilliseconds(120),
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
};
transform.BeginAnimation(TranslateTransform.YProperty, animation);
}

public event MouseButtonEventHandler ButtonMouseDown;
public event MouseEventHandler ButtonMouseLeave;
public event MouseButtonEventHandler ButtonMouseUp;
Expand Down
Loading