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

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