diff --git a/PanoPainter.vcxproj b/PanoPainter.vcxproj index 85f4df0..15437a4 100644 --- a/PanoPainter.vcxproj +++ b/PanoPainter.vcxproj @@ -345,6 +345,7 @@ + @@ -472,6 +473,7 @@ + diff --git a/PanoPainter.vcxproj.filters b/PanoPainter.vcxproj.filters index d359561..ffe4c4e 100644 --- a/PanoPainter.vcxproj.filters +++ b/PanoPainter.vcxproj.filters @@ -369,6 +369,9 @@ Source Files + + Source Files + @@ -614,6 +617,9 @@ Header Files + + Header Files + diff --git a/src/app.h b/src/app.h index 4331397..c1bccc3 100644 --- a/src/app.h +++ b/src/app.h @@ -241,6 +241,7 @@ public: void dialog_layer_rename(); void dialog_resize(); void dialog_preset_download(); + void dialog_ppbr_export(); void cloud_upload(); void cloud_upload_all(); diff --git a/src/app_dialogs.cpp b/src/app_dialogs.cpp index f611497..91f8a50 100644 --- a/src/app_dialogs.cpp +++ b/src/app_dialogs.cpp @@ -12,6 +12,7 @@ #ifdef __QUEST__ #include "oculus_vr.h" #endif +#include "node_dialog_export_ppbr.h" std::shared_ptr App::show_progress(const std::string& title, int total /*= 0*/) { @@ -595,3 +596,25 @@ void App::dialog_preset_download() { } + +void App::dialog_ppbr_export() +{ + auto root = layout[main_id]; + auto dialog = root->add_child_ref(); + dialog->btn_ok->on_click = [this,dialog] (Node*) { +#if __IOS__ + App::I->pick_file_save("ppbr", [this](std::string path) { + presets->export_ppbr(path, {}); + }); +#else + App::I->pick_file_save({ "ppbr" }, [this](std::string path) { + std::thread([this, path] { + BT_SetTerminate(); + presets->export_ppbr(path, {}); + App::I->message_box("Export PPBR", "Brushes exported to:\n" + path); + }).detach(); + }); +#endif + dialog->destroy(); + }; +} \ No newline at end of file diff --git a/src/node.cpp b/src/node.cpp index 4bd66bf..1aecbce 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -92,6 +92,9 @@ Node* Node::root() kEventResult Node::on_event(Event* e) { kEventResult ret = kEventResult::Available; + + if (e->m_cat == kEventCategory::KeyEvent && current_key_capture) + return current_key_capture->on_event(e); if (current_mouse_capture && current_mouse_capture.get() != this) { diff --git a/src/node_dialog_export_ppbr.cpp b/src/node_dialog_export_ppbr.cpp new file mode 100644 index 0000000..87f8a10 --- /dev/null +++ b/src/node_dialog_export_ppbr.cpp @@ -0,0 +1,32 @@ +#include "pch.h" +#include "log.h" +#include "node_dialog_export_ppbr.h" + +Node* NodeDialogExportPPBR::clone_instantiate() const +{ + return new NodeDialogExportPPBR(); +} + +void NodeDialogExportPPBR::clone_finalize(Node* dest) const +{ + NodeDialogExportPPBR* n = static_cast(dest); + n->init_controls(); +} + +void NodeDialogExportPPBR::init() +{ + auto tpl = static_cast(init_template("dialog-brush-upload")); + m_color = tpl->m_color; + m_border_color = tpl->m_border_color;; + m_thinkness = tpl->m_thinkness;; + init_controls(); +} + +void NodeDialogExportPPBR::init_controls() +{ + btn_ok = find("btn-ok"); + btn_cancel = find("btn-cancel"); + btn_cancel->on_click = [this](Node*) { + destroy(); + }; +} diff --git a/src/node_dialog_export_ppbr.h b/src/node_dialog_export_ppbr.h new file mode 100644 index 0000000..76ce186 --- /dev/null +++ b/src/node_dialog_export_ppbr.h @@ -0,0 +1,16 @@ +#pragma once +#include "node_border.h" +#include "node_button.h" +#include "node_combobox.h" +#include "node_text.h" + +class NodeDialogExportPPBR : public NodeBorder +{ +public: + NodeButton* btn_cancel; + NodeButton* btn_ok; + virtual Node* clone_instantiate() const override; + virtual void clone_finalize(Node* dest) const override; + virtual void init() override; + void init_controls(); +}; diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index 98e485e..9b8d208 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -502,19 +502,7 @@ void NodePanelBrushPreset::init() }); break; case 1: // export file - #if __IOS__ - App::I->pick_file_save("ppbr", [this] (std::string path) { - export_ppbr(path, {}); - }); - #else - App::I->pick_file_save({ "ppbr" }, [this] (std::string path) { - std::thread([this, path] { - BT_SetTerminate(); - export_ppbr(path, {}); - App::I->message_box("Export PPBR", "Brushes exported to:\n" + path); - }).detach(); - }); - #endif + App::I->dialog_ppbr_export(); break; case 2: // download break; @@ -732,7 +720,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& hea info.props["num_brush_patt"] = std::make_shared(img_patterns.size()); info.props["num_brushes"] = std::make_shared(m_container->m_children.size()); - auto pb = App::I->show_progress("Exporting ABR", 1 + img_brushes.size() + + auto pb = App::I->show_progress("Exporting PPBR", 1 + img_brushes.size() + img_patterns.size() + m_container->m_children.size() * 2); sw << info; @@ -833,7 +821,7 @@ bool NodePanelBrushPreset::import_ppbr(const std::string& path) std::string info_dump = info.str(0, "Info"); LOG("%s", info_dump.c_str()); - auto pb = App::I->show_progress("Importing ABR", 1 + num_brush_patt + num_brush_tips + num_brushes * 2); + auto pb = App::I->show_progress("Importing PPBR", 1 + num_brush_patt + num_brush_tips + num_brushes * 2); // header image Image header_image; diff --git a/src/node_text_input.cpp b/src/node_text_input.cpp index cb8998b..27ec9e5 100644 --- a/src/node_text_input.cpp +++ b/src/node_text_input.cpp @@ -12,10 +12,16 @@ Node* NodeTextInput::clone_instantiate() const void NodeTextInput::on_tick(float dt) { timer += dt; + + bool focus = root()->current_key_capture.get() == this; + if (m_cursor && !focus) + m_cursor->m_display = false; + m_thinkness = focus; + if (timer > 1.0) { timer = 0; - if (m_cursor) + if (focus && m_cursor) { m_cursor->m_display = !m_cursor->m_display; app_redraw(); @@ -67,6 +73,9 @@ kEventResult NodeTextInput::handle_event(Event* e) break; case kEventType::MouseUpL: key_capture(); + timer = 0; + if (m_cursor) + m_cursor->m_display = true; break; case kEventType::KeyDown: //switch (ke->m_key) diff --git a/src/node_text_input.h b/src/node_text_input.h index 7885763..48e73e9 100644 --- a/src/node_text_input.h +++ b/src/node_text_input.h @@ -8,6 +8,7 @@ public: float timer = 0; NodeText* m_text; NodeBorder* m_cursor; + NodeBorder* m_border; std::string m_string; std::function on_return; virtual Node* clone_instantiate() const override;