mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 21:58:10 +00:00
LibGUI: Clip to paint event rect in most widgets.
This commit is contained in:
parent
737a4d2377
commit
3fe7ddadaf
5 changed files with 10 additions and 5 deletions
|
@ -22,9 +22,10 @@ void GButton::set_caption(String&& caption)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GButton::paint_event(GPaintEvent&)
|
void GButton::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
GStyle::the().paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered);
|
GStyle::the().paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered);
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,10 @@ void GCheckBox::set_checked(bool b)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCheckBox::paint_event(GPaintEvent&)
|
void GCheckBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
auto text_rect = rect();
|
auto text_rect = rect();
|
||||||
text_rect.set_left(s_box_width + 4);
|
text_rect.set_left(s_box_width + 4);
|
||||||
|
|
|
@ -24,9 +24,10 @@ void GLabel::set_text(String&& text)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLabel::paint_event(GPaintEvent&)
|
void GLabel::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
|
painter.set_clip_rect(event.rect());
|
||||||
if (fill_with_background_color())
|
if (fill_with_background_color())
|
||||||
painter.fill_rect({ 0, 0, width(), height() }, background_color());
|
painter.fill_rect({ 0, 0, width(), height() }, background_color());
|
||||||
if (m_icon) {
|
if (m_icon) {
|
||||||
|
|
|
@ -17,9 +17,10 @@ Rect GListBox::item_rect(int index) const
|
||||||
return Rect { 2, 2 + (index * item_height), width() - 4, item_height };
|
return Rect { 2, 2 + (index * item_height), width() - 4, item_height };
|
||||||
}
|
}
|
||||||
|
|
||||||
void GListBox::paint_event(GPaintEvent&)
|
void GListBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
||||||
painter.draw_rect(rect(), foreground_color());
|
painter.draw_rect(rect(), foreground_color());
|
||||||
|
|
|
@ -22,9 +22,10 @@ void GTextBox::set_text(String&& text)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTextBox::paint_event(GPaintEvent&)
|
void GTextBox::paint_event(GPaintEvent& event)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
|
painter.set_clip_rect(event.rect());
|
||||||
|
|
||||||
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
||||||
painter.draw_rect(rect(), foreground_color());
|
painter.draw_rect(rect(), foreground_color());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue