mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 07:38:10 +00:00
LibGfx+Everywhere: Change Gfx::Rect
to be endpoint exclusive
Previously, calling `.right()` on a `Gfx::Rect` would return the last column's coordinate still inside the rectangle, or `left + width - 1`. This is called 'endpoint inclusive' and does not make a lot of sense for `Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would return 4 as its right side. This same problem exists for `.bottom()`. This changes `Gfx::Rect` to be endpoint exclusive, which gives us the nice property that `width = right - left` and `height = bottom - top`. It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly the same. All users of `Gfx::Rect` have been updated accordingly.
This commit is contained in:
parent
b7f4363791
commit
f391ccfe53
88 changed files with 524 additions and 518 deletions
|
@ -105,7 +105,7 @@ void AbstractScrollableWidget::custom_layout()
|
|||
{
|
||||
int vertical_scrollbar_width = m_vertical_scrollbar->effective_min_size().width().as_int();
|
||||
m_vertical_scrollbar->set_relative_rect(
|
||||
inner_rect.right() + 1 - vertical_scrollbar_width,
|
||||
inner_rect.right() - vertical_scrollbar_width,
|
||||
inner_rect.top() + height_wanted_by_banner_widget,
|
||||
vertical_scrollbar_width,
|
||||
inner_rect.height() - height_wanted_by_horizontal_scrollbar - height_wanted_by_banner_widget);
|
||||
|
@ -115,14 +115,14 @@ void AbstractScrollableWidget::custom_layout()
|
|||
int horizontal_scrollbar_height = m_horizontal_scrollbar->effective_min_size().height().as_int();
|
||||
m_horizontal_scrollbar->set_relative_rect(
|
||||
inner_rect.left(),
|
||||
inner_rect.bottom() + 1 - horizontal_scrollbar_height,
|
||||
inner_rect.bottom() - horizontal_scrollbar_height,
|
||||
inner_rect.width() - width_wanted_by_vertical_scrollbar,
|
||||
horizontal_scrollbar_height);
|
||||
}
|
||||
|
||||
m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible());
|
||||
if (m_corner_widget->is_visible()) {
|
||||
Gfx::IntRect corner_rect { m_horizontal_scrollbar->relative_rect().right() + 1, m_vertical_scrollbar->relative_rect().bottom() + 1, width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() };
|
||||
Gfx::IntRect corner_rect { m_horizontal_scrollbar->relative_rect().right(), m_vertical_scrollbar->relative_rect().bottom(), width_occupied_by_vertical_scrollbar(), height_occupied_by_horizontal_scrollbar() };
|
||||
m_corner_widget->set_relative_rect(corner_rect);
|
||||
}
|
||||
}
|
||||
|
@ -273,18 +273,16 @@ void AbstractScrollableWidget::scroll_into_view(Gfx::IntRect const& rect, bool s
|
|||
return;
|
||||
|
||||
if (scroll_vertically) {
|
||||
if (rect.top() < visible_content_rect.top()) {
|
||||
if (rect.top() < visible_content_rect.top())
|
||||
m_vertical_scrollbar->set_value(rect.top());
|
||||
} else if (rect.top() > visible_content_rect.top() && rect.bottom() > visible_content_rect.bottom()) {
|
||||
m_vertical_scrollbar->set_value(rect.bottom() - visible_content_rect.height() + 1);
|
||||
}
|
||||
else if (rect.top() > visible_content_rect.top() && rect.bottom() > visible_content_rect.bottom())
|
||||
m_vertical_scrollbar->set_value(rect.bottom() - visible_content_rect.height());
|
||||
}
|
||||
if (scroll_horizontally) {
|
||||
if (rect.left() < visible_content_rect.left()) {
|
||||
if (rect.left() < visible_content_rect.left())
|
||||
m_horizontal_scrollbar->set_value(rect.left());
|
||||
} else if (rect.left() > visible_content_rect.left() && rect.right() > visible_content_rect.right()) {
|
||||
m_horizontal_scrollbar->set_value(rect.right() - visible_content_rect.width() + 1);
|
||||
}
|
||||
else if (rect.left() > visible_content_rect.left() && rect.right() > visible_content_rect.right())
|
||||
m_horizontal_scrollbar->set_value(rect.right() - visible_content_rect.width());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ void AbstractThemePreview::paint_window(StringView title, Gfx::IntRect const& re
|
|||
int window_button_width = m_preview_palette.window_title_button_width();
|
||||
int window_button_height = m_preview_palette.window_title_button_height();
|
||||
auto titlebar_text_rect = Gfx::WindowTheme::current().titlebar_text_rect(Gfx::WindowTheme::WindowType::Normal, Gfx::WindowTheme::WindowMode::Other, rect, m_preview_palette);
|
||||
int pos = titlebar_text_rect.right() + 1;
|
||||
int pos = titlebar_text_rect.right();
|
||||
|
||||
Array possible_buttons {
|
||||
Button { {}, m_close_bitmap.is_null() ? m_default_close_bitmap : m_close_bitmap },
|
||||
|
|
|
@ -222,7 +222,7 @@ void Button::set_menu(RefPtr<GUI::Menu> menu)
|
|||
void Button::mousedown_event(MouseEvent& event)
|
||||
{
|
||||
if (m_menu) {
|
||||
m_menu->popup(screen_relative_rect().bottom_left(), {}, rect());
|
||||
m_menu->popup(screen_relative_rect().bottom_left().moved_up(1), {}, rect());
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ void CheckBox::paint_event(PaintEvent& event)
|
|||
auto box_rect = this->box_rect();
|
||||
auto text_rect = rect();
|
||||
if (m_checkbox_position == CheckBoxPosition::Left)
|
||||
text_rect.set_left(box_rect.right() + 1 + gap_between_box_and_rect());
|
||||
text_rect.set_left(box_rect.right() + gap_between_box_and_rect());
|
||||
text_rect.set_width(font().width_rounded_up(text()));
|
||||
text_rect.set_top(height() / 2 - font().pixel_size_rounded_up() / 2);
|
||||
text_rect.set_height(font().pixel_size_rounded_up());
|
||||
|
|
|
@ -80,8 +80,8 @@ void ColumnsView::second_paint_event(PaintEvent& event)
|
|||
auto column_right = column_x + m_rubber_band_origin_column.width;
|
||||
|
||||
// The rubber band rect always stays inside the widget inner rect, the vertical component is handled by mousemove
|
||||
auto rubber_band_left = clamp(column_left, widget_inner_rect().left(), widget_inner_rect().right() + 1);
|
||||
auto rubber_band_right = clamp(column_right, widget_inner_rect().left(), widget_inner_rect().right() + 1);
|
||||
auto rubber_band_left = clamp(column_left, widget_inner_rect().left(), widget_inner_rect().right());
|
||||
auto rubber_band_right = clamp(column_right, widget_inner_rect().left(), widget_inner_rect().right());
|
||||
|
||||
auto rubber_band_rect = Gfx::IntRect::from_two_points({ rubber_band_left, m_rubber_band_origin }, { rubber_band_right, m_rubber_band_current });
|
||||
|
||||
|
@ -155,7 +155,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
Gfx::IntRect text_rect = {
|
||||
icon_rect.right() + 1 + icon_spacing(), row * item_height(),
|
||||
icon_rect.right() + icon_spacing(), row * item_height(),
|
||||
column.width - icon_spacing() - icon_size() - icon_spacing() - icon_spacing() - static_cast<int>(s_arrow_bitmap.width()) - icon_spacing(), item_height()
|
||||
};
|
||||
draw_item_text(painter, index, is_selected_row, text_rect, index.data().to_deprecated_string(), font_for_index(index), Gfx::TextAlignment::CenterLeft, Gfx::TextElision::None);
|
||||
|
@ -172,7 +172,7 @@ void ColumnsView::paint_event(PaintEvent& event)
|
|||
bool expandable = model()->row_count(index) > 0;
|
||||
if (expandable) {
|
||||
Gfx::IntRect arrow_rect = {
|
||||
text_rect.right() + 1 + icon_spacing(), 0,
|
||||
text_rect.right() + icon_spacing(), 0,
|
||||
s_arrow_bitmap.width(), s_arrow_bitmap.height()
|
||||
};
|
||||
arrow_rect.center_vertically_within(row_rect);
|
||||
|
@ -339,7 +339,7 @@ void ColumnsView::mousedown_event(MouseEvent& event)
|
|||
void ColumnsView::mousemove_event(MouseEvent& event)
|
||||
{
|
||||
if (m_rubber_banding) {
|
||||
m_rubber_band_current = clamp(event.position().y(), widget_inner_rect().top(), widget_inner_rect().bottom() + 1);
|
||||
m_rubber_band_current = clamp(event.position().y(), widget_inner_rect().top(), widget_inner_rect().bottom());
|
||||
|
||||
auto parent = m_rubber_band_origin_column.parent_index;
|
||||
int row_count = model()->row_count(parent);
|
||||
|
|
|
@ -246,11 +246,11 @@ void ComboBox::open()
|
|||
auto max_height = min(m_list_view->item_height() * m_max_visible_items, m_list_view->content_height());
|
||||
auto min_width = m_list_view->content_width() + frame;
|
||||
Gfx::IntSize size { max(width(), min_width), max_height + frame };
|
||||
Gfx::IntRect rect { screen_relative_rect().bottom_left(), size };
|
||||
Gfx::IntRect rect { screen_relative_rect().bottom_left().moved_up(1), size };
|
||||
|
||||
auto desktop = Desktop::the().rect();
|
||||
auto min_height = 5 * m_list_view->item_height() + frame;
|
||||
auto go_upwards_instead = rect.bottom() >= desktop.height() && rect.intersected(desktop).height() < min_height;
|
||||
auto go_upwards_instead = rect.bottom() - 1 >= desktop.height() && rect.intersected(desktop).height() < min_height;
|
||||
if (go_upwards_instead) {
|
||||
auto origin = screen_relative_rect().top_left();
|
||||
rect = { Gfx::IntPoint { origin.x(), origin.y() - size.height() }, size };
|
||||
|
|
|
@ -81,8 +81,8 @@ HeaderView::VisibleSectionRange HeaderView::visible_section_range() const
|
|||
auto section_count = this->section_count();
|
||||
auto is_horizontal = m_orientation == Orientation::Horizontal;
|
||||
auto rect = m_table_view.visible_content_rect();
|
||||
auto start = is_horizontal ? rect.top_left().x() : rect.top_left().y();
|
||||
auto end = is_horizontal ? (rect.top_left().x() + m_table_view.content_width()) : rect.bottom_left().y();
|
||||
auto start = is_horizontal ? rect.left() : rect.top();
|
||||
auto end = is_horizontal ? (rect.left() + m_table_view.content_width()) : rect.bottom() - 1;
|
||||
auto offset = 0;
|
||||
VisibleSectionRange range;
|
||||
for (; range.end < section_count; ++range.end) {
|
||||
|
@ -113,7 +113,7 @@ Gfx::IntRect HeaderView::section_resize_grabbable_rect(int section) const
|
|||
if (m_orientation == Gfx::Orientation::Vertical)
|
||||
return {};
|
||||
auto rect = section_rect(section);
|
||||
return { rect.right() - 1, rect.top(), 4, rect.height() };
|
||||
return { rect.right() - 2, rect.top(), 4, rect.height() };
|
||||
}
|
||||
|
||||
int HeaderView::section_count() const
|
||||
|
@ -250,8 +250,8 @@ void HeaderView::mouseup_event(MouseEvent& event)
|
|||
|
||||
void HeaderView::paint_horizontal(Painter& painter)
|
||||
{
|
||||
painter.draw_line({ 0, 0 }, { rect().right(), 0 }, palette().threed_highlight());
|
||||
painter.draw_line({ 0, rect().bottom() }, { rect().right(), rect().bottom() }, palette().threed_shadow1());
|
||||
painter.draw_line({ 0, 0 }, { rect().right() - 1, 0 }, palette().threed_highlight());
|
||||
painter.draw_line({ 0, rect().bottom() - 1 }, { rect().right() - 1, rect().bottom() - 1 }, palette().threed_shadow1());
|
||||
auto range = visible_section_range();
|
||||
int x_offset = range.start_offset;
|
||||
for (int section = range.start; section < range.end; ++section) {
|
||||
|
@ -283,7 +283,7 @@ void HeaderView::paint_horizontal(Painter& painter)
|
|||
x_offset += section_width + m_table_view.horizontal_padding() * 2;
|
||||
}
|
||||
|
||||
if (x_offset < rect().right()) {
|
||||
if (x_offset < rect().right() - 1) {
|
||||
Gfx::IntRect cell_rect(x_offset, 0, width() - x_offset, height());
|
||||
Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, false, false);
|
||||
}
|
||||
|
@ -291,8 +291,8 @@ void HeaderView::paint_horizontal(Painter& painter)
|
|||
|
||||
void HeaderView::paint_vertical(Painter& painter)
|
||||
{
|
||||
painter.draw_line(rect().top_left(), rect().bottom_left(), palette().threed_highlight());
|
||||
painter.draw_line(rect().top_right(), rect().bottom_right(), palette().threed_shadow1());
|
||||
painter.draw_line(rect().top_left(), rect().bottom_left().moved_up(1), palette().threed_highlight());
|
||||
painter.draw_line(rect().top_right().moved_left(1), rect().bottom_right().translated(-1), palette().threed_shadow1());
|
||||
auto range = visible_section_range();
|
||||
int y_offset = range.start_offset;
|
||||
for (int section = range.start; section < range.end; ++section) {
|
||||
|
@ -312,7 +312,7 @@ void HeaderView::paint_vertical(Painter& painter)
|
|||
y_offset += section_size;
|
||||
}
|
||||
|
||||
if (y_offset < rect().bottom()) {
|
||||
if (y_offset < rect().bottom() - 1) {
|
||||
Gfx::IntRect cell_rect(0, y_offset, width(), height() - y_offset);
|
||||
Gfx::StylePainter::paint_button(painter, cell_rect, palette(), Gfx::ButtonStyle::Normal, false, false);
|
||||
}
|
||||
|
|
|
@ -431,7 +431,7 @@ void IconView::get_item_rects(int item_index, ItemData& item_data, Gfx::Font con
|
|||
int unwrapped_text_width = font.width_rounded_up(item_data.text);
|
||||
int available_width = item_rect.width() - 6;
|
||||
|
||||
item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6 + 1, 0, font.pixel_size_rounded_up() };
|
||||
item_data.text_rect = { 0, item_data.icon_rect.bottom() + 6, 0, font.pixel_size_rounded_up() };
|
||||
item_data.wrapped_text_lines.clear();
|
||||
|
||||
if ((unwrapped_text_width > available_width) && (item_data.selected || m_hovered_index == item_data.index || cursor_index() == item_data.index || m_always_wrap_item_labels)) {
|
||||
|
@ -789,7 +789,7 @@ inline IterationDecision IconView::for_each_item_intersecting_rect(Gfx::IntRect
|
|||
int begin_row, begin_column;
|
||||
column_row_from_content_position(rect.top_left(), begin_row, begin_column);
|
||||
int end_row, end_column;
|
||||
column_row_from_content_position(rect.bottom_right(), end_row, end_column);
|
||||
column_row_from_content_position(rect.bottom_right().translated(-1), end_row, end_column);
|
||||
|
||||
int items_per_flow_axis_step;
|
||||
int item_index;
|
||||
|
|
|
@ -118,8 +118,8 @@ void IncrementalSearchBanner::paint_event(PaintEvent& event)
|
|||
|
||||
Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.draw_line({ 0, rect().bottom() - 1 }, { width(), rect().bottom() - 1 }, palette().threed_shadow1());
|
||||
painter.draw_line({ 0, rect().bottom() }, { width(), rect().bottom() }, palette().threed_shadow2());
|
||||
painter.draw_line({ 0, rect().bottom() - 2 }, { width(), rect().bottom() - 2 }, palette().threed_shadow1());
|
||||
painter.draw_line({ 0, rect().bottom() - 1 }, { width(), rect().bottom() - 1 }, palette().threed_shadow2());
|
||||
}
|
||||
|
||||
Optional<UISize> IncrementalSearchBanner::calculated_min_size() const
|
||||
|
|
|
@ -98,7 +98,7 @@ void LinkLabel::paint_event(PaintEvent& event)
|
|||
GUI::Painter painter(*this);
|
||||
|
||||
if (m_hovered)
|
||||
painter.draw_line({ 0, rect().bottom() }, { font().width_rounded_up(text()), rect().bottom() }, palette().link());
|
||||
painter.draw_line({ 0, rect().bottom() - 1 }, { font().width_rounded_up(text()), rect().bottom() - 1 }, palette().link());
|
||||
|
||||
if (is_focused())
|
||||
painter.draw_focus_rect(text_rect(), palette().focus_outline());
|
||||
|
|
|
@ -47,16 +47,15 @@ void OpacitySlider::paint_event(PaintEvent& event)
|
|||
constexpr int notch_size = 3;
|
||||
if (orientation() == Gfx::Orientation::Horizontal) {
|
||||
int notch_y_top = inner_rect.top() + notch_size;
|
||||
int notch_y_bottom = inner_rect.bottom() - notch_size;
|
||||
int notch_y_bottom = inner_rect.bottom() - 1 - notch_size;
|
||||
int notch_x = inner_rect.left() + ((float)value() / (float)max() * (float)inner_rect.width());
|
||||
|
||||
// Top notch
|
||||
painter.set_pixel(notch_x, notch_y_top, palette().threed_shadow2());
|
||||
for (int i = notch_size; i >= 0; --i) {
|
||||
painter.set_pixel(notch_x - (i + 1), notch_y_top - i - 1, palette().threed_highlight());
|
||||
for (int j = 0; j < i * 2; ++j) {
|
||||
for (int j = 0; j < i * 2; ++j)
|
||||
painter.set_pixel(notch_x - (i + 1) + j + 1, notch_y_top - i - 1, palette().button());
|
||||
}
|
||||
painter.set_pixel(notch_x + (i + 0), notch_y_top - i - 1, palette().threed_shadow1());
|
||||
painter.set_pixel(notch_x + (i + 1), notch_y_top - i - 1, palette().threed_shadow2());
|
||||
}
|
||||
|
@ -65,9 +64,8 @@ void OpacitySlider::paint_event(PaintEvent& event)
|
|||
painter.set_pixel(notch_x, notch_y_bottom, palette().threed_shadow2());
|
||||
for (int i = 0; i < notch_size; ++i) {
|
||||
painter.set_pixel(notch_x - (i + 1), notch_y_bottom + i + 1, palette().threed_highlight());
|
||||
for (int j = 0; j < i * 2; ++j) {
|
||||
for (int j = 0; j < i * 2; ++j)
|
||||
painter.set_pixel(notch_x - (i + 1) + j + 1, notch_y_bottom + i + 1, palette().button());
|
||||
}
|
||||
painter.set_pixel(notch_x + (i + 0), notch_y_bottom + i + 1, palette().threed_shadow1());
|
||||
painter.set_pixel(notch_x + (i + 1), notch_y_bottom + i + 1, palette().threed_shadow2());
|
||||
}
|
||||
|
@ -83,16 +81,15 @@ void OpacitySlider::paint_event(PaintEvent& event)
|
|||
painter.draw_line({ notch_x - 1, notch_y_top }, { notch_x - 1, notch_y_bottom }, Color(h, h, h, 255));
|
||||
} else {
|
||||
int notch_x_left = inner_rect.left() + notch_size;
|
||||
int notch_x_right = inner_rect.right() - notch_size;
|
||||
int notch_x_right = inner_rect.right() - 1 - notch_size;
|
||||
int notch_y = inner_rect.top() + ((float)value() / (float)max() * (float)inner_rect.height());
|
||||
|
||||
// Left notch
|
||||
painter.set_pixel(notch_x_left, notch_y, palette().threed_shadow2());
|
||||
for (int i = notch_size; i >= 0; --i) {
|
||||
painter.set_pixel(notch_x_left - i - 1, notch_y - (i + 1), palette().threed_highlight());
|
||||
for (int j = 0; j < i * 2; ++j) {
|
||||
for (int j = 0; j < i * 2; ++j)
|
||||
painter.set_pixel(notch_x_left - i - 1, notch_y - (i + 1) + j + 1, palette().button());
|
||||
}
|
||||
painter.set_pixel(notch_x_left - i - 1, notch_y + (i + 0), palette().threed_shadow1());
|
||||
painter.set_pixel(notch_x_left - i - 1, notch_y + (i + 1), palette().threed_shadow2());
|
||||
}
|
||||
|
@ -101,9 +98,8 @@ void OpacitySlider::paint_event(PaintEvent& event)
|
|||
painter.set_pixel(notch_x_right, notch_y, palette().threed_shadow2());
|
||||
for (int i = 0; i < notch_size; ++i) {
|
||||
painter.set_pixel(notch_x_right + i + 1, notch_y - (i + 1), palette().threed_highlight());
|
||||
for (int j = 0; j < i * 2; ++j) {
|
||||
for (int j = 0; j < i * 2; ++j)
|
||||
painter.set_pixel(notch_x_right + i + 1, notch_y - (i + 1) + j + 1, palette().button());
|
||||
}
|
||||
painter.set_pixel(notch_x_right + i + 1, notch_y + (i + 0), palette().threed_shadow1());
|
||||
painter.set_pixel(notch_x_right + i + 1, notch_y + (i + 1), palette().threed_shadow2());
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ void RadioButton::paint_event(PaintEvent& event)
|
|||
|
||||
Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed());
|
||||
|
||||
Gfx::IntRect text_rect { circle_rect.right() + 5 + horizontal_padding(), 0, font().width_rounded_up(text()), font().pixel_size_rounded_up() };
|
||||
Gfx::IntRect text_rect { circle_rect.right() + 4 + horizontal_padding(), 0, font().width_rounded_up(text()), font().pixel_size_rounded_up() };
|
||||
text_rect.center_vertically_within(rect());
|
||||
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
|
||||
|
||||
|
|
|
@ -179,21 +179,21 @@ void Scrollbar::paint_event(PaintEvent& event)
|
|||
Gfx::IntRect rect_to_fill = rect();
|
||||
if (orientation() == Orientation::Vertical) {
|
||||
if (m_gutter_click_state == GutterClickState::BeforeScrubber) {
|
||||
rect_to_fill.set_top(decrement_button_rect().bottom());
|
||||
rect_to_fill.set_bottom(scrubber_rect().top());
|
||||
rect_to_fill.set_top(decrement_button_rect().bottom() - 1);
|
||||
rect_to_fill.set_bottom(scrubber_rect().top() + 1);
|
||||
} else {
|
||||
VERIFY(m_gutter_click_state == GutterClickState::AfterScrubber);
|
||||
rect_to_fill.set_top(scrubber_rect().bottom());
|
||||
rect_to_fill.set_bottom(increment_button_rect().top());
|
||||
rect_to_fill.set_top(scrubber_rect().bottom() - 1);
|
||||
rect_to_fill.set_bottom(increment_button_rect().top() + 1);
|
||||
}
|
||||
} else {
|
||||
if (m_gutter_click_state == GutterClickState::BeforeScrubber) {
|
||||
rect_to_fill.set_left(decrement_button_rect().right());
|
||||
rect_to_fill.set_right(scrubber_rect().left());
|
||||
rect_to_fill.set_left(decrement_button_rect().right() - 1);
|
||||
rect_to_fill.set_right(scrubber_rect().left() + 1);
|
||||
} else {
|
||||
VERIFY(m_gutter_click_state == GutterClickState::AfterScrubber);
|
||||
rect_to_fill.set_left(scrubber_rect().right());
|
||||
rect_to_fill.set_right(increment_button_rect().left());
|
||||
rect_to_fill.set_left(scrubber_rect().right() - 1);
|
||||
rect_to_fill.set_right(increment_button_rect().left() + 1);
|
||||
}
|
||||
}
|
||||
painter.fill_rect_with_dither_pattern(rect_to_fill, palette().button(), palette().button().lightened(0.77f));
|
||||
|
|
|
@ -29,12 +29,12 @@ void SeparatorWidget::paint_event(PaintEvent& event)
|
|||
|
||||
if (m_orientation == Gfx::Orientation::Vertical) {
|
||||
painter.translate(rect().center().x() - 1, 0);
|
||||
painter.draw_line({ 0, 0 }, { 0, rect().bottom() }, palette().threed_shadow1());
|
||||
painter.draw_line({ 1, 0 }, { 1, rect().bottom() }, palette().threed_highlight());
|
||||
painter.draw_line({ 0, 0 }, { 0, rect().bottom() - 1 }, palette().threed_shadow1());
|
||||
painter.draw_line({ 1, 0 }, { 1, rect().bottom() - 1 }, palette().threed_highlight());
|
||||
} else {
|
||||
painter.translate(0, rect().center().y() - 1);
|
||||
painter.draw_line({ 0, 0 }, { rect().right(), 0 }, palette().threed_shadow1());
|
||||
painter.draw_line({ 0, 1 }, { rect().right(), 1 }, palette().threed_highlight());
|
||||
painter.draw_line({ 0, 0 }, { rect().right() - 1, 0 }, palette().threed_shadow1());
|
||||
painter.draw_line({ 0, 1 }, { rect().right() - 1, 1 }, palette().threed_highlight());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
icon_rect.translate_by(4, (button_rect.height() / 2) - (icon_rect.height() / 2));
|
||||
|
||||
painter.draw_scaled_bitmap(icon_rect, *icon, icon->rect());
|
||||
text_rect.set_x(icon_rect.right() + 1 + 4);
|
||||
text_rect.set_x(icon_rect.right() + 4);
|
||||
text_rect.intersect(button_rect);
|
||||
};
|
||||
|
||||
|
@ -288,12 +288,12 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
|
||||
Gfx::IntRect icon_rect { close_button_rect.x() + 3, close_button_rect.y() + 3, 6, 6 };
|
||||
if (!m_tabs[i].modified) {
|
||||
painter.draw_line(icon_rect.top_left(), icon_rect.bottom_right(), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right(), icon_rect.bottom_left(), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_left(), icon_rect.bottom_right().translated(-1), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(1), icon_rect.bottom_left().moved_up(1), palette().button_text());
|
||||
} else {
|
||||
painter.draw_line(icon_rect.top_left().moved_right(1), icon_rect.bottom_right().translated(-1, -1), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(1), icon_rect.bottom_left().translated(1, -1), palette().button_text());
|
||||
painter.draw_line(icon_rect.bottom_left().moved_down(1), icon_rect.bottom_right().moved_down(1), palette().button_text(), 1, Painter::LineStyle::Dotted);
|
||||
painter.draw_line(icon_rect.top_left().moved_right(1), icon_rect.bottom_right().translated(-2), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(2), icon_rect.bottom_left().translated(1, -2), palette().button_text());
|
||||
painter.draw_line(icon_rect.bottom_left(), icon_rect.bottom_right().moved_left(1), palette().button_text(), 1, Painter::LineStyle::Dotted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -329,12 +329,12 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
if (m_tab_position == TabPosition::Top) {
|
||||
painter.draw_line(button_rect.bottom_left().translated(1, 1), button_rect.bottom_right().translated(-1, 1), palette().button());
|
||||
painter.draw_line(button_rect.bottom_left().moved_right(1), button_rect.bottom_right().translated(-2, 0), palette().button());
|
||||
} else if (m_tab_position == TabPosition::Bottom) {
|
||||
painter.set_pixel(button_rect.top_left().translated(0, -1), palette().threed_highlight());
|
||||
painter.set_pixel(button_rect.top_right().translated(-1, -1), palette().threed_shadow1());
|
||||
painter.draw_line(button_rect.top_left().translated(1, -1), button_rect.top_right().translated(-2, -1), palette().button());
|
||||
painter.draw_line(button_rect.top_left().translated(1, -2), button_rect.top_right().translated(-2, -2), palette().button());
|
||||
painter.set_pixel(button_rect.top_right().translated(-2, -1), palette().threed_shadow1());
|
||||
painter.draw_line(button_rect.top_left().translated(1, -1), button_rect.top_right().translated(-3, -1), palette().button());
|
||||
painter.draw_line(button_rect.top_left().translated(1, -2), button_rect.top_right().translated(-3, -2), palette().button());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -362,12 +362,12 @@ void TabWidget::paint_event(PaintEvent& event)
|
|||
|
||||
Gfx::IntRect icon_rect { close_button_rect.x() + 3, close_button_rect.y() + 3, 6, 6 };
|
||||
if (!m_tabs[i].modified) {
|
||||
painter.draw_line(icon_rect.top_left(), icon_rect.bottom_right(), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right(), icon_rect.bottom_left(), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_left(), icon_rect.bottom_right().translated(-1), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(1), icon_rect.bottom_left().moved_up(1), palette().button_text());
|
||||
} else {
|
||||
painter.draw_line(icon_rect.top_left().moved_right(1), icon_rect.bottom_right().translated(-1, -1), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(1), icon_rect.bottom_left().translated(1, -1), palette().button_text());
|
||||
painter.draw_line(icon_rect.bottom_left().moved_down(1), icon_rect.bottom_right().moved_down(1), palette().button_text(), 1, Painter::LineStyle::Dotted);
|
||||
painter.draw_line(icon_rect.top_left().moved_right(1), icon_rect.bottom_right().translated(-2, -2), palette().button_text());
|
||||
painter.draw_line(icon_rect.top_right().moved_left(2), icon_rect.bottom_left().moved_right(1), palette().button_text());
|
||||
painter.draw_line(icon_rect.bottom_left(), icon_rect.bottom_right().moved_left(1), palette().button_text(), 1, Painter::LineStyle::Dotted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ Gfx::IntRect TabWidget::close_button_rect(size_t index) const
|
|||
auto rect = button_rect(index);
|
||||
Gfx::IntRect close_button_rect { 0, 0, 12, 12 };
|
||||
|
||||
close_button_rect.translate_by(rect.right(), rect.top());
|
||||
close_button_rect.translate_by(rect.right() - 1, rect.top());
|
||||
close_button_rect.translate_by(-(close_button_rect.width() + 4), (rect.height() / 2) - (close_button_rect.height() / 2));
|
||||
|
||||
return close_button_rect;
|
||||
|
@ -459,9 +459,8 @@ int TabWidget::TabData::width(Gfx::Font const& font) const
|
|||
// text and the focus rect has an odd number of pixels, and this
|
||||
// causes the text (and subsequently the focus rect) to not be aligned
|
||||
// to the center perfectly.
|
||||
if (width % 2 == 0) {
|
||||
if (width % 2 == 0)
|
||||
width++;
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void TableView::paint_event(PaintEvent& event)
|
|||
|
||||
bool dummy;
|
||||
int first_visible_row = index_at_event_position(frame_inner_rect().top_left().translated(x_offset, y_offset), dummy).row();
|
||||
int last_visible_row = index_at_event_position(frame_inner_rect().bottom_right().translated(x_offset, y_offset), dummy).row();
|
||||
int last_visible_row = index_at_event_position(frame_inner_rect().bottom_right().translated(-1).translated(x_offset, y_offset), dummy).row();
|
||||
|
||||
if (first_visible_row == -1)
|
||||
first_visible_row = 0;
|
||||
|
@ -136,9 +136,9 @@ void TableView::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
if (m_grid_style == GridStyle::Horizontal || m_grid_style == GridStyle::Both)
|
||||
painter.draw_line(cell_rect_for_fill.bottom_left(), cell_rect_for_fill.bottom_right(), palette().ruler());
|
||||
painter.draw_line(cell_rect_for_fill.bottom_left().moved_up(1), cell_rect_for_fill.bottom_right().translated(-1), palette().ruler());
|
||||
if (m_grid_style == GridStyle::Vertical || m_grid_style == GridStyle::Both)
|
||||
painter.draw_line(cell_rect_for_fill.top_right(), cell_rect_for_fill.bottom_right(), palette().ruler());
|
||||
painter.draw_line(cell_rect_for_fill.top_right().moved_left(1), cell_rect_for_fill.bottom_right().translated(-1), palette().ruler());
|
||||
|
||||
if (selection_behavior() == SelectionBehavior::SelectItems && cell_index == cursor_index())
|
||||
painter.draw_rect(cell_rect_for_fill, palette().text_cursor());
|
||||
|
@ -173,7 +173,7 @@ void TableView::second_paint_event(PaintEvent& event)
|
|||
|
||||
// The rubber band rect always borders the widget inner to the left and right
|
||||
auto rubber_band_left = widget_inner_rect().left();
|
||||
auto rubber_band_right = widget_inner_rect().right() + 1;
|
||||
auto rubber_band_right = widget_inner_rect().right();
|
||||
|
||||
auto rubber_band_rect = Gfx::IntRect::from_two_points({ rubber_band_left, m_rubber_band_origin }, { rubber_band_right, m_rubber_band_current });
|
||||
|
||||
|
@ -250,7 +250,7 @@ void TableView::mousemove_event(MouseEvent& event)
|
|||
{
|
||||
if (m_rubber_banding) {
|
||||
// The rubber band rect cannot go outside the bounds of the rect enclosing all rows
|
||||
m_rubber_band_current = clamp(event.position().y(), widget_inner_rect().top() + column_header().height(), widget_inner_rect().bottom() + 1);
|
||||
m_rubber_band_current = clamp(event.position().y(), widget_inner_rect().top() + column_header().height(), widget_inner_rect().bottom());
|
||||
|
||||
int row_count = model()->row_count();
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ void PasswordBox::paint_event(PaintEvent& event)
|
|||
painter.fill_ellipse(dot_indicator_rect, icon_color);
|
||||
|
||||
Gfx::IntPoint arc_start_point { dot_indicator_rect.x() - dot_indicator_padding / 2, dot_indicator_rect.y() + dot_indicator_padding / 2 };
|
||||
Gfx::IntPoint arc_end_point = { dot_indicator_rect.top_right().x() + dot_indicator_padding / 2, dot_indicator_rect.top_right().y() + dot_indicator_padding / 2 };
|
||||
Gfx::IntPoint arc_end_point = { dot_indicator_rect.right() - 1 + dot_indicator_padding / 2, dot_indicator_rect.top() + dot_indicator_padding / 2 };
|
||||
Gfx::IntPoint arc_center_point = { dot_indicator_rect.center().x(), dot_indicator_rect.top() - dot_indicator_padding };
|
||||
painter.draw_quadratic_bezier_curve(arc_center_point, arc_start_point, arc_end_point, icon_color, 1);
|
||||
}
|
||||
|
|
|
@ -167,11 +167,11 @@ TextPosition TextEditor::text_position_at_content_position(Gfx::IntPoint content
|
|||
continue;
|
||||
|
||||
auto& rect = m_line_data[i]->visual_rect;
|
||||
if (position.y() >= rect.top() && position.y() <= rect.bottom()) {
|
||||
if (rect.contains_vertically(position.y())) {
|
||||
line_index = i;
|
||||
break;
|
||||
}
|
||||
if (position.y() > rect.bottom())
|
||||
if (position.y() >= rect.bottom())
|
||||
line_index = last_visible_line_index;
|
||||
}
|
||||
line_index = max((size_t)0, min(line_index, last_visible_line_index));
|
||||
|
@ -473,7 +473,7 @@ Gfx::IntRect TextEditor::gutter_indicator_rect(size_t line_number, int indicator
|
|||
auto gutter_rect = gutter_content_rect(line_number);
|
||||
auto indicator_size = gutter_rect.height();
|
||||
return Gfx::IntRect {
|
||||
gutter_rect.right() - static_cast<int>(lroundf(indicator_size * (indicator_position + 1.5f))),
|
||||
gutter_rect.right() - 1 - static_cast<int>(lroundf(indicator_size * (indicator_position + 1.5f))),
|
||||
gutter_rect.top(),
|
||||
indicator_size,
|
||||
indicator_size
|
||||
|
@ -538,7 +538,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
}
|
||||
if (attributes.underline_style.has_value()) {
|
||||
auto bottom_left = [&]() {
|
||||
auto point = rect.bottom_left().translated(0, 1);
|
||||
auto point = rect.bottom_left();
|
||||
|
||||
if constexpr (IsSame<RemoveCVReference<decltype(rect)>, Gfx::IntRect>)
|
||||
return point;
|
||||
|
@ -547,7 +547,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
};
|
||||
|
||||
auto bottom_right = [&]() {
|
||||
auto point = rect.bottom_right().translated(0, 1);
|
||||
auto point = rect.bottom_right().translated(-1, 0);
|
||||
|
||||
if constexpr (IsSame<RemoveCVReference<decltype(rect)>, Gfx::IntRect>)
|
||||
return point;
|
||||
|
@ -584,13 +584,13 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
auto gutter_rect = gutter_rect_in_inner_coordinates();
|
||||
painter.fill_rect(gutter_rect, palette().gutter());
|
||||
if (!m_ruler_visible)
|
||||
painter.draw_line(gutter_rect.top_right(), gutter_rect.bottom_right(), palette().gutter_border());
|
||||
painter.draw_line(gutter_rect.top_right().translated(-1, 0), gutter_rect.bottom_right().translated(-1), palette().gutter_border());
|
||||
}
|
||||
|
||||
if (m_ruler_visible) {
|
||||
auto ruler_rect = ruler_rect_in_inner_coordinates().inflated(0, folding_indicator_width(), 0, 0);
|
||||
painter.fill_rect(ruler_rect, palette().ruler());
|
||||
painter.draw_line(ruler_rect.top_right(), ruler_rect.bottom_right(), palette().ruler_border());
|
||||
painter.draw_line(ruler_rect.top_right().translated(-1, 0), ruler_rect.bottom_right().translated(-1), palette().ruler_border());
|
||||
|
||||
// Paint +/- buttons for folding regions
|
||||
for (auto const& folding_region : document().folding_regions()) {
|
||||
|
@ -606,7 +606,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
}
|
||||
|
||||
size_t first_visible_line = text_position_at(event.rect().top_left()).line();
|
||||
size_t last_visible_line = text_position_at(event.rect().bottom_right()).line();
|
||||
size_t last_visible_line = text_position_at(event.rect().bottom_right().translated(-1)).line();
|
||||
|
||||
auto selection = normalized_selection();
|
||||
bool has_selection = selection.is_valid();
|
||||
|
@ -855,7 +855,7 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
|
||||
int selection_right = selection_ends_on_current_visual_line
|
||||
? content_x_for_position({ line_index, (size_t)selection_end_column_within_line })
|
||||
: visual_line_rect.right() + 1;
|
||||
: visual_line_rect.right();
|
||||
|
||||
Gfx::IntRect selection_rect {
|
||||
selection_left,
|
||||
|
@ -1842,7 +1842,7 @@ void TextEditor::try_show_autocomplete(UserRequestedAutocomplete user_requested_
|
|||
{
|
||||
force_update_autocomplete([&, user_requested_autocomplete = move(user_requested_autocomplete)] {
|
||||
if (user_requested_autocomplete == Yes || m_autocomplete_box->has_suggestions()) {
|
||||
auto position = content_rect_for_position(cursor()).translated(0, -visible_content_rect().y()).bottom_right().translated(screen_relative_rect().top_left().translated(ruler_width(), 0).translated(10, 5));
|
||||
auto position = content_rect_for_position(cursor()).translated(0, -visible_content_rect().y()).bottom_right().translated(screen_relative_rect().top_left().translated(ruler_width(), 0).translated(9, 4));
|
||||
m_autocomplete_box->show(position);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -169,7 +169,7 @@ Optional<UISize> Toolbar::calculated_min_size() const
|
|||
ErrorOr<void> Toolbar::create_overflow_objects()
|
||||
{
|
||||
m_overflow_action = Action::create("Overflow Menu", { Mod_Ctrl | Mod_Shift, Key_O }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/overflow-menu.png"sv)), [&](auto&) {
|
||||
m_overflow_menu->popup(m_overflow_button->screen_relative_rect().bottom_left(), {}, m_overflow_button->rect());
|
||||
m_overflow_menu->popup(m_overflow_button->screen_relative_rect().bottom_left().moved_up(1), {}, m_overflow_button->rect());
|
||||
});
|
||||
m_overflow_action->set_status_tip("Show hidden toolbar actions");
|
||||
m_overflow_action->set_enabled(false);
|
||||
|
|
|
@ -31,8 +31,8 @@ void ToolbarContainer::paint_event(GUI::PaintEvent& event)
|
|||
for_each_child_widget([&](auto& widget) {
|
||||
if (widget.is_visible()) {
|
||||
auto rect = widget.relative_rect();
|
||||
painter.draw_line(rect.top_left().translated(0, -1), rect.top_right().translated(0, -1), palette().threed_highlight());
|
||||
painter.draw_line(rect.bottom_left().translated(0, 1), rect.bottom_right().translated(0, 1), palette().threed_shadow1());
|
||||
painter.draw_line(rect.top_left().moved_up(1), rect.top_right().translated(-1), palette().threed_highlight());
|
||||
painter.draw_line(rect.bottom_left(), rect.bottom_right().moved_left(1), palette().threed_shadow1());
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -82,7 +82,7 @@ void Tray::paint_event(GUI::PaintEvent& event)
|
|||
icon_rect.center_vertically_within(rect);
|
||||
|
||||
Gfx::IntRect text_rect {
|
||||
icon_rect.right() + 5,
|
||||
icon_rect.right() + 4,
|
||||
rect.y(),
|
||||
rect.width(),
|
||||
rect.height(),
|
||||
|
|
|
@ -327,7 +327,7 @@ void TreeView::paint_event(PaintEvent& event)
|
|||
Gfx::IntRect icon_rect = { rect.x(), rect.y(), icon_size(), icon_size() };
|
||||
icon_rect.center_vertically_within(rect);
|
||||
Gfx::IntRect background_rect = {
|
||||
icon_rect.right() + 1 + icon_spacing(), rect.y(),
|
||||
icon_rect.right() + icon_spacing(), rect.y(),
|
||||
min(rect.width(), column_width - indent_width) - icon_size() - icon_spacing(), rect.height()
|
||||
};
|
||||
Gfx::IntRect text_rect = background_rect.shrunken(text_padding() * 2, 0);
|
||||
|
|
|
@ -84,7 +84,7 @@ void ValueSlider::paint_event(PaintEvent& event)
|
|||
painter.fill_rect_with_gradient(m_orientation, bar_rect(), palette().inactive_window_border1(), palette().inactive_window_border2());
|
||||
|
||||
auto unfilled_rect = bar_rect();
|
||||
unfilled_rect.set_left(knob_rect().right());
|
||||
unfilled_rect.set_left(knob_rect().right() - 1);
|
||||
painter.fill_rect(unfilled_rect, palette().base());
|
||||
|
||||
Gfx::StylePainter::paint_frame(painter, bar_rect(), palette(), Gfx::FrameStyle::SunkenContainer);
|
||||
|
@ -143,7 +143,7 @@ int ValueSlider::value_at(Gfx::IntPoint position) const
|
|||
float leftmost_knob_center = (float)bar_rect().left() + (float)knob_thickness / 2;
|
||||
if (position.x() < leftmost_knob_center)
|
||||
return min();
|
||||
float rightmost_knob_center = (float)bar_rect().right() - (float)knob_thickness / 2;
|
||||
float rightmost_knob_center = (float)(bar_rect().right() - 1) - (float)knob_thickness / 2;
|
||||
if (position.x() > rightmost_knob_center)
|
||||
return max();
|
||||
float relative_offset = (float)(position.x() - leftmost_knob_center) / (rightmost_knob_center - leftmost_knob_center);
|
||||
|
|
|
@ -354,7 +354,7 @@ void Widget::handle_keydown_event(KeyEvent& event)
|
|||
}
|
||||
|
||||
if (event.key() == KeyCode::Key_Menu) {
|
||||
ContextMenuEvent c_event(window_relative_rect().bottom_right(), screen_relative_rect().bottom_right());
|
||||
ContextMenuEvent c_event(window_relative_rect().bottom_right().translated(-1), screen_relative_rect().bottom_right().translated(-1));
|
||||
dispatch_event(c_event);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue