fix iOS text input and export ppbr

This commit is contained in:
2019-09-19 15:25:33 +02:00
parent 77a3bdde03
commit b8c646f748
6 changed files with 27 additions and 22 deletions

View File

@@ -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
}
@@ -491,7 +494,7 @@ std::set<UITouch*> ignored_touch;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
view.enableSetNeedsDisplay = NO;
glview = view;
App::I->width = view.frame.size.width * view.contentScaleFactor;
App::I->height = view.frame.size.height * view.contentScaleFactor;
App::I->zoom = Settings::value_or<Serializer::Float>("ui-scale", (float)view.contentScaleFactor);

View File

@@ -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*) {
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] (std::string path) {
presets->export_ppbr(path, dialog->m_header_image);
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] (std::string path) {
std::thread([this, path, dialog] {
App::I->pick_file_save({ "ppbr" }, [this, dialog, info] (std::string path) {
std::thread([this, path, dialog, info] {
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;
presets->export_ppbr(path, info);
dialog->destroy();
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
@@ -622,4 +623,4 @@ void App::dialog_ppbr_export()
});
#endif
};
}
}

View File

@@ -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);
});
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;