fix iOS text input and export ppbr
This commit is contained in:
@@ -211,11 +211,14 @@ std::recursive_mutex lock_mutex;
|
||||
|
||||
- (void)insertText:(NSString *)text
|
||||
{
|
||||
if (const char* cstr = [text cStringUsingEncoding:NSASCIIStringEncoding])
|
||||
if (const char* cstr = [text cStringUsingEncoding:NSISOLatin1StringEncoding])
|
||||
{
|
||||
char c = cstr[0];
|
||||
App::I->ui_task_async([=]
|
||||
{
|
||||
App::I->key_char(cstr[0]);
|
||||
App::I->key_char(c);
|
||||
});
|
||||
}
|
||||
NSLog(@"%@", text);
|
||||
// Do something with the typed character
|
||||
}
|
||||
|
||||
@@ -602,19 +602,20 @@ void App::dialog_ppbr_export()
|
||||
auto root = layout[main_id];
|
||||
auto dialog = root->add_child_ref<NodeDialogExportPPBR>();
|
||||
dialog->btn_ok->on_click = [this, dialog] (Node*) {
|
||||
#if __IOS__
|
||||
App::I->pick_file_save("ppbr", [this, dialog] (std::string path) {
|
||||
presets->export_ppbr(path, dialog->m_header_image);
|
||||
});
|
||||
#else
|
||||
App::I->pick_file_save({ "ppbr" }, [this, dialog] (std::string path) {
|
||||
std::thread([this, path, dialog] {
|
||||
BT_SetTerminate();
|
||||
NodePanelBrushPreset::PPBRInfo info;
|
||||
info.author = dialog->txt_author->m_text;
|
||||
info.url = dialog->txt_url->m_text;
|
||||
info.email = dialog->txt_email->m_text;
|
||||
info.descr = dialog->txt_descr->m_text;
|
||||
info.header_image = dialog->m_header_image;
|
||||
#if __IOS__
|
||||
App::I->pick_file_save("ppbr", [this, dialog, info] (std::string path) {
|
||||
presets->export_ppbr(path, info);
|
||||
});
|
||||
#else
|
||||
App::I->pick_file_save({ "ppbr" }, [this, dialog, info] (std::string path) {
|
||||
std::thread([this, path, dialog, info] {
|
||||
BT_SetTerminate();
|
||||
presets->export_ppbr(path, info);
|
||||
dialog->destroy();
|
||||
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
|
||||
|
||||
@@ -38,7 +38,7 @@ void NodeDialogExportPPBR::init_controls()
|
||||
};
|
||||
btn_header_clear = find<NodeButton>("header-clear");
|
||||
btn_header_clear->on_click = [this] (Node*) {
|
||||
m_header_image.destroy();
|
||||
m_header_image.reset();
|
||||
img_header->tex.destroy();
|
||||
txt_header_descr->SetVisibility(true);
|
||||
};
|
||||
@@ -57,9 +57,10 @@ void NodeDialogExportPPBR::init_controls()
|
||||
void NodeDialogExportPPBR::open_header()
|
||||
{
|
||||
App::I->pick_image([this](std::string path) {
|
||||
m_header_image.load(path);
|
||||
m_header_image.resize(256, 128);
|
||||
img_header->tex.create(m_header_image);
|
||||
m_header_image = std::make_shared<Image>();
|
||||
m_header_image->load(path);
|
||||
m_header_image->resize(256, 128);
|
||||
img_header->tex.create(*m_header_image);
|
||||
txt_header_descr->SetVisibility(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
NodeButton* btn_header_clear;
|
||||
NodeButton* btn_header_gen;
|
||||
NodeImageTexture* img_header;
|
||||
Image m_header_image;
|
||||
std::shared_ptr<Image> m_header_image;
|
||||
NodeText* txt_header_descr;
|
||||
NodeText* txt_author;
|
||||
NodeText* txt_descr;
|
||||
|
||||
@@ -724,7 +724,7 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
|
||||
info.class_id = "ppbr_info";
|
||||
info.name = L"info header";
|
||||
|
||||
bool has_header_image = info_data.header_image.m_data != nullptr;
|
||||
bool has_header_image = info_data.header_image != nullptr;
|
||||
|
||||
info.props["author"] = std::make_shared<Serializer::String>(info_data.author);
|
||||
info.props["email"] = std::make_shared<Serializer::String>(info_data.email);
|
||||
@@ -743,8 +743,8 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo&
|
||||
// header image
|
||||
if (has_header_image)
|
||||
{
|
||||
sw << info_data.header_image;
|
||||
info_data.header_image.save_jpg(out_path + "/header.jpg", 75);
|
||||
sw << *info_data.header_image;
|
||||
info_data.header_image->save_jpg(out_path + "/header.jpg", 75);
|
||||
}
|
||||
|
||||
pb->increment();
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
std::string email;
|
||||
std::string url;
|
||||
std::string descr;
|
||||
Image header_image;
|
||||
std::shared_ptr<Image> header_image;
|
||||
};
|
||||
|
||||
Node* m_container;
|
||||
|
||||
Reference in New Issue
Block a user