mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:27:43 +00:00
SharedGraphics: Add some useful painting helpers and make use of them.
This commit is contained in:
parent
b782055b96
commit
38f589a9cb
6 changed files with 38 additions and 22 deletions
|
@ -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);
|
||||
|
|
|
@ -68,17 +68,11 @@ void GCheckBox::paint_event(GPaintEvent&)
|
|||
painter.fill_rect(box_rect, Color::White);
|
||||
painter.draw_rect(box_rect, Color::Black);
|
||||
|
||||
if (m_being_modified) {
|
||||
auto modification_rect = box_rect;
|
||||
modification_rect.shrink(2, 2);
|
||||
painter.draw_rect(modification_rect, Color::MidGray);
|
||||
}
|
||||
if (m_being_modified)
|
||||
painter.draw_rect(box_rect.shrunken(2, 2), Color::MidGray);
|
||||
|
||||
if (m_checked) {
|
||||
auto bitmap_rect = box_rect;
|
||||
bitmap_rect.shrink(2, 2);
|
||||
painter.draw_bitmap(bitmap_rect.location(), *s_checked_bitmap, foreground_color());
|
||||
}
|
||||
if (m_checked)
|
||||
painter.draw_bitmap(box_rect.shrunken(2, 2).location(), *s_checked_bitmap, foreground_color());
|
||||
|
||||
if (!caption().is_empty())
|
||||
painter.draw_text(text_rect, caption(), Painter::TextAlignment::TopLeft, foreground_color());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue