mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:55:06 +00:00
Rename Painter::set_clip_rect() to add_clip_rect().
It was confusing to see multiple calls to set_foo() in a row. Since this is an intersecting operation, let's call it add_clip_rect() instead.
This commit is contained in:
parent
474340b9cd
commit
f249c40aaa
18 changed files with 28 additions and 28 deletions
|
@ -105,6 +105,6 @@ void MemoryStatsWidget::timer_event(GTimerEvent&)
|
|||
void MemoryStatsWidget::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
StylePainter::the().paint_surface(painter, rect());
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ void GButton::set_caption(const String& caption)
|
|||
void GButton::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
StylePainter::the().paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ void GCheckBox::set_checked(bool b)
|
|||
void GCheckBox::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
auto text_rect = rect();
|
||||
text_rect.set_left(s_box_width + 4);
|
||||
|
|
|
@ -17,7 +17,7 @@ void GFrame::paint_event(GPaintEvent& event)
|
|||
return;
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
Color top_left_color;
|
||||
Color bottom_right_color;
|
||||
|
|
|
@ -99,8 +99,8 @@ void GItemView::paint_event(GPaintEvent& event)
|
|||
GFrame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(widget_inner_rect());
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(widget_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::White);
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ void GLabel::paint_event(GPaintEvent& event)
|
|||
GFrame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
if (m_icon) {
|
||||
if (m_should_stretch_icon) {
|
||||
|
|
|
@ -20,7 +20,7 @@ Rect GListBox::item_rect(int index) const
|
|||
void GListBox::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
painter.fill_rect({ rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2 }, background_color());
|
||||
painter.draw_rect(rect(), foreground_color());
|
||||
|
|
|
@ -39,8 +39,8 @@ void GProgressBar::paint_event(GPaintEvent& event)
|
|||
|
||||
GPainter painter(*this);
|
||||
auto rect = frame_inner_rect();
|
||||
painter.set_clip_rect(rect);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(rect);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
// First we fill the entire widget with the gradient. This incurs a bit of
|
||||
// overdraw but ensures a consistent look throughout the progression.
|
||||
|
@ -69,7 +69,7 @@ void GProgressBar::paint_event(GPaintEvent& event)
|
|||
// We draw the text a third time, clipped and inverse, for sharp contrast.
|
||||
float progress_width = progress * width();
|
||||
Rect hole_rect { (int)progress_width, 0, (int)(width() - progress_width), height() };
|
||||
painter.set_clip_rect(hole_rect);
|
||||
painter.add_clip_rect(hole_rect);
|
||||
painter.fill_rect(hole_rect, Color::White);
|
||||
painter.draw_text(rect.translated(0, 0), progress_text, TextAlignment::Center, Color::Black);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ Rect GScrollBar::scrubber_rect() const
|
|||
void GScrollBar::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
painter.fill_rect(rect(), Color::from_rgb(0xd6d2ce));
|
||||
|
||||
|
|
|
@ -35,6 +35,6 @@ String GStatusBar::text() const
|
|||
void GStatusBar::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
StylePainter::the().paint_surface(painter, rect(), !spans_entire_window_horizontally());
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
GFrame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(frame_inner_rect());
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.save();
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ Point GTextBox::cursor_content_position() const
|
|||
void GTextBox::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
painter.fill_rect(rect().shrunken(2, 2), background_color());
|
||||
painter.draw_rect(rect(), foreground_color());
|
||||
|
@ -85,7 +85,7 @@ void GTextBox::paint_event(GPaintEvent& event)
|
|||
Rect inner_rect = rect();
|
||||
inner_rect.shrink(6, 6);
|
||||
|
||||
painter.set_clip_rect(inner_rect);
|
||||
painter.add_clip_rect(inner_rect);
|
||||
painter.translate(-m_scroll_offset, 0);
|
||||
|
||||
int space_width = font().glyph_width(' ') + font().glyph_spacing();
|
||||
|
|
|
@ -153,8 +153,8 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
GFrame::paint_event(event);
|
||||
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(widget_inner_rect());
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(widget_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::White);
|
||||
|
||||
Rect ruler_rect { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar()};
|
||||
|
@ -189,7 +189,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
painter.set_clip_rect({ m_ruler_visible ? (ruler_rect.right() + 1) : 0, 0, width() - width_occupied_by_vertical_scrollbar() - ruler_width(), height() - height_occupied_by_horizontal_scrollbar() });
|
||||
painter.add_clip_rect({ m_ruler_visible ? (ruler_rect.right() + 1) : 0, 0, width() - width_occupied_by_vertical_scrollbar() - ruler_width(), height() - height_occupied_by_horizontal_scrollbar() });
|
||||
|
||||
for (int i = first_visible_line; i <= last_visible_line; ++i) {
|
||||
auto& line = *m_lines[i];
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
virtual void paint_event(GPaintEvent& event) override
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.translate(rect().center().x() - 1, 0);
|
||||
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, Color::MidGray);
|
||||
painter.draw_line({ 1, 0 }, { 1, rect().bottom() }, Color::White);
|
||||
|
@ -78,6 +78,6 @@ void GToolBar::add_separator()
|
|||
void GToolBar::paint_event(GPaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
StylePainter::the().paint_surface(painter, rect(), !spans_entire_window_horizontally());
|
||||
}
|
||||
|
|
|
@ -184,8 +184,8 @@ void GTreeView::paint_event(GPaintEvent& event)
|
|||
{
|
||||
GFrame::paint_event(event);
|
||||
GPainter painter(*this);
|
||||
painter.set_clip_rect(frame_inner_rect());
|
||||
painter.set_clip_rect(event.rect());
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::White);
|
||||
painter.translate(frame_inner_rect().location());
|
||||
|
||||
|
|
|
@ -952,12 +952,12 @@ void WSWindowManager::compose()
|
|||
if (!any_dirty_rect_intersects_window(window))
|
||||
return IterationDecision::Continue;
|
||||
PainterStateSaver saver(*m_back_painter);
|
||||
m_back_painter->set_clip_rect(outer_window_rect(window));
|
||||
m_back_painter->add_clip_rect(outer_window_rect(window));
|
||||
for (auto& dirty_rect : dirty_rects.rects()) {
|
||||
if (any_opaque_window_above_this_one_contains_rect(window, dirty_rect))
|
||||
continue;
|
||||
PainterStateSaver saver(*m_back_painter);
|
||||
m_back_painter->set_clip_rect(dirty_rect);
|
||||
m_back_painter->add_clip_rect(dirty_rect);
|
||||
paint_window_frame(window);
|
||||
if (!backing_store)
|
||||
continue;
|
||||
|
|
|
@ -489,7 +489,7 @@ void Painter::draw_focus_rect(const Rect& rect)
|
|||
draw_rect(focus_rect, Color::from_rgb(0x84351a));
|
||||
}
|
||||
|
||||
void Painter::set_clip_rect(const Rect& rect)
|
||||
void Painter::add_clip_rect(const Rect& rect)
|
||||
{
|
||||
state().clip_rect.intersect(rect.translated(m_clip_origin.location()));
|
||||
state().clip_rect.intersect(m_target->rect());
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void set_draw_op(DrawOp op) { state().draw_op = op; }
|
||||
DrawOp draw_op() const { return state().draw_op; }
|
||||
|
||||
void set_clip_rect(const Rect& rect);
|
||||
void add_clip_rect(const Rect& rect);
|
||||
void clear_clip_rect();
|
||||
Rect clip_rect() const { return state().clip_rect; }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue