change 1: add settings pointer and some member variables to page

This commit is contained in:
Kaiyu Wang 2019-07-19 19:47:27 -07:00
parent 3086671bc7
commit 5c7ff43b83
4 changed files with 98 additions and 1 deletions

View file

@ -18,6 +18,7 @@ using namespace winrt::Microsoft::Terminal::Settings;
using namespace winrt::Microsoft::Terminal::TerminalControl;
using namespace winrt::Microsoft::Terminal::TerminalConnection;
using namespace ::TerminalApp;
using namespace winrt::TerminalApp;
namespace winrt
{
@ -69,6 +70,7 @@ namespace winrt::TerminalApp::implementation
*/
auto terminalPage = winrt::make_self<TerminalPage>();
_root = terminalPage.as<winrt::Windows::UI::Xaml::Controls::Control>();
terminalPage->SetSettings(_settings.get());
_tabContent = terminalPage->TabContent();
_tabRow = terminalPage->TabRow();
_tabView = _tabRow.TabView();
@ -1488,6 +1490,36 @@ namespace winrt::TerminalApp::implementation
return connection;
}
winrt::TerminalApp::AppKeyBindings App::GetKeybindingsFromSettings()
{
return _settings->GetKeybindings();
}
/*std::basic_string_view<Profile> App::GetProfilesFromSettings()
{
return _settings->GetProfiles();
}
GUID App::GetDefaultProfileFromSettings()
{
return _settings->GlobalSettings().GetDefaultProfile();
}
TerminalSettings App::MakeSettingsFromProfile(GUID profileGuid)
{
return _settings->MakeSettings(profileGuid);
}
Profile* App::FindProfileFromSettings(GUID profileGuid)
{
return _settings->FindProfile(profileGuid);
}
bool App::GetAlwaysShowTabs()
{
return _settings->GlobalSettings().GetAlwaysShowTabs();
}*/
// -------------------------------- WinRT Events ---------------------------------
// Winrt events need a method for adding a callback to the event and removing the callback.
// These macros will define them both for you.

View file

@ -44,6 +44,18 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTitleBarContent, _setTitleBarContentHandlers, TerminalApp::App, winrt::Windows::UI::Xaml::UIElement);
DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(RequestedThemeChanged, _requestedThemeChangedHandlers, TerminalApp::App, winrt::Windows::UI::Xaml::ElementTheme);
winrt::TerminalApp::AppKeyBindings GetKeybindingsFromSettings();
/*std::basic_string_view<Profile> GetProfilesFromSettings();
GUID GetDefaultProfileFromSettings();
TerminalSettings MakeSettingsFromProfile(GUID profileGuid);
Profile* FindProfileFromSettings(GUID profileGuid);
bool GetAlwaysShowTabs();*/
private:
// If you add controls here, but forget to null them either here or in
// the ctor, you're going to have a bad time. It'll mysteriously fail to

View file

@ -11,8 +11,40 @@ using namespace Windows::UI::Xaml;
namespace winrt::TerminalApp::implementation
{
TerminalPage::TerminalPage()
TerminalPage::TerminalPage() :
_settings{ nullptr }
{
InitializeComponent();
}
void TerminalPage::SetSettings(::TerminalApp::CascadiaSettings* settings)
{
if (!_settings)
{
_settings = settings;
}
}
void TerminalPage::_Create()
{
_tabContent = this->TabContent();
_tabView = this->TabView();
_tabRow = this->TabRow();
_newTabButton = this->NewTabButton();
//Event Bindings (Early)
}
void TerminalPage::_CreateNewTabFlyout()
{
}
// Method Description:
// - Bound in the Xaml editor to the [+] button.
// Arguments:
// - sender
// - event arguments
void TerminalPage::OnNewTabButtonClick(IInspectable const&, Controls::SplitButtonClickEventArgs const&)
{
}
}

View file

@ -6,12 +6,33 @@
#include "winrt/Microsoft.UI.Xaml.Controls.h"
#include "TerminalPage.g.h"
#include "Tab.h"
#include "CascadiaSettings.h"
namespace winrt::TerminalApp::implementation
{
struct TerminalPage : TerminalPageT<TerminalPage>
{
public:
TerminalPage();
void SetSettings(::TerminalApp::CascadiaSettings* settings);
void OnNewTabButtonClick(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Controls::SplitButtonClickEventArgs const& args);
private:
Microsoft::UI::Xaml::Controls::TabView _tabView{ nullptr };
Windows::UI::Xaml::Controls::Grid _tabRow{ nullptr };
Windows::UI::Xaml::Controls::Grid _tabContent{ nullptr };
Windows::UI::Xaml::Controls::SplitButton _newTabButton{ nullptr };
::TerminalApp::CascadiaSettings* _settings;
std::vector<std::shared_ptr<Tab>> _tabs;
void _Create();
void _CreateNewTabFlyout();
};
}