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

Allow creating and editing unfocused appearances in the SUI #10317

Merged
41 commits merged into from
Jul 13, 2021

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented Jun 3, 2021

Summary of the Pull Request

Adds unfocused appearance creation/configuration in the SUI

There is now an 'Unfocused Appearance' section at the bottom of the 'Appearance' tab in a profile. There is a '+' button to create an unfocused appearance if one does not exist, or a delete button to delete the unfocused appearance if one exists (only one of these buttons is visible at a time).

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I work here

Validation Steps Performed

unfocusedSUI

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Looks like you're making good progress 😊

Comment on lines +261 to +263
// make sure to send all the property changed events once here
// we do this in the case an old appearance was deleted and then a new one is created,
// the old settings need to be updated in xaml
Copy link
Member

Choose a reason for hiding this comment

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

Hmm... could we somehow detect something like "AppearanceChanged"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what's happening here already! (Note that we only get here from the _ViewModelChanged event)

The thing is the Appearances object (not the view model) has some settings that xaml binds to (like CurrentColorScheme) that hang around even if the view model is deleted, then when a new view model is created we need to tell xaml that these settings may have changed

src/cascadia/TerminalSettingsModel/Profile.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Profiles.xaml Outdated Show resolved Hide resolved
Comment on lines +82 to +84
void CreateUnfocusedAppearance();
void DeleteUnfocusedAppearance();

Copy link
Member

Choose a reason for hiding this comment

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

You can probably remove these two functions and just go through the profile instead, right? These don't feel like they should be a part of the navigation state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately we need some way to pass the list of color schemes and the window root to the profile view model for it to create an appearance view model. The PVM doesn't have the list of color schemes nor the window root, only the navigation state does.

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 4, 2021
@PankajBhojwani PankajBhojwani marked this pull request as ready for review June 11, 2021 21:02
@PankajBhojwani PankajBhojwani force-pushed the dev/pabhoj/sui_unfocused_appearance branch from 07cf8f2 to 9a6d580 Compare June 21, 2021 22:08
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Mostly nits. I'd still like a demo of this in the teams chat before approving.

Comment on lines +349 to +397
<Button.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ButtonBackground"
Color="Firebrick" />
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
Color="#C23232" />
<SolidColorBrush x:Key="ButtonBackgroundPressed"
Color="#A21212" />
<SolidColorBrush x:Key="ButtonForeground"
Color="White" />
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="White" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="White" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ButtonBackground"
Color="Firebrick" />
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
Color="#C23232" />
<SolidColorBrush x:Key="ButtonBackgroundPressed"
Color="#A21212" />
<SolidColorBrush x:Key="ButtonForeground"
Color="White" />
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="White" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="White" />
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<SolidColorBrush x:Key="ButtonBackground"
Color="{ThemeResource SystemColorButtonFaceColor}" />
<SolidColorBrush x:Key="ButtonBackgroundPointerOver"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="ButtonBackgroundPressed"
Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="ButtonForeground"
Color="{ThemeResource SystemColorButtonTextColor}" />
<SolidColorBrush x:Key="ButtonForegroundPointerOver"
Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="ButtonForegroundPressed"
Color="{ThemeResource SystemColorHighlightTextColor}" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Button.Resources>
Copy link
Member

Choose a reason for hiding this comment

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

Seeing this gave me an idea: #10454

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to updating this once a PR for that goes through!

src/cascadia/TerminalSettingsEditor/Profiles.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jun 22, 2021
Base automatically changed from dev/pabhoj/sui_appearances to main July 9, 2021 20:44
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Discussed offline. Try making the "Unfocused appearance" a title instead of a "subtitle" to see if that helps it pop more and help differentiate it from the subgroups. Other than that, looks great! :)

We'll iterate on the design. I'm sure the team'll give more feedback once it's merged to main and we get a build to selfhost.

@DHowett
Copy link
Member

DHowett commented Jul 13, 2021

want to slap a til::feature on it? to make sure it only happens in preview?

@PankajBhojwani
Copy link
Contributor Author

want to slap a til::feature on it? to make sure it only happens in preview?

Good idea, done!

@PankajBhojwani PankajBhojwani added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 13, 2021
@ghost
Copy link

ghost commented Jul 13, 2021

Hello @PankajBhojwani!

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.

@mdtauk
Copy link

mdtauk commented Jul 13, 2021

What about a pivot within the "Appearance" section, with Focused and Unfocused?

@ghost ghost merged commit d13c37c into main Jul 13, 2021
@ghost ghost deleted the dev/pabhoj/sui_unfocused_appearance branch July 13, 2021 23:33

bool ProfileViewModel::EditableUnfocusedAppearance()
{
if constexpr (Feature_EditableUnfocusedAppearance::IsEnabled())
Copy link
Member

Choose a reason for hiding this comment

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

This is the same as "return Feature_x::IsEnabled()"

Copy link
Member

Choose a reason for hiding this comment

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

Curious: isn't this technically faster because of the if constexpr? I suppose straight up returning IsEnabled() wouldn't be much slower haha, unless it's inline/constexpr? idk much about this stuff hahaha

Copy link
Member

@DHowett DHowett Jul 14, 2021

Choose a reason for hiding this comment

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

No. The compiler is smart enough to optimize...

if (true) { return true; }
return false;

into

return true;

on its own.

@ghost
Copy link

ghost commented Aug 31, 2021

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

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants