1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:57:34 +00:00

LibGfx: Unpublish Gfx::Rect from global namespace

This commit is contained in:
Andreas Kling 2020-02-06 13:02:38 +01:00
parent c39d44fc2e
commit 20cfd2a6bf
78 changed files with 262 additions and 260 deletions

View file

@ -56,7 +56,7 @@ int main(int argc, char** argv)
auto window = GUI::Window::construct();
window->set_title("About SerenityOS");
Rect window_rect { 0, 0, 240, 180 };
Gfx::Rect window_rect { 0, 0, 240, 180 };
window_rect.center_within(GUI::Desktop::the().rect());
window->set_resizable(false);
window->set_rect(window_rect);

View file

@ -70,7 +70,7 @@ void GlyphEditorWidget::paint_event(GUI::PaintEvent& event)
for (int y = 0; y < font().glyph_height(); ++y) {
for (int x = 0; x < font().max_glyph_width(); ++x) {
Rect rect { x * m_scale, y * m_scale, m_scale, m_scale };
Gfx::Rect rect { x * m_scale, y * m_scale, m_scale, m_scale };
if (x >= font().glyph_width(m_glyph)) {
painter.fill_rect(rect, Color::MidGray);
} else {

View file

@ -62,11 +62,11 @@ void GlyphMapWidget::set_selected_glyph(u8 glyph)
update();
}
Rect GlyphMapWidget::get_outer_rect(u8 glyph) const
Gfx::Rect GlyphMapWidget::get_outer_rect(u8 glyph) const
{
int row = glyph / columns();
int column = glyph % columns();
return Rect {
return Gfx::Rect {
column * (font().max_glyph_width() + m_horizontal_spacing) + 1,
row * (font().glyph_height() + m_vertical_spacing) + 1,
font().max_glyph_width() + m_horizontal_spacing,
@ -94,8 +94,8 @@ void GlyphMapWidget::paint_event(GUI::PaintEvent& event)
for (int row = 0; row < rows(); ++row) {
for (int column = 0; column < columns(); ++column, ++glyph) {
Rect outer_rect = get_outer_rect(glyph);
Rect inner_rect(
Gfx::Rect outer_rect = get_outer_rect(glyph);
Gfx::Rect inner_rect(
outer_rect.x() + m_horizontal_spacing / 2,
outer_rect.y() + m_vertical_spacing / 2,
font().max_glyph_width(),

View file

@ -55,7 +55,7 @@ private:
virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousedown_event(GUI::MouseEvent&) override;
Rect get_outer_rect(u8 glyph) const;
Gfx::Rect get_outer_rect(u8 glyph) const;
RefPtr<Gfx::Font> m_font;
int m_rows { 8 };

View file

@ -335,7 +335,7 @@ void HexEditor::scroll_position_into_view(int position)
{
int y = position / bytes_per_row();
int x = position % bytes_per_row();
Rect rect {
Gfx::Rect rect {
frame_thickness() + offset_margin_width() + (x * (character_width() * 3)) + 10,
frame_thickness() + 5 + (y * line_height()),
(character_width() * 3),
@ -477,7 +477,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
painter.translate(frame_thickness(), frame_thickness());
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
Rect offset_clip_rect {
Gfx::Rect offset_clip_rect {
0,
vertical_scrollbar().value(),
85,
@ -497,7 +497,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
// paint offsets
for (int i = min_row; i < max_row; i++) {
Rect side_offset_rect {
Gfx::Rect side_offset_rect {
frame_thickness() + 5,
frame_thickness() + 5 + (i * line_height()),
width() - width_occupied_by_vertical_scrollbar(),
@ -530,7 +530,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
}
}
Rect hex_display_rect {
Gfx::Rect hex_display_rect {
frame_thickness() + offset_margin_width() + (j * (character_width() * 3)) + 10,
frame_thickness() + 5 + (i * line_height()),
(character_width() * 3),
@ -546,7 +546,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
auto line = String::format("%02X", m_buffer[byte_position]);
painter.draw_text(hex_display_rect, line, Gfx::TextAlignment::TopLeft, text_color);
Rect text_display_rect {
Gfx::Rect text_display_rect {
frame_thickness() + offset_margin_width() + (bytes_per_row() * (character_width() * 3)) + (j * character_width()) + 20,
frame_thickness() + 5 + (i * line_height()),
character_width(),

View file

@ -42,7 +42,7 @@ EllipseTool::~EllipseTool()
void EllipseTool::draw_using(GUI::Painter& painter)
{
auto ellipse_intersecting_rect = Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position);
auto ellipse_intersecting_rect = Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position);
switch (m_mode) {
case Mode::Outline:
painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_widget->color_for(m_drawing_button), m_thickness);

View file

@ -38,21 +38,21 @@ EraseTool::~EraseTool()
{
}
Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect)
Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect)
{
const int base_eraser_size = 10;
const int eraser_size = (base_eraser_size * m_thickness);
const int eraser_radius = eraser_size / 2;
const auto ex = pos.x();
const auto ey = pos.y();
return Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect);
}
void EraseTool::on_mousedown(GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right)
return;
Rect r = build_rect(event.position(), m_widget->bitmap().rect());
Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect());
GUI::Painter painter(m_widget->bitmap());
painter.fill_rect(r, get_color());
m_widget->update();
@ -64,7 +64,7 @@ void EraseTool::on_mousemove(GUI::MouseEvent& event)
return;
if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) {
Rect r = build_rect(event.position(), m_widget->bitmap().rect());
Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect());
GUI::Painter painter(m_widget->bitmap());
painter.fill_rect(r, get_color());
m_widget->update();

View file

@ -46,7 +46,7 @@ public:
private:
Color get_color() const;
virtual const char* class_name() const override { return "EraseTool"; }
Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect);
Gfx::Rect build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_rect);
RefPtr<GUI::Menu> m_context_menu;
bool m_use_secondary_color { true };

View file

@ -95,7 +95,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par
m_primary_color_widget->set_frame_thickness(2);
m_primary_color_widget->set_frame_shape(Gfx::FrameShape::Container);
m_primary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken);
Rect rect { 0, 0, 38, 15 };
Gfx::Rect rect { 0, 0, 38, 15 };
rect.center_within(m_secondary_color_widget->relative_rect());
m_primary_color_widget->set_relative_rect(rect);
m_primary_color_widget->set_fill_with_background_color(true);

View file

@ -42,7 +42,7 @@ RectangleTool::~RectangleTool()
void RectangleTool::draw_using(GUI::Painter& painter)
{
auto rect_to_draw = Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
auto rect_to_draw = Gfx::Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position);
switch (m_mode) {
case Mode::Fill:
painter.fill_rect(rect_to_draw, m_widget->color_for(m_drawing_button));

View file

@ -183,7 +183,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
int x = 0;
int i = 0;
for (;;) {
Rect rect(x, 0, white_key_width, frame_inner_rect().height());
Gfx::Rect rect(x, 0, white_key_width, frame_inner_rect().height());
painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::White);
painter.draw_rect(rect, Color::Black);
if (i < white_key_labels_count) {
@ -205,7 +205,7 @@ void KeysWidget::paint_event(GUI::PaintEvent& event)
x = white_key_width - black_key_x_offset;
i = 0;
for (;;) {
Rect rect(x, 0, black_key_width, black_key_height);
Gfx::Rect rect(x, 0, black_key_width, black_key_height);
painter.fill_rect(rect, m_key_on[note] ? note_pressed_color : Color::Black);
painter.draw_rect(rect, Color::Black);
if (i < black_key_labels_count) {
@ -263,7 +263,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const
bool black_key_on_left = note != 0 && key_pattern[(note - 1) % notes_per_octave] == Black;
if (black_key_on_left) {
int black_key_x = (white_keys * white_key_width) - black_key_x_offset;
Rect black_key(black_key_x, 0, black_key_width, black_key_height);
Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height);
if (black_key.contains(point))
return note - 1;
}
@ -271,7 +271,7 @@ int KeysWidget::note_for_event_position(const Gfx::Point& a_point) const
bool black_key_on_right = key_pattern[(note + 1) % notes_per_octave] == Black;
if (black_key_on_right) {
int black_key_x = ((white_keys + 1) * white_key_width) - black_key_x_offset;
Rect black_key(black_key_x, 0, black_key_width, black_key_height);
Gfx::Rect black_key(black_key_x, 0, black_key_width, black_key_height);
if (black_key.contains(point))
return note + 1;
}

View file

@ -80,7 +80,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
int x_pos = x * note_width;
int next_x_pos = (x + 1) * note_width;
int distance_to_next_x = next_x_pos - x_pos;
Rect rect(x_pos, y_pos, distance_to_next_x, note_height);
Gfx::Rect rect(x_pos, y_pos, distance_to_next_x, note_height);
if (m_roll_notes[y + note_offset][x] == On)
painter.fill_rect(rect, note_pressed_color);

View file

@ -69,7 +69,7 @@ void GraphWidget::paint_event(GUI::PaintEvent& event)
}
if (!m_values.is_empty() && text_formatter) {
Rect text_rect = inner_rect.shrunken(8, 8);
Gfx::Rect text_rect = inner_rect.shrunken(8, 8);
text_rect.set_height(font().glyph_height());
auto text = text_formatter(m_values.last(), m_max);
painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, Color::Black);

View file

@ -123,7 +123,7 @@ void TaskbarWindow::create_quick_launch_bar()
void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect)
{
Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
Gfx::Rect new_rect { rect.x(), rect.bottom() - taskbar_height() + 1, rect.width(), taskbar_height() };
set_rect(new_rect);
}

View file

@ -50,7 +50,7 @@ public:
String title() const { return m_title; }
void set_title(const String& title) { m_title = title; }
Rect rect() const { return m_rect; }
Gfx::Rect rect() const { return m_rect; }
void set_rect(const Gfx::Rect& rect) { m_rect = rect; }
GUI::Button* button() { return m_button; }

View file

@ -90,7 +90,7 @@ int main(int argc, char** argv)
auto window = GUI::Window::construct();
window->set_title("Welcome to Serenity");
Rect window_rect { 0, 0, 640, 360 };
Gfx::Rect window_rect { 0, 0, 640, 360 };
window_rect.center_within(GUI::Desktop::the().rect());
window->set_resizable(true);
window->set_rect(window_rect);