Improved mask also work on erase. Improved shaders for layer opacity, now when drawing doesn't change opacity. Improved layers panel layout to be similar to PS. Added layer blending option and visibility. Added custom icons to checkboxes and fixed the combobox items.
This commit is contained in:
@@ -88,6 +88,26 @@ void App::init_toolbar_main()
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> std::shared_ptr<T> find_or_create_panel(NodeScroll* panels)
|
||||
{
|
||||
std::shared_ptr<T> ret;
|
||||
auto node_find = std::find_if(panels->m_children.begin(), panels->m_children.end(),
|
||||
[](const std::shared_ptr<Node>&p) { return (bool)std::dynamic_pointer_cast<T>(p); });
|
||||
if (node_find != panels->m_children.end())
|
||||
{
|
||||
ret = std::static_pointer_cast<T>(*node_find);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = std::make_shared<T>();
|
||||
ret->m_manager = panels->m_manager;
|
||||
ret->init();
|
||||
ret->create();
|
||||
ret->loaded();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void App::init_sidebar()
|
||||
{
|
||||
sidebar = layout[main_id]->find<NodeBorder>("sidebar");
|
||||
@@ -99,50 +119,12 @@ void App::init_sidebar()
|
||||
//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();
|
||||
|
||||
auto grid_find = std::find_if(panels->m_children.begin(), panels->m_children.end(),
|
||||
[](const std::shared_ptr<Node>&p) { return (bool)std::dynamic_pointer_cast<NodePanelGrid>(p); });
|
||||
if (grid_find != panels->m_children.end())
|
||||
{
|
||||
grid = std::static_pointer_cast<NodePanelGrid>(*grid_find);
|
||||
}
|
||||
else
|
||||
{
|
||||
grid = std::make_shared<NodePanelGrid>();
|
||||
grid->m_manager = &layout;
|
||||
grid->init();
|
||||
grid->create();
|
||||
grid->loaded();
|
||||
}
|
||||
|
||||
presets = std::make_shared<NodePanelBrushPreset>();
|
||||
presets->m_manager = &layout;
|
||||
presets->init();
|
||||
presets->create();
|
||||
presets->loaded();
|
||||
brushes = find_or_create_panel<NodePanelBrush>(panels);
|
||||
layers = find_or_create_panel<NodePanelLayer>(panels);
|
||||
color = find_or_create_panel<NodePanelColor>(panels);
|
||||
stroke = find_or_create_panel<NodePanelStroke>(panels);
|
||||
grid = find_or_create_panel<NodePanelGrid>(panels);
|
||||
presets = find_or_create_panel<NodePanelBrushPreset>(panels);
|
||||
|
||||
// if (canvas)
|
||||
// {
|
||||
@@ -175,6 +157,8 @@ void App::init_sidebar()
|
||||
|
||||
layers->on_layer_add = [this](Node*) {
|
||||
canvas->m_canvas->layer_add(layers->m_layers.back()->m_label_text.c_str());
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_change = [this](Node*, int old_idx, int new_idx) {
|
||||
@@ -183,18 +167,38 @@ void App::init_sidebar()
|
||||
|
||||
layers->on_layer_order = [this](Node*, int old_idx, int new_idx) {
|
||||
canvas->m_canvas->layer_order(old_idx, new_idx);
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_delete = [this](Node*, int idx) {
|
||||
canvas->m_canvas->layer_remove(idx);
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_opacity_changed = [this](Node*, int idx, float value) {
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_opacity = value;
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_visibility_changed = [this](Node*, int idx, bool visible) {
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_alpha_locked = visible;
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_visible = visible;
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_alpha_lock_changed = [this](Node*, int idx, bool locked) {
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_alpha_locked = locked;
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_blend_mode_changed = [this](Node*, int idx, int mode) {
|
||||
canvas->m_canvas->m_layers[canvas->m_canvas->m_order[idx]].m_blend_mode = mode;
|
||||
canvas->m_canvas->m_unsaved = true;
|
||||
title_update();
|
||||
};
|
||||
|
||||
layers->on_layer_highlight_changed = [this](Node*, int idx, bool highlight) {
|
||||
|
||||
Reference in New Issue
Block a user