diff --git a/Services/WindowServer/Button.cpp b/Services/WindowServer/Button.cpp index 5dd45093dd..e87e64a558 100644 --- a/Services/WindowServer/Button.cpp +++ b/Services/WindowServer/Button.cpp @@ -33,10 +33,9 @@ namespace WindowServer { -Button::Button(WindowFrame& frame, NonnullRefPtr&& bitmap, Function&& on_click_handler) +Button::Button(WindowFrame& frame, Function&& on_click_handler) : on_click(move(on_click_handler)) , m_frame(frame) - , m_bitmap(move(bitmap)) { } @@ -50,11 +49,13 @@ void Button::paint(Gfx::Painter& painter) Gfx::PainterStateSaver saver(painter); painter.translate(relative_rect().location()); Gfx::StylePainter::paint_button(painter, rect(), palette, Gfx::ButtonStyle::Normal, m_pressed, m_hovered); - auto x_location = rect().center(); - x_location.move_by(-(m_bitmap->width() / 2), -(m_bitmap->height() / 2)); - if (m_pressed) - x_location.move_by(1, 1); - painter.draw_bitmap(x_location, *m_bitmap, palette.button_text()); + + if (m_icon) { + auto icon_location = rect().center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)); + if (m_pressed) + painter.translate(1, 1); + painter.blit(icon_location, *m_icon, m_icon->rect()); + } } void Button::on_mouse_event(const MouseEvent& event) diff --git a/Services/WindowServer/Button.h b/Services/WindowServer/Button.h index 0002e92f88..7a2d6b82e9 100644 --- a/Services/WindowServer/Button.h +++ b/Services/WindowServer/Button.h @@ -27,10 +27,9 @@ #pragma once #include -#include #include -#include #include +#include namespace WindowServer { @@ -39,7 +38,7 @@ class WindowFrame; class Button : public Weakable