Remove GetControl() for IControlHost
I didn't like it there. What if an element has lots of controls? It's just not a sustainable model.
This commit is contained in:
parent
d298ff025d
commit
2e3c61fcee
|
@ -1362,9 +1362,9 @@ namespace winrt::TerminalApp::implementation
|
|||
GUID realGuid = { 0 };
|
||||
|
||||
// TextBlockControlHost controlHost{};
|
||||
// RichTextBoxControlHost controlHost{};
|
||||
RichTextBoxControlHost controlHost{};
|
||||
// MediaControlHost controlHost{};
|
||||
WebViewHost controlHost{};
|
||||
// WebViewHost controlHost{};
|
||||
|
||||
const int focusedTabIndex = _GetFocusedTabIndex();
|
||||
auto focusedTab = _tabs[focusedTabIndex];
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace TerminalApp
|
|||
|
||||
interface IControlHost
|
||||
{
|
||||
Windows.UI.Xaml.Controls.Control GetControl();
|
||||
// Windows.UI.Xaml.Controls.Control GetControl();
|
||||
Windows.UI.Xaml.UIElement GetRoot();
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<IControlHost, ClosedEventArgs> CloseRequested;
|
||||
|
@ -18,7 +18,7 @@ namespace TerminalApp
|
|||
Windows.Foundation.Size MinimumSize { get; };
|
||||
|
||||
// Other things we'll need:
|
||||
// * bool IsFocused();
|
||||
// * void Focus()
|
||||
Boolean IsFocused();
|
||||
void Focus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ namespace winrt::TerminalApp::implementation
|
|||
// = SystemMediaTransportControls.GetForCurrentView();
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Controls::Control MediaControlHost::GetControl()
|
||||
{
|
||||
return _Editor();
|
||||
}
|
||||
// Windows::UI::Xaml::Controls::Control MediaControlHost::GetControl()
|
||||
// {
|
||||
// return _Editor();
|
||||
// }
|
||||
|
||||
Windows::UI::Xaml::UIElement MediaControlHost::GetRoot()
|
||||
{
|
||||
|
@ -53,6 +53,15 @@ namespace winrt::TerminalApp::implementation
|
|||
return { 32, 32 };
|
||||
}
|
||||
|
||||
bool MediaControlHost::IsFocused()
|
||||
{
|
||||
return _Editor().FocusState() != FocusState::Unfocused;
|
||||
}
|
||||
void MediaControlHost::Focus()
|
||||
{
|
||||
_Editor().Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(MediaControlHost, CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(MediaControlHost, TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,15 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
MediaControlHost();
|
||||
|
||||
Windows::UI::Xaml::Controls::Control GetControl();
|
||||
// Windows::UI::Xaml::Controls::Control GetControl();
|
||||
Windows::UI::Xaml::UIElement GetRoot();
|
||||
void Close();
|
||||
hstring GetTitle();
|
||||
Windows::Foundation::Size MinimumSize() const;
|
||||
|
||||
bool IsFocused();
|
||||
void Focus();
|
||||
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
|
||||
|
|
|
@ -463,7 +463,7 @@ bool Pane::_HasFocusedChild() const noexcept
|
|||
// We're intentionally making this one giant expression, so the compiler
|
||||
// will skip the following lookups if one of the lookups before it returns
|
||||
// true
|
||||
return (_control && _control.GetControl().FocusState() != FocusState::Unfocused) ||
|
||||
return (_control && _control.IsFocused()) ||
|
||||
(_firstChild && _firstChild->_HasFocusedChild()) ||
|
||||
(_secondChild && _secondChild->_HasFocusedChild());
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ void Pane::UpdateFocus()
|
|||
if (_IsLeaf())
|
||||
{
|
||||
const auto controlFocused = _control &&
|
||||
_control.GetControl().FocusState() != FocusState::Unfocused;
|
||||
_control.IsFocused();
|
||||
|
||||
_lastFocused = controlFocused;
|
||||
}
|
||||
|
@ -505,7 +505,8 @@ void Pane::_FocusFirstChild()
|
|||
{
|
||||
if (_IsLeaf())
|
||||
{
|
||||
_control.GetControl().Focus(FocusState::Programmatic);
|
||||
_control.Focus();
|
||||
// _control.GetControl().Focus(FocusState::Programmatic);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -612,7 +613,8 @@ void Pane::_CloseChild(const bool closeFirst)
|
|||
|
||||
if (_lastFocused)
|
||||
{
|
||||
_control.GetControl().Focus(FocusState::Programmatic);
|
||||
_control.Focus();
|
||||
// _control.GetControl().Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
_splitState = SplitState::None;
|
||||
|
|
|
@ -10,13 +10,12 @@ namespace winrt::TerminalApp::implementation
|
|||
RichTextBoxControlHost::RichTextBoxControlHost()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Controls::Control RichTextBoxControlHost::GetControl()
|
||||
{
|
||||
return _Editor();
|
||||
}
|
||||
// Windows::UI::Xaml::Controls::Control RichTextBoxControlHost::GetControl()
|
||||
// {
|
||||
// return _Editor();
|
||||
// }
|
||||
|
||||
Windows::UI::Xaml::UIElement RichTextBoxControlHost::GetRoot()
|
||||
{
|
||||
|
@ -38,6 +37,15 @@ namespace winrt::TerminalApp::implementation
|
|||
return { 32, 32 };
|
||||
}
|
||||
|
||||
bool RichTextBoxControlHost::IsFocused()
|
||||
{
|
||||
return _Editor().FocusState() != winrt::Windows::UI::Xaml::FocusState::Unfocused;
|
||||
}
|
||||
void RichTextBoxControlHost::Focus()
|
||||
{
|
||||
_Editor().Focus(winrt::Windows::UI::Xaml::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(RichTextBoxControlHost, CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(RichTextBoxControlHost, TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
RichTextBoxControlHost();
|
||||
|
||||
Windows::UI::Xaml::Controls::Control GetControl();
|
||||
// Windows::UI::Xaml::Controls::Control GetControl();
|
||||
Windows::UI::Xaml::UIElement GetRoot();
|
||||
void Close();
|
||||
hstring GetTitle();
|
||||
Windows::Foundation::Size MinimumSize() const;
|
||||
|
||||
bool IsFocused();
|
||||
void Focus();
|
||||
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ namespace winrt::TerminalApp::implementation
|
|||
// TODO: Hookup the control's titlechanged event, closed event
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Controls::Control TermControlHost::GetControl()
|
||||
{
|
||||
return _control.GetControl();
|
||||
}
|
||||
// Windows::UI::Xaml::Controls::Control TermControlHost::GetControl()
|
||||
// {
|
||||
// return _control.GetControl();
|
||||
// }
|
||||
|
||||
Windows::UI::Xaml::UIElement TermControlHost::GetRoot()
|
||||
{
|
||||
|
@ -40,6 +40,15 @@ namespace winrt::TerminalApp::implementation
|
|||
return _control.MinimumSize();
|
||||
}
|
||||
|
||||
bool TermControlHost::IsFocused()
|
||||
{
|
||||
return _control.GetControl().FocusState() != winrt::Windows::UI::Xaml::FocusState::Unfocused;
|
||||
}
|
||||
void TermControlHost::Focus()
|
||||
{
|
||||
_control.GetControl().Focus(winrt::Windows::UI::Xaml::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControlHost, CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TermControlHost, TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
TermControlHost(Microsoft::Terminal::TerminalControl::TermControl control);
|
||||
|
||||
Windows::UI::Xaml::Controls::Control GetControl();
|
||||
// Windows::UI::Xaml::Controls::Control GetControl();
|
||||
Windows::UI::Xaml::UIElement GetRoot();
|
||||
|
||||
void Close();
|
||||
|
@ -17,6 +17,9 @@ namespace winrt::TerminalApp::implementation
|
|||
Microsoft::Terminal::TerminalControl::TermControl Terminal();
|
||||
Windows::Foundation::Size MinimumSize() const;
|
||||
|
||||
bool IsFocused();
|
||||
void Focus();
|
||||
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ namespace winrt::TerminalApp::implementation
|
|||
// _textBox.Text(L"I am a TextBox");
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Controls::Control TextBlockControlHost::GetControl()
|
||||
{
|
||||
return _textBox;
|
||||
}
|
||||
// Windows::UI::Xaml::Controls::Control TextBlockControlHost::GetControl()
|
||||
// {
|
||||
// return _textBox;
|
||||
// }
|
||||
Windows::UI::Xaml::UIElement TextBlockControlHost::GetRoot()
|
||||
{
|
||||
return _textBox;
|
||||
|
@ -41,6 +41,15 @@ namespace winrt::TerminalApp::implementation
|
|||
return { 32, 32 };
|
||||
}
|
||||
|
||||
bool TextBlockControlHost::IsFocused() const
|
||||
{
|
||||
return _textBox.FocusState() != FocusState::Unfocused;
|
||||
}
|
||||
void TextBlockControlHost::Focus()
|
||||
{
|
||||
_textBox.Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TextBlockControlHost, CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TextBlockControlHost, TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
TextBlockControlHost();
|
||||
|
||||
Windows::UI::Xaml::Controls::Control GetControl();
|
||||
// Windows::UI::Xaml::Controls::Control GetControl();
|
||||
Windows::UI::Xaml::UIElement GetRoot();
|
||||
void Close();
|
||||
hstring GetTitle();
|
||||
Windows::Foundation::Size MinimumSize() const;
|
||||
|
||||
bool IsFocused() const;
|
||||
void Focus();
|
||||
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace winrt::TerminalApp::implementation
|
|||
});
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Controls::Control WebViewHost::GetControl()
|
||||
{
|
||||
return _Editor();
|
||||
}
|
||||
// Windows::UI::Xaml::Controls::Control WebViewHost::GetControl()
|
||||
// {
|
||||
// return _Editor();
|
||||
// }
|
||||
|
||||
Windows::UI::Xaml::UIElement WebViewHost::GetRoot()
|
||||
{
|
||||
|
@ -64,6 +64,15 @@ namespace winrt::TerminalApp::implementation
|
|||
return { 32, 32 };
|
||||
}
|
||||
|
||||
bool WebViewHost::IsFocused()
|
||||
{
|
||||
return _Editor().FocusState() != FocusState::Unfocused;
|
||||
}
|
||||
void WebViewHost::Focus()
|
||||
{
|
||||
_Editor().Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(WebViewHost, CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(WebViewHost, TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
}
|
||||
|
|
|
@ -9,17 +9,20 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
WebViewHost();
|
||||
|
||||
Windows::UI::Xaml::Controls::Control GetControl();
|
||||
// Windows::UI::Xaml::Controls::Control GetControl();
|
||||
Windows::UI::Xaml::UIElement GetRoot();
|
||||
void Close();
|
||||
hstring GetTitle();
|
||||
Windows::Foundation::Size MinimumSize() const;
|
||||
|
||||
bool IsFocused();
|
||||
void Focus();
|
||||
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(CloseRequested, _closeRequestedHandlers, TerminalApp::IControlHost, TerminalApp::ClosedEventArgs);
|
||||
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangedHandlers, TerminalApp::IControlHost, Microsoft::Terminal::TerminalControl::TitleChangedEventArgs);
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::WebView _webView{ nullptr };
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::WebView _webView{ nullptr };
|
||||
};
|
||||
}
|
||||
namespace winrt::TerminalApp::factory_implementation
|
||||
|
|
Loading…
Reference in a new issue