Try to get the sxnui font size to match the control, but this is w e i r d

This commit is contained in:
Mike Griese
2024-06-03 11:10:04 -05:00
parent 01e4df152e
commit 6c0508611f
5 changed files with 21 additions and 4 deletions

View File

@@ -1104,4 +1104,13 @@ namespace winrt::TerminalApp::implementation
_searchBox().Select(filter.size(), 0);
}
double SuggestionsControl::FontHeight()
{
return winrt::unbox_value_or<double>(Resources().Lookup(winrt::box_value(L"ListFontSize")), 12.0);
}
void SuggestionsControl::FontHeight(double height)
{
Resources().Insert(winrt::box_value(L"ListFontSize"), winrt::box_value(height));
}
}

View File

@@ -50,12 +50,16 @@ namespace winrt::TerminalApp::implementation
til::typed_event<winrt::TerminalApp::SuggestionsControl, Microsoft::Terminal::Settings::Model::Command> DispatchCommandRequested;
til::typed_event<Windows::Foundation::IInspectable, Microsoft::Terminal::Settings::Model::Command> PreviewAction;
double FontHeight();
void FontHeight(double height);
til::property_changed_event PropertyChanged;
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ControlName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParentCommandName, PropertyChanged.raise);
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, ParsedCommandLineText, PropertyChanged.raise);
// WINRT_OBSERVABLE_PROPERTY(double, FontHeight, PropertyChanged.raise, 12.0);
private:
struct winrt_object_hash

View File

@@ -28,6 +28,7 @@ namespace TerminalApp
String SearchBoxPlaceholderText { get; };
String ControlName { get; };
String ParentCommandName { get; };
Double FontHeight{ get; set; };
Windows.UI.Xaml.FrameworkElement SelectedItem { get; };

View File

@@ -25,15 +25,15 @@
<UserControl.Resources>
<ResourceDictionary>
<x:Double x:Key="ListFontSize">12</x:Double>
<DataTemplate x:Key="ListItemTemplate"
x:DataType="local:FilteredCommand">
<ListViewItem Height="32"
MinHeight="0"
Padding="16,0,12,0"
<ListViewItem MinHeight="0"
Padding="16,6,12,6"
HorizontalContentAlignment="Stretch"
AutomationProperties.AcceleratorKey="{x:Bind Item.KeyChordText, Mode=OneWay}"
AutomationProperties.Name="{x:Bind Item.Name, Mode=OneWay}"
FontSize="12" />
FontSize="{ThemeResource ListFontSize}" />
</DataTemplate>
<DataTemplate x:Key="GeneralItemTemplate"
@@ -200,6 +200,7 @@
CanReorderItems="False"
ChoosingItemContainer="_choosingItemContainer"
ContainerContentChanging="_containerContentChanging"
FontSize="32"
IsItemClickEnabled="True"
ItemClick="_listItemClicked"
ItemsSource="{x:Bind FilteredActions}"

View File

@@ -4764,6 +4764,8 @@ namespace winrt::TerminalApp::implementation
const auto realCursorPos{ controlTransform.TransformPoint({ cursorPos.X, cursorPos.Y }) }; // == controlTransform + cursorPos
const Windows::Foundation::Size windowDimensions{ gsl::narrow_cast<float>(ActualWidth()), gsl::narrow_cast<float>(ActualHeight()) };
sxnUi.FontHeight(characterSize.Height);
sxnUi.Open(mode,
commandsCollection,
filterText,