fix color picker, add project delete button with message box
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "canvas.h"
|
||||
#include "node_image_texture.h"
|
||||
#include "asset.h"
|
||||
#include "node_message_box.h"
|
||||
#include "app.h"
|
||||
|
||||
Node* NodeDialogOpen::clone_instantiate() const
|
||||
{
|
||||
@@ -32,6 +34,40 @@ void NodeDialogOpen::init_controls()
|
||||
btn_cancel->on_click = [this](Node*) {
|
||||
destroy();
|
||||
};
|
||||
btn_delete = find<NodeButton>("btn-delete");
|
||||
btn_delete->on_click = [this](Node*) {
|
||||
if (!current)
|
||||
return;
|
||||
|
||||
auto msgbox = new NodeMessageBox();
|
||||
msgbox->m_manager = m_manager;
|
||||
msgbox->init();
|
||||
msgbox->m_title->set_text("Delete Project");
|
||||
msgbox->m_message->set_text(("Are you sure you want to delete " + current->m_file_name + "?").c_str());
|
||||
msgbox->btn_ok->on_click = [this,msgbox](Node*){
|
||||
auto path = current->m_path;
|
||||
int idx = container->get_child_index(current);
|
||||
container->remove_child(current);
|
||||
if (!container->m_children.empty())
|
||||
{
|
||||
int newidx = std::min<int>(idx, (int)container->m_children.size() - 1);
|
||||
auto next = (NodeDialogOpenItem*)container->get_child_at(newidx);
|
||||
current = nullptr;
|
||||
next->on_selected(next);
|
||||
next->m_selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current = nullptr;
|
||||
auto image_tex = find<NodeImageTexture>("thumb-tex");
|
||||
image_tex->tex.destroy();
|
||||
}
|
||||
Asset::delete_file(path);
|
||||
msgbox->destroy();
|
||||
};
|
||||
root()->add_child(msgbox);
|
||||
root()->update();
|
||||
};
|
||||
container = find<Node>("files-list");
|
||||
auto names = Asset::list_files(data_path, false, ".*\\.pano");
|
||||
for (const auto& n : names)
|
||||
@@ -43,7 +79,6 @@ void NodeDialogOpen::init_controls()
|
||||
node->m_path = data_path + "/" + n;
|
||||
node->m_file_name = n;
|
||||
node->on_selected = [&](NodeDialogOpenItem* target) {
|
||||
static NodeDialogOpenItem* current = nullptr;
|
||||
if (target == current)
|
||||
return;
|
||||
ui::Image thumb = ui::Canvas::I->thumbnail_read(target->m_path);
|
||||
|
||||
Reference in New Issue
Block a user