mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
WindowServer: Paint menu checkboxes as such instead of as frames
Fixes disabled checkboxes appearing enabled in menus.
This commit is contained in:
parent
c93dfe8097
commit
918dfa51a2
Notes:
sideshowbarker
2024-07-17 20:25:24 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/918dfa51a2b Pull-request: https://github.com/SerenityOS/serenity/pull/12082
1 changed files with 3 additions and 26 deletions
|
@ -55,18 +55,6 @@ const Gfx::Font& Menu::font() const
|
||||||
return Gfx::FontDatabase::default_font();
|
return Gfx::FontDatabase::default_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* s_checked_bitmap_data = {
|
|
||||||
" "
|
|
||||||
" # "
|
|
||||||
" ## "
|
|
||||||
" ### "
|
|
||||||
" ## ### "
|
|
||||||
" ##### "
|
|
||||||
" ### "
|
|
||||||
" # "
|
|
||||||
" "
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char* s_submenu_arrow_bitmap_data = {
|
static const char* s_submenu_arrow_bitmap_data = {
|
||||||
" "
|
" "
|
||||||
" # "
|
" # "
|
||||||
|
@ -79,9 +67,6 @@ static const char* s_submenu_arrow_bitmap_data = {
|
||||||
" "
|
" "
|
||||||
};
|
};
|
||||||
|
|
||||||
static Gfx::CharacterBitmap* s_checked_bitmap;
|
|
||||||
static const int s_checked_bitmap_width = 9;
|
|
||||||
static const int s_checked_bitmap_height = 9;
|
|
||||||
static const int s_submenu_arrow_bitmap_width = 9;
|
static const int s_submenu_arrow_bitmap_width = 9;
|
||||||
static const int s_submenu_arrow_bitmap_height = 9;
|
static const int s_submenu_arrow_bitmap_height = 9;
|
||||||
static const int s_item_icon_width = 16;
|
static const int s_item_icon_width = 16;
|
||||||
|
@ -199,9 +184,6 @@ void Menu::draw()
|
||||||
painter.draw_rect(rect, Color::Black);
|
painter.draw_rect(rect, Color::Black);
|
||||||
painter.fill_rect(rect.shrunken(2, 2), palette.menu_base());
|
painter.fill_rect(rect.shrunken(2, 2), palette.menu_base());
|
||||||
|
|
||||||
if (!s_checked_bitmap)
|
|
||||||
s_checked_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_checked_bitmap_data, s_checked_bitmap_width, s_checked_bitmap_height).leak_ref();
|
|
||||||
|
|
||||||
bool has_checkable_items = false;
|
bool has_checkable_items = false;
|
||||||
bool has_items_with_icon = false;
|
bool has_items_with_icon = false;
|
||||||
for (auto& item : m_items) {
|
for (auto& item : m_items) {
|
||||||
|
@ -258,14 +240,9 @@ void Menu::draw(MenuItem const& item, bool is_drawing_all)
|
||||||
radio_rect.center_vertically_within(text_rect);
|
radio_rect.center_vertically_within(text_rect);
|
||||||
Gfx::StylePainter::paint_radio_button(painter, radio_rect, palette, item.is_checked(), false);
|
Gfx::StylePainter::paint_radio_button(painter, radio_rect, palette, item.is_checked(), false);
|
||||||
} else {
|
} else {
|
||||||
Gfx::IntRect checkmark_rect { item.rect().x() + 7, 0, s_checked_bitmap_width, s_checked_bitmap_height };
|
Gfx::IntRect checkbox_rect { item.rect().x() + 5, 0, 13, 13 };
|
||||||
checkmark_rect.center_vertically_within(text_rect);
|
checkbox_rect.center_vertically_within(text_rect);
|
||||||
Gfx::IntRect checkbox_rect = checkmark_rect.inflated(4, 4);
|
Gfx::StylePainter::paint_check_box(painter, checkbox_rect, palette, item.is_enabled(), item.is_checked(), false);
|
||||||
painter.fill_rect(checkbox_rect, palette.base());
|
|
||||||
Gfx::StylePainter::paint_frame(painter, checkbox_rect, palette, Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2);
|
|
||||||
if (item.is_checked()) {
|
|
||||||
painter.draw_bitmap(checkmark_rect.location(), *s_checked_bitmap, palette.button_text());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (item.icon()) {
|
} else if (item.icon()) {
|
||||||
Gfx::IntRect icon_rect { item.rect().x() + 3, 0, s_item_icon_width, s_item_icon_width };
|
Gfx::IntRect icon_rect { item.rect().x() + 3, 0, s_item_icon_width, s_item_icon_width };
|
||||||
|
|
Loading…
Reference in a new issue