change node children from unique to shared ptr, rename Canvas2D to StrokePreview, add panel toolbar with icon buttons to toggle

This commit is contained in:
2017-03-25 17:28:57 +00:00
parent 4da0c3696a
commit a1e3fd4ecf
15 changed files with 216 additions and 65 deletions

View File

@@ -184,7 +184,7 @@ void App::initLayout()
NodeBorder::static_init();
NodeImage::static_init();
NodeIcon::static_init();
NodeCanvas2D::static_init();
NodeStrokePreview::static_init();
layout.on_loaded = [&] {
LOG("initializing layout updating after load");
@@ -192,10 +192,36 @@ void App::initLayout()
LOG("initializing layout components");
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
color = layout[main_id]->find<NodePanelColor>("panel-color");
stroke = layout[main_id]->find<NodePanelStroke>("panel-stroke");
panels = layout[main_id]->find<Node>("panels");
//brushes = layout[main_id]->find<NodePanelBrush>("panel-brush");
//layers = layout[main_id]->find<NodePanelLayer>("panel-layer");
//color = layout[main_id]->find<NodePanelColor>("panel-color");
//stroke = layout[main_id]->find<NodePanelStroke>("panel-stroke");
brushes = std::make_shared<NodePanelBrush>();
brushes->m_manager = &layout;
brushes->init();
brushes->create();
brushes->loaded();
layers = std::make_shared<NodePanelLayer>();
layers->m_manager = &layout;
layers->init();
layers->create();
layers->loaded();
color = std::make_shared<NodePanelColor>();
color->m_manager = &layout;
color->init();
color->create();
color->loaded();
stroke = std::make_shared<NodePanelStroke>();
stroke->m_manager = &layout;
stroke->init();
stroke->create();
stroke->loaded();
brushes->on_brush_changed = [this](Node* target, int index) {
auto tid = brushes->get_texture_id(index);
@@ -217,6 +243,67 @@ void App::initLayout()
on_stroke_change();
};
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-stroke"))
{
button->on_click = [this](Node*) {
panels->remove_all_children();
if (current_panel != stroke.get())
{
panels->add_child(std::static_pointer_cast<Node>(stroke));
current_panel = stroke.get();
}
else
{
current_panel = nullptr;
}
};
}
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-brush"))
{
button->on_click = [this](Node*) {
panels->remove_all_children();
if (current_panel != brushes.get())
{
panels->add_child(std::static_pointer_cast<Node>(brushes));
current_panel = brushes.get();
}
else
{
current_panel = nullptr;
}
};
}
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-color"))
{
button->on_click = [this](Node*) {
panels->remove_all_children();
if (current_panel != color.get())
{
panels->add_child(std::static_pointer_cast<Node>(color));
current_panel = color.get();
}
else
{
current_panel = nullptr;
}
};
}
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-layer"))
{
button->on_click = [this](Node*) {
panels->remove_all_children();
if (current_panel != layers.get())
{
panels->add_child(std::static_pointer_cast<Node>(layers));
current_panel = layers.get();
}
else
{
current_panel = nullptr;
}
};
}
if (auto* button = layout[main_id]->find<NodeButton>("btn-close"))
{
button->on_click = [](Node*) { exit(0); };