presets options when empty

This commit is contained in:
2019-08-31 17:21:47 +02:00
parent ef2210b57c
commit 295f85157d
6 changed files with 65 additions and 16 deletions

View File

@@ -61,6 +61,18 @@
<!-- PANEL PRESETS -->
<layout id="tpl-panel-brush-preset">
<node rtl="ltr" min-width="315">
<border id="notification" color=".4" align="center" justify="center" grow="2">
<text text="No brush presets loaded."/>
<text text="Import from Photoshop ABR files."/>
<text text="Or download free ones."/>
<border color=".3" dir="row" height="60" margin="15 0 15 0">
<button id="import" text="Import ABR" pad="10" height="100%"/>
<button id="download" text="Download" pad="10" height="100%"/>
</border>
<text text="Otherwise you can create new brushes,"/>
<text text="using the Brush Settings Tool and add"/>
<text text="the new brush here with the + button"/>
</border>
<scroll id="brushes" color=".4" pad="5 20 5 5" dir="col" wrap="0" flood-events="1" grow="1" height="1"/>
<border id="toolbar" height="40" color=".5" dir="row" align="center" flood-events="1">
<button-custom id="btn-add" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 2 0 5">
@@ -72,9 +84,9 @@
<button-custom id="btn-down" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 2 0 0">
<icon width="30" icon="bullet_arrow_down"/>
</button-custom>
<button-custom id="btn-save" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 2 0 0">
<!--<button-custom id="btn-save" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 2 0 0">
<icon width="30" icon="bullet_disk"/>
</button-custom>
</button-custom>-->
<node grow="1"></node>
<button-custom id="btn-remove" thickness="1" color="0 0" border-color=".0" shrink="1" margin="0 10 0 0">
<icon width="30" icon="bin_closed"/>
@@ -99,14 +111,17 @@
</layout>
<layout id="tpl-brush-popup">
<popup-menu positioning="absolute" position="100 100" width="200" thickness="1" border-color=".1" color=".4 .4 .4 .8" dir="col">
<button-custom id="download" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Download Brushes" grow="1" margin="0 0 0 5"/>
</button-custom>
<button-custom id="import" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Import Brushes" grow="1" margin="0 0 0 5"/>
<text text="Import from File" grow="1" margin="0 0 0 5"/>
</button-custom>
<button-custom id="export" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Export Brushes" grow="1" margin="0 0 0 5"/>
<text text="Export to File" grow="1" margin="0 0 0 5"/>
</button-custom>
<button-custom id="download" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Download from Cloud" grow="1" margin="0 0 0 5"/>
</button-custom>
<button-custom id="share" height="40" align="center" color=".2" pad="0 0 0 10" dir="row">
<text text="Share to Cloud" grow="1" margin="0 0 0 5"/>
</button-custom>
</popup-menu>
</layout>

View File

@@ -235,6 +235,7 @@ public:
void dialog_export_cube_faces();
void dialog_layer_rename();
void dialog_resize();
void dialog_preset_download();
void cloud_upload();
void cloud_upload_all();

View File

@@ -575,3 +575,8 @@ void App::dialog_layer_rename()
App::I->hideKeyboard();
};
}
void App::dialog_preset_download()
{
}

View File

@@ -804,8 +804,8 @@ void App::init_menu_tools()
{
fpanel->m_container->add_child(floating_presets);
}
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
popup_time->find<NodeButtonCustom>("panel-color")->on_click = [this, popup_time, popup_exp, visible](Node*) {
@@ -830,8 +830,8 @@ void App::init_menu_tools()
{
fpanel->m_container->add_child(floating_color);
}
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
popup_time->find<NodeButtonCustom>("panel-color-adv")->on_click = [this, popup_time, popup_exp, visible](Node*) {
if (visible(floating_picker.get()))
@@ -855,8 +855,8 @@ void App::init_menu_tools()
{
fpanel->m_container->add_child(floating_picker);
}
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
popup_time->find<NodeButtonCustom>("panel-layers")->on_click = [this, popup_time, popup_exp, visible](Node*) {
if (visible(layers.get()))
@@ -872,8 +872,8 @@ void App::init_menu_tools()
layers->SetHeightP(100);
layers->SetFlexShrink(0);
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
popup_time->find<NodeButtonCustom>("panel-brush")->on_click = [this, popup_time, popup_exp, visible](Node*) {
if (visible(stroke.get()))
@@ -887,8 +887,8 @@ void App::init_menu_tools()
stroke->SetWidthP(100);
stroke->SetHeightP(100);
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
popup_time->find<NodeButtonCustom>("panel-grids")->on_click = [this, popup_time, popup_exp, visible](Node*) {
if (visible(grid.get()))
@@ -902,8 +902,8 @@ void App::init_menu_tools()
grid->SetWidthP(100);
grid->SetHeightP(100);
popup_time->destroy();
popup_exp->destroy();
popup_time->destroy();
};
}
};
@@ -1499,7 +1499,7 @@ void App::ui_restore()
{
floating_presets = f->m_container->add_child_ref<NodePanelBrushPreset>();
floating_presets->SetHeightP(100);
floating_presets->find("toolbar")->destroy();
//floating_presets->find("toolbar")->destroy();
floating_presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
auto c = Canvas::I->m_current_brush->m_tip_color;
*Canvas::I->m_current_brush = *b;

View File

@@ -427,6 +427,7 @@ void NodePanelBrushPreset::init()
save();
}
};
/*
m_btn_save = find<NodeButtonCustom>("btn-save");
m_btn_save->on_click = [this](Node*) {
if (m_current)
@@ -437,6 +438,7 @@ void NodePanelBrushPreset::init()
save();
}
};
*/
m_btn_delete = find<NodeButtonCustom>("btn-remove");
m_btn_delete->on_click = [this](Node*) {
if (!m_current)
@@ -454,6 +456,7 @@ void NodePanelBrushPreset::init()
m_current->m_selected = true;
}
save();
m_notification->SetVisibility(m_container->m_children.size() == 0);
};
m_btn_menu = find<NodeButtonCustom>("btn-menu");
m_btn_menu->on_click = [this](Node* b) {
@@ -469,10 +472,11 @@ void NodePanelBrushPreset::init()
case 0: // download
break;
case 1: // import
App::I->pick_file({"abr", "ppbr"}, [] (std::string path) {
std::thread([path] {
App::I->pick_file({"abr", "ppbr"}, [this] (std::string path) {
std::thread([this, path] {
BT_SetTerminate();
App::I->stroke->import_abr(path);
m_notification->SetVisibility(m_container->m_children.size() == 0);
}).detach();
});
break;
@@ -482,6 +486,21 @@ void NodePanelBrushPreset::init()
popup->destroy();
};
};
m_btn_import = find<NodeButton>("import");
m_btn_import->on_click = [this] (Node*) {
App::I->pick_file({ "abr", "ppbr" }, [this](std::string path) {
std::thread([this, path] {
BT_SetTerminate();
App::I->stroke->import_abr(path);
m_notification->SetVisibility(m_container->m_children.size() == 0);
}).detach();
});
};
m_btn_download = find<NodeButton>("download");
m_btn_download->on_click = [] (Node*) {
App::I->dialog_preset_download();
};
m_notification = find("notification");
if (Asset::exist(App::I->data_path + "/settings/presets.bin") && !restore())
{
@@ -494,6 +513,7 @@ void NodePanelBrushPreset::init()
mb->destroy();
};
}
m_notification->SetVisibility(m_container->m_children.size() == 0);
}
kEventResult NodePanelBrushPreset::handle_event(Event* e)
@@ -608,6 +628,7 @@ bool NodePanelBrushPreset::restore()
brush->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1);
}
}
m_notification->SetVisibility(m_container->m_children.size() == 0);
return true;
}
return false;
@@ -630,14 +651,17 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr<Brush> brush)
b->m_thumb->set_image(brush->m_brush_thumb_path);
b->m_caption_size->set_text_format("%d", (int)brush->m_tip_size);
b->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1);
m_notification->SetVisibility(m_container->m_children.size() == 0);
}
void NodePanelBrushPreset::clear_brushes()
{
m_container->remove_all_children();
m_notification->SetVisibility(m_container->m_children.size() == 0);
}
void NodePanelBrushPreset::added(Node* parent)
{
m_interacted = false;
m_notification->SetVisibility(m_container->m_children.size() == 0);
}

View File

@@ -7,6 +7,7 @@
#include "node_scroll.h"
#include "node_text.h"
#include "serializer.h"
#include "node_button.h"
class NodeButtonBrush : public NodeButtonCustom, public Serializer::Type
{
@@ -82,6 +83,9 @@ class NodePanelBrushPreset : public Node
NodeButtonCustom* m_btn_delete;
NodeButtonCustom* m_btn_save;
NodeButtonCustom* m_btn_menu;
NodeButton* m_btn_import;
NodeButton* m_btn_download;
Node* m_notification;
public:
Node* m_container;
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;