fix some ui glitch with NodeButton, start implementing working dir option
This commit is contained in:
@@ -182,6 +182,9 @@ void App::initLog()
|
||||
CreateDirectoryA(rec_path.c_str(), NULL);
|
||||
#endif
|
||||
|
||||
// TODO: save this path somewhere in the settings, don't overwrite every start
|
||||
work_path = data_path;
|
||||
|
||||
//LogRemote::I.start();
|
||||
LogRemote::I.file_init();
|
||||
LOG("%s", g_version);
|
||||
|
||||
@@ -37,7 +37,7 @@ class App
|
||||
public:
|
||||
static App I;
|
||||
std::string data_path{ "." };
|
||||
|
||||
std::string work_path{ "." };
|
||||
std::string rec_path{ "." };
|
||||
std::thread rec_thread;
|
||||
bool rec_running = false;
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
#endif
|
||||
void pick_image(std::function<void(std::string path)> callback);
|
||||
void pick_file(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||
void pick_dir(std::function<void(std::string path)> callback);
|
||||
void display_file(std::string path);
|
||||
void showKeyboard();
|
||||
void hideKeyboard();
|
||||
|
||||
@@ -90,6 +90,27 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
// NOT IMPLEMENTED
|
||||
#elif __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
std::string path = [osx_view pick_dir];
|
||||
if (!path.empty())
|
||||
callback(path);
|
||||
});
|
||||
#elif __ANDROID__
|
||||
// NOT IMPLEMENTED
|
||||
#elif _WIN32
|
||||
// TODO: to be implemented
|
||||
// std::string path = win32_open_file();
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::display_file(std::string path)
|
||||
{
|
||||
#ifdef __IOS__
|
||||
|
||||
@@ -64,6 +64,7 @@ void NodeButton::loaded()
|
||||
|
||||
void NodeButton::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
|
||||
{
|
||||
Node::parse_attributes(ka, attr);
|
||||
switch (ka)
|
||||
{
|
||||
case kAttribute::Color:
|
||||
@@ -84,7 +85,7 @@ void NodeButton::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* a
|
||||
m_text->parse_attributes(ka, attr);
|
||||
break;
|
||||
default:
|
||||
Node::parse_attributes(ka, attr);
|
||||
// Node::parse_attributes(ka, attr);
|
||||
break;
|
||||
}
|
||||
// m_border->parse_attributes(ka, attr);
|
||||
|
||||
@@ -233,9 +233,18 @@ void NodeDialogNewDoc::init_controls()
|
||||
btn_ok->on_click(btn_ok);
|
||||
};
|
||||
#if defined(_WIN32) || defined(__OSX__)
|
||||
working_path = find<NodeText>("path");
|
||||
static char path_buffer[256];
|
||||
realpath(App::I.data_path.c_str(), path_buffer);
|
||||
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());
|
||||
App::I.work_path = path;
|
||||
realpath(path.c_str(), path_buffer);
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
});
|
||||
};
|
||||
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
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class NodeDialogNewDoc : public NodeBorder
|
||||
public:
|
||||
NodeButton* btn_cancel;
|
||||
NodeButton* btn_ok;
|
||||
NodeButton* btn_path;
|
||||
NodeTextInput* input;
|
||||
NodeText* working_path;
|
||||
NodeComboBox* m_resolution;
|
||||
|
||||
Reference in New Issue
Block a user