mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:57:36 +00:00
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.
This commit is contained in:
parent
1d445356b6
commit
5917545633
8 changed files with 28 additions and 19 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue