1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 10:14:58 +00:00

SharedGraphics: Add some useful painting helpers and make use of them.

This commit is contained in:
Andreas Kling 2019-02-05 11:42:35 +01:00
parent b782055b96
commit 38f589a9cb
6 changed files with 38 additions and 22 deletions

View file

@ -28,15 +28,11 @@ void GButton::paint_event(GPaintEvent&)
Color shadow_color = Color(96, 96, 96);
Painter painter(*this);
painter.draw_line({ 1, 0 }, { width() - 2, 0 }, Color::Black);
painter.draw_line({ 1, height() - 1 }, { width() - 2, height() - 1}, Color::Black);
painter.draw_line({ 0, 1 }, { 0, height() - 2 }, Color::Black);
painter.draw_line({ width() - 1, 1 }, { width() - 1, height() - 2 }, Color::Black);
painter.draw_rect(rect(), Color::Black, true);
if (m_being_pressed) {
// Base
painter.fill_rect({ 1, 1, width() - 2, height() - 2 }, button_color);
painter.fill_rect(rect().shrunken(2, 2), button_color);
// Sunken shadow
painter.draw_line({ 1, 1 }, { width() - 2, 1 }, shadow_color);