export ppbr wip
This commit is contained in:
@@ -43,13 +43,13 @@
|
|||||||
<border id="background" positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center" mouse-capture="true">
|
<border id="background" positioning="absolute" position="0 0" color=".4 .4 .4 .8" width="100%" height="100%" align="center" justify="center" mouse-capture="true">
|
||||||
<border id="form" thickness="1" border-color=".2" pad="3" width="650" dir="col">
|
<border id="form" thickness="1" border-color=".2" pad="3" width="650" dir="col">
|
||||||
<border id="title-bar" width="100%" height="30" color=".2 .2 .2 .9" dir="row" align="center" justify="center">
|
<border id="title-bar" width="100%" height="30" color=".2 .2 .2 .9" dir="row" align="center" justify="center">
|
||||||
<text text="Upload Brushes"></text>
|
<text text="Save Brushes"></text>
|
||||||
</border>
|
</border>
|
||||||
<border width="100%" color="0 0 0 .9" pad="10" dir="row" grow="1">
|
<border width="100%" color="0 0 0 .9" pad="10" dir="row" grow="1">
|
||||||
<border id="files-list" dir="row" wrap="1" flood-events="1" grow="1" height="100%" margin="0 0 0 0" pad="10" color=".2 .2 .2 1">
|
<border id="files-list" dir="row" wrap="1" flood-events="1" grow="1" height="100%" margin="0 0 0 0" pad="10" color=".2 .2 .2 1">
|
||||||
<node dir="col" margin="0 20 0 0">
|
<node dir="col" margin="0 20 0 0">
|
||||||
<image-texture id="header-tex" width="256" height="128" pad="10">
|
<image-texture id="header-tex" width="256" height="128" pad="10">
|
||||||
<text text="Header image.\nSelect a 256x128 pixels image that will be displayed as a preview for this brushes collection." text-wrap-width="230" color=".5"/>
|
<text id="header-descr" text="Header image.\nSelect a 256x128 pixels image that will be displayed as a preview for this brushes collection." text-wrap-width="230" color=".5"/>
|
||||||
</image-texture>
|
</image-texture>
|
||||||
<node dir="row" width="256" height="30" justify="center" margin="10 0 0 0">
|
<node dir="row" width="256" height="30" justify="center" margin="10 0 0 0">
|
||||||
<button id="header-gen" text="Generate" grow="1" height="100%"/>
|
<button id="header-gen" text="Generate" grow="1" height="100%"/>
|
||||||
|
|||||||
@@ -601,20 +601,20 @@ void App::dialog_ppbr_export()
|
|||||||
{
|
{
|
||||||
auto root = layout[main_id];
|
auto root = layout[main_id];
|
||||||
auto dialog = root->add_child_ref<NodeDialogExportPPBR>();
|
auto dialog = root->add_child_ref<NodeDialogExportPPBR>();
|
||||||
dialog->btn_ok->on_click = [this,dialog] (Node*) {
|
dialog->btn_ok->on_click = [this, dialog] (Node*) {
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
App::I->pick_file_save("ppbr", [this](std::string path) {
|
App::I->pick_file_save("ppbr", [this, dialog] (std::string path) {
|
||||||
presets->export_ppbr(path, {});
|
presets->export_ppbr(path, dialog->m_header_image);
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
App::I->pick_file_save({ "ppbr" }, [this](std::string path) {
|
App::I->pick_file_save({ "ppbr" }, [this, dialog] (std::string path) {
|
||||||
std::thread([this, path] {
|
std::thread([this, path, dialog] {
|
||||||
BT_SetTerminate();
|
BT_SetTerminate();
|
||||||
presets->export_ppbr(path, {});
|
presets->export_ppbr(path, dialog->m_header_image);
|
||||||
|
dialog->destroy();
|
||||||
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
|
App::I->message_box("Export PPBR", "Brushes exported to:\n" + path);
|
||||||
}).detach();
|
}).detach();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
dialog->destroy();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
10
src/font.cpp
10
src/font.cpp
@@ -75,13 +75,14 @@ void FontManager::change_scale(float scale)
|
|||||||
std::vector<TextMesh::Token> TextMesh::tokenize(const std::string& s, const Font& f) const noexcept
|
std::vector<TextMesh::Token> TextMesh::tokenize(const std::string& s, const Font& f) const noexcept
|
||||||
{
|
{
|
||||||
std::vector<std::string> parts;
|
std::vector<std::string> parts;
|
||||||
std::array<char, 7> delims = { ' ', '\n', ',', '.', ':', '?', '!' };
|
std::array<char, 10> delims = { ' ', '\n', ',', '.', ':', ';', '?', '!', '\\', '/' };
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
bool wrap = false;
|
bool wrap = false;
|
||||||
for (char c : s)
|
for (char c : s)
|
||||||
{
|
{
|
||||||
bool is_delim = std::find(delims.begin(), delims.end(), c) != delims.end();
|
bool is_delim = std::find(delims.begin(), delims.end(), c) != delims.end();
|
||||||
wrap |= is_delim;
|
wrap |= is_delim; // set wrap to notify a delimiter has been reached
|
||||||
|
// when a new non-delim char is detected, start a new token
|
||||||
if (wrap && !is_delim)
|
if (wrap && !is_delim)
|
||||||
{
|
{
|
||||||
parts.push_back(tmp);
|
parts.push_back(tmp);
|
||||||
@@ -90,9 +91,10 @@ std::vector<TextMesh::Token> TextMesh::tokenize(const std::string& s, const Font
|
|||||||
}
|
}
|
||||||
tmp.push_back(c);
|
tmp.push_back(c);
|
||||||
}
|
}
|
||||||
|
// insert last partial token
|
||||||
if (!tmp.empty())
|
if (!tmp.empty())
|
||||||
parts.push_back(tmp);
|
parts.push_back(tmp);
|
||||||
|
// measure each token length
|
||||||
std::vector<TextMesh::Token> ret;
|
std::vector<TextMesh::Token> ret;
|
||||||
for (auto p : parts)
|
for (auto p : parts)
|
||||||
{
|
{
|
||||||
@@ -147,7 +149,7 @@ void TextMesh::update(kFont id, const char* text)
|
|||||||
|
|
||||||
for (auto p : parts)
|
for (auto p : parts)
|
||||||
{
|
{
|
||||||
if (max_width > 0 && x + p.w > max_width * f.scale /*font scale factor*/)
|
if (max_width > 0 && x + p.w > max_width * f.scale)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
y += f.size * f.scale;
|
y += f.size * f.scale;
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ void NodeDialogExportPPBR::init()
|
|||||||
void NodeDialogExportPPBR::init_controls()
|
void NodeDialogExportPPBR::init_controls()
|
||||||
{
|
{
|
||||||
btn_ok = find<NodeButton>("btn-ok");
|
btn_ok = find<NodeButton>("btn-ok");
|
||||||
btn_ok->on_click = [this] (Node*) {
|
|
||||||
start_exporting();
|
|
||||||
};
|
|
||||||
btn_cancel = find<NodeButton>("btn-cancel");
|
btn_cancel = find<NodeButton>("btn-cancel");
|
||||||
btn_cancel->on_click = [this](Node*) {
|
btn_cancel->on_click = [this](Node*) {
|
||||||
destroy();
|
destroy();
|
||||||
@@ -43,13 +40,14 @@ void NodeDialogExportPPBR::init_controls()
|
|||||||
btn_header_clear->on_click = [this] (Node*) {
|
btn_header_clear->on_click = [this] (Node*) {
|
||||||
m_header_image.destroy();
|
m_header_image.destroy();
|
||||||
img_header->tex.destroy();
|
img_header->tex.destroy();
|
||||||
|
txt_header_descr->SetVisibility(true);
|
||||||
};
|
};
|
||||||
btn_header_gen = find<NodeButton>("header-gen");
|
btn_header_gen = find<NodeButton>("header-gen");
|
||||||
btn_header_gen->on_click = [this] (Node*) {
|
btn_header_gen->on_click = [this] (Node*) {
|
||||||
App::I->message_box("WIP", "This feature is not yet implemented.");
|
App::I->message_box("WIP", "This feature is not yet implemented.");
|
||||||
};
|
};
|
||||||
img_header = find<NodeImageTexture>("header-tex");
|
img_header = find<NodeImageTexture>("header-tex");
|
||||||
|
txt_header_descr = find<NodeText>("header-descr");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDialogExportPPBR::open_header()
|
void NodeDialogExportPPBR::open_header()
|
||||||
@@ -58,14 +56,10 @@ void NodeDialogExportPPBR::open_header()
|
|||||||
m_header_image.load(path);
|
m_header_image.load(path);
|
||||||
m_header_image.resize(256, 128);
|
m_header_image.resize(256, 128);
|
||||||
img_header->tex.create(m_header_image);
|
img_header->tex.create(m_header_image);
|
||||||
|
txt_header_descr->SetVisibility(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDialogExportPPBR::start_exporting()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeDialogExportPPBR::added(Node* parent)
|
void NodeDialogExportPPBR::added(Node* parent)
|
||||||
{
|
{
|
||||||
NodeBorder::added(parent);
|
NodeBorder::added(parent);
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ public:
|
|||||||
NodeButton* btn_header_gen;
|
NodeButton* btn_header_gen;
|
||||||
NodeImageTexture* img_header;
|
NodeImageTexture* img_header;
|
||||||
Image m_header_image;
|
Image m_header_image;
|
||||||
|
NodeText* txt_header_descr;
|
||||||
virtual Node* clone_instantiate() const override;
|
virtual Node* clone_instantiate() const override;
|
||||||
virtual void clone_finalize(Node* dest) const override;
|
virtual void clone_finalize(Node* dest) const override;
|
||||||
virtual void init() override;
|
virtual void init() override;
|
||||||
virtual void added(Node* parent) override;
|
virtual void added(Node* parent) override;
|
||||||
void init_controls();
|
void init_controls();
|
||||||
void open_header();
|
void open_header();
|
||||||
void start_exporting();
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user