forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
18 changed files
with
1,107 additions
and
148 deletions.
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
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,46 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "ColorFlyoutSubItem.h" | ||
#include "Utils.h" | ||
|
||
#include "ColorFlyoutSubItem.g.cpp" | ||
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> | ||
|
||
|
||
using namespace winrt; | ||
using namespace winrt::Windows::UI::Xaml; | ||
using namespace winrt::Windows::UI::Core; | ||
using namespace winrt::Windows::System; | ||
using namespace winrt::Windows::ApplicationModel::DataTransfer; | ||
using namespace winrt::Windows::UI::Text; | ||
using namespace winrt::Microsoft::Terminal; | ||
using namespace winrt::Microsoft::Terminal::TerminalControl; | ||
using namespace winrt::Microsoft::Terminal::TerminalConnection; | ||
using namespace winrt::Microsoft::Terminal::Settings; | ||
using namespace ::TerminalApp; | ||
|
||
namespace winrt | ||
{ | ||
namespace MUX = Microsoft::UI::Xaml; | ||
using IInspectable = Windows::Foundation::IInspectable; | ||
} | ||
|
||
namespace winrt::ColorFlyoutSubItem::implementation | ||
{ | ||
ColorFlyoutSubItem::ColorFlyoutSubItem() {} | ||
|
||
ColorFlyoutSubItem::ColorFlyoutSubItem(std::shared_ptr<ScopedResourceLoader> resourceLoader) | ||
{ | ||
InitializeComponent(); | ||
|
||
_resourceLoader = resourceLoader; | ||
} | ||
|
||
|
||
void ColorFlyoutSubItem::Create() | ||
{ | ||
|
||
} | ||
} |
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,37 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "winrt/Microsoft.UI.Xaml.Controls.h" | ||
|
||
#include "ColorFlyoutSubItem.g.h" | ||
#include "ScopedResourceLoader.h" | ||
|
||
#include <winrt/Microsoft.Terminal.TerminalControl.h> | ||
#include <winrt/Microsoft.Terminal.TerminalConnection.h> | ||
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h> | ||
#include <winrt/Windows.ApplicationModel.DataTransfer.h> | ||
#include <winrt/Microsoft.UI.Xaml.XamlTypeInfo.h> | ||
|
||
namespace winrt::ColorFlyoutSubItem::implementation | ||
{ | ||
struct ColorFlyoutSubItem : ColorFlyoutSubItemT<ColorFlyoutSubItem> | ||
{ | ||
public: | ||
ColorFlyoutSubItem(); | ||
|
||
ColorFlyoutSubItem(std::shared_ptr<ScopedResourceLoader> resourceLoader); | ||
void Create(); | ||
|
||
private: | ||
std::shared_ptr<ScopedResourceLoader> _resourceLoader{ nullptr }; | ||
}; | ||
} | ||
|
||
namespace winrt::TerminalApp::factory_implementation | ||
{ | ||
struct ColorFlyoutSubItem : ColorFlyoutSubItemT<ColorFlyoutSubItem, implementation::ColorFlyoutSubItem> | ||
{ | ||
}; | ||
} |
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,11 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import "..\App.idl"; | ||
|
||
//namespace TerminalApp | ||
//{ | ||
// [default_interface] runtimeclass ColorFlyoutSubItem : Windows.UI.Xaml.Controls.MenuFlyoutSubItem | ||
// { | ||
// ColorFlyoutSubItem(); | ||
// } | ||
//} |
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,13 @@ | ||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under | ||
the MIT License. See LICENSE in the project root for license information. --> | ||
<Grid | ||
x:Class="TerminalApp.ColorFlyoutSubItem" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TerminalApp" | ||
xmlns:mux="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
</Grid> |
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,57 @@ | ||
#include "pch.h" | ||
#include "ColorPickupFlyout.h" | ||
#include "ColorPickupFlyout.g.cpp" | ||
#include "winrt/Windows.UI.Xaml.Media.h" | ||
#include "winrt/Windows.UI.Xaml.Shapes.h" | ||
#include "winrt/Windows.UI.Xaml.Interop.h" | ||
|
||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
ColorPickupFlyout::ColorPickupFlyout() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void ColorPickupFlyout::ColorButton_Click(IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const&) | ||
{ | ||
auto btn{ sender.as<Windows::UI::Xaml::Controls::Button>() }; | ||
auto rectangle{ btn.Content().as<Windows::UI::Xaml::Shapes::Rectangle>() }; | ||
auto rectClr{ rectangle.Fill().as<Windows::UI::Xaml::Media::SolidColorBrush>() }; | ||
SelectedColor(rectClr.Color()); | ||
Hide(); | ||
} | ||
|
||
void ColorPickupFlyout::CustomColorButton_Click(Windows::Foundation::IInspectable const&, Windows::UI::Xaml::RoutedEventArgs const&) | ||
{ | ||
auto targetType = this->FlyoutPresenterStyle().TargetType(); | ||
auto s = Windows::UI::Xaml::Style{ }; | ||
s.TargetType(targetType); | ||
auto visibility = customColorPicker().Visibility(); | ||
if (visibility == winrt::Windows::UI::Xaml::Visibility::Collapsed) | ||
{ | ||
customColorPicker().Visibility(winrt::Windows::UI::Xaml::Visibility::Visible); | ||
auto setter = Windows::UI::Xaml::Setter(Windows::UI::Xaml::FrameworkElement::MinWidthProperty(), winrt::box_value(540)); | ||
s.Setters().Append(setter); | ||
} | ||
else | ||
{ | ||
customColorPicker().Visibility(winrt::Windows::UI::Xaml::Visibility::Collapsed); | ||
auto setter = Windows::UI::Xaml::Setter(Windows::UI::Xaml::FrameworkElement::MinWidthProperty(), winrt::box_value(0)); | ||
s.Setters().Append(setter); | ||
} | ||
this->FlyoutPresenterStyle(s); | ||
} | ||
|
||
Windows::UI::Xaml::DependencyProperty ColorPickupFlyout::m_SelectedColorProperty = | ||
Windows::UI::Xaml::DependencyProperty::Register( | ||
L"SelectedColor", | ||
winrt::xaml_typename<winrt::Windows::UI::Color>(), | ||
winrt::xaml_typename<TerminalApp::ColorPickupFlyout>(), | ||
Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(winrt::Windows::UI::Colors::Transparent()), | ||
Windows::UI::Xaml::PropertyChangedCallback{ &ColorPickupFlyout::OnSelectedColorChanged } }); | ||
|
||
void ColorPickupFlyout::OnSelectedColorChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& /* e */) | ||
{ | ||
} | ||
} |
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,35 @@ | ||
#pragma once | ||
#include "ColorPickupFlyout.g.h" | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
struct ColorPickupFlyout : ColorPickupFlyoutT<ColorPickupFlyout> | ||
{ | ||
ColorPickupFlyout(); | ||
void ColorButton_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); | ||
void CustomColorButton_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); | ||
|
||
winrt::Windows::UI::Color SelectedColor() | ||
{ | ||
return winrt::unbox_value<winrt::Windows::UI::Color>(GetValue(m_SelectedColorProperty)); | ||
} | ||
|
||
void SelectedColor(winrt::Windows::UI::Color const& color) | ||
{ | ||
SetValue(m_SelectedColorProperty, winrt::box_value(color)); | ||
} | ||
|
||
static Windows::UI::Xaml::DependencyProperty SelectedColorProperty() { return m_SelectedColorProperty; } | ||
static void OnSelectedColorChanged(Windows::UI::Xaml::DependencyObject const&, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const&); | ||
|
||
private: | ||
static Windows::UI::Xaml::DependencyProperty m_SelectedColorProperty; | ||
}; | ||
} | ||
namespace winrt::TerminalApp::factory_implementation | ||
{ | ||
struct ColorPickupFlyout : ColorPickupFlyoutT<ColorPickupFlyout, implementation::ColorPickupFlyout> | ||
{ | ||
|
||
}; | ||
} |
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,11 @@ | ||
// BgLabelControl.idl | ||
namespace TerminalApp | ||
{ | ||
[default_interface] | ||
runtimeclass ColorPickupFlyout : Windows.UI.Xaml.Controls.Flyout | ||
{ | ||
ColorPickupFlyout(); | ||
Windows.UI.Color SelectedColor{ get; }; | ||
static Windows.UI.Xaml.DependencyProperty SelectedColorProperty{ get; }; | ||
} | ||
} |
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,137 @@ | ||
<Flyout | ||
x:Class="TerminalApp.ColorPickupFlyout" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:TerminalApp" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<Flyout.FlyoutPresenterStyle> | ||
<Style TargetType="FlyoutPresenter"> | ||
<Setter Property="MinWidth" Value="0"/> | ||
</Style> | ||
</Flyout.FlyoutPresenterStyle> | ||
<StackPanel Orientation="Horizontal"> | ||
<VariableSizedWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4"> | ||
<VariableSizedWrapGrid.Resources> | ||
<Style TargetType="Rectangle"> | ||
<Setter Property="Width" Value="30"/> | ||
<Setter Property="Height" Value="30"/> | ||
</Style> | ||
<Style TargetType="Button"> | ||
<Setter Property="Padding" Value="0"/> | ||
<Setter Property="MinWidth" Value="0"/> | ||
<Setter Property="MinHeight" Value="0"/> | ||
<Setter Property="Margin" Value="2"/> | ||
</Style> | ||
</VariableSizedWrapGrid.Resources> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="DarkRed"> | ||
<Button.Content> | ||
<Rectangle Fill="DarkRed"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="DarkBlue"> | ||
<Button.Content> | ||
<Rectangle Fill="DarkBlue"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="DarkGreen"> | ||
<Button.Content> | ||
<Rectangle Fill="DarkGreen"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="DarkOrange"> | ||
<Button.Content> | ||
<Rectangle Fill="DarkOrange"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Red"> | ||
<Button.Content> | ||
<Rectangle Fill="Red"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Green"> | ||
<Button.Content> | ||
<Rectangle Fill="Green"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Blue"> | ||
<Button.Content> | ||
<Rectangle Fill="Blue"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Yellow"> | ||
<Button.Content> | ||
<Rectangle Fill="Yellow"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Magenta"> | ||
<Button.Content> | ||
<Rectangle Fill="Magenta"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Purple"> | ||
<Button.Content> | ||
<Rectangle Fill="Purple"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="LimeGreen"> | ||
<Button.Content> | ||
<Rectangle Fill="LimeGreen"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Tan"> | ||
<Button.Content> | ||
<Rectangle Fill="Tan"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Crimson"> | ||
<Button.Content> | ||
<Rectangle Fill="Crimson"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Teal"> | ||
<Button.Content> | ||
<Rectangle Fill="Teal"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="LightBlue"> | ||
<Button.Content> | ||
<Rectangle Fill="LightBlue"/> | ||
</Button.Content> | ||
</Button> | ||
<Button Click="ColorButton_Click" AutomationProperties.Name="Gray"> | ||
<Button.Content> | ||
<Rectangle Fill="Gray"/> | ||
</Button.Content> | ||
</Button> | ||
<Button VariableSizedWrapGrid.ColumnSpan="4" | ||
Padding="5" | ||
Click="CustomColorButton_Click"> | ||
Select custom color | ||
</Button> | ||
</VariableSizedWrapGrid> | ||
<!--<Viewbox Margin="5" MaxWidth="250" Stretch="Fill">--> | ||
<ColorPicker Visibility="Collapsed" x:Name="customColorPicker" | ||
IsMoreButtonVisible="True" | ||
IsColorSliderVisible="False" | ||
IsColorChannelTextInputVisible="True" | ||
IsHexInputVisible="True" | ||
IsAlphaEnabled="False" | ||
IsAlphaSliderVisible="True" | ||
IsAlphaTextInputVisible="True" | ||
FontSize="10" | ||
> | ||
<ColorPicker.Resources> | ||
<Style TargetType="ComboBox"> | ||
<Setter Property="FontSize" Value="10" /> | ||
</Style> | ||
<Style TargetType="TextBox"> | ||
<Setter Property="FontSize" Value="10" /> | ||
</Style> | ||
</ColorPicker.Resources> | ||
</ColorPicker> | ||
<!--FontSize="12"--> | ||
<!--</Viewbox>--> | ||
</StackPanel> | ||
</Flyout> |
Oops, something went wrong.