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

[Settings UI] Represent Cursor Height as a slider #9386

Merged
2 commits merged into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,9 @@
"description": "Sets the color of the cursor. Overrides the cursor color from the color scheme. Uses hex color format: \"#rrggbb\"."
},
"cursorHeight": {
"description": "Sets the percentage height of the cursor starting from the bottom. Only works when cursorShape is set to \"vintage\". Accepts values from 25-100.",
"description": "Sets the percentage height of the cursor starting from the bottom. Only works when cursorShape is set to \"vintage\". Accepts values from 1-100.",
"maximum": 100,
"minimum": 25,
"minimum": 1,
"type": ["integer","null"],
"default": 25
},
Expand Down
20 changes: 14 additions & 6 deletions src/cascadia/TerminalSettingsEditor/Profiles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,20 @@ the MIT License. See LICENSE in the project root for license information. -->
ClearSettingValue="{x:Bind State.Profile.ClearCursorHeight}"
SettingOverrideSource="{x:Bind State.Profile.CursorHeightOverrideSource, Mode=OneWay}"
Visibility="{x:Bind IsVintageCursor, Mode=OneWay}">
<muxc:NumberBox Value="{x:Bind State.Profile.CursorHeight, Mode=TwoWay}"
Style="{StaticResource NumberBoxSettingStyle}"
Minimum="1"
Maximum="100"
SmallChange="1"
LargeChange="10"/>
<Grid Style="{StaticResource CustomSliderControlGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Slider x:Name="CursorHeightSlider"
Grid.Column="0"
Minimum="1"
Maximum="100"
Value="{x:Bind State.Profile.CursorHeight, Mode=TwoWay}"/>
<TextBlock Grid.Column="1"
Text="{Binding ElementName=CursorHeightSlider, Path=Value, Mode=OneWay}"
Style="{StaticResource SliderValueLabelStyle}"/>
</Grid>
</local:SettingContainer>
</StackPanel>

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/dx/CustomTextRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Microsoft::Console::Render
Outline
};

constexpr const ULONG MinCursorHeightPercent = 25;
constexpr const ULONG MinCursorHeightPercent = 1;
Copy link
Member

Choose a reason for hiding this comment

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

(oops, the comment didn't save)

Only thing I'm concerned about is some kind of side effect here.

  1. @miniksa @DHowett Any ideas why this was set to 25 before? Will this horrifically explode in some way?
  2. So if we set the value to something less than 25, the cursor height updates accordingly right? We're not clamping it to 25 anymore, so setting it to less than 25 actually get smaller?

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 bet we specifically mention a minimum of 25 in the docs too. Mind making a PR over there and updating that too (then linking it here)?

Sure! But I could not found any mention of the minimum cursor height value in docs. Do you mean documentation in the doc folder or there is a separate repo for that?

The cursor becomes smaller on values less than 25, but if I set the value to less than 6, the cursor disappears.

I probably found why the minimum value was set to 25:

// the following values are used to create the textmode cursor.
static constexpr unsigned int CURSOR_SMALL_SIZE = 25; // large enough to be one pixel on a six pixel font

Copy link
Member

Choose a reason for hiding this comment

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

Sure! But I could not found any mention of the minimum cursor height value in docs. Do you mean documentation in the doc folder or there is a separate repo for that?

Ah, yes. My bad. I'm thinking about this section of the docs site, in particular. That's generated by our docs repo here.

The cursor becomes smaller on values less than 25, but if I set the value to less than 6, the cursor disappears.

I probably found why the minimum value was set to 25:

Hmm. That "large enough to be one pixel on a six pixel font" comment seems like a reason keep the minimum size to 25 imo. I think we should revert the changes to the schema and renderer, and change the minimum value on the slider to 25 then.

But I definitely want Michael or Dustin to check on this one to be safe (along with what you found in the GdiEngine).

Sorry for blocking on such an annoying little thing!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, if we revert the minimum value back to 25 shouldn't we also change the slider to number box? The slider looks prettier, but one with minimum value of 25 seems a little bit odd, in my opinion.

cursorHeightSlider25

constexpr const ULONG MaxCursorHeightPercent = 100;

class CustomTextRenderer : public ::Microsoft::WRL::RuntimeClass<::Microsoft::WRL::RuntimeClassFlags<::Microsoft::WRL::ClassicCom | ::Microsoft::WRL::InhibitFtmBase>, IDWriteTextRenderer>
Expand Down