-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Implement #1949 Background Image Align (as one setting) #1959
Implement #1949 Background Image Align (as one setting) #1959
Conversation
TerminalSettings now has two new properties: * BackgroundImageHorizontalAlignment * BackgroundImageVerticalAlignment These properties are used in TermControl::_InitializeBackgroundBrush to specify the alignment for TermControl::_bgImageLayer. This is a base commit that will split into two possible branches: * Use one setting in profiles.json: "backgroundImageAlignment" * Use two settings in profiles.json: "backgroundImageHorizontal/VerticalAlignment"
Implement background image alignment as one profile setting. * This has the benefit of acting as a single setting when the user would likely want to change both horizontal and vertical alignment. * HorizontalAlignment and VerticalAlignment are still stored as a tuple in Profile because they are an optional field. And thus, it would not make sense for one of the alignments to be left unused while the other is not. * Cons are that the tuple signature is quite long, but it is only used in a small number of locations. The Serialize method is also a little mishapen with the nested switch statements. Empty lines have been added between base-level cases to improve readability.
In Profiles.cpp, the key for the image stretch mode json property had a lowercase 'i' in "Backgroundimage", not following proper UpperCamelCase. The "i" has been capitalized and the two usages of the constant have been updated as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good and reasonable to me. However, would you mind updating SettingsSchema.md
as well?
Of course. Wasn't sure if documentation was delegated to other parties or not. I'll also add entries for the original 3 |
* Adds entries SettingsSchema.md for the original 3 backgroundImage settings in addition to the new backgroundImageAlignment setting.
* The background image example in UsingJsonSettings.md listing a backgroundImageStretchMode of "Fill" has been corrected to "fill".
4 new entries have been added to the In addition, one background image-related setting capitalization typo (which results in an invalid value) has been fixed in the Also my apologies, I should have added a |
@@ -35,6 +35,10 @@ Properties listed below are specific to each unique profile. | |||
| `startingDirectory` | _Required_ | String | `%USERPROFILE%` | The directory the shell starts in when it is loaded. | | |||
| `useAcrylic` | _Required_ | Boolean | `false` | When set to `true`, the window will have an acrylic background. When set to `false`, the window will have a plain, untextured background. | | |||
| `background` | Optional | String | | Sets the background color of the profile. Overrides `background` set in color scheme if `colorscheme` is set. Uses hex color format: `"#rrggbb"`. | | |||
| `backgroundImage` | Optional | String | | Sets the file location of the Image to draw over the window background. | | |||
| `backgroundImageAlignment` | Optional | String | `center` | Sets how the background image aligns to the boundaries of the window. Possible values: `"center"`, `"left"`, `"top"`, `"right"`, `"bottom"`, `"topLeft"`, `"topRight"`, `"bottomLeft"`, `"bottomRight"` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you list out what the default behavior will be if you don't set the alignment/opacity/stretch given they're optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that's what column 4 is for, but I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, column 4 ( Default ) lists the default settings of center
, 1.0
, and uniformToFill
respectively. Default values are listed for other optional settings in the Globals category as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the one setting. Good work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
🎉 Handy links: |
Summary of the Pull Request
Implement #1949:
profiles.json
has been given a setting for background images labeled as shown below, with the following valid values. This allows background images to be anchored to different corners/sides of the console to fit that background image's intended use-case and focus.When
left
,top
,right
, orbottom
is specified, the other axis is implied to be centered, as that is the default behavior. I went in favor of labeling the default value ascenter
instead ofnone
as "none" does not clearly list the alignment behavior.Alternative Setting
The branch dev/trigger/background-image-align-two-settings implements the exact same functionality, but by splitting the
profiles.json
setting into separate horizontal and vertical settings. I am happy to submit it as a PR if the two-setting approach is preferred.References
There seems to be no other issues or pull requests relevant to background image alignment.
PR Checklist
added/passedDetailed Description of the Pull Request / Additional comments
The
Profile
class defines methods for parsing and serializing the combinedHorizontalAlignment
andVerticalAlignment
enums to and from JSON. Anstd::tuple<HorizontalAlignment, VerticalAlignment>
field_backgroundImageAlignment
has been added for storing the profile setting in one place, as it logically makes sense that both alignments to be in use together.TerminalSettings
andIControlSettings
have been givenBackgroundImageHorizontalAlignment
andBackgroundImageVerticalAlignment
properties. The combination ofstd::tuple<HorizontalAlignment, VerticalAlignment>
is gone once we leave theProfile
class. Combining the two enums is only relevant to how they are stored inprofiles.json
.TerminalSettings
defines the default values of both alignment properties asCenter
.The
TermControl
class changes the image setup inTermControl::_InitializeBackgroundBrush()
to assign the_bgImageLayer
's (background image control's) alignments to that of the specified alignment settings. The alignments assignments have also been moved from within the image source assignment block, to the bottom of the additional images settings definitions (Stretch
andOpacity
).Additional Fixes
The line below for the constant definition has a lowercase
i
at the beginning of the word "image". Thei
has been capitalized to follow proper UpperCamelCase. The two references to thisBackgroundImageStretchModeKey
constant have been updated to reflect the new name.terminal/src/cascadia/TerminalApp/Profile.cpp
Line 43 in fad7638
(This change was performed in its own commit, so it can be reverted if needed.)
Validation Steps Performed
Preview Example Alignments
Below are examples of the alignments
bottom
(Left) andbottomRight
(Right) in use.Figure A (Left) shows the use of
bottom
alignment withuniformToFill
stretch mode. The waves will always be at the bottom and stay centered horizontally. Figure B (Right) shows the use ofbottomRight
alignment withnone
stretch mode. The image will always remain in the bottom right corner and remain the same size.