Skip to content

Commit

Permalink
real xaml
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 16, 2024
1 parent e72b1bf commit 0bb13f9
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1449,8 +1449,8 @@ namespace winrt::TerminalApp::implementation
{
if (Feature_ScratchpadPane::IsEnabled())
{
const auto& scratchPane{ winrt::make_self<TasksPaneContent>(_settings) };

const auto& scratchPane{ winrt::make_self<TasksPaneContent>() };
scratchPane->UpdateSettings(_settings);
// This is maybe a little wacky - add our key event handler to the pane
// we made. So that we can get actions for keys that the content didn't
// handle.
Expand Down
24 changes: 12 additions & 12 deletions src/cascadia/TerminalApp/TasksPaneContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ namespace winrt

namespace winrt::TerminalApp::implementation
{
TasksPaneContent::TasksPaneContent(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings)
TasksPaneContent::TasksPaneContent()
{
_root = winrt::Windows::UI::Xaml::Controls::Grid{};
InitializeComponent();

// _root = this; // 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>());
/*_root.*/ Background(bg.try_as<WUX::Media::Brush>());

_treeView = winrt::Microsoft::UI::Xaml::Controls::TreeView{};
_root.Children().Append(_treeView);
// _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;
// UpdateSettings(settings);
}
MUX::Controls::TreeViewNode _buildTreeViewNode(const Model::Command& task)
{
Expand All @@ -53,18 +53,18 @@ namespace winrt::TerminalApp::implementation
}
void TasksPaneContent::UpdateSettings(const CascadiaSettings& settings)
{
_treeView.RootNodes().Clear();
_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);
_treeView().RootNodes().Append(treeNode);
}
}

winrt::Windows::UI::Xaml::FrameworkElement TasksPaneContent::GetRoot()
{
return _root;
return *this;
}
winrt::Windows::Foundation::Size TasksPaneContent::MinSize()
{
Expand Down Expand Up @@ -93,6 +93,6 @@ namespace winrt::TerminalApp::implementation

winrt::Windows::UI::Xaml::Media::Brush TasksPaneContent::BackgroundBrush()
{
return _root.Background();
return Background();
}
}
6 changes: 3 additions & 3 deletions src/cascadia/TerminalApp/TasksPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace winrt::TerminalApp::implementation
{
struct TasksPaneContent : TasksPaneContentT<TasksPaneContent>
{
TasksPaneContent(const winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
TasksPaneContent();

winrt::Windows::UI::Xaml::FrameworkElement GetRoot();

Expand Down Expand Up @@ -37,8 +37,8 @@ namespace winrt::TerminalApp::implementation
til::typed_event<> FocusRequested;

private:
winrt::Windows::UI::Xaml::Controls::Grid _root{ nullptr };
winrt::Microsoft::UI::Xaml::Controls::TreeView _treeView{ nullptr };
// winrt::Windows::UI::Xaml::Controls::Grid _root{ nullptr };
// winrt::Microsoft::UI::Xaml::Controls::TreeView _treeView{ nullptr };
};
}

Expand Down
42 changes: 42 additions & 0 deletions src/cascadia/TerminalApp/TasksPaneContent.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
the MIT License. See LICENSE in the project root for license information.
-->
<UserControl x:Class="TerminalApp.TasksPaneContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:SettingsModel="using:Microsoft.Terminal.Settings.Model"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:TerminalApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:Microsoft.Terminal.Settings.Model"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
AllowFocusOnInteraction="True"
IsTabStop="True"
TabNavigation="Cycle"
mc:Ignorable="d">

<UserControl.Resources>
<ResourceDictionary>
<model:IconPathConverter x:Key="IconSourceConverter" />

<DataTemplate x:Key="ListItemTemplate"
x:DataType="local:FilteredCommand">
<ListViewItem Height="32"
MinHeight="0"
Padding="16,0,12,0"
HorizontalContentAlignment="Stretch"
AutomationProperties.AcceleratorKey="{x:Bind Item.KeyChordText, Mode=OneWay}"
AutomationProperties.Name="{x:Bind Item.Name, Mode=OneWay}"
FontSize="12" />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>

<StackPanel Orientation="Horizontal">
<TextBlock x:Name="_title"
Text="Tasks" />
<mux:TreeView x:Name="_treeView" />
</StackPanel>

</UserControl>
12 changes: 9 additions & 3 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<Page Include="SuggestionsControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="TasksPaneContent.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<!-- ========================= Headers ======================== -->
<ItemGroup>
Expand Down Expand Up @@ -168,7 +171,7 @@
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
</ClInclude>
<ClInclude Include="TasksPaneContent.h">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
<DependentUpon>TasksPaneContent.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="SettingsPaneContent.h">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
Expand Down Expand Up @@ -287,7 +290,7 @@
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
</ClCompile>
<ClCompile Include="TasksPaneContent.cpp">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
<DependentUpon>TasksPaneContent.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="SettingsPaneContent.cpp">
<DependentUpon>TerminalPaneContent.idl</DependentUpon>
Expand Down Expand Up @@ -366,7 +369,10 @@
<Midl Include="FilteredCommand.idl" />
<Midl Include="EmptyStringVisibilityConverter.idl" />
<Midl Include="IPaneContent.idl" />
<Midl Include="TerminalPaneContent.idl" />
<Midl Include="TerminalPaneContent.idl" >
<DependentUpon>TaskPaneContent.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
</ItemGroup>
<!-- ========================= Misc Files ======================== -->
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/TerminalPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ namespace TerminalApp
SettingsPaneContent(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
}

[default_interface] runtimeclass TasksPaneContent : IPaneContent
[default_interface] runtimeclass TasksPaneContent : Windows.UI.Xaml.Controls.UserControl, IPaneContent
{
TasksPaneContent(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
TasksPaneContent();
}

}

0 comments on commit 0bb13f9

Please sign in to comment.