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

Implement InitialPosition and CenterOnLaunch in the SUI #13605

Merged
12 commits merged into from Oct 5, 2022
Merged

Conversation

PankajBhojwani
Copy link
Contributor

Summary of the Pull Request

InitialPosition and CenterOnLaunch can now be edited in the SUI

PR Checklist

  • Closes SUI: Add settings for initalPosition, centerOnLaunch #9075
  • 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'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: #xxx

Detailed Description of the Pull Request / Additional comments

InitialPosition follows the same style as LaunchSize, with a number box for the x coordinate and a number box for the y coordinate. When there is no value for either of these coordinates, the respective number box is empty (and displays the text Undefined).

Validation Steps Performed

They work

@ghost ghost added Area-Settings UI Anything specific to the SUI Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Jul 26, 2022
@github-actions

This comment has been minimized.

@PankajBhojwani

This comment was marked as outdated.

@DHowett
Copy link
Member

DHowett commented Jul 26, 2022

Should we put Center on Launch inside the expander for position? it's categorically related

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.

Design Questions/Topics

  • Do we want to add a toggle switch to x/y-pos labeled something like "Use system default", and when it's enabled, we disable the x/y-pos?
    • My concern is that the "Undefined" (or NaN value) isn't discoverable. I assume most people would want to keep this as "Use system default".
  • Ideally, we would have a better UI than just putting the number in. I envisioned something like using your cursor as a crosshair to pick the position on a monitor, or pick the monitor itself. Then, that position gets converted to the InitialPosition in the settings UI. That said, that requires a lot more design and work. If we're not going down that path (or at least a path that's more user friendly), I suggest we file a work-item and throw it in the backlog to track this work.
  • Building on that, maybe we want to expose this completely differently without the complex control above. Consider this...
    • a ComboBox with...
      • "Let windows decide" or "Use system default"
      • "On a monitor"
        • when selected, we show a NumberBox for "Monitor ID" that refers to the same monitor as that of Settings app > System > Display (hmm, this part might be hard, ugh)
        • we could probably just use this this as an alias for "center on launch" too?
      • "Custom position in pixels"
        • show the two number pickers for x and y
    • The main thing missing here is just the case where "fullscreen"/"maximized" mode have you pick the monitor. :/. Maybe we make it so that if you change the launch mode to either of those values, we update this control to be "on a monitor"?

Corner cases

  • What happens if the user puts in (via SUI)...
    • invalid input --> do we change to "Undefined"?
    • a decimal number --> do we store it as an int in the settings model, but (more importantly) show it as a decimal or int in the SUI?

// put the placeholder text in the box instead
if (auto xCoord{ x.try_as<int64_t>() })
{
return xCoord.has_value() ? gsl::narrow_cast<double>(xCoord.value()) : NAN;
Copy link
Member

Choose a reason for hiding this comment

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

urgh. Do we have to worry about the data getting corrupted with this narrow_cast? Like, if the JSON has a really big int that couldn't fit in the double?

src/cascadia/TerminalSettingsEditor/LaunchViewModel.cpp 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 Jul 28, 2022
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 28, 2022
@PankajBhojwani PankajBhojwani added the Needs-Discussion Something that requires a team discussion before we can proceed label Jul 28, 2022
@zadjii-msft zadjii-msft added this to the Terminal v1.16 milestone Aug 1, 2022
@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label Aug 1, 2022
@PankajBhojwani
Copy link
Contributor Author

Consensus from discussion:

  • Remove CenterOnLaunch as a setting in the UI, add it as an enum option to LaunchMode and the VM can handle the backend of mapping that enum to our internal CenterOnLaunch
  • Combine the LaunchMode combo box and the LaunchPosition number boxes into one expander

Follow up in a future PR:

  • Add a button Use current position that will populate the fields according to the Terminal's current position

@DHowett
Copy link
Member

DHowett commented Aug 1, 2022

(Given the consensus opinion, How do you propose to have "centered focus mode" as a launch mode in the drop-down?)

@zadjii-msft
Copy link
Member

How do you propose to have "centered focus mode" as a launch mode in the drop-down?

Okay fine, we need "Centered focus mode" in there too. But "Centered Maximized*" seemed viable to leave out. Technically yea you can have it launch centered (and maximize itself), and then restore down to centered. This design occludes that particular combination of settings for presenting the user something more sensible.

If we're dead set on including that as a separate toggle, I'd instead propose:

A set of controls under the Launch Positioning expander.

  • The "launch mode" dropdown
  • Positioning radio buttons
    • Position manually
      • An X/Y input
        • The "use current position" button
    • Use system default
  • A toggle for "center on launch

Heck, it doesn't even need to be one expando then. Could be three:

  • mode
  • position (with the system default checkbox, ala the "desktopBackground" checkbox in the profile appearance page, and eventually the "use current pos" button)
  • center on launch

Maybe we hoped on the "add center to the dropdown" crazy idea train too fast. <discuss more>

@PankajBhojwani PankajBhojwani added the Needs-Discussion Something that requires a team discussion before we can proceed label Sep 6, 2022
@zadjii-msft
Copy link
Member

PXL_20220912_211433391

@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label Sep 12, 2022
@PankajBhojwani
Copy link
Contributor Author

updated screenshots:

image

image

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.

Good work! I all of these are small changes.

<comment>Header for a set of settings that determine how terminal launches.</comment>
</data>
<data name="Globals_LaunchParameters.HelpText" xml:space="preserve">
<value>Settings that control how the terminal launches</value>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<value>Settings that control how the terminal launches</value>
<value>Settings that control where the terminal launches</value>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer just 'where' though, this expander now also contains LaunchMode

src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsEditor/Launch.xaml 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 Oct 3, 2022
@PankajBhojwani PankajBhojwani added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 5, 2022
@ghost
Copy link

ghost commented Oct 5, 2022

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.

@ghost ghost merged commit 40bc3d7 into main Oct 5, 2022
@ghost ghost deleted the dev/pabhoj/dxd_sui branch October 5, 2022 19:37
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.

Post-hoc


if (UseDefaultLaunchPosition())
{
result = fmt::format(L"{}, {}, {}", launchModeString, RS_(L"Globals_LaunchModeDefault/Content"), centerOnLaunchString);
Copy link
Member

Choose a reason for hiding this comment

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

I would have structured it a bit differently.

It would say:

Maximized, Default Position

Normal, Default Position, Centered

Minimized, (3, 3)

Focus, (4, 100), Centered

That way, we wouldn't include the less-meaningful strings "on" and "off" and we would only show contextually-appropriate data.


if (UseDefaultLaunchPosition())
{
result = fmt::format(L"{}, {}, {}", launchModeString, RS_(L"Globals_LaunchModeDefault/Content"), centerOnLaunchString);
Copy link
Member

Choose a reason for hiding this comment

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

(That is: replace off with nothing, and on with Centered)

{
InitialPosX(NAN);
InitialPosY(NAN);
_NotifyChanges(L"InitialPosX", L"InitialPosY");
Copy link
Member

Choose a reason for hiding this comment

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

This will generate up to three notifications for LaunchParametersCurrentValue, right? Because it will cascade through the InitialPos# setters as well.

ghost pushed a commit that referenced this pull request Oct 11, 2022
Addressing post-hoc comments on the launch parameters expander in the SUI (added in #13605)

- Use more contextually appropriate strings (`Centered` instead of `On` / `Off`)
- Don't emit an extra `NotifyChanges`

References #13605
@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:

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-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met 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.

SUI: Add settings for initalPosition, centerOnLaunch
5 participants