fix some ui glitch with NodeButton, start implementing working dir option
This commit is contained in:
@@ -61,6 +61,26 @@ std::mutex task_mutex;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
- (std::string)pick_dir
|
||||
{
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
[panel setCanChooseFiles:NO];
|
||||
[panel setCanChooseDirectories:YES];
|
||||
[panel setAllowsMultipleSelection:NO]; // yes if more than one dir is allowed
|
||||
|
||||
NSInteger clicked = [panel runModal];
|
||||
|
||||
std::string ret;
|
||||
if (clicked == NSFileHandlingPanelOKButton)
|
||||
{
|
||||
for (NSURL *url in [panel URLs])
|
||||
{
|
||||
LOG("selected path: %s", [[url path] cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
ret = [[url path] cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
- (instancetype)initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
gl_ready = false;
|
||||
|
||||
@@ -23,4 +23,5 @@
|
||||
- (void)async_unlock;
|
||||
- (void)async_swap;
|
||||
- (std::string)pick_file:(NSArray<NSString*>*)types;
|
||||
- (std::string)pick_dir;
|
||||
@end
|
||||
|
||||
@@ -317,7 +317,7 @@
|
||||
<text id="message" text="Longer description for the error or the message." font-face="arial" font-size="11"></text>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Ok" width="50" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -335,7 +335,7 @@
|
||||
<border width="50" height="30" grow="1" margin="0 10 0 0" color=".2">
|
||||
<border id="progress" width="50%" color="1 0 0 1" height="30"/>
|
||||
</border>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -403,8 +403,8 @@
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Rename Layer" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-ok" text="Rename Layer" width="110" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -427,7 +427,7 @@
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Resize" width="70" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -455,7 +455,7 @@
|
||||
<node id="footer" height="40" dir="row" align="flex-end" justify="flex-end" pad="10">
|
||||
<node grow="1"><button id="btn-delete" text="Delete Project" width="100" height="30" margin="0 10 0 0" color="1 0 0 1"/></node>
|
||||
<button id="btn-ok" text="Open Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -483,7 +483,7 @@
|
||||
<node id="footer" height="40" dir="row" align="flex-end" justify="flex-end" pad="10">
|
||||
<node grow="1"/>
|
||||
<button id="btn-ok" text="Open Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -518,7 +518,7 @@
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<node grow="1"><button id="btn-delete" text="Delete Project" width="100" height="30" margin="0 10 0 0" color="1 0 0 1"/></node>
|
||||
<button id="btn-ok" text="Open Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -539,7 +539,7 @@
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Save Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -562,8 +562,9 @@
|
||||
</border>
|
||||
<text os="win,osx" id="path" text="Workind dir: path" text-wrap-width="470" font-face="arial" font-size="11" margin="10 5 10 5"/>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Create Project" width="100" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30" pad="10"/>
|
||||
<node grow="1" os="win,osx"><button id="btn-path" text="Set working dir" width="120" height="30" margin="0 10 0 0"/></node>
|
||||
<button id="btn-ok" text="Create Project" width="110" height="30" margin="0 10 0 0"/>
|
||||
<button id="btn-cancel" text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
@@ -601,7 +602,7 @@
|
||||
<!--footer buttons-->
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Ok" width="50" height="30" margin="0 10 0 0"/>
|
||||
<button text="Cancel" width="60" height="30" pad="10"/>
|
||||
<button text="Cancel" width="60" height="30"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
|
||||
@@ -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