Skip to content

Commit

Permalink
Rename Painter::set_clip_rect() to add_clip_rect().
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awesomekling committed Mar 29, 2019
1 parent 474340b commit f249c40
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Applications/ProcessManager/MemoryStatsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
2 changes: 1 addition & 1 deletion LibGUI/GButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion LibGUI/GCheckBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion LibGUI/GFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions LibGUI/GItemView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion LibGUI/GLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion LibGUI/GListBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions LibGUI/GProgressBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion LibGUI/GScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion LibGUI/GStatusBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
4 changes: 2 additions & 2 deletions LibGUI/GTableView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions LibGUI/GTextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions LibGUI/GTextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()};
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions LibGUI/GToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SeparatorWidget final : public GWidget {
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);
Expand All @@ -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());
}
4 changes: 2 additions & 2 deletions LibGUI/GTreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
4 changes: 2 additions & 2 deletions Servers/WindowServer/WSWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion SharedGraphics/Painter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion SharedGraphics/Painter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Painter {
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; }

Expand Down

0 comments on commit f249c40

Please sign in to comment.