summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2023-04-14 08:54:06 -0400
committerAndreas Kling <kling@serenityos.org>2023-04-15 15:24:50 +0200
commit479e67212a1074bc76a6790186d1d05e2c421ee6 (patch)
treef185e1fb9c906449102cf82c6458289086aee9a1 /Userland
parent5181fafce67dc861e53c2f6412adb63bd37c4c5b (diff)
downloadserenity-479e67212a1074bc76a6790186d1d05e2c421ee6.zip
LibGUI: Implement calculated_min_size() for DialogButton
Dialog buttons now scale based on presentation size to accomodate larger fonts while retaining uniform widths. Scaling by 8 is arbitrary but preserves the historical 80 pixel width with Katica 10. This needs improvement but works well for most fonts as a start.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/Button.cpp10
-rw-r--r--Userland/Libraries/LibGUI/Button.h5
2 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp
index 10874bd0e4..90168754da 100644
--- a/Userland/Libraries/LibGUI/Button.cpp
+++ b/Userland/Libraries/LibGUI/Button.cpp
@@ -291,4 +291,14 @@ Optional<UISize> Button::calculated_min_size() const
return UISize(width, height);
}
+Optional<UISize> DialogButton::calculated_min_size() const
+{
+ int constexpr scale = 8;
+ int constexpr padding = 6;
+ int width = max(80, font().presentation_size() * scale);
+ int height = max(22, font().pixel_size_rounded_up() + padding);
+
+ return UISize(width, height);
+}
+
}
diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h
index 6936517963..8dd50fa675 100644
--- a/Userland/Libraries/LibGUI/Button.h
+++ b/Userland/Libraries/LibGUI/Button.h
@@ -95,8 +95,11 @@ public:
explicit DialogButton(String text = {})
: Button(move(text))
{
- set_fixed_width(80);
+ set_min_size({ SpecialDimension::Shrink });
+ set_preferred_size({ SpecialDimension::Shrink });
}
+
+ virtual Optional<UISize> calculated_min_size() const override;
};
}