add save dialog to specify file name
This commit is contained in:
@@ -283,7 +283,20 @@ void App::initLayout()
|
||||
button->on_click = [this,button](Node*) {
|
||||
if (canvas)
|
||||
{
|
||||
canvas->m_canvas->project_save(data_path);
|
||||
auto dialog = std::make_shared<NodeDialogSave>();
|
||||
dialog->m_manager = &layout;
|
||||
dialog->init();
|
||||
dialog->create();
|
||||
dialog->loaded();
|
||||
|
||||
layout[main_id]->add_child(dialog);
|
||||
layout[main_id]->update();
|
||||
|
||||
dialog->btn_ok->on_click = [this, dialog](Node*)
|
||||
{
|
||||
canvas->m_canvas->project_save(data_path + "/" + dialog->input->m_string + ".pano");
|
||||
dialog->destroy();
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1000,12 +1000,12 @@ void ui::Canvas::export_anim(std::string data_path)
|
||||
|
||||
void ui::Canvas::project_save(std::string data_path)
|
||||
{
|
||||
static char name[128];
|
||||
sprintf(name, "%s/latlong.pano", data_path.c_str());
|
||||
FILE* fp = fopen(name, "wb");
|
||||
// static char name[128];
|
||||
// sprintf(name, "%s/latlong.pano", data_path.c_str());
|
||||
FILE* fp = fopen(data_path.c_str(), "wb");
|
||||
if (!fp)
|
||||
{
|
||||
LOG("cannot write project to %s", name);
|
||||
LOG("cannot write project to %s", data_path.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ void ui::Canvas::project_save(std::string data_path)
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
LOG("project saved to %s", name);
|
||||
LOG("project saved to %s", data_path.c_str());
|
||||
}
|
||||
|
||||
void ui::Canvas::project_open(std::string data_path)
|
||||
|
||||
@@ -66,9 +66,6 @@ void NodeDialogOpen::init_controls()
|
||||
|
||||
void NodeDialogOpen::loaded()
|
||||
{
|
||||
// ui::Image thumb = ui::Canvas::I->thumbnail_read(data_path);
|
||||
// auto image_tex = find<NodeImageTexture>("thumb-tex");
|
||||
// image_tex->tex.create(thumb);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@@ -126,4 +123,37 @@ kEventResult NodeDialogOpenItem::handle_event(Event* e)
|
||||
break;
|
||||
}
|
||||
return kEventResult::Consumed;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
Node* NodeDialogSave::clone_instantiate() const
|
||||
{
|
||||
return new NodeDialogSave;
|
||||
}
|
||||
void NodeDialogSave::clone_finalize(Node* dest) const
|
||||
{
|
||||
NodeDialogSave* n = static_cast<NodeDialogSave*>(dest);
|
||||
n->init_controls();
|
||||
}
|
||||
void NodeDialogSave::init()
|
||||
{
|
||||
auto tpl = static_cast<const NodeBorder*>(init_template("dialog-save"));
|
||||
m_color = tpl->m_color;
|
||||
m_border_color = tpl->m_border_color;
|
||||
m_thinkness = tpl->m_thinkness;
|
||||
init_controls();
|
||||
}
|
||||
void NodeDialogSave::init_controls()
|
||||
{
|
||||
btn_ok = find<NodeButton>("btn-ok");
|
||||
btn_cancel = find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [this](Node*) {
|
||||
destroy();
|
||||
};
|
||||
input = find<NodeTextInput>("txt-input");
|
||||
}
|
||||
void NodeDialogSave::loaded()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "node_button.h"
|
||||
#include "node_image_texture.h"
|
||||
#include "node_text.h"
|
||||
#include "node_text_input.h"
|
||||
|
||||
class NodeDialogOpenItem : public NodeBorder
|
||||
{
|
||||
@@ -38,3 +39,17 @@ public:
|
||||
void init_controls();
|
||||
virtual void loaded() override;
|
||||
};
|
||||
|
||||
class NodeDialogSave : public NodeBorder
|
||||
{
|
||||
public:
|
||||
NodeButton* btn_cancel;
|
||||
NodeButton* btn_ok;
|
||||
NodeTextInput* input;
|
||||
std::string selected_path;
|
||||
virtual Node* clone_instantiate() const override;
|
||||
virtual void clone_finalize(Node* dest) const override;
|
||||
virtual void init() override;
|
||||
void init_controls();
|
||||
virtual void loaded() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user