add ppbr info data

This commit is contained in:
2019-09-19 10:14:31 +02:00
parent 814fd76292
commit 4d788bb174
7 changed files with 45 additions and 12 deletions

View File

@@ -61,17 +61,21 @@
</node>
</node>
<node grow="1">
<node dir="row" height="30" align="center" grow="1">
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
<text text="Author" margin="0 5 0 0"/>
<text-input pad="5" grow="1" height="30" color=".3"/>
<text-input id="info-author" pad="5" grow="1" height="30" color=".3"/>
</node>
<node dir="row" height="30" align="center" grow="1">
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
<text text="Email" margin="0 5 0 0"/>
<text-input id="info-email" pad="5" grow="1" height="30" color=".3"/>
</node>
<node dir="row" height="30" align="center" grow="1" margin="0 0 4 0">
<text text="URL" margin="0 5 0 0"/>
<text-input pad="5" grow="1" height="30" color=".3"/>
<text-input id="info-url" pad="5" grow="1" height="30" color=".3"/>
</node>
<node dir="row" height="80" align="center" grow="1">
<text text="Description" margin="0 5 0 0"/>
<text-input text-vertical-align="top" pad="5" grow="1" min-height="80" color=".3" multiline="1"/>
<text-input id="info-descr" text-vertical-align="top" pad="5" grow="1" min-height="80" color=".3" multiline="1"/>
</node>
</node>
</border>

View File

@@ -610,7 +610,12 @@ void App::dialog_ppbr_export()
App::I->pick_file_save({ "ppbr" }, [this, dialog] (std::string path) {
std::thread([this, path, dialog] {
BT_SetTerminate();
presets->export_ppbr(path, dialog->m_header_image);
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);
}).detach();

View File

@@ -48,6 +48,10 @@ void NodeDialogExportPPBR::init_controls()
};
img_header = find<NodeImageTexture>("header-tex");
txt_header_descr = find<NodeText>("header-descr");
txt_author = find<NodeText>("info-author");
txt_email = find<NodeText>("info-email");
txt_url = find<NodeText>("info-url");
txt_descr = find<NodeText>("info-descr");
}
void NodeDialogExportPPBR::open_header()

View File

@@ -16,6 +16,10 @@ public:
NodeImageTexture* img_header;
Image m_header_image;
NodeText* txt_header_descr;
NodeText* txt_author;
NodeText* txt_descr;
NodeText* txt_url;
NodeText* txt_email;
virtual Node* clone_instantiate() const override;
virtual void clone_finalize(Node* dest) const override;
virtual void init() override;

View File

@@ -684,7 +684,7 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr<Brush> brush)
m_notification->SetVisibility(m_container->m_children.size() == 0);
}
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& header_image)
bool NodePanelBrushPreset::export_ppbr(const std::string& path, const PPBRInfo& info_data)
{
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::smatch m;
@@ -724,8 +724,12 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& hea
info.class_id = "ppbr_info";
info.name = L"info header";
bool has_header_image = header_image.m_data != nullptr;
bool has_header_image = info_data.header_image.m_data != nullptr;
info.props["author"] = std::make_shared<Serializer::String>(info_data.author);
info.props["email"] = std::make_shared<Serializer::String>(info_data.email);
info.props["url"] = std::make_shared<Serializer::String>(info_data.url);
info.props["descr"] = std::make_shared<Serializer::String>(info_data.descr);
info.props["has_header_image"] = std::make_shared<Serializer::Boolean>(has_header_image);
info.props["num_brush_tips"] = std::make_shared<Serializer::Integer>(img_brushes.size());
info.props["num_brush_patt"] = std::make_shared<Serializer::Integer>(img_patterns.size());
@@ -739,8 +743,8 @@ bool NodePanelBrushPreset::export_ppbr(const std::string& path, const Image& hea
// header image
if (has_header_image)
{
sw << header_image;
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

@@ -88,20 +88,32 @@ class NodePanelBrushPreset : public Node
NodeButton* m_btn_download;
Node* m_notification;
public:
struct PPBRInfo
{
std::string author;
std::string email;
std::string url;
std::string descr;
Image header_image;
};
Node* m_container;
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
std::function<void(Node* target)> on_popup_close;
NodePanelBrushPreset();
~NodePanelBrushPreset();
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual kEventResult handle_event(Event* e) override;
virtual void added(Node* parent) override;
void handle_click(Node* target);
bool save();
bool restore();
void add_brush(std::shared_ptr<Brush> brush);
bool export_ppbr(const std::string& path, const Image& header_image);
bool export_ppbr(const std::string& path, const PPBRInfo& info);
bool import_ppbr(const std::string& path);
bool import_abr(const std::string& path);
bool import_brush(const std::string& path);

View File

@@ -744,7 +744,7 @@ public:
}
else
{
LOG("Error image with %ld channels\n", channels.size());
LOG("Error image with %zd channels\n", channels.size());
}
return {};
}