mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-04 05:35:20 +00:00
Correct for the size of the tabs when calculating our initial window size (#4825)
## Summary of the Pull Request This fixes our calculation for the initial size of the window. WE weren't accounting for the height of the tabs, so the `initialRows` was consistently wrong. ## PR Checklist * [x] Closes #2061 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments For the tabs below the titlebar case, there's 6px (unscaled) of space that I cannot account for. I seriously have no idea where it's coming from. When we end up creating the first `TermControl` after startup, there's an inexplicable `6*scale` difference between the height of the `tabContent` and the `SwapChainPanel`'s size. ## Validation Steps Performed Checked all six of the following cases: * 1.0 DPI scaling, Tabs in Titlebar * 1.25 DPI scaling, Tabs in Titlebar * 1.0 DPI scaling, Tabs NOT in Titlebar, always show tabs * 1.0 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs * 1.25 DPI scaling, Tabs NOT in Titlebar, always show tabs * 1.25 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs
This commit is contained in:
@@ -400,11 +400,44 @@ namespace winrt::TerminalApp::implementation
|
||||
// Use the default profile to determine how big of a window we need.
|
||||
const auto [_, settings] = _settings->BuildSettings(nullptr);
|
||||
|
||||
// TODO MSFT:21150597 - If the global setting "Always show tab bar" is
|
||||
auto proposedSize = TermControl::GetProposedDimensions(settings, dpi);
|
||||
|
||||
const float scale = static_cast<float>(dpi) / static_cast<float>(USER_DEFAULT_SCREEN_DPI);
|
||||
|
||||
// GH#2061 - If the global setting "Always show tab bar" is
|
||||
// set or if "Show tabs in title bar" is set, then we'll need to add
|
||||
// the height of the tab bar here.
|
||||
if (_settings->GlobalSettings().GetShowTabsInTitlebar())
|
||||
{
|
||||
// If we're showing the tabs in the titlebar, we need to use a
|
||||
// TitlebarContol here to calculate how much space to reserve.
|
||||
//
|
||||
// We'll create a fake TitlebarControl, and we'll propose an
|
||||
// available size to it with Measure(). After Measure() is called,
|
||||
// the TitlebarControl's DesiredSize will contain the _unscaled_
|
||||
// size that the titlebar would like to use. We'll use that as part
|
||||
// of the height calculation here.
|
||||
auto titlebar = TitlebarControl{ static_cast<uint64_t>(0) };
|
||||
titlebar.Measure({ SHRT_MAX, SHRT_MAX });
|
||||
proposedSize.Y += (titlebar.DesiredSize().Height) * scale;
|
||||
}
|
||||
else if (_settings->GlobalSettings().GetAlwaysShowTabs())
|
||||
{
|
||||
// Otherwise, let's use a TabRowControl to calculate how much extra
|
||||
// space we'll need.
|
||||
//
|
||||
// Similarly to above, we'll measure it with an arbitrarily large
|
||||
// available space, to make sure we get all the space it wants.
|
||||
auto tabControl = TabRowControl();
|
||||
tabControl.Measure({ SHRT_MAX, SHRT_MAX });
|
||||
|
||||
return TermControl::GetProposedDimensions(settings, dpi);
|
||||
// For whatever reason, there's about 6px of unaccounted-for space
|
||||
// in the application. I couldn't tell you where these 6px are
|
||||
// coming from, but they need to be included in this math.
|
||||
proposedSize.Y += (tabControl.DesiredSize().Height + 6) * scale;
|
||||
}
|
||||
|
||||
return proposedSize;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@@ -492,6 +492,8 @@ SIZE NonClientIslandWindow::GetTotalNonClientExclusiveSize(UINT dpi) const noexc
|
||||
|
||||
islandFrame.top = -topBorderVisibleHeight;
|
||||
|
||||
// If we have a titlebar, this is being called after we've initialized, and
|
||||
// we can just ask that titlebar how big it wants to be.
|
||||
const auto titleBarHeight = _titlebar ? static_cast<LONG>(_titlebar.ActualHeight()) : 0;
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user