mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibDraw: Put all classes in the Gfx namespace
I started adding things to a Draw namespace, but it somehow felt really wrong seeing Draw::Rect and Draw::Bitmap, etc. So instead, let's rename the library to LibGfx. :^)
This commit is contained in:
parent
939a605334
commit
11580babbf
Notes:
sideshowbarker
2024-07-19 09:35:13 +09:00
Author: https://github.com/awesomekling
Commit: 11580babbf
269 changed files with 1513 additions and 1315 deletions
|
@ -63,13 +63,13 @@ VBForm::VBForm(const String& name, GUI::Widget* parent)
|
|||
widget->gwidget()->move_to_back();
|
||||
}));
|
||||
m_context_menu->add_separator();
|
||||
m_context_menu->add_action(GUI::Action::create("Lay out horizontally", load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) {
|
||||
m_context_menu->add_action(GUI::Action::create("Lay out horizontally", Gfx::load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) {
|
||||
if (auto* widget = single_selected_widget()) {
|
||||
dbg() << "Giving " << *widget->gwidget() << " a horizontal box layout";
|
||||
widget->gwidget()->set_layout(make<GUI::HBoxLayout>());
|
||||
}
|
||||
}));
|
||||
m_context_menu->add_action(GUI::Action::create("Lay out vertically", load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) {
|
||||
m_context_menu->add_action(GUI::Action::create("Lay out vertically", Gfx::load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) {
|
||||
if (auto* widget = single_selected_widget()) {
|
||||
dbg() << "Giving " << *widget->gwidget() << " a vertical box layout";
|
||||
widget->gwidget()->set_layout(make<GUI::VBoxLayout>());
|
||||
|
@ -138,7 +138,7 @@ bool VBForm::is_selected(const VBWidget& widget) const
|
|||
return m_selected_widgets.contains(const_cast<VBWidget*>(&widget));
|
||||
}
|
||||
|
||||
VBWidget* VBForm::widget_at(const Point& position)
|
||||
VBWidget* VBForm::widget_at(const Gfx::Point& position)
|
||||
{
|
||||
auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No);
|
||||
if (!result.widget)
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
void set_name(const String& name) { m_name = name; }
|
||||
|
||||
bool is_selected(const VBWidget&) const;
|
||||
VBWidget* widget_at(const Point&);
|
||||
VBWidget* widget_at(const Gfx::Point&);
|
||||
|
||||
void set_should_snap_to_grip(bool snap) { m_should_snap_to_grid = snap; }
|
||||
bool should_snap_to_grid() const { return m_should_snap_to_grid; }
|
||||
|
@ -83,8 +83,8 @@ private:
|
|||
NonnullRefPtrVector<VBWidget> m_widgets;
|
||||
HashMap<GUI::Widget*, VBWidget*> m_gwidget_map;
|
||||
HashTable<VBWidget*> m_selected_widgets;
|
||||
Point m_transform_event_origin;
|
||||
Point m_next_insertion_position;
|
||||
Gfx::Point m_transform_event_origin;
|
||||
Gfx::Point m_next_insertion_position;
|
||||
Direction m_resize_direction { Direction::None };
|
||||
Direction m_mouse_direction_type { Direction::None };
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
|
|
@ -64,7 +64,7 @@ Rect VBWidget::rect() const
|
|||
return m_gwidget->window_relative_rect();
|
||||
}
|
||||
|
||||
void VBWidget::set_rect(const Rect& rect)
|
||||
void VBWidget::set_rect(const Gfx::Rect& rect)
|
||||
{
|
||||
if (rect == m_gwidget->window_relative_rect())
|
||||
return;
|
||||
|
@ -106,7 +106,7 @@ Rect VBWidget::grabber_rect(Direction direction) const
|
|||
}
|
||||
}
|
||||
|
||||
Direction VBWidget::grabber_at(const Point& position) const
|
||||
Direction VBWidget::grabber_at(const Gfx::Point& position) const
|
||||
{
|
||||
Direction found_grabber = Direction::None;
|
||||
for_each_direction([&](Direction direction) {
|
||||
|
|
|
@ -80,10 +80,10 @@ public:
|
|||
bool is_selected() const;
|
||||
|
||||
Rect rect() const;
|
||||
void set_rect(const Rect&);
|
||||
void set_rect(const Gfx::Rect&);
|
||||
|
||||
Rect grabber_rect(Direction) const;
|
||||
Direction grabber_at(const Point&) const;
|
||||
Direction grabber_at(const Gfx::Point&) const;
|
||||
|
||||
GUI::Widget* gwidget() { return m_gwidget; }
|
||||
|
||||
|
@ -113,5 +113,5 @@ private:
|
|||
RefPtr<GUI::Widget> m_gwidget;
|
||||
NonnullOwnPtrVector<VBProperty> m_properties;
|
||||
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
|
||||
Rect m_transform_origin_rect;
|
||||
Gfx::Rect m_transform_origin_rect;
|
||||
};
|
||||
|
|
|
@ -61,8 +61,8 @@ GUI::Model::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) co
|
|||
{
|
||||
UNUSED_PARAM(column);
|
||||
if (column == Column::Name)
|
||||
return { 110, TextAlignment::CenterLeft, &Font::default_bold_font() };
|
||||
return { 90, TextAlignment::CenterLeft };
|
||||
return { 110, Gfx::TextAlignment::CenterLeft, &Gfx::Font::default_bold_font() };
|
||||
return { 90, Gfx::TextAlignment::CenterLeft };
|
||||
}
|
||||
|
||||
GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
|
|
|
@ -82,7 +82,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto help_menu = GUI::Menu::construct("Help");
|
||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||
GUI::AboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window);
|
||||
GUI::AboutDialog::show("Visual Builder", Gfx::load_png("/res/icons/32x32/app-visual-builder.png"), window);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
|
@ -113,82 +113,82 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
window->set_main_widget(widget);
|
||||
|
||||
auto label_button = GUI::Button::construct(widget);
|
||||
label_button->set_button_style(ButtonStyle::CoolBar);
|
||||
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
label_button->set_tooltip("GLabel");
|
||||
label_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
label_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GLabel);
|
||||
};
|
||||
|
||||
auto button_button = GUI::Button::construct(widget);
|
||||
button_button->set_button_style(ButtonStyle::CoolBar);
|
||||
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
button_button->set_tooltip("GButton");
|
||||
button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GButton);
|
||||
};
|
||||
auto spinbox_button = GUI::Button::construct(widget);
|
||||
spinbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
spinbox_button->set_tooltip("GSpinBox");
|
||||
spinbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSpinBox);
|
||||
};
|
||||
auto editor_button = GUI::Button::construct(widget);
|
||||
editor_button->set_button_style(ButtonStyle::CoolBar);
|
||||
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
editor_button->set_tooltip("GTextEditor");
|
||||
editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GTextEditor);
|
||||
};
|
||||
auto progress_bar_button = GUI::Button::construct(widget);
|
||||
progress_bar_button->set_button_style(ButtonStyle::CoolBar);
|
||||
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
progress_bar_button->set_tooltip("GProgressBar");
|
||||
progress_bar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
progress_bar_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GProgressBar);
|
||||
};
|
||||
auto slider_button = GUI::Button::construct(widget);
|
||||
slider_button->set_button_style(ButtonStyle::CoolBar);
|
||||
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
slider_button->set_tooltip("GSlider");
|
||||
slider_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
slider_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSlider);
|
||||
};
|
||||
auto checkbox_button = GUI::Button::construct(widget);
|
||||
checkbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
checkbox_button->set_tooltip("GCheckBox");
|
||||
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
checkbox_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GCheckBox);
|
||||
};
|
||||
auto radiobutton_button = GUI::Button::construct(widget);
|
||||
radiobutton_button->set_button_style(ButtonStyle::CoolBar);
|
||||
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
radiobutton_button->set_tooltip("GRadioButton");
|
||||
radiobutton_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
radiobutton_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GRadioButton);
|
||||
};
|
||||
auto scrollbar_button = GUI::Button::construct(widget);
|
||||
scrollbar_button->set_button_style(ButtonStyle::CoolBar);
|
||||
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
scrollbar_button->set_tooltip("GScrollBar");
|
||||
scrollbar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
scrollbar_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GScrollBar);
|
||||
};
|
||||
auto groupbox_button = GUI::Button::construct(widget);
|
||||
groupbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
groupbox_button->set_tooltip("GGroupBox");
|
||||
groupbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
groupbox_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GGroupBox);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue