Compare commits

...

3 Commits

Author SHA1 Message Date
Mike Griese
63b1599406 This is the dumbest possible thing I could have done 2024-06-03 12:31:55 -05:00
Mike Griese
75ee4559a3 I thought this was clever. It apparently wasn't 2024-06-03 11:19:58 -05:00
Mike Griese
6c0508611f Try to get the sxnui font size to match the control, but this is w e i r d 2024-06-03 11:10:04 -05:00
5 changed files with 45 additions and 5 deletions

View File

@@ -996,6 +996,22 @@ namespace winrt::TerminalApp::implementation
args.ItemContainer(listViewItem);
}
}
// Incredibly bodgy:
//
// Now that we've found the right ListViewItem, set the font size on it,
// to match the size of the control. This might change over the life of
// the window.
// * we can't use a Style in the resources to set this (it only gets evaluated once)
// * we can't bind from the DataTemplate to the parent UserControl's properties
//
// But this method (_choosingItemContainer) is called on each and every
// ListViewItem every time we're opened.
if (const auto item{ args.ItemContainer().try_as<ListViewItem>() })
{
item.FontSize(_FontHeight);
}
args.IsContainerPrepared(true);
}
// Method Description:
@@ -1104,4 +1120,19 @@ namespace winrt::TerminalApp::implementation
_searchBox().Select(filter.size(), 0);
}
// double SuggestionsControl::FontHeight()
// {
// return _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));
// for (const auto& container : _filteredActionsView().Items())
// {
// auto item{container.try_as<winrt::Windows::UI::Xaml::Controls::ListViewItem>()};
// item.FontSize(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
@@ -86,6 +90,7 @@ namespace winrt::TerminalApp::implementation
winrt::TerminalApp::PaletteItemTemplateSelector _itemTemplateSelector{ nullptr };
std::unordered_map<Windows::UI::Xaml::DataTemplate, std::unordered_set<Windows::UI::Xaml::Controls::Primitives::SelectorItem, winrt_object_hash>, winrt_object_hash> _listViewItemsCache;
Windows::UI::Xaml::DataTemplate _listItemTemplate;
double _fontHeight{ 12.0 };
void _switchToMode();
void _setDirection(TerminalApp::SuggestionsDirection direction);

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,16 @@
<UserControl.Resources>
<ResourceDictionary>
<!-- <Style TargetType="ListViewItem" x:Key="Foo">
<Setter Property="FontSize" Value="{x:Bind FontHeight, Mode=OneWay}" />
</Style>-->
<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" />
AutomationProperties.Name="{x:Bind Item.Name, Mode=OneWay}" />
</DataTemplate>
<DataTemplate x:Key="GeneralItemTemplate"

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,