-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
092b355
commit 81b35ff
Showing
9 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "TasksPaneContent.h" | ||
#include "PaneArgs.h" | ||
#include "TasksPaneContent.g.cpp" | ||
|
||
using namespace winrt::Windows::Foundation; | ||
using namespace winrt::Microsoft::Terminal::Settings; | ||
using namespace winrt::Microsoft::Terminal::Settings::Model; | ||
|
||
namespace winrt | ||
{ | ||
namespace WUX = Windows::UI::Xaml; | ||
namespace MUX = Microsoft::UI::Xaml; | ||
using IInspectable = Windows::Foundation::IInspectable; | ||
} | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
TasksPaneContent::TasksPaneContent(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings) | ||
{ | ||
_root = winrt::Windows::UI::Xaml::Controls::Grid{}; | ||
// Vertical and HorizontalAlignment are Stretch by default | ||
|
||
auto res = Windows::UI::Xaml::Application::Current().Resources(); | ||
auto bg = res.Lookup(winrt::box_value(L"UnfocusedBorderBrush")); | ||
_root.Background(bg.try_as<WUX::Media::Brush>()); | ||
|
||
_treeView = winrt::Microsoft::UI::Xaml::Controls::TreeView{}; | ||
_root.Children().Append(_treeView); | ||
// _box.Margin({ 10, 10, 10, 10 }); | ||
// _box.AcceptsReturn(true); | ||
// _box.TextWrapping(TextWrapping::Wrap); | ||
|
||
UpdateSettings(settings); | ||
|
||
settings; | ||
} | ||
MUX::Controls::TreeViewNode _buildTreeViewNode(Model::Command task) | ||
{ | ||
MUX::Controls::TreeViewNode item{}; | ||
item.Content(winrt::box_value(task.Name())); | ||
return item; | ||
} | ||
void TasksPaneContent::UpdateSettings(const CascadiaSettings& settings) | ||
{ | ||
_treeView.RootNodes().Clear(); | ||
const auto tasks = settings.GlobalSettings().ActionMap().FilterToSendInput(L""); // IVector<Model::Command> | ||
for (const auto& t : tasks) | ||
{ | ||
const auto& treeNode = _buildTreeViewNode(t); | ||
_treeView.RootNodes().Append(treeNode); | ||
} | ||
} | ||
|
||
winrt::Windows::UI::Xaml::FrameworkElement TasksPaneContent::GetRoot() | ||
{ | ||
return _root; | ||
} | ||
winrt::Windows::Foundation::Size TasksPaneContent::MinSize() | ||
{ | ||
return { 1, 1 }; | ||
} | ||
void TasksPaneContent::Focus(winrt::Windows::UI::Xaml::FocusState reason) | ||
{ | ||
reason; | ||
// _box.Focus(reason); | ||
} | ||
void TasksPaneContent::Close() | ||
{ | ||
CloseRequested.raise(*this, nullptr); | ||
} | ||
|
||
NewTerminalArgs TasksPaneContent::GetNewTerminalArgs(const bool /* asContent */) const | ||
{ | ||
return nullptr; | ||
} | ||
|
||
winrt::hstring TasksPaneContent::Icon() const | ||
{ | ||
static constexpr std::wstring_view glyph{ L"\xe70b" }; // QuickNote | ||
return winrt::hstring{ glyph }; | ||
} | ||
|
||
winrt::Windows::UI::Xaml::Media::Brush TasksPaneContent::BackgroundBrush() | ||
{ | ||
return _root.Background(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
#include "TasksPaneContent.g.h" | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
struct TasksPaneContent : TasksPaneContentT<TasksPaneContent> | ||
{ | ||
TasksPaneContent(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings); | ||
|
||
winrt::Windows::UI::Xaml::FrameworkElement GetRoot(); | ||
|
||
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings); | ||
|
||
winrt::Windows::Foundation::Size MinSize(); | ||
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic); | ||
void Close(); | ||
winrt::Microsoft::Terminal::Settings::Model::NewTerminalArgs GetNewTerminalArgs(const bool asContent) const; | ||
|
||
winrt::hstring Title() { return L"Scratchpad"; } | ||
uint64_t TaskbarState() { return 0; } | ||
uint64_t TaskbarProgress() { return 0; } | ||
bool ReadOnly() { return false; } | ||
winrt::hstring Icon() const; | ||
Windows::Foundation::IReference<winrt::Windows::UI::Color> TabColor() const noexcept { return nullptr; } | ||
winrt::Windows::UI::Xaml::Media::Brush BackgroundBrush(); | ||
|
||
til::typed_event<> CloseRequested; | ||
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::BellEventArgs> BellRequested; | ||
til::typed_event<> TitleChanged; | ||
til::typed_event<> TabColorChanged; | ||
til::typed_event<> TaskbarProgressChanged; | ||
til::typed_event<> ConnectionStateChanged; | ||
til::typed_event<> ReadOnlyChanged; | ||
til::typed_event<> FocusRequested; | ||
|
||
private: | ||
winrt::Windows::UI::Xaml::Controls::Grid _root{ nullptr }; | ||
winrt::Microsoft::UI::Xaml::Controls::TreeView _treeView{ nullptr }; | ||
}; | ||
} | ||
|
||
namespace winrt::TerminalApp::factory_implementation | ||
{ | ||
BASIC_FACTORY(TasksPaneContent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters