53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
#include "pch.h"
|
|
#include "log.h"
|
|
#include "node_panel_stroke.h"
|
|
|
|
Node* NodePanelStroke::clone_instantiate() const
|
|
{
|
|
return new NodePanelStroke();
|
|
}
|
|
|
|
void NodePanelStroke::clone_finalize(Node* dest) const
|
|
{
|
|
NodePanelStroke* n = static_cast<NodePanelStroke*>(dest);
|
|
n->init_controls();
|
|
}
|
|
|
|
void NodePanelStroke::init()
|
|
{
|
|
init_template("tpl-panel-stroke");
|
|
init_controls();
|
|
}
|
|
|
|
void NodePanelStroke::init_controls()
|
|
{
|
|
m_canvas = find<NodeStrokePreview>("canvas");
|
|
|
|
init_slider(m_tip_size, "tip-size", &ui::Brush::m_tip_size);
|
|
init_slider(m_tip_spacing, "tip-spacing", &ui::Brush::m_tip_spacing);
|
|
init_slider(m_tip_flow, "tip-flow", &ui::Brush::m_tip_flow);
|
|
init_slider(m_tip_opacity, "tip-opacity", &ui::Brush::m_tip_opacity);
|
|
init_slider(m_tip_angle, "tip-angle", &ui::Brush::m_tip_angle);
|
|
init_slider(m_jitter_scale, "jitter-scale", &ui::Brush::m_jitter_scale);
|
|
init_slider(m_jitter_angle, "jitter-angle", &ui::Brush::m_jitter_angle);
|
|
init_slider(m_jitter_spread, "jitter-spread", &ui::Brush::m_jitter_spread);
|
|
init_slider(m_jitter_flow, "jitter-flow", &ui::Brush::m_jitter_flow);
|
|
//m_canvas->draw_stroke();
|
|
}
|
|
|
|
void NodePanelStroke::init_slider(NodeSliderH*& slider, const char* id, float ui::Brush::* prop)
|
|
{
|
|
slider = find<NodeSliderH>(id);
|
|
slider->on_value_changed = std::bind(&NodePanelStroke::handle_slide,
|
|
this, prop, std::placeholders::_1, std::placeholders::_2);
|
|
m_canvas->m_brush.*prop = slider->m_value.x;
|
|
}
|
|
|
|
void NodePanelStroke::handle_slide(float ui::Brush::* prop, Node* target, float value)
|
|
{
|
|
m_canvas->m_brush.*prop = value;
|
|
m_canvas->draw_stroke();
|
|
if (on_stroke_change)
|
|
on_stroke_change(this);
|
|
}
|