diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj
index 667d395..85f4df0 100644
--- a/PanoPainter.vcxproj
+++ b/PanoPainter.vcxproj
@@ -352,6 +352,7 @@
+
@@ -478,6 +479,7 @@
+
diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters
index 5e0ede5..d359561 100644
--- a/PanoPainter.vcxproj.filters
+++ b/PanoPainter.vcxproj.filters
@@ -366,6 +366,9 @@
libs\glad
+
+ Source Files
+
@@ -608,6 +611,9 @@
Header Files\ui
+
+ Header Files
+
diff --git a/data/layout.xml b/data/layout.xml
index e9eaa1e..d225c2f 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -869,7 +869,28 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app.h b/src/app.h
index 03a27f8..7ad814b 100644
--- a/src/app.h
+++ b/src/app.h
@@ -33,6 +33,7 @@
#endif
#include "node_panel_grid.h"
#include "node_panel_quick.h"
+#include "node_input_box.h"
struct VRController
{
@@ -206,7 +207,6 @@ public:
bool key_char(char key);
void toggle_ui();
void set_stylus();
- std::shared_ptr message_box(const std::string& title, const std::string& text, bool cancel_button = false);
void rec_clear();
void rec_loop();
@@ -241,11 +241,17 @@ public:
void cloud_upload();
void cloud_upload_all();
void cloud_browse();
- void upload(std::string filename, std::string name = "", std::function progress = nullptr);
- void download(std::string url, std::string dest_filepath, std::function progress = nullptr);
+ void upload(std::string filename, std::string name = "",
+ std::function progress = nullptr);
+ void download(std::string url, std::string dest_filepath,
+ std::function progress = nullptr);
bool check_license();
std::shared_ptr show_progress(const std::string& title, int total = 0);
+ std::shared_ptr message_box(const std::string& title,
+ const std::string& text, bool cancel_button = false);
+ std::shared_ptr input_box(const std::string& title,
+ const std::string& field_name, const std::string& ok_caption = "Ok");
void brush_update(bool update_color, bool update_brush);
void title_update();
diff --git a/src/app_dialogs.cpp b/src/app_dialogs.cpp
index 320d11c..f611497 100644
--- a/src/app_dialogs.cpp
+++ b/src/app_dialogs.cpp
@@ -44,6 +44,21 @@ std::shared_ptr App::message_box(const std::string &title, const
return m;
}
+std::shared_ptr App::input_box(const std::string& title,
+ const std::string& field_name, const std::string& ok_caption /*= "Ok"*/)
+{
+ auto m = std::make_shared();
+ m->m_manager = &layout;
+ m->init();
+ m->create();
+ m->loaded();
+ m->m_title->set_text(title.c_str());
+ m->m_field_name->set_text(field_name.c_str());
+ m->btn_ok->m_text->set_text(ok_caption.c_str());
+ layout[main_id]->add_child(m);
+ return m;
+}
+
void App::dialog_usermanual()
{
auto dialog = std::make_shared();
diff --git a/src/node_input_box.cpp b/src/node_input_box.cpp
new file mode 100644
index 0000000..347b891
--- /dev/null
+++ b/src/node_input_box.cpp
@@ -0,0 +1,57 @@
+#include "pch.h"
+#include "log.h"
+#include "node_input_box.h"
+#include "layout.h"
+
+Node* NodeInputBox::clone_instantiate() const
+{
+ return new NodeInputBox();
+}
+
+void NodeInputBox::init()
+{
+ SetPosition(0, 0);
+ SetWidthP(100);
+ SetHeightP(100);
+ SetPositioning(YGPositionTypeAbsolute);
+ auto m_template = (*m_manager)[const_hash("input-box")]->m_children[0]->clone();
+ add_child(m_template);
+ m_title = m_template->find("title");
+ m_field_name = m_template->find("field-name");
+ m_field_text = m_template->find("field-text");
+ btn_ok = m_template->find("btn-ok");
+ btn_ok->on_click = [&](Node*) {
+ if (on_submit)
+ on_submit(this, m_field_text->m_text->m_text);
+ };
+ btn_cancel = m_template->find("btn-cancel");
+ btn_cancel->on_click = [&](Node*) { destroy(); };
+ m_capture_children = false; // don't capture children events on mouse_capture
+}
+
+kEventResult NodeInputBox::handle_event(Event* e)
+{
+ Node::handle_event(e);
+ auto ke = (KeyEvent*)e;
+ switch (e->m_type)
+ {
+ case kEventType::KeyDown:
+ break;
+ case kEventType::KeyUp:
+ if (ke->m_key == kKey::KeyEnter && on_submit)
+ on_submit(this, m_field_text->m_text->m_text);
+ break;
+ case kEventType::KeyChar:
+ break;
+ default:
+ return kEventResult::Available;
+ break;
+ }
+ return kEventResult::Consumed;
+}
+
+void NodeInputBox::added(Node* parent)
+{
+ Node::added(parent);
+ mouse_capture();
+}
diff --git a/src/node_input_box.h b/src/node_input_box.h
new file mode 100644
index 0000000..4511239
--- /dev/null
+++ b/src/node_input_box.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "node.h"
+#include "node_button.h"
+#include "node_text_input.h"
+
+class NodeInputBox : public Node
+{
+public:
+ std::function on_submit = nullptr;
+ NodeButton* btn_ok;
+ NodeButton* btn_cancel;
+ NodeText* m_field_name;
+ NodeTextInput* m_field_text;
+ NodeText* m_title;
+ virtual Node* clone_instantiate() const override;
+ virtual void init() override;
+ virtual kEventResult handle_event(Event* e) override;
+ virtual void added(Node* parent) override;
+};