[PR #1959] [MERGED] Implement #1949 Background Image Align (as one setting) #24728

Open
opened 2026-01-31 09:05:00 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/1959
Author: @trigger-segfault
Created: 7/13/2019
Status: Merged
Merged: 7/25/2019
Merged by: @DHowett-MSFT

Base: masterHead: dev/trigger/background-image-align-one-setting


📝 Commits (5)

  • 5d9d117 Implement base background image alignment settings
  • 0889fc3 Implement background image alignment profile setting
  • f48961c Fix capitalization typo for BackgroundImageStretchModeKey
  • 28cec5c Document Background Image settings
  • 7f0ee15 Fix setting capitalization error in UsingJsonSettings.md

📊 Changes

8 files changed (+183 additions, -8 deletions)

View changed files

📝 doc/cascadia/SettingsSchema.md (+4 -0)
📝 doc/user-docs/UsingJsonSettings.md (+1 -1)
📝 src/cascadia/TerminalApp/Profile.cpp (+142 -4)
📝 src/cascadia/TerminalApp/Profile.h (+3 -0)
📝 src/cascadia/TerminalControl/TermControl.cpp (+3 -3)
📝 src/cascadia/TerminalSettings/IControlSettings.idl (+2 -0)
📝 src/cascadia/TerminalSettings/TerminalSettings.cpp (+22 -0)
📝 src/cascadia/TerminalSettings/terminalsettings.h (+6 -0)

📄 Description

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.

"backgroundImageAlignment": "center" | "left" | "top" | "right" | "bottom"
                   | "topLeft" | "topRight" | "bottomLeft" | "bottomRight"

When left, top, right, or bottom 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 as center instead of none 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

  • Closes Tab Tearing (#1949)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated (SettingsSchema.md, UsingJsonSettings.md (optional))
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #1949

Detailed Description of the Pull Request / Additional comments

The Profile class defines methods for parsing and serializing the combined HorizontalAlignment and VerticalAlignment enums to and from JSON. An std::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 and IControlSettings have been given BackgroundImageHorizontalAlignment and BackgroundImageVerticalAlignment properties. The combination of std::tuple<HorizontalAlignment, VerticalAlignment> is gone once we leave the Profile class. Combining the two enums is only relevant to how they are stored in profiles.json. TerminalSettings defines the default values of both alignment properties as Center.

The TermControl class changes the image setup in TermControl::_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 and Opacity).

Additional Fixes

The line below for the constant definition has a lowercase i at the beginning of the word "image". The i has been capitalized to follow proper UpperCamelCase. The two references to this BackgroundImageStretchModeKey constant have been updated to reflect the new name.

fad7638bb3/src/cascadia/TerminalApp/Profile.cpp (L43)

(This change was performed in its own commit, so it can be reverted if needed.)

Validation Steps Performed

  • Test and observe all 9 possible alignment values, invalid input, and not specifying the setting at all.
    • For each image stretch mode.
    • For when a background image is defined or not.
    • Confirm alignment names match up.
  • For each alignment value, confirm they are re-serialized correctly when opening Windows Terminal.
  • Confirm default setting results in a centered background image.
  • Test and observe if alignment settings are properly applied when first opening the Windows Terminal or opening a new profile tab.

Preview Example Alignments

Below are examples of the alignments bottom (Left) and bottomRight (Right) in use.

Preview Figure A (Left) and Figure B (Right)

Figure A (Left) shows the use of bottom alignment with uniformToFill stretch mode. The waves will always be at the bottom and stay centered horizontally. Figure B (Right) shows the use of bottomRight alignment with none stretch mode. The image will always remain in the bottom right corner and remain the same size.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/1959 **Author:** [@trigger-segfault](https://github.com/trigger-segfault) **Created:** 7/13/2019 **Status:** ✅ Merged **Merged:** 7/25/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/trigger/background-image-align-one-setting` --- ### 📝 Commits (5) - [`5d9d117`](https://github.com/microsoft/terminal/commit/5d9d11707f7f399e2f86443afba0fae442cc91e1) Implement base background image alignment settings - [`0889fc3`](https://github.com/microsoft/terminal/commit/0889fc316bddad638ef5427db2f87f22113adb03) Implement background image alignment profile setting - [`f48961c`](https://github.com/microsoft/terminal/commit/f48961c490aee7c1260e10fd50e5521125474be0) Fix capitalization typo for BackgroundImageStretchModeKey - [`28cec5c`](https://github.com/microsoft/terminal/commit/28cec5cdeb3527ba4d3a7c585448c6877548492b) Document Background Image settings - [`7f0ee15`](https://github.com/microsoft/terminal/commit/7f0ee15a9fd96ed0f272c9b9a5858edd69fbcf13) Fix setting capitalization error in UsingJsonSettings.md ### 📊 Changes **8 files changed** (+183 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/SettingsSchema.md` (+4 -0) 📝 `doc/user-docs/UsingJsonSettings.md` (+1 -1) 📝 `src/cascadia/TerminalApp/Profile.cpp` (+142 -4) 📝 `src/cascadia/TerminalApp/Profile.h` (+3 -0) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+3 -3) 📝 `src/cascadia/TerminalSettings/IControlSettings.idl` (+2 -0) 📝 `src/cascadia/TerminalSettings/TerminalSettings.cpp` (+22 -0) 📝 `src/cascadia/TerminalSettings/terminalsettings.h` (+6 -0) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## 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. ```json "backgroundImageAlignment": "center" | "left" | "top" | "right" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" ``` When `left`, `top`, `right`, or `bottom` 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 as `center` instead of `none` as "none" does not clearly list the alignment behavior. ### Alternative Setting The branch [dev/trigger/background-image-align-two-settings](https://github.com/trigger-segfault/terminal/tree/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. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References There seems to be no other issues or pull requests relevant to background image alignment. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes #1949 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [X] Tests ~~added~~/passed * [X] Requires documentation to be updated <sup>([SettingsSchema.md](https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md), [UsingJsonSettings.md](https://github.com/microsoft/terminal/blob/master/doc/user-docs/UsingJsonSettings.md) (optional))</sup> * [X] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #1949 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments The `Profile` class defines methods for parsing and serializing the combined `HorizontalAlignment` and `VerticalAlignment` enums to and from JSON. An `std::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` and `IControlSettings` have been given `BackgroundImageHorizontalAlignment` and `BackgroundImageVerticalAlignment` properties. The combination of `std::tuple<HorizontalAlignment, VerticalAlignment>` is gone once we leave the `Profile` class. Combining the two enums is only relevant to how they are stored in `profiles.json`. `TerminalSettings` defines the default values of both alignment properties as `Center`. The `TermControl` class changes the image setup in `TermControl::_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` and `Opacity`). ### Additional Fixes The line below for the constant definition has a lowercase `i` at the beginning of the word *"image"*. The `i` has been capitalized to follow proper UpperCamelCase. The two references to this `BackgroundImageStretchModeKey` constant have been updated to reflect the new name. https://github.com/microsoft/terminal/blob/fad7638bb39d5c5107431605a1adf50010f8646a/src/cascadia/TerminalApp/Profile.cpp#L43 *(This change was performed in its own commit, so it can be reverted if needed.)* <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed * [X] Test and observe all 9 possible alignment values, invalid input, and not specifying the setting at all. * [X] For each image stretch mode. * [X] For when a background image is defined or not. * [X] Confirm alignment names match up. * [X] For each alignment value, confirm they are re-serialized correctly when opening Windows Terminal. * [X] Confirm default setting results in a centered background image. * [X] Test and observe if alignment settings are properly applied when first opening the Windows Terminal or opening a new profile tab. ## Preview Example Alignments Below are examples of the alignments `bottom` (Left) and `bottomRight` (Right) in use. <p align="center"><img alt="Preview Figure A (Left) and Figure B (Right)" src="https://i.imgur.com/4g0bs5E.png"></p> *Figure A (Left) shows the use of `bottom` alignment with `uniformToFill` stretch mode. The waves will always be at the bottom and stay centered horizontally. Figure B (Right) shows the use of `bottomRight` alignment with `none` stretch mode. The image will always remain in the bottom right corner and remain the same size.* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:05:00 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24728