mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:57:44 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -45,43 +45,43 @@ VBForm* VBForm::current()
|
|||
return s_current;
|
||||
}
|
||||
|
||||
VBForm::VBForm(const String& name, GWidget* parent)
|
||||
: GWidget(parent)
|
||||
VBForm::VBForm(const String& name, GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
, m_name(name)
|
||||
{
|
||||
s_current = this;
|
||||
set_fill_with_background_color(true);
|
||||
set_greedy_for_hits(true);
|
||||
|
||||
m_context_menu = GMenu::construct();
|
||||
m_context_menu->add_action(GCommonActions::make_move_to_front_action([this](auto&) {
|
||||
m_context_menu = GUI::Menu::construct();
|
||||
m_context_menu->add_action(GUI::CommonActions::make_move_to_front_action([this](auto&) {
|
||||
if (auto* widget = single_selected_widget())
|
||||
widget->gwidget()->move_to_front();
|
||||
}));
|
||||
m_context_menu->add_action(GCommonActions::make_move_to_back_action([this](auto&) {
|
||||
m_context_menu->add_action(GUI::CommonActions::make_move_to_back_action([this](auto&) {
|
||||
if (auto* widget = single_selected_widget())
|
||||
widget->gwidget()->move_to_back();
|
||||
}));
|
||||
m_context_menu->add_separator();
|
||||
m_context_menu->add_action(GAction::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", 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<GHBoxLayout>());
|
||||
widget->gwidget()->set_layout(make<GUI::HBoxLayout>());
|
||||
}
|
||||
}));
|
||||
m_context_menu->add_action(GAction::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", 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<GVBoxLayout>());
|
||||
widget->gwidget()->set_layout(make<GUI::VBoxLayout>());
|
||||
}
|
||||
}));
|
||||
m_context_menu->add_separator();
|
||||
m_context_menu->add_action(GCommonActions::make_delete_action([this](auto&) {
|
||||
m_context_menu->add_action(GUI::CommonActions::make_delete_action([this](auto&) {
|
||||
delete_selected_widgets();
|
||||
}));
|
||||
}
|
||||
|
||||
void VBForm::context_menu_event(GContextMenuEvent& event)
|
||||
void VBForm::context_menu_event(GUI::ContextMenuEvent& event)
|
||||
{
|
||||
m_context_menu->popup(event.screen_position());
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ VBForm::~VBForm()
|
|||
{
|
||||
}
|
||||
|
||||
void VBForm::paint_event(GPaintEvent& event)
|
||||
void VBForm::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
for (int y = 0; y < height(); y += m_grid_size) {
|
||||
|
@ -114,9 +114,9 @@ void VBForm::paint_event(GPaintEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void VBForm::second_paint_event(GPaintEvent& event)
|
||||
void VBForm::second_paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GPainter painter(*this);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
for (auto& widget : m_widgets) {
|
||||
|
@ -140,7 +140,7 @@ bool VBForm::is_selected(const VBWidget& widget) const
|
|||
|
||||
VBWidget* VBForm::widget_at(const Point& position)
|
||||
{
|
||||
auto result = hit_test(position, GWidget::ShouldRespectGreediness::No);
|
||||
auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No);
|
||||
if (!result.widget)
|
||||
return nullptr;
|
||||
auto* gwidget = result.widget;
|
||||
|
@ -152,14 +152,14 @@ VBWidget* VBForm::widget_at(const Point& position)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void VBForm::grabber_mousedown_event(GMouseEvent& event, Direction grabber)
|
||||
void VBForm::grabber_mousedown_event(GUI::MouseEvent& event, Direction grabber)
|
||||
{
|
||||
m_transform_event_origin = event.position();
|
||||
for_each_selected_widget([](auto& widget) { widget.capture_transform_origin_rect(); });
|
||||
m_resize_direction = grabber;
|
||||
}
|
||||
|
||||
void VBForm::keydown_event(GKeyEvent& event)
|
||||
void VBForm::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
if (event.key() == KeyCode::Key_Delete) {
|
||||
delete_selected_widgets();
|
||||
|
@ -252,7 +252,7 @@ void VBForm::remove_from_selection(VBWidget& widget)
|
|||
update();
|
||||
}
|
||||
|
||||
void VBForm::mousedown_event(GMouseEvent& event)
|
||||
void VBForm::mousedown_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (m_resize_direction == Direction::None) {
|
||||
bool hit_grabber = false;
|
||||
|
@ -273,7 +273,7 @@ void VBForm::mousedown_event(GMouseEvent& event)
|
|||
set_single_selected_widget(nullptr);
|
||||
return;
|
||||
}
|
||||
if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) {
|
||||
if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) {
|
||||
m_transform_event_origin = event.position();
|
||||
if (event.modifiers() == Mod_Ctrl)
|
||||
remove_from_selection(*widget);
|
||||
|
@ -286,9 +286,9 @@ void VBForm::mousedown_event(GMouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void VBForm::mousemove_event(GMouseEvent& event)
|
||||
void VBForm::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (event.buttons() & GMouseButton::Left) {
|
||||
if (event.buttons() & GUI::MouseButton::Left) {
|
||||
if (m_resize_direction == Direction::None) {
|
||||
update();
|
||||
auto delta = event.position() - m_transform_event_origin;
|
||||
|
@ -383,7 +383,7 @@ void VBForm::load_from_file(const String& path)
|
|||
{
|
||||
auto file = Core::File::construct(path);
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
GMessageBox::show(String::format("Could not open '%s' for reading", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(String::format("Could not open '%s' for reading", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ void VBForm::load_from_file(const String& path)
|
|||
auto form_json = JsonValue::from_string(file_contents);
|
||||
|
||||
if (!form_json.is_object()) {
|
||||
GMessageBox::show(String::format("Could not parse '%s'", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(String::format("Could not parse '%s'", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,7 @@ void VBForm::write_to_file(const String& path)
|
|||
{
|
||||
auto file = Core::File::construct(path);
|
||||
if (!file->open(Core::IODevice::WriteOnly)) {
|
||||
GMessageBox::show(String::format("Could not open '%s' for writing", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window());
|
||||
GUI::MessageBox::show(String::format("Could not open '%s' for writing", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -459,9 +459,9 @@ void VBForm::dump()
|
|||
}
|
||||
}
|
||||
|
||||
void VBForm::mouseup_event(GMouseEvent& event)
|
||||
void VBForm::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (event.button() == GMouseButton::Left) {
|
||||
if (event.button() == GUI::MouseButton::Left) {
|
||||
m_transform_event_origin = {};
|
||||
m_resize_direction = Direction::None;
|
||||
}
|
||||
|
@ -496,22 +496,22 @@ void VBForm::set_cursor_type_from_grabber(Direction grabber)
|
|||
switch (grabber) {
|
||||
case Direction::Up:
|
||||
case Direction::Down:
|
||||
window()->set_override_cursor(GStandardCursor::ResizeVertical);
|
||||
window()->set_override_cursor(GUI::StandardCursor::ResizeVertical);
|
||||
break;
|
||||
case Direction::Left:
|
||||
case Direction::Right:
|
||||
window()->set_override_cursor(GStandardCursor::ResizeHorizontal);
|
||||
window()->set_override_cursor(GUI::StandardCursor::ResizeHorizontal);
|
||||
break;
|
||||
case Direction::UpLeft:
|
||||
case Direction::DownRight:
|
||||
window()->set_override_cursor(GStandardCursor::ResizeDiagonalTLBR);
|
||||
window()->set_override_cursor(GUI::StandardCursor::ResizeDiagonalTLBR);
|
||||
break;
|
||||
case Direction::UpRight:
|
||||
case Direction::DownLeft:
|
||||
window()->set_override_cursor(GStandardCursor::ResizeDiagonalBLTR);
|
||||
window()->set_override_cursor(GUI::StandardCursor::ResizeDiagonalBLTR);
|
||||
break;
|
||||
case Direction::None:
|
||||
window()->set_override_cursor(GStandardCursor::None);
|
||||
window()->set_override_cursor(GUI::StandardCursor::None);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class VBForm : public GWidget {
|
||||
class VBForm : public GUI::Widget {
|
||||
C_OBJECT(VBForm)
|
||||
friend class VBWidget;
|
||||
public:
|
||||
explicit VBForm(const String& name, GWidget* parent = nullptr);
|
||||
explicit VBForm(const String& name, GUI::Widget* parent = nullptr);
|
||||
virtual ~VBForm() override;
|
||||
|
||||
static VBForm* current();
|
||||
|
@ -57,16 +57,16 @@ public:
|
|||
void dump();
|
||||
|
||||
protected:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void second_paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void context_menu_event(GContextMenuEvent&) override;
|
||||
virtual void keydown_event(GKeyEvent&) override;
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void second_paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void context_menu_event(GUI::ContextMenuEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
|
||||
private:
|
||||
void grabber_mousedown_event(GMouseEvent&, Direction grabber);
|
||||
void grabber_mousedown_event(GUI::MouseEvent&, Direction grabber);
|
||||
void set_single_selected_widget(VBWidget*);
|
||||
void add_to_selection(VBWidget&);
|
||||
void remove_from_selection(VBWidget&);
|
||||
|
@ -81,11 +81,11 @@ private:
|
|||
int m_grid_size { 5 };
|
||||
bool m_should_snap_to_grid { true };
|
||||
NonnullRefPtrVector<VBWidget> m_widgets;
|
||||
HashMap<GWidget*, VBWidget*> m_gwidget_map;
|
||||
HashMap<GUI::Widget*, VBWidget*> m_gwidget_map;
|
||||
HashTable<VBWidget*> m_selected_widgets;
|
||||
Point m_transform_event_origin;
|
||||
Point m_next_insertion_position;
|
||||
Direction m_resize_direction { Direction::None };
|
||||
Direction m_mouse_direction_type { Direction::None };
|
||||
RefPtr<GMenu> m_context_menu;
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
};
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class BoolValuesModel final : public GModel {
|
||||
class BoolValuesModel final : public GUI::Model {
|
||||
public:
|
||||
virtual int row_count(const GModelIndex&) const override { return 2; }
|
||||
virtual int column_count(const GModelIndex&) const override { return 1; }
|
||||
virtual int row_count(const GUI::ModelIndex&) const override { return 2; }
|
||||
virtual int column_count(const GUI::ModelIndex&) const override { return 1; }
|
||||
virtual void update() override {}
|
||||
virtual GVariant data(const GModelIndex& index, Role role) const override
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, Role role) const override
|
||||
{
|
||||
if (role != Role::Display)
|
||||
return {};
|
||||
|
@ -52,25 +52,25 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class BoolModelEditingDelegate : public GModelEditingDelegate {
|
||||
class BoolModelEditingDelegate : public GUI::ModelEditingDelegate {
|
||||
public:
|
||||
BoolModelEditingDelegate() {}
|
||||
virtual ~BoolModelEditingDelegate() override {}
|
||||
|
||||
virtual RefPtr<GWidget> create_widget() override
|
||||
virtual RefPtr<GUI::Widget> create_widget() override
|
||||
{
|
||||
auto combo = GComboBox::construct(nullptr);
|
||||
auto combo = GUI::ComboBox::construct(nullptr);
|
||||
combo->set_only_allow_values_from_model(true);
|
||||
combo->set_model(adopt(*new BoolValuesModel));
|
||||
combo->on_return_pressed = [this] { commit(); };
|
||||
combo->on_change = [this](auto&, auto&) { commit(); };
|
||||
return combo;
|
||||
}
|
||||
virtual GVariant value() const override { return static_cast<const GComboBox*>(widget())->text() == "true"; }
|
||||
virtual void set_value(const GVariant& value) override { static_cast<GComboBox*>(widget())->set_text(value.to_string()); }
|
||||
virtual GUI::Variant value() const override { return static_cast<const GUI::ComboBox*>(widget())->text() == "true"; }
|
||||
virtual void set_value(const GUI::Variant& value) override { static_cast<GUI::ComboBox*>(widget())->set_text(value.to_string()); }
|
||||
virtual void will_begin_editing() override
|
||||
{
|
||||
auto& combo = *static_cast<GComboBox*>(widget());
|
||||
auto& combo = *static_cast<GUI::ComboBox*>(widget());
|
||||
combo.select_all();
|
||||
combo.open();
|
||||
}
|
||||
|
@ -81,26 +81,26 @@ VBPropertiesWindow::VBPropertiesWindow()
|
|||
set_title("Properties");
|
||||
set_rect(780, 200, 240, 280);
|
||||
|
||||
auto widget = GWidget::construct();
|
||||
auto widget = GUI::Widget::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GVBoxLayout>());
|
||||
widget->set_layout(make<GUI::VBoxLayout>());
|
||||
widget->layout()->set_margins({ 2, 2, 2, 2 });
|
||||
set_main_widget(widget);
|
||||
|
||||
m_table_view = GTableView::construct(widget);
|
||||
m_table_view = GUI::TableView::construct(widget);
|
||||
m_table_view->set_headers_visible(false);
|
||||
m_table_view->set_editable(true);
|
||||
|
||||
m_table_view->aid_create_editing_delegate = [this](auto& index) -> OwnPtr<GModelEditingDelegate> {
|
||||
m_table_view->aid_create_editing_delegate = [this](auto& index) -> OwnPtr<GUI::ModelEditingDelegate> {
|
||||
if (!m_table_view->model())
|
||||
return nullptr;
|
||||
auto type_index = m_table_view->model()->index(index.row(), VBWidgetPropertyModel::Column::Type);
|
||||
auto type = m_table_view->model()->data(type_index, GModel::Role::Custom).to_i32();
|
||||
switch ((GVariant::Type)type) {
|
||||
case GVariant::Type::Bool:
|
||||
auto type = m_table_view->model()->data(type_index, GUI::Model::Role::Custom).to_i32();
|
||||
switch ((GUI::Variant::Type)type) {
|
||||
case GUI::Variant::Type::Bool:
|
||||
return make<BoolModelEditingDelegate>();
|
||||
default:
|
||||
return make<GStringModelEditingDelegate>();
|
||||
return make<GUI::StringModelEditingDelegate>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,18 +28,20 @@
|
|||
|
||||
#include <LibGUI/GWindow.h>
|
||||
|
||||
class GTableView;
|
||||
class GTextBox;
|
||||
namespace GUI {
|
||||
class TableView;
|
||||
class TextBox;
|
||||
}
|
||||
|
||||
class VBPropertiesWindow final : public GWindow {
|
||||
class VBPropertiesWindow final : public GUI::Window {
|
||||
C_OBJECT(VBPropertiesWindow)
|
||||
public:
|
||||
VBPropertiesWindow();
|
||||
virtual ~VBPropertiesWindow() override;
|
||||
|
||||
GTableView& table_view() { return *m_table_view; }
|
||||
const GTableView& table_view() const { return *m_table_view; }
|
||||
GUI::TableView& table_view() { return *m_table_view; }
|
||||
const GUI::TableView& table_view() const { return *m_table_view; }
|
||||
|
||||
private:
|
||||
RefPtr<GTableView> m_table_view;
|
||||
RefPtr<GUI::TableView> m_table_view;
|
||||
};
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
#include "VBProperty.h"
|
||||
#include "VBWidget.h"
|
||||
|
||||
VBProperty::VBProperty(VBWidget& widget, const String& name, const GVariant& value)
|
||||
VBProperty::VBProperty(VBWidget& widget, const String& name, const GUI::Variant& value)
|
||||
: m_widget(widget)
|
||||
, m_name(name)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
VBProperty::VBProperty(VBWidget& widget, const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter)
|
||||
VBProperty::VBProperty(VBWidget& widget, const String& name, Function<GUI::Variant(const GUI::Widget&)>&& getter, Function<void(GUI::Widget&, const GUI::Variant&)>&& setter)
|
||||
: m_widget(widget)
|
||||
, m_name(name)
|
||||
, m_getter(move(getter))
|
||||
|
@ -48,7 +48,7 @@ VBProperty::~VBProperty()
|
|||
{
|
||||
}
|
||||
|
||||
void VBProperty::set_value(const GVariant& value)
|
||||
void VBProperty::set_value(const GUI::Variant& value)
|
||||
{
|
||||
if (m_value == value)
|
||||
return;
|
||||
|
|
|
@ -26,24 +26,27 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGUI/GVariant.h>
|
||||
|
||||
class GWidget;
|
||||
namespace GUI {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
class VBWidget;
|
||||
|
||||
class VBProperty {
|
||||
friend class VBWidget;
|
||||
|
||||
public:
|
||||
VBProperty(VBWidget&, const String& name, const GVariant& value);
|
||||
VBProperty(VBWidget&, const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter);
|
||||
VBProperty(VBWidget&, const String& name, const GUI::Variant& value);
|
||||
VBProperty(VBWidget&, const String& name, Function<GUI::Variant(const GUI::Widget&)>&& getter, Function<void(GUI::Widget&, const GUI::Variant&)>&& setter);
|
||||
~VBProperty();
|
||||
|
||||
String name() const { return m_name; }
|
||||
const GVariant& value() const { return m_value; }
|
||||
void set_value(const GVariant&);
|
||||
const GUI::Variant& value() const { return m_value; }
|
||||
void set_value(const GUI::Variant&);
|
||||
|
||||
bool is_readonly() const { return m_readonly; }
|
||||
void set_readonly(bool b) { m_readonly = b; }
|
||||
|
@ -53,8 +56,8 @@ public:
|
|||
private:
|
||||
VBWidget& m_widget;
|
||||
String m_name;
|
||||
GVariant m_value;
|
||||
Function<GVariant(const GWidget&)> m_getter;
|
||||
Function<void(GWidget&, const GVariant&)> m_setter;
|
||||
GUI::Variant m_value;
|
||||
Function<GUI::Variant(const GUI::Widget&)> m_getter;
|
||||
Function<void(GUI::Widget&, const GUI::Variant&)> m_setter;
|
||||
bool m_readonly { false };
|
||||
};
|
||||
|
|
|
@ -123,7 +123,7 @@ void VBWidget::for_each_property(Function<void(VBProperty&)> callback)
|
|||
}
|
||||
}
|
||||
|
||||
void VBWidget::add_property(const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter)
|
||||
void VBWidget::add_property(const String& name, Function<GUI::Variant(const GUI::Widget&)>&& getter, Function<void(GUI::Widget&, const GUI::Variant&)>&& setter)
|
||||
{
|
||||
auto& prop = property(name);
|
||||
prop.m_getter = move(getter);
|
||||
|
@ -133,74 +133,74 @@ void VBWidget::add_property(const String& name, Function<GVariant(const GWidget&
|
|||
#define VB_ADD_PROPERTY(gclass, name, getter, setter, variant_type) \
|
||||
add_property( \
|
||||
name, \
|
||||
[](auto& widget) -> GVariant { return ((const gclass&)widget).getter(); }, \
|
||||
[](auto& widget) -> GUI::Variant { return ((const gclass&)widget).getter(); }, \
|
||||
[](auto& widget, auto& value) { ((gclass&)widget).setter(value.to_##variant_type()); })
|
||||
|
||||
void VBWidget::setup_properties()
|
||||
{
|
||||
VB_ADD_PROPERTY(Core::Object, "name", name, set_name, string);
|
||||
|
||||
VB_ADD_PROPERTY(GWidget, "width", width, set_width, i32);
|
||||
VB_ADD_PROPERTY(GWidget, "height", height, set_height, i32);
|
||||
VB_ADD_PROPERTY(GWidget, "x", x, set_x, i32);
|
||||
VB_ADD_PROPERTY(GWidget, "y", y, set_y, i32);
|
||||
VB_ADD_PROPERTY(GWidget, "visible", is_visible, set_visible, bool);
|
||||
VB_ADD_PROPERTY(GWidget, "enabled", is_enabled, set_enabled, bool);
|
||||
VB_ADD_PROPERTY(GWidget, "tooltip", tooltip, set_tooltip, string);
|
||||
VB_ADD_PROPERTY(GWidget, "backcolor", background_color, set_background_color, color);
|
||||
VB_ADD_PROPERTY(GWidget, "forecolor", foreground_color, set_foreground_color, color);
|
||||
VB_ADD_PROPERTY(GWidget, "autofill", fill_with_background_color, set_fill_with_background_color, bool);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "width", width, set_width, i32);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "height", height, set_height, i32);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "x", x, set_x, i32);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "y", y, set_y, i32);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "visible", is_visible, set_visible, bool);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "enabled", is_enabled, set_enabled, bool);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "tooltip", tooltip, set_tooltip, string);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "backcolor", background_color, set_background_color, color);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "forecolor", foreground_color, set_foreground_color, color);
|
||||
VB_ADD_PROPERTY(GUI::Widget, "autofill", fill_with_background_color, set_fill_with_background_color, bool);
|
||||
|
||||
if (m_type == VBWidgetType::GLabel) {
|
||||
VB_ADD_PROPERTY(GLabel, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GUI::Label, "text", text, set_text, string);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GButton) {
|
||||
VB_ADD_PROPERTY(GButton, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GUI::Button, "text", text, set_text, string);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GGroupBox) {
|
||||
VB_ADD_PROPERTY(GGroupBox, "title", title, set_title, string);
|
||||
VB_ADD_PROPERTY(GUI::GroupBox, "title", title, set_title, string);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GScrollBar) {
|
||||
VB_ADD_PROPERTY(GScrollBar, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GScrollBar, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GScrollBar, "value", value, set_value, i32);
|
||||
VB_ADD_PROPERTY(GScrollBar, "step", step, set_step, i32);
|
||||
VB_ADD_PROPERTY(GUI::ScrollBar, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GUI::ScrollBar, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GUI::ScrollBar, "value", value, set_value, i32);
|
||||
VB_ADD_PROPERTY(GUI::ScrollBar, "step", step, set_step, i32);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GSpinBox) {
|
||||
VB_ADD_PROPERTY(GSpinBox, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GSpinBox, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GSpinBox, "value", value, set_value, i32);
|
||||
VB_ADD_PROPERTY(GUI::SpinBox, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GUI::SpinBox, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GUI::SpinBox, "value", value, set_value, i32);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GProgressBar) {
|
||||
VB_ADD_PROPERTY(GProgressBar, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GProgressBar, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GProgressBar, "value", value, set_value, i32);
|
||||
VB_ADD_PROPERTY(GUI::ProgressBar, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GUI::ProgressBar, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GUI::ProgressBar, "value", value, set_value, i32);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GSlider) {
|
||||
VB_ADD_PROPERTY(GSlider, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GSlider, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GSlider, "value", value, set_value, i32);
|
||||
VB_ADD_PROPERTY(GUI::Slider, "min", min, set_min, i32);
|
||||
VB_ADD_PROPERTY(GUI::Slider, "max", max, set_max, i32);
|
||||
VB_ADD_PROPERTY(GUI::Slider, "value", value, set_value, i32);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GTextEditor) {
|
||||
VB_ADD_PROPERTY(GTextEditor, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GTextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool);
|
||||
VB_ADD_PROPERTY(GUI::TextEditor, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GUI::TextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GCheckBox) {
|
||||
VB_ADD_PROPERTY(GCheckBox, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GCheckBox, "checked", is_checked, set_checked, bool);
|
||||
VB_ADD_PROPERTY(GUI::CheckBox, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GUI::CheckBox, "checked", is_checked, set_checked, bool);
|
||||
}
|
||||
|
||||
if (m_type == VBWidgetType::GRadioButton) {
|
||||
VB_ADD_PROPERTY(GRadioButton, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GRadioButton, "checked", is_checked, set_checked, bool);
|
||||
VB_ADD_PROPERTY(GUI::RadioButton, "text", text, set_text, string);
|
||||
VB_ADD_PROPERTY(GUI::RadioButton, "checked", is_checked, set_checked, bool);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ VBProperty& VBWidget::property(const String& name)
|
|||
if (prop.name() == name)
|
||||
return prop;
|
||||
}
|
||||
m_properties.append(make<VBProperty>(*this, name, GVariant()));
|
||||
m_properties.append(make<VBProperty>(*this, name, GUI::Variant()));
|
||||
return m_properties.last();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,11 @@
|
|||
#include <LibDraw/Rect.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class GPainter;
|
||||
class GVariant;
|
||||
namespace GUI {
|
||||
class Painter;
|
||||
class Variant;
|
||||
}
|
||||
|
||||
class VBForm;
|
||||
class VBProperty;
|
||||
class VBWidgetPropertyModel;
|
||||
|
@ -82,7 +85,7 @@ public:
|
|||
Rect grabber_rect(Direction) const;
|
||||
Direction grabber_at(const Point&) const;
|
||||
|
||||
GWidget* gwidget() { return m_gwidget; }
|
||||
GUI::Widget* gwidget() { return m_gwidget; }
|
||||
|
||||
VBProperty& property(const String&);
|
||||
|
||||
|
@ -103,11 +106,11 @@ public:
|
|||
private:
|
||||
VBWidget(VBWidgetType, VBForm&, VBWidget* parent);
|
||||
|
||||
void add_property(const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter);
|
||||
void add_property(const String& name, Function<GUI::Variant(const GUI::Widget&)>&& getter, Function<void(GUI::Widget&, const GUI::Variant&)>&& setter);
|
||||
|
||||
VBWidgetType m_type { VBWidgetType::None };
|
||||
VBForm& m_form;
|
||||
RefPtr<GWidget> m_gwidget;
|
||||
RefPtr<GUI::Widget> m_gwidget;
|
||||
NonnullOwnPtrVector<VBProperty> m_properties;
|
||||
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
|
||||
Rect m_transform_origin_rect;
|
||||
|
|
|
@ -38,7 +38,7 @@ VBWidgetPropertyModel::~VBWidgetPropertyModel()
|
|||
{
|
||||
}
|
||||
|
||||
int VBWidgetPropertyModel::row_count(const GModelIndex&) const
|
||||
int VBWidgetPropertyModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return m_widget.m_properties.size();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ String VBWidgetPropertyModel::column_name(int column) const
|
|||
}
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const
|
||||
GUI::Model::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const
|
||||
{
|
||||
UNUSED_PARAM(column);
|
||||
if (column == Column::Name)
|
||||
|
@ -65,7 +65,7 @@ GModel::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const
|
|||
return { 90, TextAlignment::CenterLeft };
|
||||
}
|
||||
|
||||
GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
if (role == Role::Custom) {
|
||||
auto& property = m_widget.m_properties[index.row()];
|
||||
|
@ -100,7 +100,7 @@ GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void VBWidgetPropertyModel::set_data(const GModelIndex& index, const GVariant& value)
|
||||
void VBWidgetPropertyModel::set_data(const GUI::ModelIndex& index, const GUI::Variant& value)
|
||||
{
|
||||
ASSERT(index.column() == Column::Value);
|
||||
auto& property = m_widget.m_properties[index.row()];
|
||||
|
@ -108,7 +108,7 @@ void VBWidgetPropertyModel::set_data(const GModelIndex& index, const GVariant& v
|
|||
property.set_value(value);
|
||||
}
|
||||
|
||||
bool VBWidgetPropertyModel::is_editable(const GModelIndex& index) const
|
||||
bool VBWidgetPropertyModel::is_editable(const GUI::ModelIndex& index) const
|
||||
{
|
||||
if (index.column() != Column::Value)
|
||||
return false;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
class VBWidget;
|
||||
class VBProperty;
|
||||
|
||||
class VBWidgetPropertyModel : public GModel {
|
||||
class VBWidgetPropertyModel : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
Name = 0,
|
||||
|
@ -43,14 +43,14 @@ public:
|
|||
static NonnullRefPtr<VBWidgetPropertyModel> create(VBWidget& widget) { return adopt(*new VBWidgetPropertyModel(widget)); }
|
||||
virtual ~VBWidgetPropertyModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex&) const override;
|
||||
virtual int column_count(const GModelIndex&) const override { return Column::__Count; }
|
||||
virtual int row_count(const GUI::ModelIndex&) const override;
|
||||
virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; }
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override { did_update(); }
|
||||
virtual bool is_editable(const GModelIndex&) const override;
|
||||
virtual void set_data(const GModelIndex&, const GVariant&) override;
|
||||
virtual bool is_editable(const GUI::ModelIndex&) const override;
|
||||
virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override;
|
||||
|
||||
private:
|
||||
explicit VBWidgetPropertyModel(VBWidget&);
|
||||
|
|
|
@ -41,7 +41,7 @@ String to_class_name(VBWidgetType type)
|
|||
{
|
||||
switch (type) {
|
||||
case VBWidgetType::GWidget:
|
||||
return "GWidget";
|
||||
return "GUI::Widget";
|
||||
case VBWidgetType::GButton:
|
||||
return "GButton";
|
||||
case VBWidgetType::GLabel:
|
||||
|
@ -69,7 +69,7 @@ String to_class_name(VBWidgetType type)
|
|||
|
||||
VBWidgetType widget_type_from_class_name(const StringView& name)
|
||||
{
|
||||
if (name == "GWidget")
|
||||
if (name == "GUI::Widget")
|
||||
return VBWidgetType::GWidget;
|
||||
if (name == "GButton")
|
||||
return VBWidgetType::GButton;
|
||||
|
@ -94,67 +94,67 @@ VBWidgetType widget_type_from_class_name(const StringView& name)
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
static RefPtr<GWidget> build_gwidget(VBWidgetType type, GWidget* parent)
|
||||
static RefPtr<GUI::Widget> build_gwidget(VBWidgetType type, GUI::Widget* parent)
|
||||
{
|
||||
switch (type) {
|
||||
case VBWidgetType::GWidget:
|
||||
return GWidget::construct(parent);
|
||||
return GUI::Widget::construct(parent);
|
||||
case VBWidgetType::GScrollBar:
|
||||
return GScrollBar::construct(Orientation::Vertical, parent);
|
||||
return GUI::ScrollBar::construct(Orientation::Vertical, parent);
|
||||
case VBWidgetType::GGroupBox:
|
||||
return GGroupBox::construct("groupbox_1", parent);
|
||||
return GUI::GroupBox::construct("groupbox_1", parent);
|
||||
case VBWidgetType::GLabel: {
|
||||
auto label = GLabel::construct(parent);
|
||||
auto label = GUI::Label::construct(parent);
|
||||
label->set_fill_with_background_color(true);
|
||||
label->set_text("label_1");
|
||||
return label;
|
||||
}
|
||||
case VBWidgetType::GButton: {
|
||||
auto button = GButton::construct(parent);
|
||||
auto button = GUI::Button::construct(parent);
|
||||
button->set_text("button_1");
|
||||
return button;
|
||||
}
|
||||
case VBWidgetType::GSpinBox: {
|
||||
auto box = GSpinBox::construct(parent);
|
||||
auto box = GUI::SpinBox::construct(parent);
|
||||
box->set_range(0, 100);
|
||||
box->set_value(0);
|
||||
return box;
|
||||
}
|
||||
case VBWidgetType::GTextEditor: {
|
||||
auto editor = GTextEditor::construct(GTextEditor::Type::MultiLine, parent);
|
||||
auto editor = GUI::TextEditor::construct(GUI::TextEditor::Type::MultiLine, parent);
|
||||
editor->set_ruler_visible(false);
|
||||
return editor;
|
||||
}
|
||||
case VBWidgetType::GProgressBar: {
|
||||
auto bar = GProgressBar::construct(parent);
|
||||
bar->set_format(GProgressBar::Format::NoText);
|
||||
auto bar = GUI::ProgressBar::construct(parent);
|
||||
bar->set_format(GUI::ProgressBar::Format::NoText);
|
||||
bar->set_range(0, 100);
|
||||
bar->set_value(50);
|
||||
return bar;
|
||||
}
|
||||
case VBWidgetType::GSlider: {
|
||||
auto slider = GSlider::construct(Orientation::Horizontal, parent);
|
||||
auto slider = GUI::Slider::construct(Orientation::Horizontal, parent);
|
||||
slider->set_range(0, 100);
|
||||
slider->set_value(50);
|
||||
return slider;
|
||||
}
|
||||
case VBWidgetType::GCheckBox: {
|
||||
auto box = GCheckBox::construct(parent);
|
||||
auto box = GUI::CheckBox::construct(parent);
|
||||
box->set_text("checkbox_1");
|
||||
return box;
|
||||
}
|
||||
case VBWidgetType::GRadioButton:
|
||||
return GRadioButton::construct("radio_1", parent);
|
||||
return GUI::RadioButton::construct("radio_1", parent);
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr<GWidget> VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GWidget* parent, NonnullOwnPtrVector<VBProperty>& properties)
|
||||
RefPtr<GUI::Widget> VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GUI::Widget* parent, NonnullOwnPtrVector<VBProperty>& properties)
|
||||
{
|
||||
auto gwidget = ::build_gwidget(type, parent);
|
||||
auto add_readonly_property = [&](const String& name, const GVariant& value) {
|
||||
auto add_readonly_property = [&](const String& name, const GUI::Variant& value) {
|
||||
auto property = make<VBProperty>(widget, name, value);
|
||||
property->set_readonly(true);
|
||||
properties.append(move(property));
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
callback((VBWidgetType)i);
|
||||
}
|
||||
|
||||
static RefPtr<GWidget> build_gwidget(VBWidget&, VBWidgetType, GWidget* parent, NonnullOwnPtrVector<VBProperty>&);
|
||||
static RefPtr<GUI::Widget> build_gwidget(VBWidget&, VBWidgetType, GUI::Widget* parent, NonnullOwnPtrVector<VBProperty>&);
|
||||
};
|
||||
|
||||
String to_class_name(VBWidgetType);
|
||||
|
|
|
@ -43,11 +43,11 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static RefPtr<GWindow> make_toolbox_window();
|
||||
static RefPtr<GUI::Window> make_toolbox_window();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GApplication app(argc, argv);
|
||||
GUI::Application app(argc, argv);
|
||||
|
||||
auto propbox = VBPropertiesWindow::construct();
|
||||
|
||||
|
@ -56,33 +56,33 @@ int main(int argc, char** argv)
|
|||
propbox->table_view().set_model(widget ? &widget->property_model() : nullptr);
|
||||
};
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = GMenu::construct("Visual Builder");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
auto app_menu = GUI::Menu::construct("Visual Builder");
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto file_menu = GMenu::construct("File");
|
||||
file_menu->add_action(GAction::create("Dump Form", [&](auto&) {
|
||||
auto file_menu = GUI::Menu::construct("File");
|
||||
file_menu->add_action(GUI::Action::create("Dump Form", [&](auto&) {
|
||||
form1->dump();
|
||||
}));
|
||||
file_menu->add_action(GAction::create("Save Form...", { Mod_Ctrl, Key_S }, [&](auto&) {
|
||||
file_menu->add_action(GUI::Action::create("Save Form...", { Mod_Ctrl, Key_S }, [&](auto&) {
|
||||
form1->write_to_file("/tmp/form.frm");
|
||||
}));
|
||||
menubar->add_menu(move(file_menu));
|
||||
|
||||
auto window = GWindow::construct();
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title(form1->name());
|
||||
window->set_rect(120, 200, 640, 400);
|
||||
window->set_main_widget(form1);
|
||||
|
||||
window->show();
|
||||
|
||||
auto help_menu = GMenu::construct("Help");
|
||||
help_menu->add_action(GAction::create("About", [&](const GAction&) {
|
||||
GAboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window);
|
||||
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);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
|
@ -100,96 +100,96 @@ int main(int argc, char** argv)
|
|||
return app.exec();
|
||||
}
|
||||
|
||||
RefPtr<GWindow> make_toolbox_window()
|
||||
RefPtr<GUI::Window> make_toolbox_window()
|
||||
{
|
||||
auto window = GWindow::construct();
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("Widgets");
|
||||
window->set_rect(20, 200, 80, 300);
|
||||
|
||||
auto widget = GWidget::construct();
|
||||
auto widget = GUI::Widget::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GVBoxLayout>());
|
||||
widget->set_layout(make<GUI::VBoxLayout>());
|
||||
widget->layout()->set_spacing(0);
|
||||
window->set_main_widget(widget);
|
||||
|
||||
auto label_button = GButton::construct(widget);
|
||||
auto label_button = GUI::Button::construct(widget);
|
||||
label_button->set_button_style(ButtonStyle::CoolBar);
|
||||
label_button->set_tooltip("GLabel");
|
||||
label_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
label_button->on_click = [](GButton&) {
|
||||
label_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GLabel);
|
||||
};
|
||||
|
||||
auto button_button = GButton::construct(widget);
|
||||
auto button_button = GUI::Button::construct(widget);
|
||||
button_button->set_button_style(ButtonStyle::CoolBar);
|
||||
button_button->set_tooltip("GButton");
|
||||
button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button->on_click = [](GButton&) {
|
||||
button_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GButton);
|
||||
};
|
||||
auto spinbox_button = GButton::construct(widget);
|
||||
auto spinbox_button = GUI::Button::construct(widget);
|
||||
spinbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
spinbox_button->set_tooltip("GSpinBox");
|
||||
spinbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button->on_click = [](GButton&) {
|
||||
spinbox_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSpinBox);
|
||||
};
|
||||
auto editor_button = GButton::construct(widget);
|
||||
auto editor_button = GUI::Button::construct(widget);
|
||||
editor_button->set_button_style(ButtonStyle::CoolBar);
|
||||
editor_button->set_tooltip("GTextEditor");
|
||||
editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button->on_click = [](GButton&) {
|
||||
editor_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GTextEditor);
|
||||
};
|
||||
auto progress_bar_button = GButton::construct(widget);
|
||||
auto progress_bar_button = GUI::Button::construct(widget);
|
||||
progress_bar_button->set_button_style(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->on_click = [](GButton&) {
|
||||
progress_bar_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GProgressBar);
|
||||
};
|
||||
auto slider_button = GButton::construct(widget);
|
||||
auto slider_button = GUI::Button::construct(widget);
|
||||
slider_button->set_button_style(ButtonStyle::CoolBar);
|
||||
slider_button->set_tooltip("GSlider");
|
||||
slider_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
slider_button->on_click = [](GButton&) {
|
||||
slider_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSlider);
|
||||
};
|
||||
auto checkbox_button = GButton::construct(widget);
|
||||
auto checkbox_button = GUI::Button::construct(widget);
|
||||
checkbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
checkbox_button->set_tooltip("GCheckBox");
|
||||
checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
checkbox_button->on_click = [](GButton&) {
|
||||
checkbox_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GCheckBox);
|
||||
};
|
||||
auto radiobutton_button = GButton::construct(widget);
|
||||
auto radiobutton_button = GUI::Button::construct(widget);
|
||||
radiobutton_button->set_button_style(ButtonStyle::CoolBar);
|
||||
radiobutton_button->set_tooltip("GRadioButton");
|
||||
radiobutton_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
radiobutton_button->on_click = [](GButton&) {
|
||||
radiobutton_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GRadioButton);
|
||||
};
|
||||
auto scrollbar_button = GButton::construct(widget);
|
||||
auto scrollbar_button = GUI::Button::construct(widget);
|
||||
scrollbar_button->set_button_style(ButtonStyle::CoolBar);
|
||||
scrollbar_button->set_tooltip("GScrollBar");
|
||||
scrollbar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
scrollbar_button->on_click = [](GButton&) {
|
||||
scrollbar_button->on_click = [](GUI::Button&) {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GScrollBar);
|
||||
};
|
||||
auto groupbox_button = GButton::construct(widget);
|
||||
auto groupbox_button = GUI::Button::construct(widget);
|
||||
groupbox_button->set_button_style(ButtonStyle::CoolBar);
|
||||
groupbox_button->set_tooltip("GGroupBox");
|
||||
groupbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
groupbox_button->on_click = [](GButton&) {
|
||||
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