Skip to content

Commit 16de50b

Browse files
committed
fix(FlyleafBar): stop disabling Activity when settings opened
Because the settings dialog is a stand-alone window, there is no need to disable Activity. [etc] - Fixed a problem with the FlyleafBar not being displayed when clicking buttons on consecutive
1 parent 730c759 commit 16de50b

File tree

5 files changed

+32
-38
lines changed

5 files changed

+32
-38
lines changed

LLPlayer/Controls/FlyleafBar.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Right Click: Open Context Menu</ToolTip>
222222
<MouseBinding Command="{Binding FL.Player.Commands.OpenFromFileDialog}" MouseAction="LeftClick" />
223223
</TextBlock.InputBindings>
224224
<TextBlock.ContextMenu>
225-
<ContextMenu Style="{StaticResource FlyleafContextMenu}" Opened="OnContextMenuOnOpened" Closed="OnContextMenuOnClosed">
225+
<ContextMenu Style="{StaticResource FlyleafContextMenu}" Opened="OnContextMenuOnOpened" Closed="OnContextMenuOnClosed" MouseMove="OnContextMenuOnMouseMove">
226226
<MenuItem Header="Open next" Command="{Binding FL.Action.CmdOpenNextFile}" />
227227
<MenuItem Header="Open prev" Command="{Binding FL.Action.CmdOpenPrevFile}" />
228228
<MenuItem Header="Open path" Command="{Binding FL.Action.CmdOpenCurrentPath}" />

LLPlayer/Controls/FlyleafBar.xaml.cs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ public FlyleafBar()
3030
LostFocus += OnMouseLeave;
3131
MouseLeave += OnMouseLeave;
3232

33+
FL.Config.PropertyChanged += (sender, args) =>
34+
{
35+
if (args.PropertyName == nameof(FL.Config.SeekBarShowOnlyMouseOver))
36+
{
37+
// Avoided a problem in which Opacity was set to 0 when switching settings and was not displayed.
38+
FL.Player.Activity.ForceFullActive();
39+
IsShowing = true;
40+
41+
if (FL.Config.SeekBarShowOnlyMouseOver && !MyCard.IsMouseOver)
42+
{
43+
IsShowing = false;
44+
}
45+
}
46+
};
47+
3348
FL.Player.Activity.PropertyChanged += (sender, args) =>
3449
{
3550
switch (args.PropertyName)
@@ -97,10 +112,9 @@ public bool IsShowing
97112

98113
private void OnMouseLeave(object sender, RoutedEventArgs e)
99114
{
100-
if (FL.Config.SeekBarShowOnlyMouseOver)
115+
if (FL.Config.SeekBarShowOnlyMouseOver && FL.Player.Activity.IsEnabled)
101116
{
102-
if (FL.Player.Activity.IsEnabled)
103-
IsShowing = false;
117+
IsShowing = false;
104118
}
105119
else
106120
{
@@ -110,10 +124,9 @@ private void OnMouseLeave(object sender, RoutedEventArgs e)
110124

111125
private void OnMouseEnter(object sender, MouseEventArgs e)
112126
{
113-
if (FL.Config.SeekBarShowOnlyMouseOver)
127+
if (FL.Config.SeekBarShowOnlyMouseOver && FL.Player.Activity.IsEnabled)
114128
{
115-
if (FL.Player.Activity.IsEnabled)
116-
IsShowing = true;
129+
IsShowing = true;
117130
}
118131
else
119132
{
@@ -144,13 +157,12 @@ private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
144157
// Do not hide seek bar when context menu is displayed (register once)
145158
btn.ContextMenu.Opened += OnContextMenuOnOpened;
146159
btn.ContextMenu.Closed += OnContextMenuOnClosed;
160+
btn.ContextMenu.MouseMove += OnContextMenuOnMouseMove;
147161
btn.ContextMenu.PlacementTarget = btn;
148162
}
149163
btn.ContextMenu.IsOpen = true;
150164
}
151165

152-
// TODO: L: Addresses the problem of disappearing after consecutive clicks
153-
// of the SeekBar button when SeekBarShowOnlyMouseOver = true.
154166
private void OnContextMenuOnOpened(object o, RoutedEventArgs args)
155167
{
156168
SetActivity(false);
@@ -160,6 +172,12 @@ private void OnContextMenuOnClosed(object o, RoutedEventArgs args)
160172
{
161173
SetActivity(true);
162174
}
175+
176+
private void OnContextMenuOnMouseMove(object o, MouseEventArgs args)
177+
{
178+
// this is necessary to keep PopupMenu visible when opened in succession when SeekBarShowOnlyMouseOver
179+
SetActivity(false);
180+
}
163181
}
164182

165183
public class SliderToolTipBehavior : Behavior<Slider>

LLPlayer/Resources/PopupMenu.xaml.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ public PopupMenu()
1111
InitializeComponent();
1212
}
1313

14-
private bool _prevActivityEnabled;
15-
1614
private void PopUpMenu_OnOpened(object sender, RoutedEventArgs e)
1715
{
1816
// TODO: L: should validate that the clipboard content is a video file?
@@ -22,10 +20,6 @@ private void PopUpMenu_OnOpened(object sender, RoutedEventArgs e)
2220
// Don't hide the seek bar while displaying the context menu
2321
if (sender is ContextMenu menu && menu.DataContext is FlyleafOverlayVM vm)
2422
{
25-
if (!_prevActivityEnabled)
26-
{
27-
_prevActivityEnabled = vm.FL.Player.Activity.IsEnabled;
28-
}
2923
vm.FL.Player.Activity.IsEnabled = false;
3024
}
3125
}
@@ -34,11 +28,7 @@ private void PopUpMenu_OnClosed(object sender, RoutedEventArgs e)
3428
{
3529
if (sender is ContextMenu menu && menu.DataContext is FlyleafOverlayVM vm)
3630
{
37-
if (_prevActivityEnabled)
38-
{
39-
vm.FL.Player.Activity.IsEnabled = true;
40-
}
41-
_prevActivityEnabled = false;
31+
vm.FL.Player.Activity.IsEnabled = true;
4232
}
4333
}
4434
}

LLPlayer/Services/AppActions.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,17 +364,11 @@ private void SubsTextCopyInternal(int subIndex, bool? suppressOsd)
364364

365365
public DelegateCommand CmdOpenWindowSettings => field ?? new(() =>
366366
{
367-
// Keep the seek bar visible at all times while the settings screen is open.
368-
int prevTimeout = _player.Activity.Timeout;
369-
370367
if (_player.IsPlaying)
371368
{
372369
_player.Pause();
373370
}
374371

375-
_player.Activity.IsEnabled = false;
376-
_player.Activity.Timeout = 0;
377-
378372
// Detects configuration changes necessary for restart
379373
// TODO: L: refactor
380374
bool requiredRestart = false;
@@ -395,6 +389,7 @@ void ConfigOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
395389
}
396390
}
397391

392+
_player.Activity.ForceFullActive();
398393
_dialogService.ShowSingleton(nameof(SettingsDialog), result =>
399394
{
400395
// Activate as it may be minimized for some reason
@@ -426,15 +421,6 @@ void ConfigOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
426421
}
427422
}
428423
}
429-
430-
// Closing the app while settings is open may cause it to be null.
431-
if (_player.Activity.Timeout == 0)
432-
{
433-
_player.Activity.Timeout = prevTimeout;
434-
}
435-
436-
_player.Activity.IsEnabled = true;
437-
438424
}, false);
439425
});
440426

LLPlayer/ViewModels/FlyleafOverlayVM.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,16 @@ private void SurfaceOnMouseMove(object sender, MouseEventArgs e)
176176

177177
private void DragMoveOwner()
178178
{
179-
bool prevEnabled = FL.Player.Activity.IsEnabled;
180-
// prevent to activate seek bar when mouse over
179+
// (!SeekBarShowOnlyMouseOver) always show cursor when moving
180+
// (SeekBarShowOnlyMouseOver) prevent to activate seek bar
181181
if (!FL.Config.SeekBarShowOnlyMouseOver)
182182
{
183183
FL.Player.Activity.IsEnabled = false;
184184
}
185185

186186
FL.FlyleafHost!.Owner.DragMove();
187187

188-
if (!FL.Config.SeekBarShowOnlyMouseOver && prevEnabled)
188+
if (!FL.Config.SeekBarShowOnlyMouseOver)
189189
{
190190
FL.Player.Activity.IsEnabled = true;
191191
}

0 commit comments

Comments
 (0)