From 5e733d47a35ffb3779d44a25c4b95fa907b68daf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 7 May 2019 23:28:35 +0200 Subject: VisualBuilder: Add a way to dump the current form to the debugger. --- Applications/VisualBuilder/VBForm.cpp | 13 +++++++++++++ Applications/VisualBuilder/VBForm.h | 2 ++ Applications/VisualBuilder/VBWidget.cpp | 7 +++++++ Applications/VisualBuilder/VBWidget.h | 2 ++ Applications/VisualBuilder/main.cpp | 3 +++ 5 files changed, 27 insertions(+) diff --git a/Applications/VisualBuilder/VBForm.cpp b/Applications/VisualBuilder/VBForm.cpp index 0b34fe2e4f..2e9af9bfea 100644 --- a/Applications/VisualBuilder/VBForm.cpp +++ b/Applications/VisualBuilder/VBForm.cpp @@ -300,6 +300,19 @@ void VBForm::mousemove_event(GMouseEvent& event) } } +void VBForm::dump() +{ + dbgprintf("[Form]\n"); + dbgprintf("Name=%s\n", m_name.characters()); + dbgprintf("\n"); + int i = 0; + for (auto& widget : m_widgets) { + dbgprintf("[Widget %d]\n", i++); + widget->dump(); + dbgprintf("\n"); + } +} + void VBForm::mouseup_event(GMouseEvent& event) { if (event.button() == GMouseButton::Left) { diff --git a/Applications/VisualBuilder/VBForm.h b/Applications/VisualBuilder/VBForm.h index 4fa49c0c26..8968719533 100644 --- a/Applications/VisualBuilder/VBForm.h +++ b/Applications/VisualBuilder/VBForm.h @@ -25,6 +25,8 @@ public: Function on_widget_selected; + void dump(); + protected: virtual void paint_event(GPaintEvent&) override; virtual void second_paint_event(GPaintEvent&) override; diff --git a/Applications/VisualBuilder/VBWidget.cpp b/Applications/VisualBuilder/VBWidget.cpp index 83e92167de..5df3eb6696 100644 --- a/Applications/VisualBuilder/VBWidget.cpp +++ b/Applications/VisualBuilder/VBWidget.cpp @@ -195,3 +195,10 @@ void VBWidget::capture_transform_origin_rect() { m_transform_origin_rect = rect(); } + +void VBWidget::dump() +{ + for (auto& property : m_properties) { + dbgprintf("%s=%s\n", property->name().characters(), property->value().to_string().characters()); + } +} diff --git a/Applications/VisualBuilder/VBWidget.h b/Applications/VisualBuilder/VBWidget.h index afd240b081..744b7e29c0 100644 --- a/Applications/VisualBuilder/VBWidget.h +++ b/Applications/VisualBuilder/VBWidget.h @@ -59,6 +59,8 @@ public: Rect transform_origin_rect() const { return m_transform_origin_rect; } void capture_transform_origin_rect(); + void dump(); + private: VBWidget(VBWidgetType, VBForm&); diff --git a/Applications/VisualBuilder/main.cpp b/Applications/VisualBuilder/main.cpp index 0e00ab45c5..27642d2a3e 100644 --- a/Applications/VisualBuilder/main.cpp +++ b/Applications/VisualBuilder/main.cpp @@ -37,6 +37,9 @@ int main(int argc, char** argv) menubar->add_menu(move(app_menu)); auto file_menu = make("File"); + file_menu->add_action(GAction::create("Dump Form", [&] (auto&) { + form1->dump(); + })); menubar->add_menu(move(file_menu)); auto edit_menu = make("Edit"); -- cgit v1.2.3