Merge branch 'master' of https://bitbucket.org/omigamedev/new_engine
* 'master' of https://bitbucket.org/omigamedev/new_engine: add text input popup
This commit is contained in:
@@ -352,6 +352,7 @@
|
||||
<ClCompile Include="src\node_icon.cpp" />
|
||||
<ClCompile Include="src\node_image.cpp" />
|
||||
<ClCompile Include="src\node_image_texture.cpp" />
|
||||
<ClCompile Include="src\node_input_box.cpp" />
|
||||
<ClCompile Include="src\node_message_box.cpp" />
|
||||
<ClCompile Include="src\node_panel_brush.cpp" />
|
||||
<ClCompile Include="src\node_panel_color.cpp" />
|
||||
@@ -478,6 +479,7 @@
|
||||
<ClInclude Include="src\node_icon.h" />
|
||||
<ClInclude Include="src\node_image.h" />
|
||||
<ClInclude Include="src\node_image_texture.h" />
|
||||
<ClInclude Include="src\node_input_box.h" />
|
||||
<ClInclude Include="src\node_message_box.h" />
|
||||
<ClInclude Include="src\node_panel_brush.h" />
|
||||
<ClInclude Include="src\node_panel_color.h" />
|
||||
|
||||
@@ -366,6 +366,9 @@
|
||||
<ClCompile Include="libs\glad\src\glad_wgl.c">
|
||||
<Filter>libs\glad</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\node_input_box.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\app.h">
|
||||
@@ -608,6 +611,9 @@
|
||||
<ClInclude Include="src\node_tool_bucket.h">
|
||||
<Filter>Header Files\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\node_input_box.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PanoPainter.rc">
|
||||
|
||||
@@ -156,6 +156,8 @@
|
||||
AD7FB09222470DE5005913AB /* app_vr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD7FB09122470DE2005913AB /* app_vr.cpp */; };
|
||||
AD7FB09322470DE5005913AB /* app_vr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD7FB09122470DE2005913AB /* app_vr.cpp */; };
|
||||
AD83A0D323268B6F005B0871 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AD83A0D223268B6F005B0871 /* MobileCoreServices.framework */; };
|
||||
AD83A0D9232A7906005B0871 /* node_input_box.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD83A0D7232A7905005B0871 /* node_input_box.cpp */; };
|
||||
AD83A0DA232A793A005B0871 /* node_input_box.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD83A0D7232A7905005B0871 /* node_input_box.cpp */; };
|
||||
ADA2A57822BE8D8E00C6B6C9 /* node_tool_bucket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADA2A57622BE8D8E00C6B6C9 /* node_tool_bucket.cpp */; };
|
||||
ADA2A57922BE8D8E00C6B6C9 /* node_tool_bucket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADA2A57622BE8D8E00C6B6C9 /* node_tool_bucket.cpp */; };
|
||||
ADA3ABF6222C8C370083B825 /* node_panel_quick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADA3ABF4222C8C350083B825 /* node_panel_quick.cpp */; };
|
||||
@@ -462,6 +464,8 @@
|
||||
AD7FB08E22470C75005913AB /* node_panel_floating.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = node_panel_floating.cpp; sourceTree = "<group>"; };
|
||||
AD7FB09122470DE2005913AB /* app_vr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = app_vr.cpp; sourceTree = "<group>"; };
|
||||
AD83A0D223268B6F005B0871 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; };
|
||||
AD83A0D7232A7905005B0871 /* node_input_box.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = node_input_box.cpp; sourceTree = "<group>"; };
|
||||
AD83A0D8232A7906005B0871 /* node_input_box.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node_input_box.h; sourceTree = "<group>"; };
|
||||
AD8CF71F1E913F0500083FFD /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = log.cpp; sourceTree = "<group>"; };
|
||||
AD8CF7201E913F0500083FFD /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = log.h; sourceTree = "<group>"; };
|
||||
AD95AEC31E41EDEC002DD03A /* font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = font.cpp; sourceTree = "<group>"; };
|
||||
@@ -728,6 +732,8 @@
|
||||
AD1063621EC7ADFA002A525F /* node_image_texture.h */,
|
||||
AD1063631EC7ADFA002A525F /* node_image.cpp */,
|
||||
AD1063641EC7ADFA002A525F /* node_image.h */,
|
||||
AD83A0D7232A7905005B0871 /* node_input_box.cpp */,
|
||||
AD83A0D8232A7906005B0871 /* node_input_box.h */,
|
||||
AD1063651EC7ADFA002A525F /* node_message_box.cpp */,
|
||||
AD1063661EC7ADFA002A525F /* node_message_box.h */,
|
||||
AD1063671EC7ADFA002A525F /* node_panel_brush.cpp */,
|
||||
@@ -1478,6 +1484,7 @@
|
||||
AD0E5CC01ECC72AD00C35669 /* node_icon.cpp in Sources */,
|
||||
AD0E5CC11ECC72AD00C35669 /* node_image_texture.cpp in Sources */,
|
||||
ADF4F7762263920400422C7C /* settings.cpp in Sources */,
|
||||
AD83A0DA232A793A005B0871 /* node_input_box.cpp in Sources */,
|
||||
AD0E5CBD1ECC72AD00C35669 /* node_checkbox.cpp in Sources */,
|
||||
ADBC8C581FAFD05A0094B339 /* node_dialog_cloud.cpp in Sources */,
|
||||
AD7FB086223E8A43005913AB /* YGLayout.cpp in Sources */,
|
||||
@@ -1512,6 +1519,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
AD83A0D9232A7906005B0871 /* node_input_box.cpp in Sources */,
|
||||
AD7FB07B223E8A42005913AB /* log.cpp in Sources */,
|
||||
AD74030F1FB9D0D3004ACFCC /* node_combobox.cpp in Sources */,
|
||||
ADBC8C571FAFD05A0094B339 /* node_dialog_cloud.cpp in Sources */,
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
- (void)async_swap;
|
||||
- (void)pick_photo:(std::function<void(std::string)>) callback;
|
||||
- (void)pick_file:(NSArray<NSString*>*)types then:(std::function<void(std::string)>)callback;
|
||||
- (void)pick_file_save:(std::string)path;
|
||||
- (void)registerForKeyboardNotifications;
|
||||
- (void)unregisterForKeyboardNotifications;
|
||||
- (void)crash;
|
||||
|
||||
@@ -180,18 +180,28 @@ std::recursive_mutex lock_mutex;
|
||||
(__bridge CFStringRef)ext, NULL);
|
||||
[UTIs addObject:typeForExt];
|
||||
}
|
||||
|
||||
|
||||
GameFilePicker *picker = [[GameFilePicker alloc] initWithDocumentTypes:UTIs inMode:UIDocumentPickerModeImport];
|
||||
picker.delegate = self;
|
||||
picker->callback = callback;
|
||||
[self presentViewController:picker animated:YES completion:NULL];
|
||||
}
|
||||
- (void)pick_file_save:(std::string)path
|
||||
{
|
||||
NSURL* url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.c_str()]];
|
||||
GameFilePicker *picker = [[GameFilePicker alloc] initWithURL:url inMode:UIDocumentPickerModeMoveToService];
|
||||
picker.delegate = self;
|
||||
[self presentViewController:picker animated:YES completion:NULL];
|
||||
}
|
||||
-(void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
|
||||
{
|
||||
NSString *chosenImage = [url path];
|
||||
GameFilePicker* p = static_cast<GameFilePicker*>(controller);
|
||||
std::string path = [chosenImage cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
p->callback(path);
|
||||
if (p->callback)
|
||||
{
|
||||
std::string path = [chosenImage cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
p->callback(path);
|
||||
}
|
||||
[controller dismissViewControllerAnimated:YES completion:NULL];
|
||||
}
|
||||
-(void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
|
||||
|
||||
@@ -873,7 +873,28 @@
|
||||
</border>
|
||||
</node>
|
||||
</layout>
|
||||
|
||||
|
||||
<!-- INPUT BOX -->
|
||||
<layout id="input-box">
|
||||
<border positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center">
|
||||
<border thickness="1" border-color=".2" pad="3">
|
||||
<border width="400" height="30" color=".2 .2 .2 .9" dir="row" align="center" justify="center">
|
||||
<text id="title" text="Just a test message"></text>
|
||||
</border>
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<node dir="row" height="30" align="center" grow="1">
|
||||
<text id="field-name" text="Field" margin="0 5 0 0"/>
|
||||
<text-input id="field-text" align="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</node>
|
||||
<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"/>
|
||||
</node>
|
||||
</border>
|
||||
</border>
|
||||
</border>
|
||||
</layout>
|
||||
|
||||
<!-- MESSAGE BOX -->
|
||||
<layout id="message-box">
|
||||
<border positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center">
|
||||
|
||||
16
src/app.h
16
src/app.h
@@ -33,6 +33,7 @@
|
||||
#endif
|
||||
#include "node_panel_grid.h"
|
||||
#include "node_panel_quick.h"
|
||||
#include "node_input_box.h"
|
||||
|
||||
struct VRController
|
||||
{
|
||||
@@ -159,7 +160,11 @@ public:
|
||||
bool clipboard_set_text(const std::string& s);
|
||||
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);
|
||||
#if __IOS__
|
||||
void pick_file_save(const std::string& type, std::function<void(std::string path)> writer);
|
||||
#else
|
||||
void pick_file_save(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||
#endif
|
||||
void pick_dir(std::function<void(std::string path)> callback);
|
||||
void display_file(std::string path);
|
||||
void share_file(std::string path);
|
||||
@@ -206,7 +211,6 @@ public:
|
||||
bool key_char(char key);
|
||||
void toggle_ui();
|
||||
void set_stylus();
|
||||
std::shared_ptr<NodeMessageBox> message_box(const std::string& title, const std::string& text, bool cancel_button = false);
|
||||
|
||||
void rec_clear();
|
||||
void rec_loop();
|
||||
@@ -241,11 +245,17 @@ public:
|
||||
void cloud_upload();
|
||||
void cloud_upload_all();
|
||||
void cloud_browse();
|
||||
void upload(std::string filename, std::string name = "", std::function<void(float)> progress = nullptr);
|
||||
void download(std::string url, std::string dest_filepath, std::function<void(float)> progress = nullptr);
|
||||
void upload(std::string filename, std::string name = "",
|
||||
std::function<void(float)> progress = nullptr);
|
||||
void download(std::string url, std::string dest_filepath,
|
||||
std::function<void(float)> progress = nullptr);
|
||||
bool check_license();
|
||||
|
||||
std::shared_ptr<NodeProgressBar> show_progress(const std::string& title, int total = 0);
|
||||
std::shared_ptr<NodeMessageBox> message_box(const std::string& title,
|
||||
const std::string& text, bool cancel_button = false);
|
||||
std::shared_ptr<NodeInputBox> input_box(const std::string& title,
|
||||
const std::string& field_name, const std::string& ok_caption = "Ok");
|
||||
|
||||
void brush_update(bool update_color, bool update_brush);
|
||||
void title_update();
|
||||
|
||||
@@ -44,6 +44,21 @@ std::shared_ptr<NodeMessageBox> App::message_box(const std::string &title, const
|
||||
return m;
|
||||
}
|
||||
|
||||
std::shared_ptr<NodeInputBox> App::input_box(const std::string& title,
|
||||
const std::string& field_name, const std::string& ok_caption /*= "Ok"*/)
|
||||
{
|
||||
auto m = std::make_shared<NodeInputBox>();
|
||||
m->m_manager = &layout;
|
||||
m->init();
|
||||
m->create();
|
||||
m->loaded();
|
||||
m->m_title->set_text(title.c_str());
|
||||
m->m_field_name->set_text(field_name.c_str());
|
||||
m->btn_ok->m_text->set_text(ok_caption.c_str());
|
||||
layout[main_id]->add_child(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
void App::dialog_usermanual()
|
||||
{
|
||||
auto dialog = std::make_shared<NodeUserManual>();
|
||||
|
||||
@@ -192,14 +192,32 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
void App::pick_file_save(const std::string& type, std::function<void(std::string)> writer)
|
||||
{
|
||||
redraw = true;
|
||||
std::thread([=]{
|
||||
auto mb = input_box("Insert", "File name");
|
||||
std::string placeholder = "name." + type;
|
||||
mb->m_field_text->set_text(placeholder.c_str());
|
||||
mb->on_submit = [this, writer, type] (Node* target, std::string name) {
|
||||
std::string ext = "." + type;
|
||||
std::string path = data_path + "/" + name;
|
||||
if (name.find(ext) == std::string::npos)
|
||||
path += ext;
|
||||
writer(path);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ios_view pick_file_save:path];
|
||||
});
|
||||
target->destroy();
|
||||
};
|
||||
}).detach();
|
||||
}
|
||||
#else
|
||||
void App::pick_file_save(std::vector<std::string> types, std::function<void (std::string)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
#ifdef __IOS__
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [ios_view pick_file_save:callback];
|
||||
// });
|
||||
#elif __OSX__
|
||||
#if __OSX__
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//NSArray* fileTypes = [NSArray arrayWithObjects:@"ppi", @"PPI", nil];
|
||||
NSMutableArray<NSString*>* fileTypes = [NSMutableArray arrayWithCapacity:types.size()];
|
||||
@@ -233,6 +251,7 @@ void App::pick_file_save(std::vector<std::string> types, std::function<void (std
|
||||
callback(path);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
{
|
||||
|
||||
57
src/node_input_box.cpp
Normal file
57
src/node_input_box.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_input_box.h"
|
||||
#include "layout.h"
|
||||
|
||||
Node* NodeInputBox::clone_instantiate() const
|
||||
{
|
||||
return new NodeInputBox();
|
||||
}
|
||||
|
||||
void NodeInputBox::init()
|
||||
{
|
||||
SetPosition(0, 0);
|
||||
SetWidthP(100);
|
||||
SetHeightP(100);
|
||||
SetPositioning(YGPositionTypeAbsolute);
|
||||
auto m_template = (*m_manager)[const_hash("input-box")]->m_children[0]->clone();
|
||||
add_child(m_template);
|
||||
m_title = m_template->find<NodeText>("title");
|
||||
m_field_name = m_template->find<NodeText>("field-name");
|
||||
m_field_text = m_template->find<NodeTextInput>("field-text");
|
||||
btn_ok = m_template->find<NodeButton>("btn-ok");
|
||||
btn_ok->on_click = [&](Node*) {
|
||||
if (on_submit)
|
||||
on_submit(this, m_field_text->m_text->m_text);
|
||||
};
|
||||
btn_cancel = m_template->find<NodeButton>("btn-cancel");
|
||||
btn_cancel->on_click = [&](Node*) { destroy(); };
|
||||
m_capture_children = false; // don't capture children events on mouse_capture
|
||||
}
|
||||
|
||||
kEventResult NodeInputBox::handle_event(Event* e)
|
||||
{
|
||||
Node::handle_event(e);
|
||||
auto ke = (KeyEvent*)e;
|
||||
switch (e->m_type)
|
||||
{
|
||||
case kEventType::KeyDown:
|
||||
break;
|
||||
case kEventType::KeyUp:
|
||||
if (ke->m_key == kKey::KeyEnter && on_submit)
|
||||
on_submit(this, m_field_text->m_text->m_text);
|
||||
break;
|
||||
case kEventType::KeyChar:
|
||||
break;
|
||||
default:
|
||||
return kEventResult::Available;
|
||||
break;
|
||||
}
|
||||
return kEventResult::Consumed;
|
||||
}
|
||||
|
||||
void NodeInputBox::added(Node* parent)
|
||||
{
|
||||
Node::added(parent);
|
||||
mouse_capture();
|
||||
}
|
||||
19
src/node_input_box.h
Normal file
19
src/node_input_box.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include "node.h"
|
||||
#include "node_button.h"
|
||||
#include "node_text_input.h"
|
||||
|
||||
class NodeInputBox : public Node
|
||||
{
|
||||
public:
|
||||
std::function<void(Node*, std::string text)> on_submit = nullptr;
|
||||
NodeButton* btn_ok;
|
||||
NodeButton* btn_cancel;
|
||||
NodeText* m_field_name;
|
||||
NodeTextInput* m_field_text;
|
||||
NodeText* m_title;
|
||||
virtual Node* clone_instantiate() const override;
|
||||
virtual void init() override;
|
||||
virtual kEventResult handle_event(Event* e) override;
|
||||
virtual void added(Node* parent) override;
|
||||
};
|
||||
@@ -502,6 +502,11 @@ void NodePanelBrushPreset::init()
|
||||
});
|
||||
break;
|
||||
case 1: // export file
|
||||
#if __IOS__
|
||||
App::I->pick_file_save("ppbr", [this] (std::string path) {
|
||||
export_ppbr(path, {});
|
||||
});
|
||||
#else
|
||||
App::I->pick_file_save({ "ppbr" }, [this] (std::string path) {
|
||||
std::thread([this, path] {
|
||||
BT_SetTerminate();
|
||||
@@ -509,6 +514,7 @@ void NodePanelBrushPreset::init()
|
||||
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
|
||||
}).detach();
|
||||
});
|
||||
#endif
|
||||
break;
|
||||
case 2: // download
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user