-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Convert Tab to a WinRT type #4350
Conversation
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.
Overall this looks good to me. Shame that we can't have the observable vector on the implementation type directly, so we wouldn't need the 100 get_self
calls, but w/e.
Hit me up on Teams if you need help with the unittests - I'll save my signoff for once you've made sure those work. Otherwise I've only got nits.
…rTerminalEvents signature
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.
Good work! Only a few minor bits and bobs.
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.
GH doesn't let me read my pending comments without a lot of work, so I'm hitting Comment
. I don't think I had any major qualms with this, though. I'll probably hit Approve
after you react to them.
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.
Looking over these comments, I guess they're just nits, so go for it
…rminal into dev/lelian/WinRTTab
for (uint32_t idx = 0; idx < _tabs.Size(); ++idx) | ||
{ | ||
auto tab{ _GetStrongTabImpl(idx) }; | ||
tab->SetFocused(false); | ||
} |
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.
minor nit: weird because GetStrongTabImpl takes an index not a tab, but these are better-formed as for(auto tab:_tabs)
like in the original code.
I also don't care as much. :)
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.
I also was nitting about this, so I sort of wanted to make GetStrongTabImpl
take a tab instead. Then I realized that the majority of the code passes in an index and so if it took a Tab, GetAt
would be littered everywhere instead. I just prefer the index route over the tab route 🤷♂
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.
You could, in theory, provide an overload. One takes a const uint32_t and one takes a ::winrt::TerminalApp::Tab
😀
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.
🤔 Do you think an overload for this function would be overkill?
EDIT: it would not be overkill
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.
up to you. it would clean our iterators up again, but also I don't hate this
@@ -94,23 +95,23 @@ namespace winrt::TerminalApp::implementation | |||
void _HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept; | |||
void _RegisterActionCallbacks(); | |||
|
|||
void _UpdateTitle(std::shared_ptr<Tab> tab); | |||
void _UpdateTabIcon(std::shared_ptr<Tab> tab); | |||
void _UpdateTitle(const Tab& tab); |
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.
why's this one const but the others aren't?
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.
_UpdateTitle
doesn't change the tab directly, it actually just calls the handlers. _UpdateTabIcon
directly calls the tab's UpdateIcon
function, so it couldn't be const 😢
Co-Authored-By: Carlos Zamora <carlos.zamora@microsoft.com>
re-queued only x86 |
Hello @DHowett-MSFT! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
Summary of the Pull Request
This PR will make the existing
Tab
class into a WinRT type. This will allow any XAML to simply bind to theObservableVector
of Tabs.This PR will be followed up with a future PR to change our TabView to use the ObservableVector, which will in turn eliminate the need for maintaining two vectors of Tabs. (We currently maintain
_tabs
inTerminalPage
and we also maintainTabView().TabViewItems()
at the same time as described here: #2740)References
#3922
PR Checklist
Detailed Description of the Pull Request / Additional comments
I've currently only exposed a Tab's Title and IconPath to keep things simple. I foresee XAML elements that bind to Tabs to only really need these two properties for displaying.
I've also converted
TerminalPage
'sstd::vector<std::shared_ptr> _tabs
into aIObservableVector<winrt::TerminalPage::Tab> _tabs
just so that future PRs will have the ground set for binding to this vector of tabs.Validation Steps Performed
Played around with Tabs and Panes and all sorts of combinations of keybindings for interacting with tabs and dragging and whatnot, it all seemed fine! Tab Tests also all pass.