Skip to content

Commit 2b77248

Browse files
authored
Merge pull request #57 from grandixximo/cursor/fix-broken-overlay-tools-by-comparing-with-main-bcb4
partially fixed some overlay tools
2 parents c92adfc + 06ad53e commit 2b77248

4 files changed

Lines changed: 87 additions & 22 deletions

File tree

src/Captura.Core/Settings/Settings.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public Settings(FFmpegSettings FFmpeg, WindowsSettings WindowsSettings)
3636
{
3737
this.FFmpeg = FFmpeg;
3838
this.WindowsSettings = WindowsSettings;
39+
40+
// Sync IncludeCursor with MousePointerOverlay.Display
41+
MousePointerOverlay.PropertyChanged += (s, e) =>
42+
{
43+
if (e.PropertyName == nameof(MousePointerOverlay.Display))
44+
{
45+
OnPropertyChanged(nameof(IncludeCursor));
46+
}
47+
};
3948
}
4049

4150
static string GetPath() => Path.Combine(ServiceProvider.SettingsDir, "Captura.json");
@@ -231,8 +240,12 @@ public string GetFileName(string Extension, string FileName = null)
231240

232241
public bool IncludeCursor
233242
{
234-
get => Get(true);
235-
set => Set(value);
243+
get => MousePointerOverlay.Display;
244+
set
245+
{
246+
MousePointerOverlay.Display = value;
247+
OnPropertyChanged();
248+
}
236249
}
237250

238251
public bool RegionPickerHotkeyAutoStartRecording

src/Captura/Pages/KeystrokesPage.xaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Page x:Class="Captura.KeystrokesPage"
1+
<Page x:Class="Captura.KeystrokesPage"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:captura="clr-namespace:Captura"
@@ -7,10 +7,14 @@
77
<ScrollViewer DataContext="{Binding AboutViewModel, Source={StaticResource ServiceLocator}}">
88
<StackPanel Margin="5"
99
DataContext="{Binding Settings.Keystrokes}">
10+
<CheckBox Content="Display"
11+
IsChecked="{Binding Display, Mode=TwoWay}"
12+
Margin="0,5"/>
13+
1014
<CheckBox Content="{Binding KeystrokesSeparateFile, Source={StaticResource Loc}, Mode=OneWay}"
1115
IsChecked="{Binding SeparateTextFile, Mode=TwoWay}"
1216
Margin="0,3"
13-
IsEnabled="{Binding MainViewModel.RecordingViewModel.RecorderState, Source={StaticResource ServiceLocator}, Converter={StaticResource NotRecordingConverter}}"/>
17+
IsEnabled="{Binding ViewConditions.IsEnabled.Value, Source={StaticResource ServiceLocator}}"/>
1418

1519
<DockPanel Margin="0,3">
1620
<Label Content="{Binding Keymap, Source={StaticResource Loc}, Mode=OneWay}"
@@ -78,6 +82,11 @@
7882
Grid.Column="1"
7983
Margin="0,5"/>
8084
</Grid>
85+
86+
<CheckBox Content="Show Repeat Counter"
87+
IsChecked="{Binding ShowRepeatCounter, Mode=TwoWay}"
88+
Margin="0,3"
89+
Visibility="{Binding SeparateTextFile, Converter={StaticResource NegatingConverter}}"/>
8190
</StackPanel>
8291
</ScrollViewer>
8392
</Grid>

src/Captura/Pages/MouseOverlayPage.xaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494

9595
<StackPanel Margin="5"
9696
DataContext="{Binding Settings.Clicks}">
97+
<CheckBox Content="Display Clicks"
98+
IsChecked="{Binding Display, Mode=TwoWay}"
99+
Margin="0,5"/>
100+
97101
<Grid>
98102
<Grid.ColumnDefinitions>
99103
<ColumnDefinition Width="Auto"/>
@@ -172,6 +176,51 @@
172176
Margin="0,5"/>
173177
</Grid>
174178
</StackPanel>
179+
180+
<Label Content="Mouse Scroll"
181+
FontWeight="DemiBold"
182+
Margin="5,10,5,0"/>
183+
<Label Content="Horizontal scrolls aren't displayed correctly"
184+
FontWeight="Light"
185+
FontSize="9"
186+
Margin="5,0"/>
187+
188+
<StackPanel Margin="5"
189+
DataContext="{Binding Settings.Clicks}"
190+
IsEnabled="{Binding Display}">
191+
<CheckBox Content="Display Scroll"
192+
IsChecked="{Binding DisplayScroll, Mode=TwoWay}"
193+
Margin="0,5"/>
194+
195+
<Grid>
196+
<Grid.ColumnDefinitions>
197+
<ColumnDefinition Width="Auto"/>
198+
<ColumnDefinition Width="*"/>
199+
</Grid.ColumnDefinitions>
200+
<Grid.RowDefinitions>
201+
<RowDefinition/>
202+
<RowDefinition/>
203+
</Grid.RowDefinitions>
204+
205+
<Label Content="Circle Color"
206+
ContentStringFormat="{}{0}: "
207+
Margin="0,5,5,5"/>
208+
<xctk:ColorPicker SelectedColor="{Binding ScrollCircleColor, Converter={StaticResource WpfColorConverter}, Mode=TwoWay}"
209+
Grid.Row="0"
210+
Grid.Column="1"
211+
Margin="0,5"/>
212+
213+
<Label Content="Arrow Color"
214+
ContentStringFormat="{}{0}: "
215+
Margin="0,5,5,5"
216+
Grid.Row="1"
217+
Grid.Column="0"/>
218+
<xctk:ColorPicker SelectedColor="{Binding ScrollArrowColor, Converter={StaticResource WpfColorConverter}, Mode=TwoWay}"
219+
Grid.Row="1"
220+
Grid.Column="1"
221+
Margin="0,5"/>
222+
</Grid>
223+
</StackPanel>
175224
</StackPanel>
176225
</ScrollViewer>
177226
</Grid>

src/Captura/Pages/OverlayPage.xaml.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Captura
2222
{
2323
public partial class OverlayPage
2424
{
25-
public OverlayPage()
25+
OverlayPage()
2626
{
2727
InitializeComponent();
2828

@@ -37,24 +37,15 @@ public OverlayPage()
3737

3838
void AddToGrid(LayerFrame Frame, bool CanResize)
3939
{
40-
if (Grid == null)
41-
return;
42-
4340
Grid.Children.Add(Frame);
4441

4542
Panel.SetZIndex(Frame, 0);
4643

47-
// Wait for visual tree to be ready before accessing AdornerLayer
48-
Frame.Loaded += (s, e) =>
49-
{
50-
var layer = AdornerLayer.GetAdornerLayer(Frame);
51-
if (layer != null)
52-
{
53-
var adorner = new OverlayPositionAdorner(Frame, CanResize);
54-
layer.Add(adorner);
55-
adorner.PositionUpdated += Frame.RaisePositionChanged;
56-
}
57-
};
44+
var layer = AdornerLayer.GetAdornerLayer(Frame);
45+
var adorner = new OverlayPositionAdorner(Frame, CanResize);
46+
layer.Add(adorner);
47+
48+
adorner.PositionUpdated += Frame.RaisePositionChanged;
5849
}
5950

6051
LayerFrame Generate(PositionedOverlaySettings Settings, string Text, Color BackgroundColor)
@@ -387,9 +378,6 @@ bool IsOutsideGrid(Point Point)
387378

388379
void UIElement_OnMouseMove(object Sender, MouseEventArgs E)
389380
{
390-
if (ServiceProvider.Get<Settings>().MousePointerOverlay.DisplayHighlight)
391-
MousePointer.Visibility = Visibility.Visible;
392-
393381
var position = E.GetPosition(Grid);
394382

395383
if (IsOutsideGrid(position))
@@ -399,6 +387,12 @@ void UIElement_OnMouseMove(object Sender, MouseEventArgs E)
399387
return;
400388
}
401389

390+
// Show/hide circle based on DisplayHighlight setting
391+
if (ServiceProvider.Get<Settings>().MousePointerOverlay.DisplayHighlight)
392+
MousePointer.Visibility = Visibility.Visible;
393+
else
394+
MousePointer.Visibility = Visibility.Collapsed;
395+
402396
if (_dragging)
403397
{
404398
UpdateMouseClickPosition(position);

0 commit comments

Comments
 (0)