summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-30 23:29:29 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-31 01:35:08 +0200
commitb8416df173ccf46c95a992b1ceea9007b58a6187 (patch)
tree16ca33dc71ac0013aed822a392ee03d3b2adc8a6 /Userland/Libraries/LibGfx
parent087bd7f767d706af2ac9357410b70bcb6db88b6d (diff)
downloadserenity-b8416df173ccf46c95a992b1ceea9007b58a6187.zip
LibGUI+LibGfx: Make scrollbar buttons a little bit thicker
The common thin-cap button look (1px highlight, 2px shadow) looks nice on regular buttons, but the scrollbar didn't feel quite right. This patch adds 1px of offset to the highlight, giving it a thick-cap look (which I have named Gfx::ButtonStyle::ThickCap) :^)
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/ClassicStylePainter.cpp15
-rw-r--r--Userland/Libraries/LibGfx/StylePainter.h1
2 files changed, 11 insertions, 5 deletions
diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
index b1a8f06a5d..c8c940662b 100644
--- a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
+++ b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
@@ -92,7 +92,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, const IntRect& rect
}
}
-static void paint_button_new(Painter& painter, const IntRect& a_rect, const Palette& palette, bool pressed, bool checked, bool hovered, bool enabled, bool focused)
+static void paint_button_new(Painter& painter, IntRect const& a_rect, Palette const& palette, ButtonStyle style, bool pressed, bool checked, bool hovered, bool enabled, bool focused)
{
Color button_color = palette.button();
Color highlight_color = palette.threed_highlight();
@@ -146,8 +146,13 @@ static void paint_button_new(Painter& painter, const IntRect& a_rect, const Pale
painter.fill_rect({ 0, 0, rect.width(), rect.height() }, button_color);
// Top highlight
- painter.draw_line({ 0, 0 }, { rect.width() - 2, 0 }, highlight_color);
- painter.draw_line({ 0, 0 }, { 0, rect.height() - 2 }, highlight_color);
+ if (style == ButtonStyle::Normal) {
+ painter.draw_line({ 0, 0 }, { rect.width() - 2, 0 }, highlight_color);
+ painter.draw_line({ 0, 0 }, { 0, rect.height() - 2 }, highlight_color);
+ } else if (style == ButtonStyle::ThickCap) {
+ painter.draw_line({ 1, 1 }, { rect.width() - 2, 1 }, highlight_color);
+ painter.draw_line({ 1, 1 }, { 1, rect.height() - 2 }, highlight_color);
+ }
// Outer shadow
painter.draw_line({ 0, rect.height() - 1 }, { rect.width() - 1, rect.height() - 1 }, shadow_color2);
@@ -161,8 +166,8 @@ static void paint_button_new(Painter& painter, const IntRect& a_rect, const Pale
void ClassicStylePainter::paint_button(Painter& painter, const IntRect& rect, const Palette& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled, bool focused)
{
- if (button_style == ButtonStyle::Normal)
- return paint_button_new(painter, rect, palette, pressed, checked, hovered, enabled, focused);
+ if (button_style == ButtonStyle::Normal || button_style == ButtonStyle::ThickCap)
+ return paint_button_new(painter, rect, palette, button_style, pressed, checked, hovered, enabled, focused);
if (button_style == ButtonStyle::Coolbar && !enabled)
return;
diff --git a/Userland/Libraries/LibGfx/StylePainter.h b/Userland/Libraries/LibGfx/StylePainter.h
index 068aec8e88..f8b24362db 100644
--- a/Userland/Libraries/LibGfx/StylePainter.h
+++ b/Userland/Libraries/LibGfx/StylePainter.h
@@ -13,6 +13,7 @@ namespace Gfx {
enum class ButtonStyle {
Normal,
+ ThickCap,
Coolbar,
Tray,
};