add ppbr export dialog, implement text input focus
This commit is contained in:
@@ -345,6 +345,7 @@
|
||||
<ClCompile Include="src\node_combobox.cpp" />
|
||||
<ClCompile Include="src\node_dialog_browse.cpp" />
|
||||
<ClCompile Include="src\node_dialog_cloud.cpp" />
|
||||
<ClCompile Include="src\node_dialog_export_ppbr.cpp" />
|
||||
<ClCompile Include="src\node_dialog_layer_rename.cpp" />
|
||||
<ClCompile Include="src\node_dialog_open.cpp" />
|
||||
<ClCompile Include="src\node_dialog_picker.cpp" />
|
||||
@@ -472,6 +473,7 @@
|
||||
<ClInclude Include="src\node_combobox.h" />
|
||||
<ClInclude Include="src\node_dialog_browse.h" />
|
||||
<ClInclude Include="src\node_dialog_cloud.h" />
|
||||
<ClInclude Include="src\node_dialog_export_ppbr.h" />
|
||||
<ClInclude Include="src\node_dialog_layer_rename.h" />
|
||||
<ClInclude Include="src\node_dialog_open.h" />
|
||||
<ClInclude Include="src\node_dialog_picker.h" />
|
||||
|
||||
@@ -369,6 +369,9 @@
|
||||
<ClCompile Include="src\node_input_box.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\node_dialog_export_ppbr.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\app.h">
|
||||
@@ -614,6 +617,9 @@
|
||||
<ClInclude Include="src\node_input_box.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\node_dialog_export_ppbr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PanoPainter.rc">
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifdef __QUEST__
|
||||
#include "oculus_vr.h"
|
||||
#endif
|
||||
#include "node_dialog_export_ppbr.h"
|
||||
|
||||
std::shared_ptr<NodeProgressBar> 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<NodeDialogExportPPBR>();
|
||||
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();
|
||||
};
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
32
src/node_dialog_export_ppbr.cpp
Normal file
32
src/node_dialog_export_ppbr.cpp
Normal file
@@ -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<NodeDialogExportPPBR*>(dest);
|
||||
n->init_controls();
|
||||
}
|
||||
|
||||
void NodeDialogExportPPBR::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(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<NodeButton>("btn-ok");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [this](Node*) {
|
||||
destroy();
|
||||
};
|
||||
}
|
||||
16
src/node_dialog_export_ppbr.h
Normal file
16
src/node_dialog_export_ppbr.h
Normal file
@@ -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();
|
||||
};
|
||||
@@ -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<Serializer::Integer>(img_patterns.size());
|
||||
info.props["num_brushes"] = std::make_shared<Serializer::Integer>(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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -8,6 +8,7 @@ public:
|
||||
float timer = 0;
|
||||
NodeText* m_text;
|
||||
NodeBorder* m_cursor;
|
||||
NodeBorder* m_border;
|
||||
std::string m_string;
|
||||
std::function<void(NodeTextInput*target)> on_return;
|
||||
virtual Node* clone_instantiate() const override;
|
||||
|
||||
Reference in New Issue
Block a user