add tick and on_tick event, fix unsaved document prompt, implement TextInput blinking cursor

This commit is contained in:
2018-10-08 01:00:49 +02:00
parent e2069fadca
commit c9c7b9f1c4
19 changed files with 226 additions and 46 deletions

View File

@@ -5,6 +5,7 @@
#include "node_image_texture.h"
#include "asset.h"
#include "node_message_box.h"
#include "node_text.h"
#include "app.h"
Node* NodeDialogBrowse::clone_instantiate() const
@@ -72,6 +73,47 @@ void NodeDialogBrowse::init_controls()
root()->update();
};
container = find<Node>("files-list");
init_list();
#if defined(_WIN32) || defined(__OSX__)
static char path_buffer[256];
btn_path = find<NodeButton>("btn-path");
btn_path->on_click = [this](Node*){
App::I.pick_dir([this](std::string path){
LOG("change working path to %s", path.c_str());
async_start();
App::I.work_path = path;
realpath(path.c_str(), path_buffer);
working_path->set_text_format("Destination dir: %s", path_buffer);
search_path = path;
clear_list();
init_list();
async_update();
async_end();
});
};
working_path = find<NodeText>("path");
realpath(App::I.work_path.c_str(), path_buffer);
working_path->set_text_format("Working dir: %s", path_buffer);
#endif
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))
// {
// first->on_selected(first);
// first->m_selected = true;
// }
}
void NodeDialogBrowse::clear_list()
{
for (auto& n : container->m_children)
{
if (auto item = std::dynamic_pointer_cast<NodeDialogBrowseItem>(n))
item->m_thumb->tex.destroy();
}
container->remove_all_children();
}
void NodeDialogBrowse::init_list()
{
auto names = Asset::list_files(search_path, false, ".*\\.ppi");
for (const auto& n : names)
{
@@ -104,11 +146,7 @@ void NodeDialogBrowse::init_controls()
}
container->add_child(node);
}
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))
// {
// first->on_selected(first);
// first->m_selected = true;
// }
}
bool NodeDialogBrowse::is_selected()
@@ -142,6 +180,7 @@ void NodeDialogBrowseItem::init()
void NodeDialogBrowseItem::init_controls()
{
m_text = find<NodeText>("title");
m_thumb = find<NodeImageTexture>("thumb-tex");
}
void NodeDialogBrowseItem::loaded()
{