Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap to character grid when resizing window #3181

Merged
merged 29 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b8a5725
Kinda works, no splitted panes
mcpiroman Sep 24, 2019
68f613b
Calc sizes more accurately
mcpiroman Sep 26, 2019
5d0f1d3
General work, add resolution for children along resize axis
mcpiroman Sep 28, 2019
90649b2
Partially fix child displacement
mcpiroman Sep 29, 2019
cbda911
Change child layout algorithm, now 100% correct
mcpiroman Oct 5, 2019
d69f8ed
Cache padding and scrollbar width, fix infinite loop
mcpiroman Oct 5, 2019
b732e74
(drastically) optimize layout algorithm ( O(n^m) -> O(n) )
mcpiroman Oct 10, 2019
0ecbec5
Fix minimum pane size calculation
mcpiroman Oct 11, 2019
3dcd00f
Style, comments, format; fix layout just after split
mcpiroman Oct 12, 2019
583541d
Review changes
mcpiroman Oct 16, 2019
b00fef8
Fix rebase
mcpiroman Oct 18, 2019
5e9b31c
Undo caching of padding and scrollbar size
mcpiroman Nov 5, 2019
bed02c5
Some review changes
mcpiroman Nov 6, 2019
76d4945
Merge with master
mcpiroman Nov 7, 2019
9a95e18
Fix height calculation in non client window
mcpiroman Nov 11, 2019
11fcd51
Some additional comments I had time for
mcpiroman Nov 25, 2019
8034bb4
Finish comment in pane.h
mcpiroman Nov 25, 2019
14cc2d8
Merge with master 2
mcpiroman Nov 27, 2019
eb67b82
Things that should've gone with merge
mcpiroman Nov 27, 2019
b4febc8
Cleanup & format
mcpiroman Nov 28, 2019
cae3963
More comments
mcpiroman Nov 28, 2019
63ed26a
Review refactor, partly fix border size calculations
mcpiroman Dec 5, 2019
b0097d2
Small PR changes
mcpiroman Dec 11, 2019
cb0186a
Move Pane.LayoutSizeNode.cpp out of lib folder
mcpiroman Dec 11, 2019
bada548
Merge with master 3
mcpiroman Dec 11, 2019
24a88a5
Merge branch 'master' into 2834-snap-to-char-grid
mcpiroman Dec 18, 2019
8cf35e8
Merge branch 'master' into 2834-snap-to-char-grid
mcpiroman Dec 20, 2019
b933528
Github apparently switched files to LF, so revert that
mcpiroman Dec 20, 2019
1ebddfc
Some things that miniksa mentioned in #4068
mcpiroman Jan 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,13 @@ namespace winrt::TerminalApp::implementation
return _settings->GlobalSettings().GetShowTabsInTitlebar();
}

// Method Description:
// - See Pane::CalcSnappedDimension
float AppLogic::CalcSnappedDimension(const bool widthOrHeight, const float dimension) const
{
return _root->CalcSnappedDimension(widthOrHeight, dimension);
}

// Method Description:
// - Attempt to load the settings. If we fail for any reason, returns an error.
// Return Value:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace winrt::TerminalApp::implementation
winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme();
LaunchMode GetLaunchMode();
bool GetShowTabsInTitlebar();
float CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;

Windows::UI::Xaml::UIElement GetRoot() noexcept;

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.idl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace TerminalApp
Windows.UI.Xaml.ElementTheme GetRequestedTheme();
LaunchMode GetLaunchMode();
Boolean GetShowTabsInTitlebar();
Single CalcSnappedDimension(Boolean widthOrHeight, Single dimension);
void TitlebarClicked();
void WindowCloseButtonClicked();

Expand Down
73 changes: 73 additions & 0 deletions src/cascadia/TerminalApp/Pane.LayoutSizeNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "pch.h"
#include "Pane.h"

Pane::LayoutSizeNode::LayoutSizeNode(const float minSize) :
size{ minSize },
isMinimumSize{ true },
firstChild{ nullptr },
secondChild{ nullptr },
nextFirstChild{ nullptr },
nextSecondChild{ nullptr }
{
}

Pane::LayoutSizeNode::LayoutSizeNode(const LayoutSizeNode& other) :
size{ other.size },
isMinimumSize{ other.isMinimumSize },
firstChild{ other.firstChild ? std::make_unique<LayoutSizeNode>(*other.firstChild) : nullptr },
secondChild{ other.secondChild ? std::make_unique<LayoutSizeNode>(*other.secondChild) : nullptr },
nextFirstChild{ other.nextFirstChild ? std::make_unique<LayoutSizeNode>(*other.nextFirstChild) : nullptr },
nextSecondChild{ other.nextSecondChild ? std::make_unique<LayoutSizeNode>(*other.nextSecondChild) : nullptr }
{
}

// Method Description:
// - Makes sure that this node and all its descendants equal the supplied node.
// This may be more efficient that copy construction since it will reuse its
// allocated children.
// Arguments:
// - other: Node to take the values from.
// Return Value:
// - itself
Pane::LayoutSizeNode& Pane::LayoutSizeNode::operator=(const LayoutSizeNode& other)
{
size = other.size;
isMinimumSize = other.isMinimumSize;

_AssignChildNode(firstChild, other.firstChild.get());
_AssignChildNode(secondChild, other.secondChild.get());
_AssignChildNode(nextFirstChild, other.nextFirstChild.get());
_AssignChildNode(nextSecondChild, other.nextSecondChild.get());

return *this;
}

// Method Description:
// - Performs assignment operation on a single child node reusing
// - current one if present.
// Arguments:
// - nodeField: Reference to our field holding concerned node.
// - other: Node to take the values from.
// Return Value:
// - <none>
void Pane::LayoutSizeNode::_AssignChildNode(std::unique_ptr<LayoutSizeNode>& nodeField, const LayoutSizeNode* const newNode)
DHowett-MSFT marked this conversation as resolved.
Show resolved Hide resolved
{
if (newNode)
{
if (nodeField)
{
*nodeField = *newNode;
}
else
{
nodeField = std::make_unique<LayoutSizeNode>(*newNode);
}
}
else
{
nodeField.release();
}
}
Loading