--- /dev/null
+#include <msp/gltk/button.h>
+#include <msp/gltk/dialog.h>
+#include <msp/gltk/entry.h>
+#include <msp/gltk/root.h>
+#include "dialogdemo.h"
+
+using namespace std;
+using namespace Msp;
+
+class PromptDialog: public GLtk::Dialog
+{
+public:
+ sigc::signal<void, string> signal_text_response;
+
+private:
+ GLtk::Entry ent_text;
+
+public:
+ PromptDialog();
+
+protected:
+ void on_response(int) override;
+};
+
+
+DialogDemo::DialogDemo()
+{
+ get_or_create_layout();
+
+ GLtk::Button *btn_prompt = new GLtk::Button("Enter some text");
+ add(*btn_prompt);
+ btn_prompt->signal_clicked.connect(sigc::mem_fun(this, &DialogDemo::button_clicked));
+
+ add(lbl_text);
+ layout->add_constraint(lbl_text, GLtk::Layout::BELOW, *btn_prompt);
+ layout->set_expand(lbl_text, true, false);
+}
+
+void DialogDemo::button_clicked()
+{
+ GLtk::Root *root = find_ancestor<GLtk::Root>();
+ PromptDialog *dialog = GLtk::AutoDialog<PromptDialog>::create();
+ root->add(*dialog);
+ root->get_or_create_layout().set_gravity(*dialog, 0, 0);
+ dialog->signal_text_response.connect(sigc::mem_fun(this, &DialogDemo::got_response));
+}
+
+void DialogDemo::got_response(const string &text)
+{
+ lbl_text.set_text(text);
+}
+
+
+PromptDialog::PromptDialog()
+{
+ get_or_create_layout();
+
+ ent_text.set_edit_size(50, 1);
+ add(ent_text);
+ layout->set_expand(ent_text, true, false);
+
+ GLtk::Button *btn_ok = new GLtk::Button("OK");
+ add_button(*btn_ok, 1);
+ layout->add_constraint(*btn_ok, GLtk::Layout::FAR_BELOW, ent_text);
+ layout->set_gravity(*btn_ok, 1, -1);
+}
+
+void PromptDialog::on_response(int)
+{
+ signal_text_response.emit(ent_text.get_text());
+}
#include <msp/gl/framebuffer.h>
#include <msp/gltk/layout.h>
#include "buttondemo.h"
+#include "dialogdemo.h"
#include "dropdowndemo.h"
#include "entrydemo.h"
#include "toggledemo.h"
root_layout.set_expand(selector, false, true);
add_demo("Button", new ButtonDemo);
+ add_demo("Dialog", new DialogDemo);
add_demo("Dropdown", new DropdownDemo);
add_demo("Entry", new EntryDemo);
add_demo("Toggle", new ToggleDemo);