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

Enable switching app theme based off of OS theme #14497

Merged
40 commits merged into from
Jan 12, 2023

Conversation

zadjii-msft
Copy link
Member

This is basically just like #14064, but with the theme instead.

If you define a pair of theme names:

    "theme": { "dark": "light", "light": "dark" },

then the Terminal will use the one relevant for the current OS theme. This cooperates with #14064, who sets the scheme based on the app's theme.

This was spec'd as a part of #3327 / #12530, but never promoted to its own issue.
Gif below.

Nicholas Bennett and others added 30 commits September 22, 2022 17:26
@ghost ghost requested a review from lhecker December 9, 2022 20:41
src/cascadia/TerminalSettingsModel/Theme.cpp Outdated Show resolved Hide resolved
}

if (!_globals->Themes().HasKey(_globals->Theme()))
if (_globals->Theme().DarkName() == _globals->Theme().LightName())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I think it'd be advantageous for us in the long term if we consistently stopped calling WinRT functions repeatedly like that. These calls are about 4x as expensive as regular, non-inlined function calls and returning a runtimeclass reference involves at least 2 such calls each time. I realize that even then these calls are plenty fast for "cold paths" like this, but I think that it might lead to impacts down the road, for instance by impacting Debug build performance to a point where it begins to be annoying (Debug build WinRT calls are over 20x more expensive), or just because one of these function calls ends up not being O(1) anymore but e.g. O(log N) or something (an ordered map lookup instead of an unordered one for instance).

Just to be clear, I'm not saying that this is a problem right now, but I'm hoping to make a case for what I think might be beneficial for our long term code health.

@@ -1178,14 +1178,32 @@ void CascadiaSettings::_validateThemeExists()
auto newTheme = winrt::make_self<Theme>();
newTheme->Name(L"system");
_globals->AddTheme(*newTheme);
_globals->Theme(L"system");
_globals->Theme(*winrt::make_self<ThemePair>(L"system"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just Model::ThemePair{ L"system" }?

@lhecker
Copy link
Member

lhecker commented Dec 16, 2022

I know we need ThemePair to be class, because that's how it works, but...
I don't like it. It's a whole object for two members, something that is basically a std::pair, it gets an entire interface too and everyone got to QI it to get to the single implementor. Also I learned today that the proper name for this is "false dilemma" and is probably what best describes the design decisions that now forced us to write a class with more lines of boilerplate (45 LOC) than lines that actually use it (20 LOC).
...but I know that this is how it works and I would've written the exact same code you did.

@zadjii-msft zadjii-msft added this to the Terminal v1.17 milestone Jan 10, 2023
zadjii-msft added a commit that referenced this pull request Jan 12, 2023
@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 12, 2023
@ghost
Copy link

ghost commented Jan 12, 2023

Hello @zadjii-msft!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 45a36cf into main Jan 12, 2023
@ghost ghost deleted the dev/migrie/f/theme-theme-switch-switch branch January 12, 2023 15:43
@DHowett DHowett restored the dev/migrie/f/theme-theme-switch-switch branch January 13, 2023 00:15
@DHowett DHowett deleted the dev/migrie/f/theme-theme-switch-switch branch January 13, 2023 00:16
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghost ghost removed the Needs-Second It's a PR that needs another sign-off label Jan 13, 2023
@ghost
Copy link

ghost commented Jan 24, 2023

🎉Windows Terminal Preview v1.17.1023 has been released which incorporates this pull request.:tada:

Handy links:

zadjii-msft added a commit to MicrosoftDocs/terminal that referenced this pull request Jan 25, 2023
Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626
@zadjii-msft
Copy link
Member Author

storing this here because I have to keep looking it up in teams chat history

theme-theme-scheme-color-switching

mattwojo added a commit to MicrosoftDocs/terminal that referenced this pull request Mar 11, 2023
* fix(powerline): update oh-my-posh CLI (#632)

* Themes updates for 1.17 (#634)

Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626

* Default prompt icon info, resolves #625 (#642)

* Add app execution alias section (#643)

* Add autoHideWindows

Resolves #633

* Add color theme FAQs

* Remove code brackets from headers

Resolves #637

* Fix default if no command specified

Called out in #638

* Add note differentiating null from no setting 

for Starting Directory. 
Resolves #624

---------

Co-authored-by: Jan De Dobbeleer <2492783+JanDeDobbeleer@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
mattwojo added a commit to MicrosoftDocs/terminal that referenced this pull request Mar 21, 2023
* fix(powerline): update oh-my-posh CLI (#632)

* Themes updates for 1.17 (#634)

Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626

* Default prompt icon info, resolves #625 (#642)

* Add app execution alias section (#643)

* Add autoHideWindows

Resolves #633

* Add color theme FAQs

* Remove code brackets from headers

Resolves #637

* Fix default if no command specified

Called out in #638

* Add note differentiating null from no setting 

for Starting Directory. 
Resolves #624

* add the adobe-target metadata for A/B testing (#646)

could you please help to merge this metadata change (adobe-target=true) to main branch and then to live? This is to enable A/B testing ability across many url base paths so we can improve Learn user experience based on data-driven decisions. This meta (adobe-target) itself will not change how your content is displayed or modify any other UI behaviors so it is safe to merge.

---------

Co-authored-by: Jan De Dobbeleer <2492783+JanDeDobbeleer@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
nguyen-dows added a commit to MicrosoftDocs/terminal that referenced this pull request May 19, 2023
* fix(powerline): update oh-my-posh CLI (#632)

* Themes updates for 1.17 (#634)

Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626

* Default prompt icon info, resolves #625 (#642)

* Add app execution alias section (#643)

* Add autoHideWindows

Resolves #633

* Add color theme FAQs

* Remove code brackets from headers

Resolves #637

* Fix default if no command specified

Called out in #638

* Add note differentiating null from no setting 

for Starting Directory. 
Resolves #624

* add the adobe-target metadata for A/B testing (#646)

could you please help to merge this metadata change (adobe-target=true) to main branch and then to live? This is to enable A/B testing ability across many url base paths so we can improve Learn user experience based on data-driven decisions. This meta (adobe-target) itself will not change how your content is displayed or modify any other UI behaviors so it is safe to merge.

* Add documentation to include information about enable/disable read-only mode functionality (#645)

* Update actions to include new enable and disable functionality

* Update panes to include new enable and disable functionality

* Many updates to commandline args docs, and some missing actions too (#649)

* Many updates to commandline args docs, and some missing actions too

* Fix anchor link warnings

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Remove Dynamic SSH profiles from doc since it has not been implemente… (#650)

* Remove Dynamic SSH profiles from doc since it has not been implemented yet.

* Updated authors and date

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* remove instances of Preview for 1.15 features (#669)

* remove enableReadOnlyMode and disableReadyOnlyMode docs in panes until it goes live in a future release (#672)

---------

Co-authored-by: Jan De Dobbeleer <2492783+JanDeDobbeleer@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Co-authored-by: juchen-ms <partychen.acm@gmail.com>
Co-authored-by: Alex Noble <6237394+Swinkid@users.noreply.github.com>
nguyen-dows added a commit to MicrosoftDocs/terminal that referenced this pull request May 23, 2023
* fix(powerline): update oh-my-posh CLI (#632)

* Themes updates for 1.17 (#634)

Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626

* Default prompt icon info, resolves #625 (#642)

* Add app execution alias section (#643)

* Add autoHideWindows

Resolves #633

* Add color theme FAQs

* Remove code brackets from headers

Resolves #637

* Fix default if no command specified

Called out in #638

* Add note differentiating null from no setting 

for Starting Directory. 
Resolves #624

* add the adobe-target metadata for A/B testing (#646)

could you please help to merge this metadata change (adobe-target=true) to main branch and then to live? This is to enable A/B testing ability across many url base paths so we can improve Learn user experience based on data-driven decisions. This meta (adobe-target) itself will not change how your content is displayed or modify any other UI behaviors so it is safe to merge.

* Add documentation to include information about enable/disable read-only mode functionality (#645)

* Update actions to include new enable and disable functionality

* Update panes to include new enable and disable functionality

* Many updates to commandline args docs, and some missing actions too (#649)

* Many updates to commandline args docs, and some missing actions too

* Fix anchor link warnings

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Remove Dynamic SSH profiles from doc since it has not been implemente… (#650)

* Remove Dynamic SSH profiles from doc since it has not been implemented yet.

* Updated authors and date

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* remove instances of Preview for 1.15 features (#669)

* remove enableReadOnlyMode and disableReadyOnlyMode docs in panes until it goes live in a future release (#672)

* Update Docs with Release 1.18 (#674)

* Stashed dynamic SSH profiles doc

* Add portable mode docs to release branch 1.18 (#655)

* added first draft of docs

* changed headings and subheadings

* Reword, add an Upgrading section

---------

Co-authored-by: Dustin Howett <duhowett@microsoft.com>

* Retool the portable mode documentation to explain our distributions (#656)

* Retool portable mode to be 'distributions'

* Fix warnings

* add preinstallation to the feature matrix

* add dci to matrix

* reword

* couple more notes

* better version note

* Use a data matrix table, re-alt-text the portable mode image

* add distributions to the toc

* address L's feedbacc

* Document 'activeOnly' value for 'showCloseButton' property. (#660)

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* Document 'activeOnly' value for 'showCloseButton' property.

---------

Co-authored-by: Christopher Nguyen <91625426+nguyen-dows@users.noreply.github.com>

* Add a small section on tab tearout in the overview page (#666)

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* initial commit

* added preview links and small grammatical fixes

* added important preview flag

* moved Important flag to the end of the section to fit Actions docs

* omit unrelated changes that got pulled in from master

* omit actions and profiles changes

* Add preview text and re-add missing enableReadOnlyMode docs (#673)

* add preview text and readd enableReadOnlyMode that was lost in the most recent commit

* add preview text for activeOnly value in showCloseButton property docs

---------

Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: kovdu <koen.vandurme@gmail.com>

---------

Co-authored-by: Jan De Dobbeleer <2492783+JanDeDobbeleer@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Co-authored-by: juchen-ms <partychen.acm@gmail.com>
Co-authored-by: Alex Noble <6237394+Swinkid@users.noreply.github.com>
Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: kovdu <koen.vandurme@gmail.com>
nguyen-dows added a commit to MicrosoftDocs/terminal that referenced this pull request May 24, 2023
…ocs (#678)

* fix(powerline): update oh-my-posh CLI (#632)

* Themes updates for 1.17 (#634)

Documents a whole pile of stuff from 1.17:

* `useMica` microsoft/terminal#13935
* theme pairs microsoft/terminal#14497
* scheme pairs microsoft/terminal#14064
* closes #626

* Default prompt icon info, resolves #625 (#642)

* Add app execution alias section (#643)

* Add autoHideWindows

Resolves #633

* Add color theme FAQs

* Remove code brackets from headers

Resolves #637

* Fix default if no command specified

Called out in #638

* Add note differentiating null from no setting 

for Starting Directory. 
Resolves #624

* add the adobe-target metadata for A/B testing (#646)

could you please help to merge this metadata change (adobe-target=true) to main branch and then to live? This is to enable A/B testing ability across many url base paths so we can improve Learn user experience based on data-driven decisions. This meta (adobe-target) itself will not change how your content is displayed or modify any other UI behaviors so it is safe to merge.

* Add documentation to include information about enable/disable read-only mode functionality (#645)

* Update actions to include new enable and disable functionality

* Update panes to include new enable and disable functionality

* Many updates to commandline args docs, and some missing actions too (#649)

* Many updates to commandline args docs, and some missing actions too

* Fix anchor link warnings

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>

* Remove Dynamic SSH profiles from doc since it has not been implemente… (#650)

* Remove Dynamic SSH profiles from doc since it has not been implemented yet.

* Updated authors and date

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* remove instances of Preview for 1.15 features (#669)

* remove enableReadOnlyMode and disableReadyOnlyMode docs in panes until it goes live in a future release (#672)

* Update Docs with Release 1.18 (#674)

* Stashed dynamic SSH profiles doc

* Add portable mode docs to release branch 1.18 (#655)

* added first draft of docs

* changed headings and subheadings

* Reword, add an Upgrading section

---------

Co-authored-by: Dustin Howett <duhowett@microsoft.com>

* Retool the portable mode documentation to explain our distributions (#656)

* Retool portable mode to be 'distributions'

* Fix warnings

* add preinstallation to the feature matrix

* add dci to matrix

* reword

* couple more notes

* better version note

* Use a data matrix table, re-alt-text the portable mode image

* add distributions to the toc

* address L's feedbacc

* Document 'activeOnly' value for 'showCloseButton' property. (#660)

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* Document 'activeOnly' value for 'showCloseButton' property.

---------

Co-authored-by: Christopher Nguyen <91625426+nguyen-dows@users.noreply.github.com>

* Add a small section on tab tearout in the overview page (#666)

* Shelfing read-only mode docs until it goes in a future release (#653)

* Added maximum history size (#657)

* added maximum history size

* empty commit to poke the bot

* initial commit

* added preview links and small grammatical fixes

* added important preview flag

* moved Important flag to the end of the section to fit Actions docs

* omit unrelated changes that got pulled in from master

* omit actions and profiles changes

* Add preview text and re-add missing enableReadOnlyMode docs (#673)

* add preview text and readd enableReadOnlyMode that was lost in the most recent commit

* add preview text for activeOnly value in showCloseButton property docs

---------

Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: kovdu <koen.vandurme@gmail.com>

* Add a tutorial for enabling shell integration (#676)

* it's basically just the blog post

* fix urls

* Right-click context menu, allowHeadless docs (#677)

* right-click context menu docs

* allowHeadless too while I'm here

---------

Co-authored-by: Jan De Dobbeleer <2492783+JanDeDobbeleer@users.noreply.github.com>
Co-authored-by: Mike Griese <migrie@microsoft.com>
Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Co-authored-by: juchen-ms <partychen.acm@gmail.com>
Co-authored-by: Alex Noble <6237394+Swinkid@users.noreply.github.com>
Co-authored-by: Dustin Howett <duhowett@microsoft.com>
Co-authored-by: kovdu <koen.vandurme@gmail.com>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Theming Anything related to the theming of elements of the window AutoMerge Marked for automatic merge by the bot when requirements are met zBugBash-Consider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants