Skip to content

Commit

Permalink
LibGfx: Unpublish Gfx::Size from the global namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Feb 6, 2020
1 parent 9b87843 commit f8b00aa
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Applications/DisplayProperties/DisplayProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void DisplayPropertiesWidget::create_resolution_list()
m_resolutions.append({ 1920, 1080 });
m_resolutions.append({ 2560, 1080 });

Size find_size;
Gfx::Size find_size;

bool okay = false;
// Let's attempt to find the current resolution and select it!
Expand Down Expand Up @@ -165,7 +165,7 @@ void DisplayPropertiesWidget::create_frame()

auto resolution_list = GUI::ListView::construct(settings_content);
resolution_list->set_background_color(Color::White);
resolution_list->set_model(*ItemListModel<Size>::create(m_resolutions));
resolution_list->set_model(*ItemListModel<Gfx::Size>::create(m_resolutions));

auto resolution_model = resolution_list->model();
auto find_first_resolution_index = m_resolutions.find_first_index(m_selected_resolution);
Expand Down
2 changes: 1 addition & 1 deletion Applications/DisplayProperties/DisplayProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DisplayPropertiesWidget final {
String m_wallpaper_path;
RefPtr<Core::ConfigFile> m_wm_config;
RefPtr<GUI::Widget> m_root_widget;
Vector<Size> m_resolutions;
Vector<Gfx::Size> m_resolutions;
Vector<String> m_wallpapers;
RefPtr<GUI::Label> m_wallpaper_preview;

Expand Down
2 changes: 1 addition & 1 deletion Applications/QuickShow/QSWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void QSWidget::set_bitmap(NonnullRefPtr<Gfx::Bitmap> bitmap)

void QSWidget::relayout()
{
Size new_size;
Gfx::Size new_size;
float scale_factor = (float)m_scale / 100.0f;
new_size.set_width(m_bitmap->width() * scale_factor);
new_size.set_height(m_bitmap->height() * scale_factor);
Expand Down
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/VBForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void VBForm::mousemove_event(GUI::MouseEvent& event)
if (widget.is_in_layout())
return;
auto new_rect = widget.transform_origin_rect();
Size minimum_size { 5, 5 };
Gfx::Size minimum_size { 5, 5 };
new_rect.set_x(new_rect.x() + change_x);
new_rect.set_y(new_rect.y() + change_y);
new_rect.set_width(max(minimum_size.width(), new_rect.width() + change_w));
Expand Down
2 changes: 1 addition & 1 deletion Games/Minesweeper/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class SquareLabel final : public GUI::Label {
bool m_chord { false };
};

Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Size)> on_size_changed)
Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Gfx::Size)> on_size_changed)
: GUI::Frame(parent)
, m_face_button(face_button)
, m_flag_label(flag_label)
Expand Down
4 changes: 2 additions & 2 deletions Games/Minesweeper/Field.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Field final : public GUI::Frame {
friend class Square;
friend class SquareLabel;
public:
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Size)> on_size_changed);
Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Gfx::Size)> on_size_changed);
virtual ~Field() override;

int rows() const { return m_rows; }
Expand Down Expand Up @@ -131,5 +131,5 @@ class Field final : public GUI::Frame {
bool m_chord_preview { false };
bool m_first_click { true };
bool m_single_chording { true };
Function<void(Size)> m_on_size_changed;
Function<void(Gfx::Size)> m_on_size_changed;
};
2 changes: 1 addition & 1 deletion Games/Minesweeper/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char** argv)
auto time_icon_label = GUI::Label::construct(container);
time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
auto time_label = GUI::Label::construct(container);
auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](Size size) {
auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](auto size) {
size.set_height(size.height() + container->preferred_size().height());
window->resize(size);
});
Expand Down
2 changes: 1 addition & 1 deletion Games/Snake/SnakeGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void SnakeGame::keydown_event(GUI::KeyEvent& event)
Gfx::Rect SnakeGame::cell_rect(const Coordinate& coord) const
{
auto game_rect = rect();
auto cell_size = Size(game_rect.width() / m_columns, game_rect.height() / m_rows);
auto cell_size = Gfx::Size(game_rect.width() / m_columns, game_rect.height() / m_rows);
return {
coord.column * cell_size.width(),
coord.row * cell_size.height(),
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibELF/exec_elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ typedef uint16_t Elf64_Quarter;
#define EI_OSABI 7 /* OS/ABI ID */
#define EI_ABIVERSION 8 /* ABI version */
#define EI_PAD 9 /* start of pad bytes */
#define EI_NIDENT 16 /* Size of e_ident[] */
#define EI_NIDENT 16 /* Gfx::Size of e_ident[] */

/* e_ident[] magic number */
#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
Expand Down Expand Up @@ -701,7 +701,7 @@ struct elf_args {
u_long arg_entry; /* program entry point */
u_long arg_interp; /* Interpreter load address */
u_long arg_phaddr; /* program header address */
u_long arg_phentsize; /* Size of program header */
u_long arg_phentsize; /* Gfx::Size of program header */
u_long arg_phnum; /* Number of program headers */
};

Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibGUI/GBoxLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void BoxLayout::run(Widget& widget)
if (m_entries.is_empty())
return;

Size available_size = widget.size();
Gfx::Size available_size = widget.size();
int number_of_entries_with_fixed_size = 0;

int number_of_visible_entries = 0;
Expand Down Expand Up @@ -91,7 +91,7 @@ void BoxLayout::run(Widget& widget)
if (should_log)
dbgprintf("BoxLayout: available_size=%s, fixed=%d, fill=%d\n", available_size.to_string().characters(), number_of_entries_with_fixed_size, number_of_entries_with_automatic_size);

Size automatic_size;
Gfx::Size automatic_size;

if (number_of_entries_with_automatic_size) {
if (m_orientation == Orientation::Horizontal) {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GComboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void ComboBox::open()
auto item_text = model()->data(index).to_string();
longest_item_width = max(longest_item_width, m_list_view->font().width(item_text));
}
Size size {
Gfx::Size size {
max(width(), longest_item_width + m_list_view->width_occupied_by_vertical_scrollbar() + m_list_view->frame_thickness() * 2 + m_list_view->horizontal_padding()),
model()->row_count() * m_list_view->item_height() + m_list_view->frame_thickness() * 2
};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GDragOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DragOperation::Outcome DragOperation::exec()
ASSERT(!m_event_loop);

int bitmap_id = -1;
Size bitmap_size;
Gfx::Size bitmap_size;
RefPtr<Gfx::Bitmap> shared_bitmap;
if (m_bitmap) {
shared_bitmap = m_bitmap->to_shareable_bitmap();
Expand Down
6 changes: 3 additions & 3 deletions Libraries/LibGUI/GEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class MultiPaintEvent final : public Event {
}

const Vector<Gfx::Rect, 32>& rects() const { return m_rects; }
Size window_size() const { return m_window_size; }
Gfx::Size window_size() const { return m_window_size; }

private:
Vector<Gfx::Rect, 32> m_rects;
Expand All @@ -182,15 +182,15 @@ class MultiPaintEvent final : public Event {

class PaintEvent final : public Event {
public:
explicit PaintEvent(const Gfx::Rect& rect, const Gfx::Size& window_size = Size())
explicit PaintEvent(const Gfx::Rect& rect, const Gfx::Size& window_size = {})
: Event(Event::Paint)
, m_rect(rect)
, m_window_size(window_size)
{
}

Gfx::Rect rect() const { return m_rect; }
Size window_size() const { return m_window_size; }
Gfx::Size window_size() const { return m_window_size; }

private:
Gfx::Rect m_rect;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GItemView.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ItemView : public AbstractView {
int horizontal_padding() const { return m_horizontal_padding; }

void scroll_into_view(const ModelIndex&, Orientation);
Size effective_item_size() const { return m_effective_item_size; }
Gfx::Size effective_item_size() const { return m_effective_item_size; }

int model_column() const { return m_model_column; }
void set_model_column(int column) { m_model_column = column; }
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int Menu::realize_menu()
int icon_buffer_id = -1;
if (action.icon()) {
ASSERT(action.icon()->format() == Gfx::Bitmap::Format::RGBA32);
ASSERT(action.icon()->size() == Size(16, 16));
ASSERT(action.icon()->size() == Gfx::Size(16, 16));
if (action.icon()->shared_buffer_id() == -1) {
auto shared_buffer = SharedBuffer::create_with_size(action.icon()->size_in_bytes());
ASSERT(shared_buffer);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GRadioButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RadioButton::~RadioButton()
{
}

Size RadioButton::circle_size()
Gfx::Size RadioButton::circle_size()
{
return { 12, 12 };
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GRadioButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RadioButton : public AbstractButton {

template<typename Callback>
void for_each_in_group(Callback);
static Size circle_size();
static Gfx::Size circle_size();
};

}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GScrollableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void ScrollableWidget::resize_event(ResizeEvent& event)
update_scrollbar_ranges();
}

Size ScrollableWidget::available_size() const
Gfx::Size ScrollableWidget::available_size() const
{
int available_width = frame_inner_rect().width() - m_size_occupied_by_fixed_elements.width() - width_occupied_by_vertical_scrollbar();
int available_height = frame_inner_rect().height() - m_size_occupied_by_fixed_elements.height() - height_occupied_by_horizontal_scrollbar();
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibGUI/GScrollableWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ScrollableWidget : public Frame {
public:
virtual ~ScrollableWidget() override;

Size content_size() const { return m_content_size; }
Gfx::Size content_size() const { return m_content_size; }
int content_width() const { return m_content_size.width(); }
int content_height() const { return m_content_size.height(); }

Expand All @@ -51,7 +51,7 @@ class ScrollableWidget : public Frame {
void set_scrollbars_enabled(bool);
bool is_scrollbars_enabled() const { return m_scrollbars_enabled; }

Size available_size() const;
Gfx::Size available_size() const;

ScrollBar& vertical_scrollbar() { return *m_vertical_scrollbar; }
const ScrollBar& vertical_scrollbar() const { return *m_vertical_scrollbar; }
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibGUI/GVariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class Variant {
return { m_value.as_point.x, m_value.as_point.y };
}

Size as_size() const
Gfx::Size as_size() const
{
return { m_value.as_size.width, m_value.as_size.height };
}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/LibGUI/GWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Widget : public Core::Object {
void set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy);
void set_size_policy(Orientation, SizePolicy);

Size preferred_size() const { return m_preferred_size; }
Gfx::Size preferred_size() const { return m_preferred_size; }
void set_preferred_size(const Gfx::Size&);
void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); }

Expand Down Expand Up @@ -156,7 +156,7 @@ class Widget : public Core::Object {
int length(Orientation orientation) const { return orientation == Orientation::Vertical ? height() : width(); }

Gfx::Rect rect() const { return { 0, 0, width(), height() }; }
Size size() const { return m_relative_rect.size(); }
Gfx::Size size() const { return m_relative_rect.size(); }

void update();
void update(const Gfx::Rect&);
Expand Down
6 changes: 3 additions & 3 deletions Libraries/LibGUI/GWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Window : public Core::Object {
int height() const { return rect().height(); }

Gfx::Rect rect() const;
Size size() const { return rect().size(); }
Gfx::Size size() const { return rect().size(); }
void set_rect(const Gfx::Rect&);
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }

Expand Down Expand Up @@ -152,9 +152,9 @@ class Window : public Core::Object {
Gfx::Bitmap* front_bitmap() { return m_front_bitmap.ptr(); }
Gfx::Bitmap* back_bitmap() { return m_back_bitmap.ptr(); }

Size size_increment() const { return m_size_increment; }
Gfx::Size size_increment() const { return m_size_increment; }
void set_size_increment(const Gfx::Size& increment) { m_size_increment = increment; }
Size base_size() const { return m_base_size; }
Gfx::Size base_size() const { return m_base_size; }
void set_base_size(const Gfx::Size& size) { m_base_size = size; }

void set_override_cursor(StandardCursor);
Expand Down
2 changes: 0 additions & 2 deletions Libraries/LibGfx/Size.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,3 @@ inline const LogStream& operator<<(const LogStream& stream, const Size& value)
}

}

using Gfx::Size;
2 changes: 1 addition & 1 deletion Libraries/LibVT/TerminalWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void TerminalWidget::relayout(const Gfx::Size& size)
m_scrollbar->set_relative_rect(scrollbar_rect);
}

Size TerminalWidget::compute_base_size() const
Gfx::Size TerminalWidget::compute_base_size() const
{
int base_width = frame_thickness() * 2 + m_inset * 2 + m_scrollbar->width();
int base_height = frame_thickness() * 2 + m_inset * 2;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LibVT/TerminalWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TerminalWidget final : public GUI::Frame

void relayout(const Gfx::Size&);

Size compute_base_size() const;
Gfx::Size compute_base_size() const;
int first_selection_column_on_row(int row) const;
int last_selection_column_on_row(int row) const;

Expand Down
2 changes: 1 addition & 1 deletion Servers/WindowServer/WSCursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class WSCursor : public RefCounted<WSCursor> {
const Gfx::Bitmap& bitmap() const { return *m_bitmap; }

Gfx::Rect rect() const { return m_bitmap->rect(); }
Size size() const { return m_bitmap->size(); }
Gfx::Size size() const { return m_bitmap->size(); }

private:
WSCursor(NonnullRefPtr<Gfx::Bitmap>&&, const Gfx::Point&);
Expand Down
2 changes: 1 addition & 1 deletion Servers/WindowServer/WSScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class WSScreen {

static WSScreen& the();

Size size() const { return { width(), height() }; }
Gfx::Size size() const { return { width(), height() }; }
Gfx::Rect rect() const { return { 0, 0, width(), height() }; }

Gfx::Point cursor_location() const { return m_cursor_location; }
Expand Down
6 changes: 3 additions & 3 deletions Servers/WindowServer/WSWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WSWindow final : public Core::Object
void set_position(const Gfx::Point& position) { set_rect({ position.x(), position.y(), width(), height() }); }
void set_position_without_repaint(const Gfx::Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }

Size size() const { return m_rect.size(); }
Gfx::Size size() const { return m_rect.size(); }

void invalidate();
void invalidate(const Gfx::Rect&);
Expand Down Expand Up @@ -193,10 +193,10 @@ class WSWindow final : public Core::Object
bool has_alpha_channel() const { return m_has_alpha_channel; }
void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }

Size size_increment() const { return m_size_increment; }
Gfx::Size size_increment() const { return m_size_increment; }
void set_size_increment(const Gfx::Size& increment) { m_size_increment = increment; }

Size base_size() const { return m_base_size; }
Gfx::Size base_size() const { return m_base_size; }
void set_base_size(const Gfx::Size& size) { m_base_size = size; }

const Gfx::Bitmap& icon() const { return *m_icon; }
Expand Down
4 changes: 2 additions & 2 deletions Servers/WindowServer/WSWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void WSWindowManager::set_resolution(int width, int height)
client.notify_about_new_screen_rect(WSScreen::the().rect());
});
if (m_wm_config) {
dbg() << "Saving resolution: " << Size(width, height) << " to config file at " << m_wm_config->file_name();
dbg() << "Saving resolution: " << Gfx::Size(width, height) << " to config file at " << m_wm_config->file_name();
m_wm_config->write_num_entry("Screen", "Width", width);
m_wm_config->write_num_entry("Screen", "Height", height);
m_wm_config->sync();
Expand Down Expand Up @@ -542,7 +542,7 @@ bool WSWindowManager::process_ongoing_window_resize(const WSMouseEvent& event, W
auto new_rect = m_resize_window_original_rect;

// First, size the new rect.
Size minimum_size { 50, 50 };
Gfx::Size minimum_size { 50, 50 };

new_rect.set_width(max(minimum_size.width(), new_rect.width() + change_w));
new_rect.set_height(max(minimum_size.height(), new_rect.height() + change_h));
Expand Down

0 comments on commit f8b00aa

Please sign in to comment.