enable rtt dtor, default values for <text> node, dual-brush wip, more brush options
This commit is contained in:
@@ -26,10 +26,11 @@ void NodePanelStroke::update_controls()
|
||||
{
|
||||
const auto& b = Canvas::I->m_current_brush;
|
||||
m_tip_size->m_value.x = glm::pow(b->m_tip_size, 1.f/3.f);
|
||||
m_tip_spacing->m_value.x = glm::pow(b->m_tip_spacing, 1.f/2.f) / 4.f;
|
||||
m_tip_spacing->m_value.x = glm::pow(b->m_tip_spacing, 1.f/2.f);
|
||||
m_tip_flow->m_value.x = glm::pow(b->m_tip_flow, 1.f/2.f);
|
||||
m_tip_opacity->m_value.x = b->m_tip_opacity;
|
||||
m_tip_angle->m_value.x = b->m_tip_angle;
|
||||
m_tip_angle_delay->m_value.x = b->m_tip_angle_delay;
|
||||
m_tip_stencil->m_value.x = b->m_tip_stencil;
|
||||
m_tip_wet->m_value.x = b->m_tip_wet;
|
||||
m_tip_noise->m_value.x = b->m_tip_noise;
|
||||
@@ -43,6 +44,28 @@ void NodePanelStroke::update_controls()
|
||||
m_tip_angle_follow->checked = b->m_tip_angle_follow;
|
||||
m_tip_flow_pressure->checked = b->m_tip_flow_pressure;
|
||||
m_tip_size_pressure->checked = b->m_tip_size_pressure;
|
||||
|
||||
m_tip_invert->checked = b->m_tip_invert;
|
||||
m_tip_flipx->checked = b->m_tip_flipx;
|
||||
m_tip_flipy->checked = b->m_tip_flipy;
|
||||
m_tex_enabled->checked = b->m_tex_enabled;
|
||||
m_dual_enabled->checked = b->m_dual_enabled;
|
||||
m_dual_scatter_axis->checked = b->m_dual_scatter_axis;
|
||||
m_dual_invert->checked = b->m_dual_invert;
|
||||
m_dual_flipx->checked = b->m_dual_flipx;
|
||||
m_dual_flipy->checked = b->m_dual_flipy;
|
||||
m_dual_randflip->checked = b->m_dual_randflip;
|
||||
m_tip_randflipx->checked = b->m_tip_randflipx;
|
||||
m_tip_randflipy->checked = b->m_tip_randflipy;
|
||||
|
||||
m_dual_size->m_value.x = b->m_dual_size;
|
||||
m_dual_spacing->m_value.x = b->m_dual_spacing;
|
||||
m_dual_scatter->m_value.x = b->m_dual_scatter;
|
||||
m_tip_aspect->m_value.x = b->m_tip_aspect;
|
||||
|
||||
m_blend_mode->set_index(b->m_blend_mode);
|
||||
m_dual_blend_mode->set_index(b->m_dual_blend_mode);
|
||||
|
||||
m_preview->m_brush = b;
|
||||
m_preview->draw_stroke();
|
||||
}
|
||||
@@ -71,17 +94,23 @@ void NodePanelStroke::init_controls()
|
||||
m_presets_popup->m_flood_events = true;
|
||||
m_presets_popup->m_capture_children = false;
|
||||
|
||||
int br_idx = std::max(m_brush_popup->find_brush("Round-Hard"), 0);
|
||||
// init main brush
|
||||
auto b = std::make_shared<Brush>();
|
||||
int br_idx = m_brush_popup->find_brush("Round-Hard");
|
||||
if (br_idx == -1)
|
||||
br_idx = 0;
|
||||
b->load_texture(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||
//b->load_stencil("data/paper.jpg");
|
||||
b->m_tip_size = .1f;
|
||||
b->m_tip_flow = .5f;
|
||||
b->m_tip_spacing = .1f;
|
||||
b->m_tip_opacity = 1.f;
|
||||
Canvas::I->m_current_brush = b;
|
||||
// init dual brush
|
||||
auto db = std::make_shared<Brush>();
|
||||
db->load_texture(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||
db->m_tip_size = .3f;
|
||||
db->m_tip_flow = .5f;
|
||||
db->m_tip_spacing = .1f;
|
||||
db->m_tip_opacity = 1.f;
|
||||
Canvas::I->m_dual_brush = db;
|
||||
|
||||
m_preset_thumb = find<NodeImage>("preset-thumb");
|
||||
m_preset_thumb->m_use_mipmaps = true;
|
||||
@@ -99,8 +128,10 @@ void NodePanelStroke::init_controls()
|
||||
tick->SetPosition(pos.x, pos.y + (m_preset_button->m_size.y - 32) * 0.5f);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
root()->update();
|
||||
if ((pos.y + m_presets_popup->m_size.y) > screen.y) pos.y = screen.y - m_presets_popup->m_size.y;
|
||||
if (pos.y < 0) pos.y = 0;
|
||||
if ((pos.y + m_presets_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_presets_popup->m_size.y;
|
||||
if (pos.y < 0)
|
||||
pos.y = 0;
|
||||
m_presets_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_presets_popup->mouse_capture();
|
||||
root()->update();
|
||||
@@ -111,7 +142,7 @@ void NodePanelStroke::init_controls()
|
||||
|
||||
m_presets_popup->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
// don't change some params
|
||||
//b->m_tip_size = Canvas::I->m_current_brush->m_tip_size;
|
||||
b->m_tip_size = Canvas::I->m_current_brush->m_tip_size;
|
||||
b->m_tip_color = Canvas::I->m_current_brush->m_tip_color;
|
||||
*Canvas::I->m_current_brush = *b;
|
||||
m_preview->draw_stroke();
|
||||
@@ -125,8 +156,54 @@ void NodePanelStroke::init_controls()
|
||||
};
|
||||
};
|
||||
|
||||
m_dual_preset_thumb = find<NodeImage>("dual-preset-thumb");
|
||||
m_dual_preset_thumb->m_use_mipmaps = true;
|
||||
m_dual_preset_preview = find<NodeStrokePreview>("dual-preset-preview");
|
||||
m_dual_preset_preview->m_brush = b;
|
||||
m_dual_preset_preview->draw_stroke();
|
||||
m_dual_preset_button = find<NodeButtonCustom>("dual-preset-button");
|
||||
m_dual_preset_button->on_click = [this](Node*) {
|
||||
auto screen = root()->m_size;
|
||||
glm::vec2 pos = m_dual_preset_button->m_pos + glm::vec2(m_dual_preset_button->m_size.x, 0);
|
||||
root()->add_child(m_presets_popup);
|
||||
auto tick = root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetSize(16, 32);
|
||||
tick->SetPosition(pos.x, pos.y + (m_dual_preset_button->m_size.y - 32) * 0.5f);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
root()->update();
|
||||
if ((pos.y + m_presets_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_presets_popup->m_size.y;
|
||||
if (pos.y < 0)
|
||||
pos.y = 0;
|
||||
m_presets_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_presets_popup->mouse_capture();
|
||||
root()->update();
|
||||
|
||||
m_presets_popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
m_presets_popup->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
|
||||
// don't change some params
|
||||
b->m_tip_size = Canvas::I->m_current_brush->m_tip_size;
|
||||
b->m_tip_color = { 0, 0, 0, 1 };
|
||||
*Canvas::I->m_dual_brush = *b;
|
||||
m_preview->draw_stroke();
|
||||
m_dual_preset_preview->draw_stroke();
|
||||
m_dual_brush_thumb->set_image(b->m_brush_thumb_path);
|
||||
m_dual_preset_thumb->set_image(b->m_brush_thumb_path);
|
||||
update_controls();
|
||||
|
||||
//m_presets_popup->mouse_release();
|
||||
//m_presets_popup->parent->remove_child(m_presets_popup.get());
|
||||
};
|
||||
};
|
||||
|
||||
m_brush_thumb = find<NodeImage>("tip-change-thumb");
|
||||
m_brush_thumb->set_image(m_brush_popup->get_thumb_path(br_idx));
|
||||
m_dual_brush_thumb = find<NodeImage>("dual-change-thumb");
|
||||
m_dual_brush_thumb->set_image(m_brush_popup->get_thumb_path(br_idx));
|
||||
|
||||
m_brush_button = find<NodeButtonCustom>("tip-change");
|
||||
m_brush_button->on_click = [this](Node*) {
|
||||
@@ -139,8 +216,10 @@ void NodePanelStroke::init_controls()
|
||||
tick->SetPosition(pos.x, pos.y + (m_brush_button->m_size.y - 32) * 0.5f);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
root()->update();
|
||||
if ((pos.y + m_brush_popup->m_size.y) > screen.y) pos.y = screen.y - m_brush_popup->m_size.y;
|
||||
if (pos.y < 0) pos.y = 0;
|
||||
if ((pos.y + m_brush_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_brush_popup->m_size.y;
|
||||
if (pos.y < 0)
|
||||
pos.y = 0;
|
||||
m_brush_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_brush_popup->mouse_capture();
|
||||
root()->update();
|
||||
@@ -160,8 +239,11 @@ void NodePanelStroke::init_controls()
|
||||
|
||||
m_preview = find<NodeStrokePreview>("canvas");
|
||||
m_blend_mode = find<NodeComboBox>("blend-mode");
|
||||
m_blend_mode->on_select = [](Node*, int index) {
|
||||
m_blend_mode->on_select = [this](Node*, int index) {
|
||||
Canvas::I->m_current_brush->m_blend_mode = index;
|
||||
m_preview->draw_stroke();
|
||||
if (on_stroke_change)
|
||||
on_stroke_change(this);
|
||||
};
|
||||
|
||||
init_slider(m_tip_size, "tip-size", &Brush::m_tip_size);
|
||||
@@ -169,6 +251,7 @@ void NodePanelStroke::init_controls()
|
||||
init_slider(m_tip_flow, "tip-flow", &Brush::m_tip_flow);
|
||||
init_slider(m_tip_opacity, "tip-opacity", &Brush::m_tip_opacity);
|
||||
init_slider(m_tip_angle, "tip-angle", &Brush::m_tip_angle);
|
||||
init_slider(m_tip_angle_delay, "tip-angle-delay", &Brush::m_tip_angle_delay);
|
||||
init_slider(m_tip_mix, "tip-mix", &Brush::m_tip_mix);
|
||||
init_slider(m_tip_stencil, "tip-stencil", &Brush::m_tip_stencil);
|
||||
init_slider(m_tip_wet, "tip-wet", &Brush::m_tip_wet);
|
||||
@@ -184,15 +267,47 @@ void NodePanelStroke::init_controls()
|
||||
init_slider(m_jitter_sat, "jitter-sat", &Brush::m_jitter_sat);
|
||||
init_slider(m_jitter_val, "jitter-val", &Brush::m_jitter_val);
|
||||
m_curves[m_tip_size] = [](float v){ return glm::pow(v, 3.f); };
|
||||
m_curves[m_tip_spacing] = [](float v){ return glm::pow(v * 4.f, 2.f); };
|
||||
m_curves[m_tip_spacing] = [](float v){ return glm::pow(v, 2.f); };
|
||||
m_curves[m_tip_flow] = [](float v){ return glm::pow(v, 2.f); };
|
||||
|
||||
init_checkbox(m_tip_angle_follow, "tip-angle-follow", &Brush::m_tip_angle_follow);
|
||||
init_checkbox(m_tip_flow_pressure, "tip-flow-pressure", &Brush::m_tip_flow_pressure);
|
||||
init_checkbox(m_tip_size_pressure, "tip-size-pressure", &Brush::m_tip_size_pressure);
|
||||
init_checkbox(m_tip_hue_pressure, "tip-hue-pressure", &Brush::m_tip_hue_pressure);
|
||||
init_checkbox(m_tip_sat_pressure, "tip-sat-pressure", &Brush::m_tip_sat_pressure);
|
||||
init_checkbox(m_tip_val_pressure, "tip-val-pressure", &Brush::m_tip_val_pressure);
|
||||
|
||||
init_checkbox(m_tip_invert, "tip-invert", &Brush::m_tip_invert);
|
||||
init_checkbox(m_tip_flipx, "tip-flipx", &Brush::m_tip_flipx);
|
||||
init_checkbox(m_tip_flipy, "tip-flipy", &Brush::m_tip_flipy);
|
||||
init_checkbox(m_tex_enabled, "tex-enabled", &Brush::m_tex_enabled);
|
||||
init_checkbox(m_dual_enabled, "dual-enabled", &Brush::m_dual_enabled);
|
||||
init_checkbox(m_dual_scatter_axis, "dual-scatter-axis", &Brush::m_dual_scatter_axis);
|
||||
init_checkbox(m_dual_invert, "dual-invert", &Brush::m_dual_invert);
|
||||
init_checkbox(m_dual_flipx, "dual-flipx", &Brush::m_dual_flipx);
|
||||
init_checkbox(m_dual_flipy, "dual-flipy", &Brush::m_dual_flipy);
|
||||
init_checkbox(m_dual_randflip, "dual-randflip", &Brush::m_dual_randflip);
|
||||
init_checkbox(m_tip_randflipx, "tip-randflipx", &Brush::m_tip_randflipx);
|
||||
init_checkbox(m_tip_randflipy, "tip-randflipy", &Brush::m_tip_randflipy);
|
||||
|
||||
init_slider(m_dual_size, "dual-size", &Brush::m_dual_size);
|
||||
init_slider(m_dual_spacing, "dual-spacing", &Brush::m_dual_spacing);
|
||||
init_slider(m_dual_scatter, "dual-scatter", &Brush::m_dual_scatter);
|
||||
init_slider(m_tip_aspect, "tip-aspect", &Brush::m_tip_aspect);
|
||||
|
||||
m_tip_aspect_reset = find<NodeButtonCustom>("tip-aspect-reset");
|
||||
m_tip_aspect_reset->on_click = [this](Node*) {
|
||||
m_tip_aspect->set_value(0.5);
|
||||
Canvas::I->m_current_brush->m_tip_aspect = 0.5f;
|
||||
m_preview->draw_stroke();
|
||||
if (on_stroke_change)
|
||||
on_stroke_change(this);
|
||||
};
|
||||
|
||||
m_dual_blend_mode = find<NodeComboBox>("blend-mode");
|
||||
m_dual_blend_mode->on_select = [this](Node*, int index) {
|
||||
Canvas::I->m_current_brush->m_dual_blend_mode = index;
|
||||
m_preview->draw_stroke();
|
||||
if (on_stroke_change)
|
||||
on_stroke_change(this);
|
||||
};
|
||||
|
||||
m_preview->m_brush = Canvas::I->m_current_brush;
|
||||
m_preview->draw_stroke();
|
||||
@@ -226,7 +341,6 @@ void NodePanelStroke::handle_slide(float Brush::* prop, Node* target, float valu
|
||||
{
|
||||
auto curve = m_curves.find((NodeSliderH*)target);
|
||||
Canvas::I->m_current_brush.get()->*prop = curve != m_curves.end() ? curve->second(value) : value;
|
||||
m_preview->m_brush = Canvas::I->m_current_brush;
|
||||
m_preview->draw_stroke();
|
||||
if (on_stroke_change)
|
||||
on_stroke_change(this);
|
||||
@@ -243,7 +357,6 @@ void NodePanelStroke::init_checkbox(NodeCheckBox*& target, const char* id, bool
|
||||
void NodePanelStroke::handle_checkbox(bool Brush::* prop, Node *target, bool value)
|
||||
{
|
||||
Canvas::I->m_current_brush.get()->*prop = value;
|
||||
m_preview->m_brush = Canvas::I->m_current_brush;
|
||||
m_preview->draw_stroke();
|
||||
if (on_stroke_change)
|
||||
on_stroke_change(this);
|
||||
|
||||
Reference in New Issue
Block a user