Skip to content

Commit

Permalink
no more ref to model in xaml
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Jul 8, 2022
1 parent 6645b8d commit e355eb9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
Expand Up @@ -56,31 +56,31 @@

<!-- Always show tabs -->
<local:SettingContainer x:Uid="Globals_AlwaysShowTabs">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.AlwaysShowTabs, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.AlwaysShowTabs, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Show Titlebar -->
<local:SettingContainer x:Uid="Globals_ShowTitlebar">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.ShowTabsInTitlebar, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.ShowTabsInTitlebar, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Show Acrylic in Tab Row -->
<local:SettingContainer x:Uid="Globals_AcrylicTabRow">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.UseAcrylicInTabRow, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.UseAcrylicInTabRow, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Show Title in Titlebar -->
<local:SettingContainer x:Uid="Globals_ShowTitleInTitlebar">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.ShowTitleInTitlebar, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.ShowTitleInTitlebar, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Always on Top -->
<local:SettingContainer x:Uid="Globals_AlwaysOnTop">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.AlwaysOnTop, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.AlwaysOnTop, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

Expand All @@ -96,19 +96,19 @@
<!-- Disable Animations -->
<!-- NOTE: the UID is "DisablePaneAnimationsReversed" not "DisablePaneAnimations". See GH#9124 for more details. -->
<local:SettingContainer x:Uid="Globals_DisableAnimationsReversed">
<ToggleSwitch IsOn="{x:Bind local:Converters.InvertBoolean(ViewModel.GlobalSettings.DisableAnimations), BindBack=ViewModel.GlobalSettings.SetInvertedDisableAnimationsValue, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.InvertedDisableAnimations, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Always Show Notification Icon -->
<local:SettingContainer x:Uid="Globals_AlwaysShowNotificationIcon">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.AlwaysShowNotificationIcon, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.AlwaysShowNotificationIcon, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>

<!-- Minimize To Notification Area -->
<local:SettingContainer x:Uid="Globals_MinimizeToNotificationArea">
<ToggleSwitch IsOn="{x:Bind ViewModel.GlobalSettings.MinimizeToNotificationArea, Mode=TwoWay}"
<ToggleSwitch IsOn="{x:Bind ViewModel.MinimizeToNotificationArea, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
</StackPanel>
Expand Down
10 changes: 10 additions & 0 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearanceViewModel.cpp
Expand Up @@ -254,4 +254,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
}
return theme.Name();
}

bool GlobalAppearanceViewModel::InvertedDisableAnimations()
{
return !_GlobalSettings.DisableAnimations();
}

void GlobalAppearanceViewModel::InvertedDisableAnimations(bool value)
{
_GlobalSettings.DisableAnimations(!value);
}
}
11 changes: 11 additions & 0 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearanceViewModel.h
Expand Up @@ -34,6 +34,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void CurrentTheme(const winrt::Windows::Foundation::IInspectable& tag);
static winrt::hstring ThemeNameConverter(const Model::Theme& theme);

bool InvertedDisableAnimations();
void InvertedDisableAnimations(bool value);

PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AlwaysShowTabs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowTabsInTitlebar);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, UseAcrylicInTabRow);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ShowTitleInTitlebar);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AlwaysOnTop);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, AlwaysShowNotificationIcon);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, MinimizeToNotificationArea);

private:
Model::GlobalAppSettings _GlobalSettings;
winrt::Windows::Foundation::Collections::IObservableVector<winrt::hstring> _languageList;
Expand Down
12 changes: 12 additions & 0 deletions src/cascadia/TerminalSettingsEditor/GlobalAppearanceViewModel.idl
Expand Up @@ -3,6 +3,8 @@

import "EnumEntry.idl";

#include "ViewModelHelpers.idl.h"

namespace Microsoft.Terminal.Settings.Editor
{
runtimeclass GlobalAppearanceViewModel : Windows.UI.Xaml.Data.INotifyPropertyChanged
Expand All @@ -21,5 +23,15 @@ namespace Microsoft.Terminal.Settings.Editor

IInspectable CurrentTabWidthMode;
Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> TabWidthModeList { get; };

Boolean InvertedDisableAnimations;

PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowTabs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTabsInTitlebar);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, UseAcrylicInTabRow);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ShowTitleInTitlebar);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysOnTop);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, AlwaysShowNotificationIcon);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, MinimizeToNotificationArea);
}
}
6 changes: 0 additions & 6 deletions src/cascadia/TerminalSettingsModel/GlobalAppSettings.h
Expand Up @@ -57,12 +57,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void DefaultProfile(const guid& defaultProfile) noexcept;
guid DefaultProfile() const;

// TODO GH#9207: Remove this once we have a GlobalAppSettingsViewModel in TerminalSettingsEditor

This comment has been minimized.

Copy link
@DHowett

DHowett Jul 8, 2022

Member

This comment saw the future!

This comment has been minimized.

Copy link
@PankajBhojwani

PankajBhojwani Jul 8, 2022

Author Contributor

Indeed!

void SetInvertedDisableAnimationsValue(bool invertedDisableAnimationsValue)
{
DisableAnimations(!invertedDisableAnimationsValue);
}

Windows::Foundation::Collections::IMapView<hstring, Model::Theme> Themes() noexcept;
void AddTheme(const Model::Theme& theme);
Model::Theme CurrentTheme() noexcept;
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl
Expand Up @@ -45,8 +45,6 @@ namespace Microsoft.Terminal.Settings.Model
[default_interface] runtimeclass GlobalAppSettings {
Guid DefaultProfile;

void SetInvertedDisableAnimationsValue(Boolean invertedDisableAnimationsValue);

INHERITABLE_SETTING(String, UnparsedDefaultProfile);

INHERITABLE_SETTING(Int32, InitialRows);
Expand Down

0 comments on commit e355eb9

Please sign in to comment.