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

Make ColorScheme a WinRT object #7238

Merged
merged 9 commits into from
Aug 15, 2020
Merged

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Aug 10, 2020

Summary of the Pull Request

ColorScheme is now a WinRT object in the TerminalApp project.

References

#7141 - ColorScheme is a settings object
#885 - this new settings object will be moved to a new TerminalSettingsModel project

PR Checklist

  • Tests passed

Detailed Description of the Pull Request / Additional comments

All of the JSON stuff can't be exposed via the idl. So the plan here is that we'll have the TerminalSettingsModel project handle all of the serialization when it's moved over. These functions will be exposed off of the implementation namespace, not projected namespace.

Validation Steps Performed

  • Tests passed
  • Deployment succeeded

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj branch 2 times, most recently from c60f366 to dc958d4 Compare August 10, 2020 23:14
@carlos-zamora carlos-zamora added Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Aug 10, 2020
Comment on lines 16 to 19
UInt32 Foreground { get; };
UInt32 Background { get; };
UInt32 SelectionBackground { get; };
UInt32 CursorColor { get; };
Copy link
Member

Choose a reason for hiding this comment

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

let's not dig this hole deeper. Introduce a Color struct type.

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 specialize its conversion to/from til::color

Copy link
Member

Choose a reason for hiding this comment

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

we probably should have just gone with Windows.UI.Color - my bad

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated ColorScheme to use Windows.UI.Color. Should I go ahead and propagate that change to ICoreSettings too? I'm already here.

src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 11, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 11, 2020
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj branch from dc958d4 to d1a30bd Compare August 11, 2020 22:44
@carlos-zamora carlos-zamora marked this pull request as ready for review August 11, 2020 22:44
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Okay other than this one comment, I'm okay with this

src/cascadia/TerminalApp/CascadiaSettings.h Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 12, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 12, 2020
Copy link
Member Author

@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.

Forgot to remove a few more TerminalSettings references

src/cascadia/TerminalApp/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/ColorScheme.h Show resolved Hide resolved
@DHowett
Copy link
Member

DHowett commented Aug 12, 2020

I don't get it. All that 7a3ca00 did was rename some variables.

The responsibility to apply a color scheme to an IControlSettings lies inside TerminalApp where TerminalSettings lives. You haven't done anything to break the dependency from colorscheme to terminal control (where IControlSettings now lives)

@carlos-zamora
Copy link
Member Author

I don't get it. All that 7a3ca00 did was rename some variables.

The responsibility to apply a color scheme to an IControlSettings lies inside TerminalApp where TerminalSettings lives. You haven't done anything to break the dependency from colorscheme to terminal control (where IControlSettings now lives)

At some point I had ColorScheme.idl referencing a TerminalSettings. That shouldn't be allowed. Making it reference an IControlSettings is better, but you're right, all of that logic should be moved to TermApp.

I was thinking of this little change being a stepping stone to #885's last step (Move the new WinRT settings objects into TerminalSettings project). We don't need the separation until then, at which point I'll also move the similar logic over for Profile.

TLDR: referencing IControlSettings > TerminalSettings

@DHowett
Copy link
Member

DHowett commented Aug 12, 2020

I actually disagree that it’s better!

Eventually, the interfaces for settings will become read-only and you will need to transition this code back to using a class type that has setters on it. Moving to the interface right now is going to be a roadblock for when you inevitably have to concentrate the logic in App.

@DHowett
Copy link
Member

DHowett commented Aug 12, 2020

(cf #7219)

@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/winrt-app-obj branch from 07dfdb7 to 1fb018d Compare August 13, 2020 21:41
@zadjii-msft zadjii-msft removed their assignment Aug 14, 2020
src/cascadia/TerminalApp/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/ColorScheme.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/ColorScheme.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp 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 Aug 14, 2020
result[i] = _table[i];
}
winrt::com_array<Color> result{ COLOR_TABLE_SIZE };
std::transform(_table.begin(), _table.end(), result.begin(), [](til::color c) -> Color { return c; });
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 fine because a til::color is small enough to fit in a single register (or two registers), but it could be an expensive copy for any other struct. prefer const x& unless otherwise okay

@DHowett DHowett merged commit e9a7053 into master Aug 15, 2020
@DHowett DHowett deleted the dev/cazamor/set/winrt-app-obj branch August 15, 2020 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CodeHealth Issues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants