Skip to content

Commit 8972d9e

Browse files
authored
Merge pull request #2741 from onesounds/240529-FixPreviewFit
Adjust Preview Panel
2 parents 870c2ba + 40dbc55 commit 8972d9e

File tree

6 files changed

+135
-78
lines changed

6 files changed

+135
-78
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,22 @@
344344
<ContentControl>
345345
<ContentControl.Style>
346346
<Style TargetType="ContentControl">
347-
<Setter Property="Visibility" Value="Collapsed" />
347+
<Setter Property="Visibility" Value="Visible" />
348348
<Style.Triggers>
349+
<MultiDataTrigger>
350+
<MultiDataTrigger.Conditions>
351+
<Condition Binding="{Binding ElementName=ResultListBox, Path=Items.Count}" Value="0" />
352+
<Condition Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Collapsed" />
353+
<Condition Binding="{Binding ElementName=History, Path=Visibility}" Value="Collapsed" />
354+
</MultiDataTrigger.Conditions>
355+
<MultiDataTrigger.Setters>
356+
<Setter Property="Visibility" Value="Collapsed" />
357+
<Setter Property="Margin" Value="0" />
358+
<Setter Property="Height" Value="0" />
359+
</MultiDataTrigger.Setters>
360+
</MultiDataTrigger>
361+
</Style.Triggers>
362+
<!--<Style.Triggers>
349363
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
350364
<Setter Property="Visibility" Value="Visible" />
351365
</DataTrigger>
@@ -355,7 +369,7 @@
355369
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
356370
<Setter Property="Visibility" Value="Visible" />
357371
</DataTrigger>
358-
</Style.Triggers>
372+
</Style.Triggers>-->
359373
</Style>
360374
</ContentControl.Style>
361375
<Rectangle
@@ -368,7 +382,7 @@
368382
</Grid>
369383
<Grid>
370384
<Grid.ColumnDefinitions>
371-
<ColumnDefinition Width="*" MinWidth="100" />
385+
<ColumnDefinition Width="*" MinWidth="80" />
372386
<ColumnDefinition Width="Auto" />
373387
<ColumnDefinition Width="0.85*" MinWidth="244" />
374388
</Grid.ColumnDefinitions>
@@ -428,6 +442,7 @@
428442
<GridSplitter
429443
Grid.Column="1"
430444
Width="{Binding PreviewVisible, Converter={StaticResource SplitterConverter}}"
445+
Margin="0"
431446
HorizontalAlignment="Center"
432447
VerticalAlignment="Stretch"
433448
Background="Transparent"
@@ -439,6 +454,7 @@
439454
Style="{DynamicResource PreviewArea}"
440455
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
441456
<Border
457+
MinHeight="380"
442458
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
443459
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
444460
Style="{DynamicResource PreviewBorderStyle}"
@@ -514,6 +530,8 @@
514530
</Grid>
515531
</Border>
516532
<Border
533+
MinHeight="380"
534+
MaxHeight="{Binding ElementName=ResultListBox, Path=ActualHeight}"
517535
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
518536
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
519537
Style="{DynamicResource PreviewBorderStyle}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,26 @@ public MainWindow()
8585

8686
private const int WM_ENTERSIZEMOVE = 0x0231;
8787
private const int WM_EXITSIZEMOVE = 0x0232;
88+
private int _initialWidth;
89+
private int _initialHeight;
8890
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
8991
{
9092
if (msg == WM_ENTERSIZEMOVE)
9193
{
94+
_initialWidth = (int)Width;
95+
_initialHeight = (int)Height;
9296
handled = true;
9397
}
9498
if (msg == WM_EXITSIZEMOVE)
9599
{
96-
OnResizeEnd();
100+
if ( _initialHeight != (int)Height)
101+
{
102+
OnResizeEnd();
103+
}
104+
if (_initialWidth != (int)Width)
105+
{
106+
FlowMainWindow.SizeToContent = SizeToContent.Height;
107+
}
97108
handled = true;
98109
}
99110
return IntPtr.Zero;
@@ -120,9 +131,8 @@ private void OnResizeEnd()
120131
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
121132
}
122133
}
123-
124-
_viewModel.MainWindowWidth = Width;
125134
FlowMainWindow.SizeToContent = SizeToContent.Height;
135+
_viewModel.MainWindowWidth = Width;
126136
}
127137

128138
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
@@ -169,7 +179,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
169179
{
170180
// MouseEventHandler
171181
PreviewMouseMove += MainPreviewMouseMove;
172-
173182
CheckFirstLaunch();
174183
HideStartup();
175184
// show notify icon when flowlauncher is hidden

Flow.Launcher/Themes/Base.xaml

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<Setter Property="BorderThickness" Value="0" />
2929
<Setter Property="FontSize" Value="28" />
3030
<Setter Property="FontWeight" Value="Regular" />
31-
<Setter Property="Margin" Value="16,7,0,7" />
32-
<Setter Property="Padding" Value="0,4,68,0" />
31+
<Setter Property="Margin" Value="16 7 0 7" />
32+
<Setter Property="Padding" Value="0 4 68 0" />
3333
<Setter Property="Background" Value="Transparent" />
3434
<Setter Property="Height" Value="48" />
3535
<Setter Property="Foreground" Value="#E3E0E3" />
@@ -69,7 +69,7 @@
6969

7070
<!-- Further font customisations are dynamically loaded in Theme.cs -->
7171
<Style x:Key="BaseQueryBoxBgStyle" TargetType="{x:Type Border}">
72-
<Setter Property="Margin" Value="0,2,0,0" />
72+
<Setter Property="Margin" Value="0 2 0 0" />
7373
</Style>
7474
<Style
7575
x:Key="QueryBoxBgStyle"
@@ -81,17 +81,17 @@
8181
TargetType="{x:Type TextBox}">
8282
<Setter Property="Foreground" Value="DarkGray" />
8383
<Setter Property="Height" Value="48" />
84-
<Setter Property="Margin" Value="16,7,0,7" />
84+
<Setter Property="Margin" Value="16 7 0 7" />
8585
<Setter Property="Background" Value="Transparent" />
86-
<Setter Property="Padding" Value="0,4,68,0" />
86+
<Setter Property="Padding" Value="0 4 68 0" />
8787
<Setter Property="HorizontalAlignment" Value="Stretch" />
8888
<Setter Property="VerticalAlignment" Value="Center" />
8989
</Style>
9090

9191
<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
9292
<Setter Property="BorderThickness" Value="0" />
9393
<Setter Property="Background" Value="#2F2F2F" />
94-
<Setter Property="Padding" Value="0,0,0,0" />
94+
<Setter Property="Padding" Value="0 0 0 0" />
9595
<Setter Property="CornerRadius" Value="5" />
9696
<Setter Property="UseLayoutRounding" Value="True" />
9797
<Setter Property="SnapsToDevicePixels" Value="True" />
@@ -115,15 +115,15 @@
115115
<Setter Property="HorizontalAlignment" Value="Right" />
116116
<Setter Property="VerticalAlignment" Value="Center" />
117117
<Setter Property="Height" Value="Auto" />
118-
<Setter Property="Margin" Value="0,0,66,0" />
118+
<Setter Property="Margin" Value="0 0 66 0" />
119119
<Setter Property="Visibility" Value="Collapsed" />
120120
</Style>
121121
<Style x:Key="BaseClockBox" TargetType="{x:Type TextBlock}">
122122
<Setter Property="FontSize" Value="20" />
123123
<Setter Property="Foreground" Value="#8f8f8f" />
124124
<Setter Property="HorizontalAlignment" Value="Right" />
125125
<Setter Property="VerticalAlignment" Value="Center" />
126-
<Setter Property="Margin" Value="0,0,0,0" />
126+
<Setter Property="Margin" Value="0 0 0 0" />
127127
<Style.Triggers>
128128
<DataTrigger Binding="{Binding ElementName=DateBox, Path=Visibility}" Value="Visible">
129129
<Setter Property="FontSize" Value="14" />
@@ -135,7 +135,7 @@
135135
<Setter Property="Foreground" Value="#8f8f8f" />
136136
<Setter Property="HorizontalAlignment" Value="Right" />
137137
<Setter Property="VerticalAlignment" Value="Center" />
138-
<Setter Property="Margin" Value="0,0,0,0" />
138+
<Setter Property="Margin" Value="0 0 0 0" />
139139
<Style.Triggers>
140140
<DataTrigger Binding="{Binding ElementName=ClockBox, Path=Visibility}" Value="Visible">
141141
<Setter Property="FontSize" Value="14" />
@@ -188,7 +188,7 @@
188188
<!-- Item Style -->
189189
<Style x:Key="ProgressBarResult" TargetType="{x:Type ProgressBar}">
190190
<Setter Property="Height" Value="18" />
191-
<Setter Property="Margin" Value="0,0,0,4" />
191+
<Setter Property="Margin" Value="0 0 0 4" />
192192
<Setter Property="VerticalAlignment" Value="Center" />
193193
<Setter Property="Maximum" Value="100" />
194194
<Setter Property="Minimum" Value="0" />
@@ -214,7 +214,7 @@
214214
<Style x:Key="BaseItemNumberStyle" TargetType="{x:Type TextBlock}">
215215
<Setter Property="VerticalAlignment" Value="Center" />
216216
<Setter Property="HorizontalAlignment" Value="Center" />
217-
<Setter Property="Margin" Value="3,0,0,0" />
217+
<Setter Property="Margin" Value="3 0 0 0" />
218218
<Setter Property="FontSize" Value="22" />
219219
</Style>
220220
<Style x:Key="BaseGlyphStyle" TargetType="{x:Type TextBlock}">
@@ -255,7 +255,7 @@
255255
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
256256
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
257257
<Setter Property="Margin" Value="{DynamicResource ResultMargin}" />
258-
<Setter Property="Padding" Value="0,0,0,0" />
258+
<Setter Property="Padding" Value="0 0 0 0" />
259259

260260
<Setter Property="Template">
261261
<Setter.Value>
@@ -265,12 +265,12 @@
265265
<Style TargetType="ScrollViewer">
266266
<Style.Triggers>
267267
<Trigger Property="ComputedVerticalScrollBarVisibility" Value="Visible">
268-
<Setter Property="Margin" Value="0,0,0,0" />
269-
<Setter Property="Padding" Value="0,0,0,0" />
268+
<Setter Property="Margin" Value="0 0 0 0" />
269+
<Setter Property="Padding" Value="0 0 0 0" />
270270
</Trigger>
271271
<Trigger Property="ComputedVerticalScrollBarVisibility" Value="Collapsed">
272-
<Setter Property="Margin" Value="0,0,0,0" />
273-
<Setter Property="Padding" Value="0,0,0,0" />
272+
<Setter Property="Margin" Value="0 0 0 0" />
273+
<Setter Property="Padding" Value="0 0 0 0" />
274274
</Trigger>
275275
</Style.Triggers>
276276
</Style>
@@ -312,7 +312,7 @@
312312
x:Name="PART_VerticalScrollBar"
313313
Grid.Row="0"
314314
Grid.Column="0"
315-
Margin="0,0,0,0"
315+
Margin="0 0 0 0"
316316
HorizontalAlignment="Right"
317317
AutomationProperties.AutomationId="VerticalScrollBar"
318318
Cursor="Arrow"
@@ -368,22 +368,7 @@
368368
</Setter.Value>
369369
</Setter>
370370
</Style>
371-
<Style x:Key="BaseSeparatorStyle" TargetType="Rectangle">
372-
<Style.Triggers>
373-
<MultiDataTrigger>
374-
<MultiDataTrigger.Conditions>
375-
<Condition Binding="{Binding ElementName=ResultListBox, Path=Items.Count}" Value="0" />
376-
<Condition Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Collapsed" />
377-
<Condition Binding="{Binding ElementName=History, Path=Visibility}" Value="Collapsed" />
378-
</MultiDataTrigger.Conditions>
379-
<MultiDataTrigger.Setters>
380-
<Setter Property="Visibility" Value="Collapsed" />
381-
<Setter Property="Margin" Value="0" />
382-
<Setter Property="Height" Value="0" />
383-
</MultiDataTrigger.Setters>
384-
</MultiDataTrigger>
385-
</Style.Triggers>
386-
</Style>
371+
<Style x:Key="BaseSeparatorStyle" TargetType="Rectangle" />
387372
<Style x:Key="HighlightStyle">
388373
<Setter Property="Inline.FontWeight" Value="Bold" />
389374
</Style>
@@ -413,15 +398,15 @@
413398
<Style x:Key="BaseSearchIconPosition" TargetType="{x:Type Canvas}">
414399
<Setter Property="Width" Value="32" />
415400
<Setter Property="Height" Value="32" />
416-
<Setter Property="Margin" Value="0,2,18,0" />
401+
<Setter Property="Margin" Value="0 2 18 0" />
417402
<Setter Property="Background" Value="Transparent" />
418403
<Setter Property="HorizontalAlignment" Value="Right" />
419404
</Style>
420405
<Style x:Key="BasePreviewBorderStyle" TargetType="{x:Type Border}">
421-
<Setter Property="BorderThickness" Value="1,0,0,0" />
406+
<Setter Property="BorderThickness" Value="1 0 0 0" />
422407
<Setter Property="BorderBrush" Value="#FFEAEAEA" />
423408
<Setter Property="Background" Value="Transparent" />
424-
<Setter Property="Margin" Value="0,0,10,10" />
409+
<Setter Property="Margin" Value="0 0 10 10" />
425410
</Style>
426411
<Style x:Key="BasePreviewGlyph" TargetType="{x:Type TextBlock}">
427412
<Setter Property="Foreground" Value="#555555" />
@@ -447,7 +432,7 @@
447432
<Style x:Key="PreviewSep" TargetType="{x:Type Separator}">
448433
<Setter Property="Visibility" Value="Visible" />
449434
<Setter Property="Background" Value="{Binding ElementName=MiddleSeparator, Path=Fill}" />
450-
<Setter Property="Margin" Value="0,15,0,5" />
435+
<Setter Property="Margin" Value="0 15 0 5" />
451436
<Style.Triggers>
452437
<DataTrigger Binding="{Binding ElementName=PreviewSubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
453438
<Setter Property="Visibility" Value="Collapsed" />
@@ -483,7 +468,7 @@
483468
<Style x:Key="PluginActivationIcon" TargetType="{x:Type Image}">
484469
<Setter Property="Width" Value="32" />
485470
<Setter Property="Height" Value="32" />
486-
<Setter Property="Margin" Value="0,0,18,0" />
471+
<Setter Property="Margin" Value="0 0 18 0" />
487472
<Setter Property="VerticalAlignment" Value="Center" />
488473
</Style>
489474

@@ -495,15 +480,15 @@
495480
<Style x:Key="SearchIconPosition" TargetType="{x:Type Canvas}">
496481
<Setter Property="Width" Value="32" />
497482
<Setter Property="Height" Value="32" />
498-
<Setter Property="Margin" Value="0,2,18,0" />
483+
<Setter Property="Margin" Value="0 2 18 0" />
499484
<Setter Property="Background" Value="Transparent" />
500485
<Setter Property="HorizontalAlignment" Value="Right" />
501486
</Style>
502487
<Style
503488
x:Key="ClockPanelPosition"
504489
BasedOn="{StaticResource BaseClockPanelPosition}"
505490
TargetType="{x:Type Canvas}">
506-
<Setter Property="Margin" Value="0,2,66,0" />
491+
<Setter Property="Margin" Value="0 2 66 0" />
507492
</Style>
508493
<Style
509494
x:Key="ItemHotkeyStyle"
@@ -536,7 +521,7 @@
536521
<Style x:Key="BasePreviewItemTitleStyle" TargetType="{x:Type TextBlock}">
537522
<Setter Property="Foreground" Value="#8f8f8f" />
538523
<Setter Property="FontSize" Value="15" />
539-
<Setter Property="Margin" Value="0,6,0,0" />
524+
<Setter Property="Margin" Value="0 6 0 0" />
540525
<Setter Property="HorizontalAlignment" Value="Stretch" />
541526
<Setter Property="TextAlignment" Value="Center" />
542527
<Setter Property="TextWrapping" Value="Wrap" />
@@ -545,7 +530,7 @@
545530
<Setter Property="Foreground" Value="#8f8f8f" />
546531
<Setter Property="FontSize" Value="12" />
547532
<Setter Property="FontWeight" Value="Normal" />
548-
<Setter Property="Margin" Value="0,6,0,10" />
533+
<Setter Property="Margin" Value="0 6 0 10" />
549534
<Setter Property="HorizontalAlignment" Value="Stretch" />
550535
<Setter Property="LineHeight" Value="18" />
551536
<Setter Property="TextAlignment" Value="Left" />

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,21 @@ public MainViewModel(Settings settings)
143143

144144
ContextMenu = new ResultsViewModel(Settings)
145145
{
146-
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
146+
LeftClickResultCommand = OpenResultCommand,
147+
RightClickResultCommand = LoadContextMenuCommand,
148+
IsPreviewOn = Settings.AlwaysPreview
147149
};
148150
Results = new ResultsViewModel(Settings)
149151
{
150-
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
152+
LeftClickResultCommand = OpenResultCommand,
153+
RightClickResultCommand = LoadContextMenuCommand,
154+
IsPreviewOn = Settings.AlwaysPreview
151155
};
152156
History = new ResultsViewModel(Settings)
153157
{
154-
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
158+
LeftClickResultCommand = OpenResultCommand,
159+
RightClickResultCommand = LoadContextMenuCommand,
160+
IsPreviewOn = Settings.AlwaysPreview
155161
};
156162
_selectedResults = Results;
157163

@@ -586,6 +592,10 @@ public void TogglePreview()
586592
{
587593
HidePreview();
588594
}
595+
596+
ContextMenu.IsPreviewOn = PreviewVisible;
597+
History.IsPreviewOn = PreviewVisible;
598+
Results.IsPreviewOn = PreviewVisible;
589599
}
590600

591601
private void ShowPreview()

0 commit comments

Comments
 (0)