Route brush refresh view through app core

This commit is contained in:
2026-06-05 01:13:34 +02:00
parent d5403f082c
commit 31c26c3127
8 changed files with 384 additions and 11 deletions

View File

@@ -1398,21 +1398,54 @@ void App::brush_update(bool update_color, bool update_brush)
// stroke->set_params(canvas->m_brush);
render_task_async([this, update_color, update_brush]
{
if (update_brush)
pp::app::BrushUiRefreshInput input;
input.update_color = update_color;
input.update_brush = update_brush;
auto current_brush = Canvas::I ? Canvas::I->m_current_brush : nullptr;
input.has_current_brush = current_brush != nullptr;
input.has_floating_picker = floating_picker != nullptr;
input.has_floating_color_panel = floating_color != nullptr;
if (input.has_current_brush)
{
input.tip_flow = current_brush->m_tip_flow;
input.tip_size = current_brush->m_tip_size;
input.r = current_brush->m_tip_color.r;
input.g = current_brush->m_tip_color.g;
input.b = current_brush->m_tip_color.b;
input.a = current_brush->m_tip_color.a;
}
const auto view = pp::app::plan_brush_ui_refresh(input);
if (!view) {
LOG("Brush UI refresh failed: %s", view.status().message);
return;
}
if (view.value().updates_stroke_controls)
{
stroke->update_controls();
}
if (view.value().updates_quick_flow)
{
quick->m_slider_flow->set_value(stroke->m_tip_flow->get_value());
}
if (view.value().updates_quick_size)
{
quick->m_slider_size->set_value(stroke->m_tip_size->get_value());
*quick->m_button_brush_current_preview->m_brush = *Canvas::I->m_current_brush;
}
if (view.value().updates_quick_brush_preview && current_brush)
{
*quick->m_button_brush_current_preview->m_brush = *current_brush;
quick->m_button_brush_current_preview->draw_stroke();
}
if (update_color)
if (view.value().updates_quick_color)
{
quick->m_button_color_current_inner->m_color = Canvas::I->m_current_brush->m_tip_color;
if (floating_picker)
floating_picker->set_color(Canvas::I->m_current_brush->m_tip_color);
if (floating_color)
floating_color->set_color(Canvas::I->m_current_brush->m_tip_color);
const glm::vec4 color(view.value().r, view.value().g, view.value().b, view.value().a);
quick->m_button_color_current_inner->m_color = color;
if (view.value().updates_floating_picker)
floating_picker->set_color(color);
if (view.value().updates_floating_color_panel)
floating_color->set_color(color);
}
}, true);
}