presets options when empty
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -575,3 +575,8 @@ void App::dialog_layer_rename()
|
||||
App::I->hideKeyboard();
|
||||
};
|
||||
}
|
||||
|
||||
void App::dialog_preset_download()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user