mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
VisualBuilder: Tweak grid size and add an (empty) toolbox window.
This commit is contained in:
parent
c6ffb3e2b8
commit
c71ece77fa
Notes:
sideshowbarker
2024-07-19 14:45:40 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c71ece77fab
5 changed files with 30 additions and 7 deletions
|
@ -11,15 +11,15 @@ VBForm::VBForm(const String& name, GWidget* parent)
|
|||
set_greedy_for_hits(true);
|
||||
|
||||
auto box1 = VBWidget::create(WidgetType::GSpinBox, *this);
|
||||
box1->set_rect({ 10, 10, 61, 21 });
|
||||
box1->set_rect({ 10, 10, 81, 25 });
|
||||
m_widgets.append(move(box1));
|
||||
|
||||
auto box2 = VBWidget::create(WidgetType::GTextEditor, *this);
|
||||
box2->set_rect({ 100, 100, 161, 141 });
|
||||
box2->set_rect({ 100, 100, 161, 161 });
|
||||
m_widgets.append(move(box2));
|
||||
|
||||
auto button1 = VBWidget::create(WidgetType::GButton, *this);
|
||||
button1->set_rect({ 200, 50, 101, 21 });
|
||||
button1->set_rect({ 200, 50, 81, 25 });
|
||||
m_widgets.append(move(button1));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
void grabber_mousedown_event(GMouseEvent&, VBWidget&, Direction grabber);
|
||||
|
||||
String m_name;
|
||||
int m_grid_size { 5 };
|
||||
int m_grid_size { 8 };
|
||||
bool m_should_snap_to_grid { true };
|
||||
Vector<Retained<VBWidget>> m_widgets;
|
||||
WeakPtr<VBWidget> m_selected_widget;
|
||||
|
|
|
@ -17,8 +17,11 @@ static GWidget* build_gwidget(WidgetType type, GWidget* parent)
|
|||
return new GButton(parent);
|
||||
case WidgetType::GSpinBox:
|
||||
return new GSpinBox(parent);
|
||||
case WidgetType::GTextEditor:
|
||||
return new GTextEditor(GTextEditor::Type::MultiLine, parent);
|
||||
case WidgetType::GTextEditor: {
|
||||
auto* editor = new GTextEditor(GTextEditor::Type::MultiLine, parent);
|
||||
editor->set_ruler_visible(false);
|
||||
return editor;
|
||||
}
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return nullptr;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static GWindow* make_toolbox_window();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GApplication app(argc, argv);
|
||||
|
@ -47,10 +49,25 @@ int main(int argc, char** argv)
|
|||
|
||||
auto* window = new GWindow;
|
||||
window->set_title(form1->name());
|
||||
window->set_rect(20, 200, 640, 400);
|
||||
window->set_rect(120, 200, 640, 400);
|
||||
window->set_main_widget(form1);
|
||||
window->set_should_exit_event_loop_on_close(true);
|
||||
window->show();
|
||||
|
||||
auto* toolbox = make_toolbox_window();
|
||||
toolbox->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
GWindow* make_toolbox_window()
|
||||
{
|
||||
auto* window = new GWindow;
|
||||
window->set_title("Widgets");
|
||||
window->set_rect(20, 200, 80, 300);
|
||||
|
||||
auto* widget = new GWidget;
|
||||
widget->set_fill_with_background_color(true);
|
||||
window->set_main_widget(widget);
|
||||
return window;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ public:
|
|||
bool is_single_line() const { return m_type == SingleLine; }
|
||||
bool is_multi_line() const { return m_type == MultiLine; }
|
||||
|
||||
bool is_ruler_visible() const { return m_ruler_visible; }
|
||||
void set_ruler_visible(bool b) { m_ruler_visible = b; }
|
||||
|
||||
Function<void()> on_cursor_change;
|
||||
|
||||
void set_text(const String&);
|
||||
|
|
Loading…
Reference in a new issue