Skip to content

Commit

Permalink
Merge pull request #2741 from onesounds/240529-FixPreviewFit
Browse files Browse the repository at this point in the history
Adjust Preview Panel
  • Loading branch information
onesounds authored May 31, 2024
2 parents 870c2ba + 40dbc55 commit 8972d9e
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 78 deletions.
24 changes: 21 additions & 3 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,22 @@
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=ResultListBox, Path=Items.Count}" Value="0" />
<Condition Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Collapsed" />
<Condition Binding="{Binding ElementName=History, Path=Visibility}" Value="Collapsed" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="Margin" Value="0" />
<Setter Property="Height" Value="0" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
<!--<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
Expand All @@ -355,7 +369,7 @@
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style.Triggers>-->
</Style>
</ContentControl.Style>
<Rectangle
Expand All @@ -368,7 +382,7 @@
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="*" MinWidth="80" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="0.85*" MinWidth="244" />
</Grid.ColumnDefinitions>
Expand Down Expand Up @@ -428,6 +442,7 @@
<GridSplitter
Grid.Column="1"
Width="{Binding PreviewVisible, Converter={StaticResource SplitterConverter}}"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Transparent"
Expand All @@ -439,6 +454,7 @@
Style="{DynamicResource PreviewArea}"
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
<Border
MinHeight="380"
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Expand Down Expand Up @@ -514,6 +530,8 @@
</Grid>
</Border>
<Border
MinHeight="380"
MaxHeight="{Binding ElementName=ResultListBox, Path=ActualHeight}"
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Expand Down
17 changes: 13 additions & 4 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,26 @@ public MainWindow()

private const int WM_ENTERSIZEMOVE = 0x0231;
private const int WM_EXITSIZEMOVE = 0x0232;
private int _initialWidth;
private int _initialHeight;
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_ENTERSIZEMOVE)
{
_initialWidth = (int)Width;
_initialHeight = (int)Height;
handled = true;
}
if (msg == WM_EXITSIZEMOVE)
{
OnResizeEnd();
if ( _initialHeight != (int)Height)
{
OnResizeEnd();
}
if (_initialWidth != (int)Width)
{
FlowMainWindow.SizeToContent = SizeToContent.Height;
}
handled = true;
}
return IntPtr.Zero;
Expand All @@ -120,9 +131,8 @@ private void OnResizeEnd()
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
}
}

_viewModel.MainWindowWidth = Width;
FlowMainWindow.SizeToContent = SizeToContent.Height;
_viewModel.MainWindowWidth = Width;
}

private void OnCopy(object sender, ExecutedRoutedEventArgs e)
Expand Down Expand Up @@ -169,7 +179,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
{
// MouseEventHandler
PreviewMouseMove += MainPreviewMouseMove;

CheckFirstLaunch();
HideStartup();
// show notify icon when flowlauncher is hidden
Expand Down
69 changes: 27 additions & 42 deletions Flow.Launcher/Themes/Base.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="28" />
<Setter Property="FontWeight" Value="Regular" />
<Setter Property="Margin" Value="16,7,0,7" />
<Setter Property="Padding" Value="0,4,68,0" />
<Setter Property="Margin" Value="16 7 0 7" />
<Setter Property="Padding" Value="0 4 68 0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="48" />
<Setter Property="Foreground" Value="#E3E0E3" />
Expand Down Expand Up @@ -69,7 +69,7 @@

<!-- Further font customisations are dynamically loaded in Theme.cs -->
<Style x:Key="BaseQueryBoxBgStyle" TargetType="{x:Type Border}">
<Setter Property="Margin" Value="0,2,0,0" />
<Setter Property="Margin" Value="0 2 0 0" />
</Style>
<Style
x:Key="QueryBoxBgStyle"
Expand All @@ -81,17 +81,17 @@
TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="DarkGray" />
<Setter Property="Height" Value="48" />
<Setter Property="Margin" Value="16,7,0,7" />
<Setter Property="Margin" Value="16 7 0 7" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="0,4,68,0" />
<Setter Property="Padding" Value="0 4 68 0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="#2F2F2F" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Padding" Value="0 0 0 0" />
<Setter Property="CornerRadius" Value="5" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
Expand All @@ -115,15 +115,15 @@
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Margin" Value="0,0,66,0" />
<Setter Property="Margin" Value="0 0 66 0" />
<Setter Property="Visibility" Value="Collapsed" />
</Style>
<Style x:Key="BaseClockBox" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="20" />
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Margin" Value="0 0 0 0" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DateBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
Expand All @@ -135,7 +135,7 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Margin" Value="0 0 0 0" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ClockBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
Expand Down Expand Up @@ -188,7 +188,7 @@
<!-- Item Style -->
<Style x:Key="ProgressBarResult" TargetType="{x:Type ProgressBar}">
<Setter Property="Height" Value="18" />
<Setter Property="Margin" Value="0,0,0,4" />
<Setter Property="Margin" Value="0 0 0 4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Maximum" Value="100" />
<Setter Property="Minimum" Value="0" />
Expand All @@ -214,7 +214,7 @@
<Style x:Key="BaseItemNumberStyle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="3,0,0,0" />
<Setter Property="Margin" Value="3 0 0 0" />
<Setter Property="FontSize" Value="22" />
</Style>
<Style x:Key="BaseGlyphStyle" TargetType="{x:Type TextBlock}">
Expand Down Expand Up @@ -255,7 +255,7 @@
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Margin" Value="{DynamicResource ResultMargin}" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Padding" Value="0 0 0 0" />

<Setter Property="Template">
<Setter.Value>
Expand All @@ -265,12 +265,12 @@
<Style TargetType="ScrollViewer">
<Style.Triggers>
<Trigger Property="ComputedVerticalScrollBarVisibility" Value="Visible">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Margin" Value="0 0 0 0" />
<Setter Property="Padding" Value="0 0 0 0" />
</Trigger>
<Trigger Property="ComputedVerticalScrollBarVisibility" Value="Collapsed">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0,0,0" />
<Setter Property="Margin" Value="0 0 0 0" />
<Setter Property="Padding" Value="0 0 0 0" />
</Trigger>
</Style.Triggers>
</Style>
Expand Down Expand Up @@ -312,7 +312,7 @@
x:Name="PART_VerticalScrollBar"
Grid.Row="0"
Grid.Column="0"
Margin="0,0,0,0"
Margin="0 0 0 0"
HorizontalAlignment="Right"
AutomationProperties.AutomationId="VerticalScrollBar"
Cursor="Arrow"
Expand Down Expand Up @@ -368,22 +368,7 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BaseSeparatorStyle" TargetType="Rectangle">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=ResultListBox, Path=Items.Count}" Value="0" />
<Condition Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Collapsed" />
<Condition Binding="{Binding ElementName=History, Path=Visibility}" Value="Collapsed" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="Margin" Value="0" />
<Setter Property="Height" Value="0" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="BaseSeparatorStyle" TargetType="Rectangle" />
<Style x:Key="HighlightStyle">
<Setter Property="Inline.FontWeight" Value="Bold" />
</Style>
Expand Down Expand Up @@ -413,15 +398,15 @@
<Style x:Key="BaseSearchIconPosition" TargetType="{x:Type Canvas}">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="0,2,18,0" />
<Setter Property="Margin" Value="0 2 18 0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style x:Key="BasePreviewBorderStyle" TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="1,0,0,0" />
<Setter Property="BorderThickness" Value="1 0 0 0" />
<Setter Property="BorderBrush" Value="#FFEAEAEA" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Margin" Value="0,0,10,10" />
<Setter Property="Margin" Value="0 0 10 10" />
</Style>
<Style x:Key="BasePreviewGlyph" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#555555" />
Expand All @@ -447,7 +432,7 @@
<Style x:Key="PreviewSep" TargetType="{x:Type Separator}">
<Setter Property="Visibility" Value="Visible" />
<Setter Property="Background" Value="{Binding ElementName=MiddleSeparator, Path=Fill}" />
<Setter Property="Margin" Value="0,15,0,5" />
<Setter Property="Margin" Value="0 15 0 5" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=PreviewSubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
<Setter Property="Visibility" Value="Collapsed" />
Expand Down Expand Up @@ -483,7 +468,7 @@
<Style x:Key="PluginActivationIcon" TargetType="{x:Type Image}">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="0,0,18,0" />
<Setter Property="Margin" Value="0 0 18 0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

Expand All @@ -495,15 +480,15 @@
<Style x:Key="SearchIconPosition" TargetType="{x:Type Canvas}">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="0,2,18,0" />
<Setter Property="Margin" Value="0 2 18 0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style
x:Key="ClockPanelPosition"
BasedOn="{StaticResource BaseClockPanelPosition}"
TargetType="{x:Type Canvas}">
<Setter Property="Margin" Value="0,2,66,0" />
<Setter Property="Margin" Value="0 2 66 0" />
</Style>
<Style
x:Key="ItemHotkeyStyle"
Expand Down Expand Up @@ -536,7 +521,7 @@
<Style x:Key="BasePreviewItemTitleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="FontSize" Value="15" />
<Setter Property="Margin" Value="0,6,0,0" />
<Setter Property="Margin" Value="0 6 0 0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="TextWrapping" Value="Wrap" />
Expand All @@ -545,7 +530,7 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="FontSize" Value="12" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Margin" Value="0,6,0,10" />
<Setter Property="Margin" Value="0 6 0 10" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="LineHeight" Value="18" />
<Setter Property="TextAlignment" Value="Left" />
Expand Down
16 changes: 13 additions & 3 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,21 @@ public MainViewModel(Settings settings)

ContextMenu = new ResultsViewModel(Settings)
{
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
LeftClickResultCommand = OpenResultCommand,
RightClickResultCommand = LoadContextMenuCommand,
IsPreviewOn = Settings.AlwaysPreview
};
Results = new ResultsViewModel(Settings)
{
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
LeftClickResultCommand = OpenResultCommand,
RightClickResultCommand = LoadContextMenuCommand,
IsPreviewOn = Settings.AlwaysPreview
};
History = new ResultsViewModel(Settings)
{
LeftClickResultCommand = OpenResultCommand, RightClickResultCommand = LoadContextMenuCommand
LeftClickResultCommand = OpenResultCommand,
RightClickResultCommand = LoadContextMenuCommand,
IsPreviewOn = Settings.AlwaysPreview
};
_selectedResults = Results;

Expand Down Expand Up @@ -586,6 +592,10 @@ public void TogglePreview()
{
HidePreview();
}

ContextMenu.IsPreviewOn = PreviewVisible;
History.IsPreviewOn = PreviewVisible;
Results.IsPreviewOn = PreviewVisible;
}

private void ShowPreview()
Expand Down
Loading

0 comments on commit 8972d9e

Please sign in to comment.