mirror of
https://github.com/ppy/osu.git
synced 2026-05-16 22:24:11 +08:00
Refactor ShearedButton to allow easier relative sizing (#36802)
This commit rearranges the contents of `ShearedButtons` to be more independent of each other in regards to sizing. Thanks to that, the custom logic related to enabling autosizing is no longer necessary. Witdh and height are no longer set via the constructor, and can be freely configured using the initializer syntax. Additionally, this allows the button to use relative sizing without having to resort to any hackery with `Size` (this will come in handy for me when implementing the new footer on multiplayer screens). Given that most of the `ShearedButton`s currently in use set their width explicitly, I did not set `AutoSizeAxes = Axes.X` like it would be by default previously. Instead it is set on the only two such buttons (show converts/selected mods on ssv2). I suppose it might be a good idea to have it set that by default if no `Width` is specified, as right now it'll just not show anything. Also I've set the margin on the text field by default in all cases instead of only when autosizing like how it was previously, since otherwise it would be a pain to set that on each button instance when needed. I've checked all affected components and could not find any text overflowing issues that this could cause. --------- Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
committed by
GitHub
Unverified
parent
6b10ef8709
commit
b76a7e1bb6
@@ -24,21 +24,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public BindableBool Active { get; } = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ShearedToggleButton"/>
|
||||
/// </summary>
|
||||
/// <param name="width">
|
||||
/// The width of the button.
|
||||
/// <list type="bullet">
|
||||
/// <item>If a non-<see langword="null"/> value is provided, this button will have a fixed width equal to the provided value.</item>
|
||||
/// <item>If a <see langword="null"/> value is provided (or the argument is omitted entirely), the button will autosize in width to fit the text.</item>
|
||||
/// </list>
|
||||
/// </param>
|
||||
public ShearedToggleButton(float? width = null)
|
||||
: base(width)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user