Merge FixPreviewPanel

This commit is contained in:
DB p 2024-05-31 09:49:20 +09:00
commit 3be0e44808
6 changed files with 135 additions and 78 deletions

View file

@ -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>
@ -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
@ -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>
@ -428,6 +442,7 @@
<GridSplitter
Grid.Column="1"
Width="{Binding PreviewVisible, Converter={StaticResource SplitterConverter}}"
Margin="0"
HorizontalAlignment="Center"
VerticalAlignment="Stretch"
Background="Transparent"
@ -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}"
@ -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}"

View file

@ -85,15 +85,26 @@ namespace Flow.Launcher
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;
@ -120,9 +131,8 @@ namespace Flow.Launcher
_settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount));
}
}
_viewModel.MainWindowWidth = Width;
FlowMainWindow.SizeToContent = SizeToContent.Height;
_viewModel.MainWindowWidth = Width;
}
private void OnCopy(object sender, ExecutedRoutedEventArgs e)
@ -169,7 +179,6 @@ namespace Flow.Launcher
{
// MouseEventHandler
PreviewMouseMove += MainPreviewMouseMove;
CheckFirstLaunch();
HideStartup();
// show notify icon when flowlauncher is hidden

View file

@ -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,0,68,0" />
<Setter Property="Margin" Value="16 7 0 7" />
<Setter Property="Padding" Value="0 0 68 0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="48" />
<Setter Property="Foreground" Value="#E3E0E3" />
@ -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,0,0,0" />
<Setter Property="Margin" Value="0 0 0 0" />
</Style>
<Style
x:Key="QueryBoxBgStyle"
@ -81,9 +81,9 @@
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,0,68,0" />
<Setter Property="Padding" Value="0 0 68 0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
@ -92,7 +92,7 @@
<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" />
@ -117,7 +117,7 @@
<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}">
@ -126,7 +126,7 @@
<Setter Property="Foreground" Value="#8f8f8f" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,0,3" />
<Setter Property="Margin" Value="0 0 0 3" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DateBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
@ -139,7 +139,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" />
@ -193,7 +193,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" />
@ -219,7 +219,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}">
@ -260,7 +260,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>
@ -270,12 +270,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>
@ -317,7 +317,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"
@ -373,22 +373,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>
@ -418,15 +403,15 @@
<Style x:Key="BaseSearchIconPosition" TargetType="{x:Type Canvas}">
<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="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" />
@ -452,7 +437,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" />
@ -488,7 +473,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>
@ -500,7 +485,7 @@
<Style x:Key="SearchIconPosition" TargetType="{x:Type Canvas}">
<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="Background" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
@ -508,7 +493,7 @@
x:Key="ClockPanelPosition"
BasedOn="{StaticResource BaseClockPanelPosition}"
TargetType="{x:Type Canvas}">
<Setter Property="Margin" Value="0,0,66,0" />
<Setter Property="Margin" Value="0 0 66 0" />
</Style>
<Style
x:Key="ItemHotkeyStyle"
@ -541,7 +526,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" />
@ -550,7 +535,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" />

View file

@ -143,15 +143,21 @@ namespace Flow.Launcher.ViewModel
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;
@ -586,6 +592,10 @@ namespace Flow.Launcher.ViewModel
{
HidePreview();
}
ContextMenu.IsPreviewOn = PreviewVisible;
History.IsPreviewOn = PreviewVisible;
Results.IsPreviewOn = PreviewVisible;
}
private void ShowPreview()

View file

@ -1,4 +1,5 @@
using Flow.Launcher.Infrastructure.UserSettings;
using System;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using System.Collections.Generic;
using System.Collections.Specialized;
@ -49,7 +50,25 @@ namespace Flow.Launcher.ViewModel
#region Properties
public double MaxHeight => MaxResults * _settings.ItemHeightSize;
public bool IsPreviewOn { get; set; }
public double MaxHeight
{
get
{
var newResultsCount = MaxResults;
if (IsPreviewOn)
{
newResultsCount = (int)Math.Ceiling(380 / _settings.ItemHeightSize);
if (newResultsCount < MaxResults)
{
newResultsCount = MaxResults;
}
}
return newResultsCount * _settings.ItemHeightSize;
}
}
public double ItemHeightSize
{
get => _settings.ItemHeightSize;

View file

@ -13,37 +13,41 @@
Margin="20 0 10 0"
VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" VerticalAlignment="Center">
<Grid Grid.Row="0" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition MinHeight="96" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Margin="0 16 0 0"
HorizontalAlignment="Stretch"
Source="{Binding PreviewImage, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
StretchDirection="DownOnly">
Grid.Row="0"
Margin="0 12 0 0"
Source="{Binding PreviewImage, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Image.Style>
<Style TargetType="Image">
<Setter Property="MaxWidth" Value="96" />
<Setter Property="MaxHeight" Value="320" />
<Style.Triggers>
<DataTrigger Binding="{Binding UseBigThumbnail}" Value="True">
<Setter Property="MaxWidth" Value="{Binding ElementName=PreviewGrid, Path=ActualWidth}" />
<Setter Property="MaxHeight" Value="{Binding ElementName=PreviewGrid, Path=ActualHeight}" />
<DataTrigger Binding="{Binding UseBigThumbnail}" Value="False">
<Setter Property="MaxWidth" Value="96" />
<Setter Property="MaxHeight" Value="96" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock
Margin="0 6 0 16"
HorizontalAlignment="Stretch"
Style="{DynamicResource PreviewItemTitleStyle}"
Text="{Binding Result.Title}"
TextAlignment="Center"
TextWrapping="Wrap" />
</StackPanel>
<StackPanel Grid.Row="1">
<Grid Grid.Row="1">
<TextBlock
Margin="0 6 0 16"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Style="{DynamicResource PreviewItemTitleStyle}"
Text="{Binding Result.Title}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid>
</Grid>
<StackPanel Grid.Row="2">
<StackPanel.Style>
<Style TargetType="StackPanel">
<Style.Triggers>
@ -53,10 +57,22 @@
</Style.Triggers>
</Style>
</StackPanel.Style>
<Separator />
<TextBlock Style="{DynamicResource PreviewItemSubTitleStyle}" Text="{Binding Result.SubTitle}" />
<Rectangle
Width="Auto"
Margin="0 0 0 0"
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}" />
<TextBlock
Margin="0 8 0 8"
Style="{DynamicResource PreviewItemSubTitleStyle}"
Text="{Binding Result.SubTitle}" />
<Rectangle
Width="Auto"
Margin="0 0 0 0"
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}" />
<StackPanel Visibility="{Binding FileInfoVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}">
<Grid Margin="0 10 0 0">
<Grid Margin="0 10 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
@ -70,7 +86,7 @@
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="0 0 8 0"
Margin="0 0 0 0"
VerticalAlignment="Top"
Style="{DynamicResource PreviewItemSubTitleStyle}"
Text="{DynamicResource FileSize}"