diff options
author | Lenny Maiorani <lenny@serenityos.org> | 2022-02-28 19:21:12 -0700 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-03-04 17:41:08 +0100 |
commit | d5fdc6096cd549e5571a5f97eedc6f2450826569 (patch) | |
tree | e33f3175efe4f5b70158ab7af597be5512f467c7 /Userland | |
parent | dc518404ce57673050c7895ffd0a76533d60b6e1 (diff) | |
download | serenity-d5fdc6096cd549e5571a5f97eedc6f2450826569.zip |
Libraries: Make CharacterBitmap instances at compile-time
`CharacterBitmap` instances are generated at run-time and put on the
heap, but they can be created in a `constexpr` context and stored in
static memory.
Also, remove additional `width` and `height` `static` values in favor
of using the `constexpr` member functions of `CharacterBitmap`.
These changes also include the removal of some initialization code
which tests if the `CharacterBitmap` is created since it is always
created and removes function-local `static` values which cause
run-time branches to ensure it is initialized each time the function
is called.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibCards/Card.cpp | 55 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ColumnsView.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ResizeCorner.cpp | 26 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.cpp | 42 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/CharacterBitmap.cpp | 26 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/CharacterBitmap.h | 30 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/ClassicStylePainter.cpp | 14 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Menu.cpp | 21 |
9 files changed, 97 insertions, 135 deletions
diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index 598e866e82..497e64ade7 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Till Mayer <till.mayer@web.de> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,7 +12,7 @@ namespace Cards { -static const NonnullRefPtr<Gfx::CharacterBitmap> s_diamond = Gfx::CharacterBitmap::create_from_ascii( +static constexpr Gfx::CharacterBitmap s_diamond { " # " " ### " " ##### " @@ -21,9 +22,10 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_diamond = Gfx::CharacterBitma " ##### " " ### " " # ", - 9, 9); + 9, 9 +}; -static const NonnullRefPtr<Gfx::CharacterBitmap> s_heart = Gfx::CharacterBitmap::create_from_ascii( +static constexpr Gfx::CharacterBitmap s_heart { " # # " " ### ### " "#########" @@ -33,9 +35,10 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_heart = Gfx::CharacterBitmap: " ##### " " ### " " # ", - 9, 9); + 9, 9 +}; -static const NonnullRefPtr<Gfx::CharacterBitmap> s_spade = Gfx::CharacterBitmap::create_from_ascii( +static constexpr Gfx::CharacterBitmap s_spade { " # " " ### " " ##### " @@ -45,9 +48,10 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_spade = Gfx::CharacterBitmap: " ## # ## " " ### " " ### ", - 9, 9); + 9, 9 +}; -static const NonnullRefPtr<Gfx::CharacterBitmap> s_club = Gfx::CharacterBitmap::create_from_ascii( +static constexpr Gfx::CharacterBitmap s_club { " ### " " ##### " " ##### " @@ -57,7 +61,8 @@ static const NonnullRefPtr<Gfx::CharacterBitmap> s_club = Gfx::CharacterBitmap:: "#### # ####" " ## ### ## " " ### ", - 11, 9); + 11, 9 +}; static RefPtr<Gfx::Bitmap> s_background; static RefPtr<Gfx::Bitmap> s_background_inverted; @@ -105,26 +110,24 @@ Card::Card(Type type, uint8_t value) auto text_rect = Gfx::IntRect { 4, 6, font.width("10"), font.glyph_height() }; painter.draw_text(text_rect, label, font, Gfx::TextAlignment::Center, color()); - NonnullRefPtr<Gfx::CharacterBitmap> symbol = s_diamond; - switch (m_type) { - case Diamonds: - symbol = s_diamond; - break; - case Clubs: - symbol = s_club; - break; - case Spades: - symbol = s_spade; - break; - case Hearts: - symbol = s_heart; - break; - default: - VERIFY_NOT_REACHED(); - } + auto const& symbol = [&]() -> Gfx::CharacterBitmap const& { + switch (m_type) { + case Diamonds: + return s_diamond; + case Clubs: + return s_club; + break; + case Spades: + return s_spade; + case Hearts: + return s_heart; + default: + VERIFY_NOT_REACHED(); + } + }(); painter.draw_bitmap( - { text_rect.x() + (text_rect.width() - symbol->size().width()) / 2, text_rect.bottom() + 5 }, + { text_rect.x() + (text_rect.width() - symbol.size().width()) / 2, text_rect.bottom() + 5 }, symbol, color()); for (int y = height / 2; y < height; ++y) { diff --git a/Userland/Libraries/LibGUI/ColumnsView.cpp b/Userland/Libraries/LibGUI/ColumnsView.cpp index 3c6b086fa0..6b409656ac 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.cpp +++ b/Userland/Libraries/LibGUI/ColumnsView.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,7 +14,7 @@ namespace GUI { -static const char* s_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_arrow_bitmap { " " " # " " ## " @@ -22,10 +23,9 @@ static const char* s_arrow_bitmap_data = { " ### " " ## " " # " - " " + " ", + 9, 9 }; -static const int s_arrow_bitmap_width = 9; -static const int s_arrow_bitmap_height = 9; ColumnsView::ColumnsView() { @@ -128,7 +128,7 @@ void ColumnsView::paint_event(PaintEvent& event) Gfx::IntRect text_rect = { icon_rect.right() + 1 + icon_spacing(), row * item_height(), - column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - s_arrow_bitmap_width - icon_spacing(), item_height() + column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - static_cast<int>(s_arrow_bitmap.width()) - icon_spacing(), item_height() }; draw_item_text(painter, index, is_selected_row, text_rect, index.data().to_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::None); @@ -145,11 +145,10 @@ void ColumnsView::paint_event(PaintEvent& event) if (expandable) { Gfx::IntRect arrow_rect = { text_rect.right() + 1 + icon_spacing(), 0, - s_arrow_bitmap_width, s_arrow_bitmap_height + s_arrow_bitmap.width(), s_arrow_bitmap.height() }; arrow_rect.center_vertically_within(row_rect); - static auto& arrow_bitmap = Gfx::CharacterBitmap::create_from_ascii(s_arrow_bitmap_data, s_arrow_bitmap_width, s_arrow_bitmap_height).leak_ref(); - painter.draw_bitmap(arrow_rect.location(), arrow_bitmap, text_color); + painter.draw_bitmap(arrow_rect.location(), s_arrow_bitmap, text_color); } } @@ -201,7 +200,7 @@ void ColumnsView::update_column_sizes() ModelIndex index = model()->index(row, m_model_column, column.parent_index); VERIFY(index.is_valid()); auto text = index.data().to_string(); - int row_width = icon_spacing() + icon_size() + icon_spacing() + font().width(text) + icon_spacing() + s_arrow_bitmap_width + icon_spacing(); + int row_width = icon_spacing() + icon_size() + icon_spacing() + font().width(text) + icon_spacing() + s_arrow_bitmap.width() + icon_spacing(); if (row_width > column.width) column.width = row_width; } diff --git a/Userland/Libraries/LibGUI/ResizeCorner.cpp b/Userland/Libraries/LibGUI/ResizeCorner.cpp index 89fb44a5c6..82917c86be 100644 --- a/Userland/Libraries/LibGUI/ResizeCorner.cpp +++ b/Userland/Libraries/LibGUI/ResizeCorner.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -12,7 +13,8 @@ namespace GUI { -static const char* s_resize_corner_shadows_data = { +static constexpr Gfx::CharacterBitmap s_resize_corner_shadows_bitmap { + " " " ## " " # " @@ -28,10 +30,11 @@ static const char* s_resize_corner_shadows_data = { " " " ## ## ## ## ## " " # # # # # " - " " + " ", + 16, 16 }; -static const char* s_resize_corner_highlights_data = { +static constexpr Gfx::CharacterBitmap s_resize_corner_highlights_bitmap { " " " " " # " @@ -47,14 +50,10 @@ static const char* s_resize_corner_highlights_data = { " " " " " # # # # # " - " " + " ", + 16, 16 }; -static Gfx::CharacterBitmap* s_resize_corner_shadows_bitmap; -static Gfx::CharacterBitmap* s_resize_corner_highlights_bitmap; -static const int s_resize_corner_bitmap_width = 16; -static const int s_resize_corner_bitmap_height = 16; - ResizeCorner::ResizeCorner() { set_override_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR); @@ -72,13 +71,8 @@ void ResizeCorner::paint_event(PaintEvent& event) painter.add_clip_rect(event.rect()); painter.fill_rect(rect(), palette().color(background_role())); - if (!s_resize_corner_shadows_bitmap) - s_resize_corner_shadows_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_resize_corner_shadows_data, s_resize_corner_bitmap_width, s_resize_corner_bitmap_height).leak_ref(); - painter.draw_bitmap({ 0, 2 }, *s_resize_corner_shadows_bitmap, palette().threed_shadow1()); - - if (!s_resize_corner_highlights_bitmap) - s_resize_corner_highlights_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_resize_corner_highlights_data, s_resize_corner_bitmap_width, s_resize_corner_bitmap_height).leak_ref(); - painter.draw_bitmap({ 0, 2 }, *s_resize_corner_highlights_bitmap, palette().threed_highlight()); + painter.draw_bitmap({ 0, 2 }, s_resize_corner_shadows_bitmap, palette().threed_shadow1()); + painter.draw_bitmap({ 0, 2 }, s_resize_corner_highlights_bitmap, palette().threed_highlight()); Widget::paint_event(event); } diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp index 6d05917962..25f0cf86d1 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.cpp +++ b/Userland/Libraries/LibGUI/Scrollbar.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +16,7 @@ REGISTER_WIDGET(GUI, Scrollbar) namespace GUI { -static const char* s_up_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_up_arrow_bitmap { " " " " " " @@ -24,10 +25,11 @@ static const char* s_up_arrow_bitmap_data = { " ##### " " ####### " " " - " " + " ", + 9, 9 }; -static const char* s_down_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_down_arrow_bitmap { " " " " " " @@ -36,10 +38,11 @@ static const char* s_down_arrow_bitmap_data = { " ### " " # " " " - " " + " ", + 9, 9 }; -static const char* s_left_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_left_arrow_bitmap { " " " # " " ## " @@ -48,10 +51,11 @@ static const char* s_left_arrow_bitmap_data = { " ### " " ## " " # " - " " + " ", + 9, 9 }; -static const char* s_right_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_right_arrow_bitmap { " " " # " " ## " @@ -60,26 +64,14 @@ static const char* s_right_arrow_bitmap_data = { " ### " " ## " " # " - " " + " ", + 9, 9 }; -static Gfx::CharacterBitmap* s_up_arrow_bitmap; -static Gfx::CharacterBitmap* s_down_arrow_bitmap; -static Gfx::CharacterBitmap* s_left_arrow_bitmap; -static Gfx::CharacterBitmap* s_right_arrow_bitmap; - Scrollbar::Scrollbar(Orientation orientation) : AbstractSlider(orientation) { m_automatic_scrolling_timer = add<Core::Timer>(); - if (!s_up_arrow_bitmap) - s_up_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_up_arrow_bitmap_data, 9, 9).leak_ref(); - if (!s_down_arrow_bitmap) - s_down_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_down_arrow_bitmap_data, 9, 9).leak_ref(); - if (!s_left_arrow_bitmap) - s_left_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_left_arrow_bitmap_data, 9, 9).leak_ref(); - if (!s_right_arrow_bitmap) - s_right_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref(); if (orientation == Orientation::Vertical) { set_fixed_width(16); @@ -210,15 +202,15 @@ void Scrollbar::paint_event(PaintEvent& event) if (decrement_pressed) decrement_location.translate_by(1, 1); if (!has_scrubber() || !is_enabled()) - painter.draw_bitmap(decrement_location.translated(1, 1), orientation() == Orientation::Vertical ? *s_up_arrow_bitmap : *s_left_arrow_bitmap, palette().threed_highlight()); - painter.draw_bitmap(decrement_location, orientation() == Orientation::Vertical ? *s_up_arrow_bitmap : *s_left_arrow_bitmap, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); + painter.draw_bitmap(decrement_location.translated(1, 1), orientation() == Orientation::Vertical ? s_up_arrow_bitmap : s_left_arrow_bitmap, palette().threed_highlight()); + painter.draw_bitmap(decrement_location, orientation() == Orientation::Vertical ? s_up_arrow_bitmap : s_left_arrow_bitmap, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); auto increment_location = increment_button_rect().location().translated(3, 3); if (increment_pressed) increment_location.translate_by(1, 1); if (!has_scrubber() || !is_enabled()) - painter.draw_bitmap(increment_location.translated(1, 1), orientation() == Orientation::Vertical ? *s_down_arrow_bitmap : *s_right_arrow_bitmap, palette().threed_highlight()); - painter.draw_bitmap(increment_location, orientation() == Orientation::Vertical ? *s_down_arrow_bitmap : *s_right_arrow_bitmap, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); + painter.draw_bitmap(increment_location.translated(1, 1), orientation() == Orientation::Vertical ? s_down_arrow_bitmap : s_right_arrow_bitmap, palette().threed_highlight()); + painter.draw_bitmap(increment_location, orientation() == Orientation::Vertical ? s_down_arrow_bitmap : s_right_arrow_bitmap, (has_scrubber() && is_enabled()) ? palette().button_text() : palette().threed_shadow1()); } if (has_scrubber() && !scrubber_rect().is_null()) diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index f4247715e7..ad6bddf71d 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -6,7 +6,6 @@ set(SOURCES BitmapFont.cpp BMPLoader.cpp BMPWriter.cpp - CharacterBitmap.cpp ClassicStylePainter.cpp ClassicWindowTheme.cpp Color.cpp diff --git a/Userland/Libraries/LibGfx/CharacterBitmap.cpp b/Userland/Libraries/LibGfx/CharacterBitmap.cpp deleted file mode 100644 index 5f9d2843ae..0000000000 --- a/Userland/Libraries/LibGfx/CharacterBitmap.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "CharacterBitmap.h" - -namespace Gfx { - -CharacterBitmap::CharacterBitmap(const char* ascii_data, unsigned width, unsigned height) - : m_bits(ascii_data) - , m_size(width, height) -{ -} - -CharacterBitmap::~CharacterBitmap() -{ -} - -NonnullRefPtr<CharacterBitmap> CharacterBitmap::create_from_ascii(const char* asciiData, unsigned width, unsigned height) -{ - return adopt_ref(*new CharacterBitmap(asciiData, width, height)); -} - -} diff --git a/Userland/Libraries/LibGfx/CharacterBitmap.h b/Userland/Libraries/LibGfx/CharacterBitmap.h index 26b9a0ab86..94c4da2a58 100644 --- a/Userland/Libraries/LibGfx/CharacterBitmap.h +++ b/Userland/Libraries/LibGfx/CharacterBitmap.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,26 +10,31 @@ #include "Size.h" #include <AK/RefCounted.h> #include <AK/RefPtr.h> +#include <AK/StringView.h> namespace Gfx { -class CharacterBitmap : public RefCounted<CharacterBitmap> { +class CharacterBitmap { public: - static NonnullRefPtr<CharacterBitmap> create_from_ascii(const char* asciiData, unsigned width, unsigned height); - ~CharacterBitmap(); + CharacterBitmap() = delete; + constexpr CharacterBitmap(StringView ascii_data, unsigned width, unsigned height) + : m_bits(ascii_data) + , m_size(width, height) + { + } - bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; } - const char* bits() const { return m_bits; } + constexpr ~CharacterBitmap() = default; - IntSize size() const { return m_size; } - unsigned width() const { return m_size.width(); } - unsigned height() const { return m_size.height(); } + constexpr bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; } + constexpr StringView bits() const { return m_bits; } -private: - CharacterBitmap(const char* b, unsigned w, unsigned h); + constexpr IntSize size() const { return m_size; } + constexpr unsigned width() const { return m_size.width(); } + constexpr unsigned height() const { return m_size.height(); } - const char* m_bits { nullptr }; - IntSize m_size; +private: + StringView m_bits {}; + IntSize m_size {}; }; } diff --git a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp index 7416f290d6..c9c178388b 100644 --- a/Userland/Libraries/LibGfx/ClassicStylePainter.cpp +++ b/Userland/Libraries/LibGfx/ClassicStylePainter.cpp @@ -2,6 +2,7 @@ * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2020, Sarah Taube <metalflakecobaltpaint@gmail.com> * Copyright (c) 2021, Filiph Sandström <filiph.sandstrom@filfatstudios.com> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -391,7 +392,7 @@ void ClassicStylePainter::paint_radio_button(Painter& painter, IntRect const& re painter.blit(rect.location(), bitmap, bitmap.rect()); } -static char const* s_checked_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_checked_bitmap { " " " # " " ## " @@ -400,13 +401,10 @@ static char const* s_checked_bitmap_data = { " ##### " " ### " " # " - " " + " ", + 9, 9 }; -static Gfx::CharacterBitmap* s_checked_bitmap; -static int const s_checked_bitmap_width = 9; -static int const s_checked_bitmap_height = 9; - void ClassicStylePainter::paint_check_box(Painter& painter, IntRect const& rect, Palette const& palette, bool is_enabled, bool is_checked, bool is_being_pressed) { painter.fill_rect(rect, is_enabled ? palette.base() : palette.window()); @@ -418,9 +416,7 @@ void ClassicStylePainter::paint_check_box(Painter& painter, IntRect const& rect, } if (is_checked) { - 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(); - painter.draw_bitmap(rect.shrunken(4, 4).location(), *s_checked_bitmap, is_enabled ? palette.base_text() : palette.threed_shadow1()); + painter.draw_bitmap(rect.shrunken(4, 4).location(), s_checked_bitmap, is_enabled ? palette.base_text() : palette.threed_shadow1()); } } diff --git a/Userland/Services/WindowServer/Menu.cpp b/Userland/Services/WindowServer/Menu.cpp index 63af0b4130..fae82b482b 100644 --- a/Userland/Services/WindowServer/Menu.cpp +++ b/Userland/Services/WindowServer/Menu.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> * Copyright (c) 2020, Shannon Booth <shannon.ml.booth@gmail.com> + * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -55,7 +56,7 @@ const Gfx::Font& Menu::font() const return Gfx::FontDatabase::default_font(); } -static const char* s_submenu_arrow_bitmap_data = { +static constexpr Gfx::CharacterBitmap s_submenu_arrow_bitmap { " " " # " " ## " @@ -64,13 +65,12 @@ static const char* s_submenu_arrow_bitmap_data = { " ### " " ## " " # " - " " + " ", + 9, 9 }; -static const int s_submenu_arrow_bitmap_width = 9; -static const int s_submenu_arrow_bitmap_height = 9; -static const int s_item_icon_width = 16; -static const int s_stripe_width = 24; +static constexpr int s_item_icon_width = 16; +static constexpr int s_stripe_width = 24; int Menu::content_width() const { @@ -269,15 +269,14 @@ void Menu::draw(MenuItem const& item, bool is_drawing_all) } painter.set_font(previous_font); if (item.is_submenu()) { - static auto& submenu_arrow_bitmap = Gfx::CharacterBitmap::create_from_ascii(s_submenu_arrow_bitmap_data, s_submenu_arrow_bitmap_width, s_submenu_arrow_bitmap_height).leak_ref(); Gfx::IntRect submenu_arrow_rect { - item.rect().right() - s_submenu_arrow_bitmap_width - 2, + item.rect().right() - static_cast<int>(s_submenu_arrow_bitmap.width()) - 2, 0, - s_submenu_arrow_bitmap_width, - s_submenu_arrow_bitmap_height + s_submenu_arrow_bitmap.width(), + s_submenu_arrow_bitmap.height() }; submenu_arrow_rect.center_vertically_within(item.rect()); - painter.draw_bitmap(submenu_arrow_rect.location(), submenu_arrow_bitmap, text_color); + painter.draw_bitmap(submenu_arrow_rect.location(), s_submenu_arrow_bitmap, text_color); } } else if (item.type() == MenuItem::Separator) { Gfx::IntPoint p1(item.rect().translated(stripe_rect.width() + 4, 0).x(), item.rect().center().y() - 1); |