Skip to content

Commit

Permalink
LibGfx: Unpublish Gfx::Rect from global namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Feb 6, 2020
1 parent c39d44f commit 20cfd2a
Show file tree
Hide file tree
Showing 78 changed files with 262 additions and 260 deletions.
2 changes: 1 addition & 1 deletion Applications/About/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Applications/FontEditor/GlyphEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Applications/FontEditor/GlyphMapWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion Applications/FontEditor/GlyphMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GlyphMapWidget final : public GUI::Frame {
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 };
Expand Down
10 changes: 5 additions & 5 deletions Applications/HexEditor/HexEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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(),
Expand Down Expand Up @@ -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),
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/EllipseTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions Applications/PaintBrush/EraseTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/EraseTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class EraseTool final : public Tool {
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 };
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/PaletteWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/RectangleTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions Applications/Piano/KeysWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -263,15 +263,15 @@ 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;
}

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;
}
Expand Down
2 changes: 1 addition & 1 deletion Applications/Piano/RollWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/GraphWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Applications/Taskbar/TaskbarWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion Applications/Taskbar/WindowList.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Window {
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; }
Expand Down
2 changes: 1 addition & 1 deletion Applications/Welcome/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions DevTools/HackStudio/CursorTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ void CursorTool::set_rubber_band_position(const Gfx::Point& position)
m_editor.form_widget().update();
}

Rect CursorTool::rubber_band_rect() const
Gfx::Rect CursorTool::rubber_band_rect() const
{
if (!m_rubber_banding)
return {};
return Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position);
return Gfx::Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position);
}

void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&)
Expand Down
20 changes: 10 additions & 10 deletions DevTools/IPCCompiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,23 @@ int main(int argc, char** argv)
dbg() << " }";
dbg() << " " << parameter.name << " = *" << parameter.name << "_impl;";
dbg() << " }";
} else if (parameter.type == "Color") {
} else if (parameter.type == "Gfx::Color") {
dbg() << " u32 " << parameter.name << "_rgba = 0;";
dbg() << " stream >> " << parameter.name << "_rgba;";
dbg() << " " << parameter.name << " = Gfx::Color::from_rgba(" << parameter.name << "_rgba);";
} else if (parameter.type == "Size") {
} else if (parameter.type == "Gfx::Size") {
dbg() << " int " << parameter.name << "_width = 0;";
dbg() << " stream >> " << parameter.name << "_width;";
dbg() << " int " << parameter.name << "_height = 0;";
dbg() << " stream >> " << parameter.name << "_height;";
dbg() << " " << parameter.name << " = { " << parameter.name << "_width, " << parameter.name << "_height };";
} else if (parameter.type == "Point") {
} else if (parameter.type == "Gfx::Point") {
dbg() << " int " << parameter.name << "_x = 0;";
dbg() << " stream >> " << parameter.name << "_x;";
dbg() << " int " << parameter.name << "_y = 0;";
dbg() << " stream >> " << parameter.name << "_y;";
dbg() << " " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y };";
} else if (parameter.type == "Rect") {
} else if (parameter.type == "Gfx::Rect") {
dbg() << " int " << parameter.name << "_x = 0;";
dbg() << " stream >> " << parameter.name << "_x;";
dbg() << " int " << parameter.name << "_y = 0;";
Expand All @@ -350,7 +350,7 @@ int main(int argc, char** argv)
dbg() << " int " << parameter.name << "_height = 0;";
dbg() << " stream >> " << parameter.name << "_height;";
dbg() << " " << parameter.name << " = { " << parameter.name << "_x, " << parameter.name << "_y, " << parameter.name << "_width, " << parameter.name << "_height };";
} else if (parameter.type == "Vector<Rect>") {
} else if (parameter.type == "Vector<Gfx::Rect>") {
dbg() << " int " << parameter.name << "_size = 0;";
dbg() << " stream >> " << parameter.name << "_size;";
dbg() << " for (int i = 0; i < " << parameter.name << "_size; ++i) {";
Expand Down Expand Up @@ -399,20 +399,20 @@ int main(int argc, char** argv)
dbg() << " stream << static_cast<i32>(m_" << parameter.name << ".length());";
dbg() << " stream << m_" << parameter.name << ";";
dbg() << " }";
} else if (parameter.type == "Color") {
} else if (parameter.type == "Gfx::Color") {
dbg() << " stream << m_" << parameter.name << ".value();";
} else if (parameter.type == "Size") {
} else if (parameter.type == "Gfx::Size") {
dbg() << " stream << m_" << parameter.name << ".width();";
dbg() << " stream << m_" << parameter.name << ".height();";
} else if (parameter.type == "Point") {
} else if (parameter.type == "Gfx::Point") {
dbg() << " stream << m_" << parameter.name << ".x();";
dbg() << " stream << m_" << parameter.name << ".y();";
} else if (parameter.type == "Rect") {
} else if (parameter.type == "Gfx::Rect") {
dbg() << " stream << m_" << parameter.name << ".x();";
dbg() << " stream << m_" << parameter.name << ".y();";
dbg() << " stream << m_" << parameter.name << ".width();";
dbg() << " stream << m_" << parameter.name << ".height();";
} else if (parameter.type == "Vector<Rect>") {
} else if (parameter.type == "Vector<Gfx::Rect>") {
dbg() << " stream << m_" << parameter.name << ".size();";
dbg() << " for (auto& rect : m_" << parameter.name << ") {";
dbg() << " stream << rect.x();";
Expand Down
4 changes: 2 additions & 2 deletions DevTools/VisualBuilder/VBWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ VBWidget::~VBWidget()
m_gwidget->parent()->remove_child(*m_gwidget);
}

Rect VBWidget::rect() const
Gfx::Rect VBWidget::rect() const
{
return m_gwidget->window_relative_rect();
}
Expand All @@ -80,7 +80,7 @@ bool VBWidget::is_selected() const
return m_form.is_selected(*this);
}

Rect VBWidget::grabber_rect(Direction direction) const
Gfx::Rect VBWidget::grabber_rect(Direction direction) const
{
int grabber_size = 5;
int half_grabber_size = grabber_size / 2;
Expand Down
6 changes: 3 additions & 3 deletions DevTools/VisualBuilder/VBWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ class VBWidget : public RefCounted<VBWidget>

bool is_selected() const;

Rect rect() const;
Gfx::Rect rect() const;
void set_rect(const Gfx::Rect&);

Rect grabber_rect(Direction) const;
Gfx::Rect grabber_rect(Direction) const;
Direction grabber_at(const Gfx::Point&) const;

GUI::Widget* gwidget() { return m_gwidget; }
Expand All @@ -98,7 +98,7 @@ class VBWidget : public RefCounted<VBWidget>

void property_did_change();

Rect transform_origin_rect() const { return m_transform_origin_rect; }
Gfx::Rect transform_origin_rect() const { return m_transform_origin_rect; }
void capture_transform_origin_rect();

bool is_in_layout() const;
Expand Down
2 changes: 1 addition & 1 deletion Games/Minesweeper/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ void Field::reset()
for (int c = 0; c < columns(); ++c) {
if (!m_squares[i])
m_squares[i] = make<Square>();
Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() };
Gfx::Rect rect = { frame_thickness() + c * square_size(), frame_thickness() + r * square_size(), square_size(), square_size() };
auto& square = this->square(r, c);
square.field = this;
square.row = r;
Expand Down
Loading

0 comments on commit 20cfd2a

Please sign in to comment.