add brush preset panel

This commit is contained in:
2017-10-03 14:35:30 +01:00
parent db55a055fd
commit 41e52b7757
7 changed files with 191 additions and 7 deletions

View File

@@ -121,6 +121,12 @@ void App::init_sidebar()
stroke->create();
stroke->loaded();
presets = std::make_shared<NodePanelBrushPreset>();
presets->m_manager = &layout;
presets->init();
presets->create();
presets->loaded();
if (canvas)
{
stroke->m_canvas->m_brush.m_tip_color = color->m_color;
@@ -136,6 +142,16 @@ void App::init_sidebar()
if (on_brush_select)
on_brush_select(index);
};
presets->on_brush_changed = [this](Node* target, int index) {
auto b = presets->get_brush(index);
// don't change some params
b.m_tip_size = stroke->m_canvas->m_brush.m_tip_size;
b.m_tip_color = stroke->m_canvas->m_brush.m_tip_color;
stroke->set_params(b);
canvas->m_brush = stroke->m_canvas->m_brush;
if (on_brush_select)
on_brush_select(index);
};
color->on_color_changed = [this](Node* target, glm::vec4 color) {
stroke->m_canvas->m_brush.m_tip_color = color;
@@ -196,6 +212,14 @@ void App::init_sidebar()
button->set_color(panels->get_child_index(brushes.get()) == -1 ? color_button_normal : color_button_hlight);
};
}
if (auto* button = layout[main_id]->find<NodeButton>("btn-brush-preset"))
{
button->on_click = [this, button](Node*) {
panels->get_child_index(presets.get()) == -1 ? panels->add_child(presets) : panels->remove_child(presets.get());
panels->fix_scroll();
button->set_color(panels->get_child_index(presets.get()) == -1 ? color_button_normal : color_button_hlight);
};
}
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-color"))
{
button->on_click = [this, button](Node*) {