-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Smart hint and text box style refactor #3486
Conversation
MaterialDesignThemes.Wpf/Converters/BooleanToDashStyleConverter.cs
Outdated
Show resolved
Hide resolved
MaterialDesignThemes.Wpf/Converters/FloatingHintMarginConverter.cs
Outdated
Show resolved
Hide resolved
MaterialDesignThemes.Wpf/Converters/FloatingHintMarginConverter.cs
Outdated
Show resolved
Hide resolved
MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.SmartHint.xaml
Outdated
Show resolved
Hide resolved
(cherry picked from commit 555d6f9979cb32e004ceb02a716d8fe11ec3d601) (cherry picked from commit 3b61edd)
…e from 0 to desired size
…t in TextBox elements
…rizontally not covered yet
Co-authored-by: Kevin B <[email protected]>
Co-authored-by: Kevin B <[email protected]>
Co-authored-by: Kevin B <[email protected]>
Co-authored-by: Kevin B <[email protected]>
…) as it is no longer relevant
…ContentAlignment()
77065f0
to
9f9c924
Compare
…I tests comparing control heights pass.
</StackPanel>"); | ||
|
||
var height = await GetHeight(stackPanel, "TextBox"); | ||
//Assert.Equal(height, await GetHeight(stackPanel, "ComboBox"), Precision); |
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.
@Keboo FYI. Look at the file as a whole. Basically I have made a duplicate test for each of the existing tests in this class in order to migrate the controls one by one as they adopt the new SmartHint
approach. The difference in height is typically around 0.5-1 pixels, but the tests expect the height to match down to the third decimal; that does not work and therefore I am, temporarily, introducing these "overloads".
In the other PR's adopting the new SmartHint
you will see controls move from the original test method into the Xxx_PostSmartHintRefactor()
"overload" method (one control per PR). An example is the ComboBox, where you can see this happen:
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/pull/3515/files#diff-e858ebe6ad71bec638332cb3f89c65f1570e5a3bcf92985e967c1ccb74f094d3
Once all styles have adopted the new approach, we can collapse into a single test with the original name again.
Also, please don't convert the XAML input to raw string literals yet; I will do a post-adoption PR where I clean up some of the leftovers like that along with collapsing methods, removing temporary classes, etc....
Smart hint and text box style refactor (MaterialDesignInXAML#3486)
This PR builds on top of the "RFC" around the
TextBox
style change: #3461(Visual) Breaking changes !!!
This PR includes breaking changes.
wpf:HintAssist.IsFloating="True"
is no longer enough to change from the default style to the floating hint style. Explicit opt-in in the form ofStyle="{StaticResource MaterialDesignFloatingHintTextBox}"
is now required.ControlTemplate.Triggers
collection.TextBox
control height in the various styles are to be expected; this also affects some of the UI tests which have been temporarily modified to run green. When all styles adopt the newSmartHint
approach, they should be able to run "normally" again.General idea
Instead of a
SmartHint
consumer relying on a lot of "magic numbers" to place the floating hint correctly, this PR attempts to let theSmartHint
handle the placement of the floating hint itself, with a few supporting properties.In the layout above, the green box represents the
PART_ContentHost
of theTextBox
style which holds the user input. The red box represents theSmartHint
as a whole; this element spans the width of the prefix-text, the user input, and the suffix-text in the layout to be able to place float the hint to either align with prefix/suffix, or with the user input. The blue/purple box represents the "scaled hint" inside of theSmartHint
.From a
SmartHint
consumers point-of-view (e.g. theTextBox
style), the idea is that you provide aSmartHint.FloatingTarget
, which similarly to thePopup.PlacementTarget
is a dependency property where the caller provides a target element which the hint will then (vertically) float on top of. In the example above, theSmartHint.FloatingTarget
is set toPART_ContentHost
to always float the hint directly on top of the user input. There are a few other supporting properties to enable the hint to horizontally align with either the user input or the prefix/suffix texts; depending on the value ofHorizontalContentAlignment
as well.Examples
In the - slowed down - animations above, you should note that the whole
SmartHint
(red box) floats upwards, but only far enough such that the "scaled down hint" (blue/purple box) rests directly on top of theSmartHint.FloatingTarget
. Effectively overlapping the user input with the "empty space" left after scaling the hint down. In the outlined style, theSmartHint.FloatingTarget
is set as the outerBorder
, and a few supporting properties have been set to allow the hint to center align (vertically) with the border line.This approach, in my opinion, works better than the old implementation. The intention is to retain all existing functionality (but improve upon it), and also add support for change of font size and multi-line input. I believe the branch in its current state nearly has that, with just a few minor things I need to look into / clean up.
The intention is to use the
TextBox
style as the guinea pig for adopting the new approach, and then to roll it out to all the other styles containing aSmartHint
afterwards. Backwards compatibility is intended to be maintained, so if a non-default value forHintAssist.FloatingOffset
is supplied, that will still be respected. It could however be considered a both a behavioral breaking change (alignment with prefix/suffix/user-input) and a (slight) visual breaking change.Funkyness
This particular (existing) feature is rather funky. I retained back-compat of it, but it is not aligned across the styles at all. It seems like a shortcut instead of doing an actual MD3 version of the styles. It basically changes the default
TextBox
style so that the underline behaves slightly different on hover.Any comments/feedback/pushback is welcome.