Improvements to the tab renamer box (#8589)
Basically, just impose a height on both the renamer box and the overall tab header control. However, to ensure that the text in the tab renamer box does not get clipped by its own border, we also need to set its font size, which is slightly smaller than it was before but it _is_ the same as the text block that it is trying to rename so I'd say its more consistent now. We also improve the tab renamer box so that it scrolls as more text is added instead of getting truncated (when the tabWidthMode is anything other than titleLength). When the tabWidthMode _is_ set to titleLength, the renamer box can increase in length much more (see GIFs below). Closes #8519
This commit is contained in:
parent
c4c3c3116b
commit
039c80d443
|
@ -23,6 +23,7 @@ namespace winrt::TerminalApp::implementation
|
|||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, Title, _PropertyChangedHandlers);
|
||||
OBSERVABLE_GETSET_PROPERTY(bool, IsPaneZoomed, _PropertyChangedHandlers);
|
||||
OBSERVABLE_GETSET_PROPERTY(double, RenamerMaxWidth, _PropertyChangedHandlers);
|
||||
OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingActive, _PropertyChangedHandlers);
|
||||
OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingIndeterminate, _PropertyChangedHandlers);
|
||||
OBSERVABLE_GETSET_PROPERTY(uint32_t, ProgressValue, _PropertyChangedHandlers);
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace TerminalApp
|
|||
{
|
||||
String Title { get; set; };
|
||||
Boolean IsPaneZoomed { get; set; };
|
||||
Double RenamerMaxWidth { get; set; };
|
||||
Boolean IsProgressRingActive { get; set; };
|
||||
Boolean IsProgressRingIndeterminate { get; set; };
|
||||
UInt32 ProgressValue { get; set; };
|
||||
|
|
|
@ -9,7 +9,24 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
mc:Ignorable="d"
|
||||
MinHeight="16">
|
||||
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Light">
|
||||
<Thickness x:Key="TextControlBorderThemeThicknessFocused">0,0,0,1</Thickness>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="Dark">
|
||||
<Thickness x:Key="TextControlBorderThemeThicknessFocused">0,0,0,1</Thickness>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Key="HighContrast">
|
||||
<Thickness x:Key="TextControlBorderThemeThicknessFocused">0,0,0,1</Thickness>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel x:Name="HeaderStackPanel"
|
||||
Orientation="Horizontal">
|
||||
|
@ -39,8 +56,11 @@ the MIT License. See LICENSE in the project root for license information. -->
|
|||
Visibility="Collapsed"
|
||||
MinHeight="0"
|
||||
Padding="4,0,4,0"
|
||||
Margin="0,-8,0,-8"
|
||||
MaxLength="1024"
|
||||
LostFocus="RenameBoxLostFocusHandler"/>
|
||||
LostFocus="RenameBoxLostFocusHandler"
|
||||
Height="16"
|
||||
FontSize="12"
|
||||
IsSpellCheckEnabled="False"
|
||||
MaxWidth="{x:Bind RenamerMaxWidth, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace winrt::TerminalApp::implementation
|
|||
tab->SetTabText(title);
|
||||
}
|
||||
});
|
||||
|
||||
_UpdateHeaderControlMaxWidth();
|
||||
|
||||
// Use our header control as the TabViewItem's header
|
||||
TabViewItem().Header(_headerControl);
|
||||
}
|
||||
|
@ -75,6 +78,26 @@ namespace winrt::TerminalApp::implementation
|
|||
_RecalculateAndApplyTabColor();
|
||||
}
|
||||
|
||||
winrt::fire_and_forget TerminalTab::_UpdateHeaderControlMaxWidth()
|
||||
{
|
||||
auto weakThis{ get_weak() };
|
||||
|
||||
co_await winrt::resume_foreground(TabViewItem().Dispatcher());
|
||||
|
||||
if (auto tab{ weakThis.get() })
|
||||
{
|
||||
const auto settings{ winrt::TerminalApp::implementation::AppLogic::CurrentAppSettings() };
|
||||
if (settings.GlobalSettings().TabWidthMode() == winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode::SizeToContent)
|
||||
{
|
||||
tab->_headerControl.RenamerMaxWidth(HeaderRenameBoxWidthTitleLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
tab->_headerControl.RenamerMaxWidth(HeaderRenameBoxWidthDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalTab::_SetToolTip(const winrt::hstring& tabTitle)
|
||||
{
|
||||
WUX::Controls::ToolTip toolTip{};
|
||||
|
@ -169,6 +192,9 @@ namespace winrt::TerminalApp::implementation
|
|||
void TerminalTab::UpdateSettings(const winrt::TerminalApp::TerminalSettings& settings, const GUID& profile)
|
||||
{
|
||||
_rootPane->UpdateSettings(settings, profile);
|
||||
|
||||
// The tabWidthMode may have changed, update the header control accordingly
|
||||
_UpdateHeaderControlMaxWidth();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
#include "TabBase.h"
|
||||
#include "TerminalTab.g.h"
|
||||
|
||||
static constexpr double HeaderRenameBoxWidthDefault{ 165 };
|
||||
static constexpr double HeaderRenameBoxWidthTitleLength{ std::numeric_limits<double>::infinity() };
|
||||
|
||||
// fwdecl unittest classes
|
||||
namespace TerminalAppLocalTests
|
||||
{
|
||||
|
@ -102,6 +105,7 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
void _MakeTabViewItem();
|
||||
|
||||
winrt::fire_and_forget _UpdateHeaderControlMaxWidth();
|
||||
void _SetToolTip(const winrt::hstring& tabTitle);
|
||||
|
||||
void _CreateContextMenu() override;
|
||||
|
|
Loading…
Reference in a new issue