mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibGfx: Unpublish Gfx::Size from the global namespace
This commit is contained in:
parent
9b87843af1
commit
f8b00aa290
Notes:
sideshowbarker
2024-07-19 09:35:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f8b00aa2901
29 changed files with 41 additions and 43 deletions
|
@ -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!
|
||||
|
@ -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);
|
||||
|
|
|
@ -67,7 +67,7 @@ private:
|
|||
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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -119,7 +119,7 @@ public:
|
|||
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)
|
||||
|
|
|
@ -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; }
|
||||
|
@ -131,5 +131,5 @@ private:
|
|||
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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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] */
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -182,7 +182,7 @@ private:
|
|||
|
||||
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)
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -45,7 +45,7 @@ RadioButton::~RadioButton()
|
|||
{
|
||||
}
|
||||
|
||||
Size RadioButton::circle_size()
|
||||
Gfx::Size RadioButton::circle_size()
|
||||
{
|
||||
return { 12, 12 };
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
|
||||
template<typename Callback>
|
||||
void for_each_in_group(Callback);
|
||||
static Size circle_size();
|
||||
static Gfx::Size circle_size();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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(); }
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
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; }
|
||||
|
|
|
@ -189,7 +189,7 @@ public:
|
|||
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 };
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
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 }); }
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
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&);
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
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 }); }
|
||||
|
||||
|
@ -152,9 +152,9 @@ public:
|
|||
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);
|
||||
|
|
|
@ -115,5 +115,3 @@ inline const LogStream& operator<<(const LogStream& stream, const Size& value)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
using Gfx::Size;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -122,7 +122,7 @@ private:
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
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&);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
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; }
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
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&);
|
||||
|
@ -193,10 +193,10 @@ public:
|
|||
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; }
|
||||
|
|
|
@ -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();
|
||||
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue