Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind Launch Mode/Size, BI Opacity, Opacity, and FontWeight #8219

Merged
17 commits merged into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cascadia/TerminalSettingsEditor/CommonResources.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.Terminal.Settings.Editor"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls">
Expand Down Expand Up @@ -31,6 +31,12 @@
<Setter Property="ToolTipService.Placement" Value="Mouse"/>
</Style>

<Style TargetType="Slider">
<Setter Property="Margin" Value="0,0,0,20"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="ToolTipService.Placement" Value="Mouse"/>
</Style>

<Style TargetType="ComboBox">
<Setter Property="Margin" Value="0,0,0,20"/>
<Setter Property="FontSize" Value="15"/>
Expand Down
32 changes: 32 additions & 0 deletions src/cascadia/TerminalSettingsEditor/FontWeightConverter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "pch.h"
#include "FontWeightConverter.h"
#include "FontWeightConverter.g.cpp"

using namespace winrt::Windows;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Text;

namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
Foundation::IInspectable FontWeightConverter::Convert(Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
Foundation::IInspectable const& /* parameter */,
hstring const& /* language */)
{
const auto weight{ winrt::unbox_value<FontWeight>(value) };
return winrt::box_value<double>(weight.Weight);
}

Foundation::IInspectable FontWeightConverter::ConvertBack(Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
Foundation::IInspectable const& /*parameter*/,
hstring const& /* language */)
{
const auto sliderVal{ winrt::unbox_value<double>(value) };
FontWeight weight{ base::ClampedNumeric<uint16_t>(sliderVal) };
return winrt::box_value<FontWeight>(weight);
}
}
30 changes: 30 additions & 0 deletions src/cascadia/TerminalSettingsEditor/FontWeightConverter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#pragma once

#include "FontWeightConverter.g.h"
#include "Utils.h"

namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
struct FontWeightConverter : FontWeightConverterT<FontWeightConverter>
{
FontWeightConverter() = default;

Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& targetType,
Windows::Foundation::IInspectable const& parameter,
hstring const& language);

Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& targetType,
Windows::Foundation::IInspectable const& parameter,
hstring const& language);
};
}

namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
{
BASIC_FACTORY(FontWeightConverter);
}
10 changes: 10 additions & 0 deletions src/cascadia/TerminalSettingsEditor/FontWeightConverter.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

namespace Microsoft.Terminal.Settings.Editor
{
runtimeclass FontWeightConverter : [default] Windows.UI.Xaml.Data.IValueConverter
{
FontWeightConverter();
};
}
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Launch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
#include "Launch.h"
#include "Launch.g.cpp"
#include "LaunchPageNavigationState.g.cpp"
#include "EnumEntry.h"

using namespace winrt::Windows::UI::Xaml::Navigation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Microsoft::Terminal::Settings::Model;

namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
Launch::Launch()
{
InitializeComponent();

INITIALIZE_BINDABLE_ENUM_SETTING(LaunchMode, LaunchMode, LaunchMode, L"Globals_LaunchMode", L"Content");
}

void Launch::OnNavigatedTo(const NavigationEventArgs& e)
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Launch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void CurrentDefaultProfile(const IInspectable& value);

GETSET_PROPERTY(Editor::LaunchPageNavigationState, State, nullptr);

GETSET_BINDABLE_ENUM_SETTING(LaunchMode, Model::LaunchMode, State().Settings().GlobalSettings, LaunchMode);
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalSettingsEditor/Launch.idl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import "EnumEntry.idl";

namespace Microsoft.Terminal.Settings.Editor
{
runtimeclass LaunchPageNavigationState
Expand All @@ -14,5 +16,8 @@ namespace Microsoft.Terminal.Settings.Editor
LaunchPageNavigationState State { get; };

IInspectable CurrentDefaultProfile;

IInspectable CurrentLaunchMode;
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> LaunchModeList { get; };
}
}
107 changes: 64 additions & 43 deletions src/cascadia/TerminalSettingsEditor/Launch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="CommonResources.xaml"/>
</ResourceDictionary.MergedDictionaries>

<DataTemplate x:DataType="local:EnumEntry" x:Key="EnumRadioButtonTemplate">
<RadioButton Content="{x:Bind EnumName, Mode=OneWay}"/>
</DataTemplate>
<SettingsModel:IconPathConverter x:Key="IconSourceConverter"/>
</ResourceDictionary>
</Page.Resources>
Expand All @@ -39,21 +43,21 @@ the MIT License. See LICENSE in the project root for license information. -->
SelectedItem="{x:Bind CurrentDefaultProfile, Mode=TwoWay}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="SettingsModel:Profile">
<Grid HorizontalAlignment="Stretch" ColumnSpacing="8" >

<Grid.ColumnDefinitions>
<Grid HorizontalAlignment="Stretch" ColumnSpacing="8" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="16"/>
<!-- icon -->
<!-- icon -->
<ColumnDefinition Width="Auto"/>
<!-- profile name -->
<!-- profile name -->
</Grid.ColumnDefinitions>

<IconSourceElement
Grid.Column="0"
Width="16"
Height="16"
IconSource="{x:Bind Icon,
Mode=OneWay,
<IconSourceElement
Grid.Column="0"
Width="16"
Height="16"
IconSource="{x:Bind Icon,
Mode=OneWay,
Converter={StaticResource IconSourceConverter}}"/>

<TextBlock Grid.Column="1"
Expand All @@ -63,39 +67,56 @@ the MIT License. See LICENSE in the project root for license information. -->
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<CheckBox x:Uid="Globals_StartOnUserLogin" IsChecked="{x:Bind State.Settings.GlobalSettings.StartOnUserLogin, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
<Controls:RadioButtons x:Uid="Globals_LaunchSize" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse">
<RadioButton x:Uid="Globals_LaunchSizeDefault" x:Name="DefaultLaunchSize"/>
<RadioButton x:Uid="Globals_LaunchSizeMaximized" x:Name="MaximizedLaunchSize"/>
<RadioButton x:Uid="Globals_LaunchSizeFullscreen" x:Name="FullscreenLaunchSize"/>
<RadioButton x:Uid="Globals_LaunchSizeFocus" x:Name="FocusLaunchSize"/>
<RadioButton x:Uid="Globals_LaunchSizeMaximizedFocus" x:Name="MaximizedFocusLaunchSize"/>
</Controls:RadioButtons>
<!--TODO: Converter here for launch position into the cols and rows number boxes-->
<!--<TextBox x:Uid="Globals_LaunchPosition" Text="{x:Bind GlobalSettings.LaunchPosition, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse"/>
<Controls:NumberBox x:Uid="Globals_InitialCols"
x:Name="InitialCols"
Value="{x:Bind GlobalSettings.InitialCols, Mode=TwoWay}"
Margin="0,0,0,20"
FontSize="15"
SpinButtonPlacementMode="Compact"
SmallChange="10"
LargeChange="100"
ToolTipService.Placement="Mouse"/>
<Controls:NumberBox x:Uid="Globals_InitialRows"
x:Name="InitialRows"
Value="{x:Bind GlobalSettings.InitialRows, Mode=TwoWay}"
Margin="0,0,0,20"
FontSize="15"
SpinButtonPlacementMode="Compact"
SmallChange="10"
LargeChange="100"
ToolTipService.Placement="Mouse"/>-->
<CheckBox x:Uid="Globals_StartOnUserLogin" IsChecked="{x:Bind State.Settings.GlobalSettings.StartOnUserLogin, Mode=TwoWay}"/>
<Controls:RadioButtons x:Uid="Globals_LaunchMode"
SelectedItem="{x:Bind CurrentLaunchMode}"
ItemsSource="{x:Bind LaunchModeList}"
ItemTemplate="{StaticResource EnumRadioButtonTemplate}"/>

<!--Launch Size-->
<Grid Margin="0,0,0,20">
<Grid.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="15"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,5,0"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>

<!--Header-->
<TextBlock x:Uid="Globals_LaunchSize"
Grid.Row="0" Grid.Column="0"
Grid.ColumnSpan="2"/>
<!--Columns-->
<StackPanel Orientation="Horizontal"
Grid.Row="1" Grid.Column="0"
Margin="0,0,10,0">
<TextBlock x:Uid="Globals_InitialCols"/>
<Controls:NumberBox Value="{x:Bind State.Settings.GlobalSettings.InitialCols, Mode=TwoWay}"
SmallChange="1"
LargeChange="10"
Margin="0"/>
</StackPanel>

<!--Rows-->
<StackPanel Orientation="Horizontal"
Grid.Row="1" Grid.Column="1">
<TextBlock x:Uid="Globals_InitialRows"/>
<Controls:NumberBox Value="{x:Bind State.Settings.GlobalSettings.InitialRows, Mode=TwoWay}"
SmallChange="1"
LargeChange="10"
Margin="0"/>
</StackPanel>
</Grid>
</StackPanel>
<!--TODO: Setting doesn't exist?-->
<!--<StackPanel Grid.Row="1" Grid.Column="1" Margin="0,0,100,0">
<CheckBox x:Uid="Globals_DisableDynamicProfiles" IsChecked="{x:Bind GlobalSettings.DisableDynamicProfiles, Mode=TwoWay}" Margin="0,0,0,20" FontSize="15" ToolTipService.Placement="Mouse" />
</StackPanel>-->
</Grid>
</ScrollViewer>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<ClInclude Include="ColorToHexConverter.h">
<DependentUpon>ColorToHexConverter.idl</DependentUpon>
</ClInclude>
<ClInclude Include="FontWeightConverter.h">
<DependentUpon>FontWeightConverter.idl</DependentUpon>
</ClInclude>
<ClInclude Include="PercentageConverter.h">
<DependentUpon>PercentageConverter.idl</DependentUpon>
</ClInclude>
<ClInclude Include="EnumEntry.h">
<DependentUpon>EnumEntry.idl</DependentUpon>
</ClInclude>
Expand Down Expand Up @@ -105,6 +111,12 @@
<ClCompile Include="ColorToHexConverter.cpp">
<DependentUpon>ColorToHexConverter.idl</DependentUpon>
</ClCompile>
<ClCompile Include="FontWeightConverter.cpp">
<DependentUpon>FontWeightConverter.idl</DependentUpon>
</ClCompile>
<ClCompile Include="PercentageConverter.cpp">
<DependentUpon>PercentageConverter.idl</DependentUpon>
</ClCompile>
<ClCompile Include="GlobalAppearance.cpp">
<DependentUpon>GlobalAppearance.xaml</DependentUpon>
</ClCompile>
Expand Down Expand Up @@ -138,6 +150,8 @@
<ItemGroup>
<Midl Include="ColorToBrushConverter.idl" />
<Midl Include="ColorToHexConverter.idl" />
<Midl Include="FontWeightConverter.idl" />
<Midl Include="PercentageConverter.idl" />
<Midl Include="EnumEntry.idl" />
<Midl Include="GlobalAppearance.idl">
<DependentUpon>GlobalAppearance.xaml</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<Midl Include="ColorToHexConverter.idl">
<Filter>Converters</Filter>
</Midl>
<Midl Include="FontWeightConverter.idl">
<Filter>Converters</Filter>
</Midl>
<Midl Include="PercentageConverter.idl">
<Filter>Converters</Filter>
</Midl>
<Midl Include="EnumEntry.idl" />
</ItemGroup>
<ItemGroup>
Expand Down
32 changes: 32 additions & 0 deletions src/cascadia/TerminalSettingsEditor/PercentageConverter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "pch.h"
#include "PercentageConverter.h"
#include "PercentageConverter.g.cpp"

using namespace winrt::Windows;
using namespace winrt::Windows::UI::Xaml;

namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
Foundation::IInspectable PercentageConverter::Convert(Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
Foundation::IInspectable const& /* parameter */,
hstring const& /* language */)
{
const auto decimal{ winrt::unbox_value<double>(value) };
const unsigned int number{ base::ClampMul(decimal, 100u) };
return winrt::box_value<double>(number);
}

Foundation::IInspectable PercentageConverter::ConvertBack(Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& /* targetType */,
Foundation::IInspectable const& /*parameter*/,
hstring const& /* language */)
{
const auto number{ winrt::unbox_value<double>(value) };
const auto decimal{ base::ClampDiv<double, double>(number, 100) };
return winrt::box_value<double>(decimal);
}
}
30 changes: 30 additions & 0 deletions src/cascadia/TerminalSettingsEditor/PercentageConverter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#pragma once

#include "PercentageConverter.g.h"
#include "Utils.h"

namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
struct PercentageConverter : PercentageConverterT<PercentageConverter>
{
PercentageConverter() = default;

Windows::Foundation::IInspectable Convert(Windows::Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& targetType,
Windows::Foundation::IInspectable const& parameter,
hstring const& language);

Windows::Foundation::IInspectable ConvertBack(Windows::Foundation::IInspectable const& value,
Windows::UI::Xaml::Interop::TypeName const& targetType,
Windows::Foundation::IInspectable const& parameter,
hstring const& language);
};
}

namespace winrt::Microsoft::Terminal::Settings::Editor::factory_implementation
{
BASIC_FACTORY(PercentageConverter);
}
10 changes: 10 additions & 0 deletions src/cascadia/TerminalSettingsEditor/PercentageConverter.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

namespace Microsoft.Terminal.Settings.Editor
{
runtimeclass PercentageConverter : [default] Windows.UI.Xaml.Data.IValueConverter
{
PercentageConverter();
};
}
Loading