-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Pane refactor: separate pane into LeafPane and ParentPane, and make them winrt types #9024
Conversation
O, so because I've got a notification, I'll just let you know some time later I had an idea to wrap the pane node in an union type which would be either pane or leaf, but in the same object. This, AFAIR, would provide a possibility to avoid much of the event rewiring (which I remember fearing), notifying parent, replacement of children, or alike. Something of this kind maybe: class PaneNode {
bool isParent;
union {
LeafPane asLeaf;
ParentPane asParent;
} pane;
public:
LeafPane* AsLeaf() const
{
return isParent ? nullptr : &pane.asLeaf;
}
ParentPane* AsParent() const
{
return isParent ? &pane.asParent : nullptr;
}
} Dunno how much, if at all, would this actually help though, as this is some vague thought I remember having, and that could be not compatible with WinRT types. I mean, I'm sure this could be achieved on the abi level but I'm more afraid of the ('safe') c++ metaprograming layer. |
.config/dotnet-tools.json
Outdated
@@ -0,0 +1,12 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this branch seems to have gotten confused as to who is the merge base and who is the merge target...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, i wsa commenting on a merge commit.
…/pabhoj/pane_refactor
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absenthpcon serializers TlgTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:microsoft/terminal.git repository
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbageIf it relates to a ... well-formed patternSee if there's a pattern that would match it. If not, try writing one and adding it to a Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines. Note that patterns can't match multiline strings. binary-ish stringPlease add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
@Rosefield given your recent work on panes, we wanted your opinion! Do you think there's any merit in splitting panes into 2 distinct types (ParentPane and LeafPane) like in this PR? |
Ideologically I would want to have a separation between "parent" type members and "leaf" type members. However, with #11153 there is a lot of logic that is shared (or with minor changes) between the two kinds so there might be a benefit to having a shared implementation that branches on whether it is a leaf or parent still. That definitely is something to get a feel for while trying to do the refactor though. I don't know how well it would translate to winrt, but if I was writing something like this in rust I would go with a model like this: struct LeafState {
_id: u64,
_control : Control,
_profile : Profile,
...
}
struct ParentState {
_firstChild: Box<Pane>, // If you're unfamiliar with rust, a Box is a pointer to a heap allocated object
_secondChild: Box<Pane>,
_splitPosition: f32,
...
}
enum PaneType {
Leaf(LeafState),
Parent(ParentState)
}
struct Pane {
_isActive : bool,
_root : Grid,
_border: Border, // or _firstBorder / _secondBorder with #11153
_zoomed: bool,
... // All of the other shared members
_type: PaneType // And then have a discriminated union of the type-specific variables
}
impl Pane {
fn split(...) {...}
fn focus(...) {...}
fn resize(...) {...}
...
fn as_leaf(&self) -> Option<&LeafState> {...}
fn as_parent(&self) -> Option<&ParentState> {...}
// Functions that work on leaves or parents specifically as needed.
// The expectation is that you would call as_* and then use that state as a token
// to call these functions. If the states have private constructors you couldn't
// get an object of this type unless you called the as_* function.
// e.g. (if you couldn't just do whatever on the LeafState directly)
fn do_foo_on_leaf(&self, state: &LeafState) { ... }
} |
Fixes #11606 This is weird, but the infobars would appear totally on top of the TerminalPage when `showTabsInTitlebar:false`. This would result in the infobar obscuring the tabs. Now, the infobars are strictly inserted after the tabs, before the content. So when they appear, they will reduce the amount of space usable for the control. That is a little annoying, but preferable to the tabs totally not existing. Relevant conversation notes from #10798: > > If the info bar is not local to the tab, then its location between the tab > > bar (when the title bar is hidden) and the terminal panes feels > > misleading. Should it instead be above the tab bar or below the terminal > > panes? > > You're... not wrong here. It's maybe not the best place for it, but _on top_ > of the tabs would look insane, and probably wouldn't even work easily, given > the way we reparent the tab row into the titlebar. > > In the pane itself would make more sense, but that runs abreast of all sorts > of things like #9024, #4998, which might make more sense. I'm just gonna go with this now, because it's _better_ than before, while we work out what's _best_.
…of (#11609) Fixes #11606 This is weird, but the infobars would appear totally on top of the TerminalPage when `showTabsInTitlebar:false`. This would result in the infobar obscuring the tabs. Now, the infobars are strictly inserted after the tabs, before the content. So when they appear, they will reduce the amount of space usable for the control. That is a little annoying, but preferable to the tabs totally not existing. Relevant conversation notes from #10798: > > If the info bar is not local to the tab, then its location between the tab > > bar (when the title bar is hidden) and the terminal panes feels > > misleading. Should it instead be above the tab bar or below the terminal > > panes? > > You're... not wrong here. It's maybe not the best place for it, but _on top_ > of the tabs would look insane, and probably wouldn't even work easily, given > the way we reparent the tab row into the titlebar. > > In the pane itself would make more sense, but that runs abreast of all sorts > of things like #9024, #4998, which might make more sense. I'm just gonna go with this now, because it's _better_ than before, while we work out what's _best_. ![gh-11606-fix](https://user-images.githubusercontent.com/18356694/138729178-b96b7003-0dd2-4521-8fff-0fd2a5989f22.gif)
…of (#11609) Fixes #11606 This is weird, but the infobars would appear totally on top of the TerminalPage when `showTabsInTitlebar:false`. This would result in the infobar obscuring the tabs. Now, the infobars are strictly inserted after the tabs, before the content. So when they appear, they will reduce the amount of space usable for the control. That is a little annoying, but preferable to the tabs totally not existing. Relevant conversation notes from #10798: > > If the info bar is not local to the tab, then its location between the tab > > bar (when the title bar is hidden) and the terminal panes feels > > misleading. Should it instead be above the tab bar or below the terminal > > panes? > > You're... not wrong here. It's maybe not the best place for it, but _on top_ > of the tabs would look insane, and probably wouldn't even work easily, given > the way we reparent the tab row into the titlebar. > > In the pane itself would make more sense, but that runs abreast of all sorts > of things like #9024, #4998, which might make more sense. I'm just gonna go with this now, because it's _better_ than before, while we work out what's _best_. ![gh-11606-fix](https://user-images.githubusercontent.com/18356694/138729178-b96b7003-0dd2-4521-8fff-0fd2a5989f22.gif) (cherry picked from commit a916a5d)
…of (#11609) Fixes #11606 This is weird, but the infobars would appear totally on top of the TerminalPage when `showTabsInTitlebar:false`. This would result in the infobar obscuring the tabs. Now, the infobars are strictly inserted after the tabs, before the content. So when they appear, they will reduce the amount of space usable for the control. That is a little annoying, but preferable to the tabs totally not existing. Relevant conversation notes from #10798: > > If the info bar is not local to the tab, then its location between the tab > > bar (when the title bar is hidden) and the terminal panes feels > > misleading. Should it instead be above the tab bar or below the terminal > > panes? > > You're... not wrong here. It's maybe not the best place for it, but _on top_ > of the tabs would look insane, and probably wouldn't even work easily, given > the way we reparent the tab row into the titlebar. > > In the pane itself would make more sense, but that runs abreast of all sorts > of things like #9024, #4998, which might make more sense. I'm just gonna go with this now, because it's _better_ than before, while we work out what's _best_. ![gh-11606-fix](https://user-images.githubusercontent.com/18356694/138729178-b96b7003-0dd2-4521-8fff-0fd2a5989f22.gif) (cherry picked from commit a916a5d)
This probably isn't gonna land. @PankajBhojwani, can I delete this branch or is there valuable work on it still? |
Should be good to delete! |
Summary of the Pull Request
There are several todos left:
- this requires a bit of discussion on how we want the tab to know about closed leaves so it can update the MRU list
Fix issues with pane splits in startup actions/commandline argumentsTurns out these issues also exist in mainTerminalTab
(most of them have just been commented out for now for the same reason as above- this is mostly done, pane.cpp has been removed and references to the old pane type have been gone
- keeping
pane.h
around for now because we might want to put some common stuff in thereReferences
Huge shoutout to @mcpiroman, a lot of the design for this PR was taken from #4068
PR Checklist
Validation Steps Performed
For now, opening and closing panes works fine (i.e. it is somewhat functional but I'm sure there are bugs that slipped past me)