Route layer panel view through app core
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "app_core/document_layer.h"
|
||||
#include "log.h"
|
||||
#include "node_panel_layer.h"
|
||||
#include "canvas.h"
|
||||
@@ -367,13 +368,38 @@ void NodePanelLayer::clear()
|
||||
|
||||
void NodePanelLayer::update_attributes()
|
||||
{
|
||||
auto& l = Canvas::I->m_layers[Canvas::I->m_current_layer_idx];
|
||||
m_opacity->set_value(l->m_opacity);
|
||||
m_alpha_lock->set_value(l->m_alpha_locked);
|
||||
m_blend_mode->set_index(l->m_blend_mode);
|
||||
for (int i = 0; i < Canvas::I->m_layers.size(); i++)
|
||||
if (!Canvas::I)
|
||||
return;
|
||||
|
||||
std::vector<pp::app::DocumentLayerPanelInput> layer_inputs;
|
||||
layer_inputs.reserve(Canvas::I->m_layers.size());
|
||||
for (int i = 0; i < static_cast<int>(Canvas::I->m_layers.size()); i++)
|
||||
{
|
||||
m_layers[i]->m_visibility->set_value(Canvas::I->m_layers[i]->m_visible);
|
||||
const auto& layer = Canvas::I->m_layers[i];
|
||||
layer_inputs.push_back(pp::app::DocumentLayerPanelInput {
|
||||
.layer_index = i,
|
||||
.name = layer->m_name,
|
||||
.opacity = layer->m_opacity,
|
||||
.visible = layer->m_visible,
|
||||
.alpha_locked = layer->m_alpha_locked,
|
||||
.blend_mode = layer->m_blend_mode,
|
||||
});
|
||||
}
|
||||
|
||||
const auto view = pp::app::plan_document_layer_panel_view(layer_inputs, Canvas::I->m_current_layer_idx);
|
||||
if (!view)
|
||||
{
|
||||
LOG("Layer panel view failed: %s", view.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
m_opacity->set_value(view.value().current_opacity);
|
||||
m_alpha_lock->set_value(view.value().current_alpha_locked);
|
||||
m_blend_mode->set_index(view.value().current_blend_mode);
|
||||
for (const auto& layer : view.value().layers)
|
||||
{
|
||||
if (layer.layer_index >= 0 && layer.layer_index < static_cast<int>(m_layers.size()))
|
||||
m_layers[layer.layer_index]->m_visibility->set_value(layer.visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user