summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-08-07 20:08:16 -0400
committerAndreas Kling <kling@serenityos.org>2022-08-09 12:08:21 +0200
commit5917545633add7685cff23d44a4d42ae228b6c16 (patch)
tree69c457fc566585831a46faece850477651a9708a
parent1d445356b6f51e5dabcbed81c76fb69d26f5a838 (diff)
downloadserenity-5917545633add7685cff23d44a4d42ae228b6c16.zip
LibGUI+LibGfx: Let Desktop::the() set widget effects
Scrolling can now be set Coarse or Smooth system-wide, Splitter knurls and Tab accents toggled on and off, and Menu flashing disabled.
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.cpp7
-rw-r--r--Userland/Libraries/LibGUI/Splitter.cpp11
-rw-r--r--Userland/Libraries/LibGUI/TabWidget.cpp7
-rw-r--r--Userland/Libraries/LibGUI/Window.cpp2
-rw-r--r--Userland/Libraries/LibGfx/ClassicStylePainter.cpp10
-rw-r--r--Userland/Libraries/LibGfx/ClassicStylePainter.h2
-rw-r--r--Userland/Libraries/LibGfx/StylePainter.cpp4
-rw-r--r--Userland/Libraries/LibGfx/StylePainter.h4
8 files changed, 28 insertions, 19 deletions
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp
index cb4cc15908..76e268ffb8 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.cpp
+++ b/Userland/Libraries/LibGUI/Scrollbar.cpp
@@ -6,6 +6,7 @@
*/
#include <LibCore/Timer.h>
+#include <LibGUI/Desktop.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Scrollbar.h>
#include <LibGfx/CharacterBitmap.h>
@@ -98,15 +99,15 @@ void Scrollbar::set_value(int value, AllowCallback allow_callback, DoClamp do_cl
void Scrollbar::set_target_value(int new_target_value)
{
- if (m_scroll_animation == Animation::CoarseScroll)
- return set_value(new_target_value);
-
new_target_value = clamp(new_target_value, min(), max());
// If we are already at or scrolling to the new target then don't touch anything
if (m_target_value == new_target_value)
return;
+ if (m_scroll_animation == Animation::CoarseScroll || !Desktop::the().system_effects().smooth_scrolling())
+ return set_value(new_target_value);
+
m_animation_time_elapsed = 0;
m_start_value = value();
m_target_value = new_target_value;
diff --git a/Userland/Libraries/LibGUI/Splitter.cpp b/Userland/Libraries/LibGUI/Splitter.cpp
index e524cf8db8..9efa14a668 100644
--- a/Userland/Libraries/LibGUI/Splitter.cpp
+++ b/Userland/Libraries/LibGUI/Splitter.cpp
@@ -6,6 +6,7 @@
*/
#include <LibGUI/BoxLayout.h>
+#include <LibGUI/Desktop.h>
#include <LibGUI/Painter.h>
#include <LibGUI/Splitter.h>
#include <LibGUI/UIDimensions.h>
@@ -60,10 +61,12 @@ void Splitter::paint_event(PaintEvent& event)
auto& rect = grabbable.paint_rect;
int primary = rect.center().primary_offset_for_orientation(m_orientation) - 1;
int secondary = rect.center().secondary_offset_for_orientation(m_orientation) - (total_knurling_width / 2) + (i * (knurl_width + knurl_spacing));
- if (m_orientation == Gfx::Orientation::Vertical)
- paint_knurl(secondary, primary);
- else
- paint_knurl(primary, secondary);
+ if (Desktop::the().system_effects().splitter_knurls()) {
+ if (m_orientation == Gfx::Orientation::Vertical)
+ paint_knurl(secondary, primary);
+ else
+ paint_knurl(primary, secondary);
+ }
}
}
}
diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp
index 0553b13425..984ebec783 100644
--- a/Userland/Libraries/LibGUI/TabWidget.cpp
+++ b/Userland/Libraries/LibGUI/TabWidget.cpp
@@ -10,6 +10,7 @@
#include <AK/GenericShorthands.h>
#include <AK/JsonValue.h>
#include <LibGUI/BoxLayout.h>
+#include <LibGUI/Desktop.h>
#include <LibGUI/Painter.h>
#include <LibGUI/TabWidget.h>
#include <LibGUI/Window.h>
@@ -256,12 +257,14 @@ void TabWidget::paint_event(PaintEvent& event)
text_rect.intersect(button_rect);
};
+ bool accented = Desktop::the().system_effects().tab_accents();
+
for (size_t i = 0; i < m_tabs.size(); ++i) {
if (m_tabs[i].widget == m_active_widget)
continue;
bool hovered = i == m_hovered_tab_index;
auto button_rect = this->button_rect(i);
- Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), false, hovered, m_tabs[i].widget->is_enabled(), m_tab_position, window()->is_active());
+ Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), false, hovered, m_tabs[i].widget->is_enabled(), m_tab_position, window()->is_active(), accented);
auto tab_button_content_rect = button_rect.shrunken(8, 0);
@@ -304,7 +307,7 @@ void TabWidget::paint_event(PaintEvent& event)
}
auto tab_button_content_rect = button_rect.shrunken(8, 0);
- Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), true, hovered, m_tabs[i].widget->is_enabled(), m_tab_position, window()->is_active());
+ Gfx::StylePainter::paint_tab_button(painter, button_rect, palette(), true, hovered, m_tabs[i].widget->is_enabled(), m_tab_position, window()->is_active(), accented);
paint_tab_icon_if_needed(m_tabs[i].icon, button_rect, tab_button_content_rect);
tab_button_content_rect.set_width(tab_button_content_rect.width() - (m_close_button_enabled ? 16 : 0));
diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp
index 54b83c3b46..a2e6ee831d 100644
--- a/Userland/Libraries/LibGUI/Window.cpp
+++ b/Userland/Libraries/LibGUI/Window.cpp
@@ -1234,6 +1234,8 @@ Menu& Window::add_menu(String name)
void Window::flash_menubar_menu_for(MenuItem const& menu_item)
{
+ if (!Desktop::the().system_effects().flash_menus())
+ return;
auto menu_id = menu_item.menu_id();
if (menu_id < 0)
return;
diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
index decf025943..e09c5b99fb 100644
--- a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
+++ b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp
@@ -18,7 +18,7 @@
namespace Gfx {
-void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window)
+void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented)
{
Color base_color = palette.button();
Color highlight_color2 = palette.threed_highlight();
@@ -41,7 +41,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
painter.fill_rect({ 1, 1, rect.width() - 2, rect.height() - 1 }, base_color);
// Top line
- if (active) {
+ if (active && accented) {
painter.draw_line({ 3, 0 }, { rect.width() - 3, 0 }, accent.darkened());
painter.fill_rect_with_gradient({ 1, 1, rect.width() - 2, 2 }, accent, accent.lightened(1.5f));
painter.set_pixel({ 2, 0 }, highlight_color2);
@@ -63,7 +63,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
painter.fill_rect({ 0, 0, rect.width() - 1, rect.height() }, base_color);
// Bottom line
- if (active) {
+ if (active && accented) {
painter.fill_rect_with_gradient({ 1, rect.height() - 3, rect.width() - 2, 2 }, accent, accent.lightened(1.5f));
painter.draw_line({ 2, rect.height() - 1 }, { rect.width() - 3, rect.height() - 1 }, accent.darkened());
} else {
@@ -86,7 +86,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
painter.draw_line({ 2, rect.height() - 1 }, { rect.width(), rect.height() - 1 }, shadow_color2);
// If the tab is active, draw the accent line
- if (active) {
+ if (active && accented) {
painter.fill_rect_with_gradient({ 1, 1, 2, rect.height() - 2 }, accent, accent.lightened(1.5f));
painter.draw_line({ 0, 2 }, { 0, rect.height() - 3 }, accent.darkened());
} else {
@@ -105,7 +105,7 @@ void ClassicStylePainter::paint_tab_button(Painter& painter, IntRect const& rect
painter.draw_line({ 0, rect.height() - 1 }, { rect.width() - 2, rect.height() - 1 }, shadow_color2);
// If the tab is active, draw the accent line
- if (active) {
+ if (active && accented) {
painter.fill_rect_with_gradient({ rect.width() - 2, 1, 2, rect.height() - 2 }, accent.lightened(1.5f), accent);
painter.draw_line({ rect.width(), 2 }, { rect.width(), rect.height() - 3 }, accent.darkened());
} else {
diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.h b/Userland/Libraries/LibGfx/ClassicStylePainter.h
index f6b548fbe6..4c9fe615ff 100644
--- a/Userland/Libraries/LibGfx/ClassicStylePainter.h
+++ b/Userland/Libraries/LibGfx/ClassicStylePainter.h
@@ -16,7 +16,7 @@ namespace Gfx {
class ClassicStylePainter : public BaseStylePainter {
public:
virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) override;
- virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window) override;
+ virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented) override;
virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) override;
virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) override;
virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) override;
diff --git a/Userland/Libraries/LibGfx/StylePainter.cpp b/Userland/Libraries/LibGfx/StylePainter.cpp
index 905e861853..37106f5b14 100644
--- a/Userland/Libraries/LibGfx/StylePainter.cpp
+++ b/Userland/Libraries/LibGfx/StylePainter.cpp
@@ -18,9 +18,9 @@ BaseStylePainter& StylePainter::current()
return style;
}
-void StylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window)
+void StylePainter::paint_tab_button(Painter& painter, IntRect const& rect, Palette const& palette, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented)
{
- current().paint_tab_button(painter, rect, palette, active, hovered, enabled, position, in_active_window);
+ current().paint_tab_button(painter, rect, palette, active, hovered, enabled, position, in_active_window, accented);
}
void StylePainter::paint_button(Painter& painter, IntRect const& rect, Palette const& palette, ButtonStyle button_style, bool pressed, bool hovered, bool checked, bool enabled, bool focused, bool default_button)
diff --git a/Userland/Libraries/LibGfx/StylePainter.h b/Userland/Libraries/LibGfx/StylePainter.h
index 0a5b23f0a3..8951a2afb5 100644
--- a/Userland/Libraries/LibGfx/StylePainter.h
+++ b/Userland/Libraries/LibGfx/StylePainter.h
@@ -38,7 +38,7 @@ public:
virtual ~BaseStylePainter() = default;
virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) = 0;
- virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window) = 0;
+ virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented) = 0;
virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) = 0;
virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) = 0;
virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) = 0;
@@ -57,7 +57,7 @@ public:
// FIXME: These are here for API compatibility, we should probably remove them and move BaseStylePainter into here
static void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false);
- static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window);
+ static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented);
static void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false);
static void paint_window_frame(Painter&, IntRect const&, Palette const&);
static void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal);