rename texture to pattern and implement initial pattern settings
This commit is contained in:
@@ -31,7 +31,7 @@ void NodePanelStroke::update_controls()
|
||||
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_pattern_opacity->m_value.x = b->m_pattern_opacity;
|
||||
m_tip_wet->m_value.x = b->m_tip_wet;
|
||||
m_tip_noise->m_value.x = b->m_tip_noise;
|
||||
m_jitter_scale->m_value.x = b->m_jitter_scale;
|
||||
@@ -48,7 +48,7 @@ void NodePanelStroke::update_controls()
|
||||
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_pattern_enabled->checked = b->m_pattern_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;
|
||||
@@ -66,8 +66,17 @@ void NodePanelStroke::update_controls()
|
||||
m_dual_opacity->m_value.x = b->m_dual_opacity;
|
||||
m_dual_rotate->m_value.x = b->m_dual_rotate;
|
||||
|
||||
m_pattern_eachsample->checked = b->m_pattern_eachsample;
|
||||
m_pattern_invert->checked = b->m_pattern_invert;
|
||||
m_pattern_flipx->checked = b->m_pattern_flipx;
|
||||
m_pattern_flipy->checked = b->m_pattern_flipy;
|
||||
m_pattern_scale->m_value.x = b->m_pattern_scale;
|
||||
m_pattern_brightness->m_value.x = b->m_pattern_brightness;
|
||||
m_pattern_contrast->m_value.x = b->m_pattern_contrast;
|
||||
|
||||
m_blend_mode->set_index(b->m_blend_mode);
|
||||
m_dual_blend_mode->set_index(b->m_dual_blend_mode);
|
||||
m_pattern_blend_mode->set_index(b->m_pattern_blend_mode);
|
||||
|
||||
m_preview->m_brush = b;
|
||||
m_preview->draw_stroke();
|
||||
@@ -87,17 +96,17 @@ void NodePanelStroke::init_controls()
|
||||
m_brush_popup->m_flood_events = true;
|
||||
m_brush_popup->m_capture_children = false;
|
||||
|
||||
m_texture_popup = std::make_shared<NodePanelBrush>();
|
||||
m_texture_popup->m_manager = m_manager;
|
||||
m_texture_popup->m_dir_name = "textures";
|
||||
m_texture_popup->init();
|
||||
m_texture_popup->create();
|
||||
m_texture_popup->loaded();
|
||||
m_texture_popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
m_texture_popup->SetSize(300, 400);
|
||||
m_texture_popup->m_mouse_ignore = false;
|
||||
m_texture_popup->m_flood_events = true;
|
||||
m_texture_popup->m_capture_children = false;
|
||||
m_pattern_popup = std::make_shared<NodePanelBrush>();
|
||||
m_pattern_popup->m_manager = m_manager;
|
||||
m_pattern_popup->m_dir_name = "textures";
|
||||
m_pattern_popup->init();
|
||||
m_pattern_popup->create();
|
||||
m_pattern_popup->loaded();
|
||||
m_pattern_popup->SetPositioning(YGPositionTypeAbsolute);
|
||||
m_pattern_popup->SetSize(300, 400);
|
||||
m_pattern_popup->m_mouse_ignore = false;
|
||||
m_pattern_popup->m_flood_events = true;
|
||||
m_pattern_popup->m_capture_children = false;
|
||||
|
||||
m_presets_popup = std::make_shared<NodePanelBrushPreset>();
|
||||
m_presets_popup->m_manager = m_manager;
|
||||
@@ -114,8 +123,9 @@ void NodePanelStroke::init_controls()
|
||||
|
||||
// init main brush
|
||||
auto b = std::make_shared<Brush>();
|
||||
b->load_texture(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||
b->load_tip(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||
b->load_dual(m_brush_popup->get_texture_path(br_idx), m_brush_popup->get_thumb_path(br_idx));
|
||||
b->load_pattern(m_pattern_popup->get_texture_path(0), m_pattern_popup->get_thumb_path(0));
|
||||
b->m_tip_size = .1f;
|
||||
b->m_tip_flow = .5f;
|
||||
b->m_tip_spacing = .1f;
|
||||
@@ -237,37 +247,37 @@ void NodePanelStroke::init_controls()
|
||||
};
|
||||
|
||||
|
||||
// TEXTURE IMAGE
|
||||
// PATTERN IMAGE
|
||||
|
||||
m_texture_thumb = find<NodeImage>("texture-change-thumb");
|
||||
m_texture_thumb->set_image(m_texture_popup->get_thumb_path(0));
|
||||
m_texture_button = find<NodeButtonCustom>("texture-change");
|
||||
m_texture_button->on_click = [this](Node*) {
|
||||
m_pattern_thumb = find<NodeImage>("pattern-change-thumb");
|
||||
m_pattern_thumb->set_image(m_pattern_popup->get_thumb_path(0));
|
||||
m_pattern_button = find<NodeButtonCustom>("pattern-change");
|
||||
m_pattern_button->on_click = [this](Node*) {
|
||||
auto screen = root()->m_size;
|
||||
glm::vec2 pos = m_texture_button->m_pos + glm::vec2(m_texture_button->m_size.x, 0);
|
||||
root()->add_child(m_texture_popup);
|
||||
glm::vec2 pos = m_pattern_button->m_pos + glm::vec2(m_pattern_button->m_size.x, 0);
|
||||
root()->add_child(m_pattern_popup);
|
||||
auto tick = root()->add_child<NodeImage>();
|
||||
tick->SetPositioning(YGPositionTypeAbsolute);
|
||||
tick->SetSize(16, 32);
|
||||
tick->SetPosition(pos.x, pos.y + (m_texture_button->m_size.y - 32) * 0.5f);
|
||||
tick->SetPosition(pos.x, pos.y + (m_pattern_button->m_size.y - 32) * 0.5f);
|
||||
tick->set_image("data/ui/popup-tick.png");
|
||||
root()->update();
|
||||
if ((pos.y + m_texture_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_texture_popup->m_size.y;
|
||||
if ((pos.y + m_pattern_popup->m_size.y) > screen.y)
|
||||
pos.y = screen.y - m_pattern_popup->m_size.y;
|
||||
if (pos.y < 0)
|
||||
pos.y = 0;
|
||||
m_texture_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_texture_popup->mouse_capture();
|
||||
m_pattern_popup->SetPosition(pos.x + 16, pos.y);
|
||||
m_pattern_popup->mouse_capture();
|
||||
root()->update();
|
||||
|
||||
m_texture_popup->on_popup_close = [this, tick](Node*) {
|
||||
m_pattern_popup->on_popup_close = [this, tick](Node*) {
|
||||
tick->destroy();
|
||||
};
|
||||
|
||||
m_texture_popup->on_brush_changed = [this](Node*, int index) {
|
||||
if (on_texture_changed)
|
||||
on_texture_changed(this, m_texture_popup->get_texture_path(index), m_texture_popup->get_thumb_path(index));
|
||||
m_texture_thumb->set_image(m_texture_popup->get_thumb_path(index));
|
||||
m_pattern_popup->on_brush_changed = [this](Node*, int index) {
|
||||
if (on_pattern_changed)
|
||||
on_pattern_changed(this, m_pattern_popup->get_texture_path(index), m_pattern_popup->get_thumb_path(index));
|
||||
m_pattern_thumb->set_image(m_pattern_popup->get_thumb_path(index));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -288,7 +298,7 @@ void NodePanelStroke::init_controls()
|
||||
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_pattern_opacity, "pattern-opacity", &Brush::m_pattern_opacity);
|
||||
init_slider(m_tip_wet, "tip-wet", &Brush::m_tip_wet);
|
||||
init_slider(m_tip_noise, "tip-noise", &Brush::m_tip_noise);
|
||||
init_slider(m_tip_hue, "tip-hue", &Brush::m_tip_hue);
|
||||
@@ -309,7 +319,7 @@ void NodePanelStroke::init_controls()
|
||||
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_pattern_enabled, "pattern-enabled", &Brush::m_pattern_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);
|
||||
@@ -318,6 +328,11 @@ void NodePanelStroke::init_controls()
|
||||
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_checkbox(m_pattern_eachsample, "pattern-eachsample", &Brush::m_pattern_eachsample);
|
||||
|
||||
init_checkbox(m_pattern_invert, "pattern-invert", &Brush::m_pattern_invert);
|
||||
init_checkbox(m_pattern_flipx, "pattern-flipx", &Brush::m_pattern_flipx);
|
||||
init_checkbox(m_pattern_flipy, "pattern-flipy", &Brush::m_pattern_flipy);
|
||||
|
||||
init_slider(m_dual_size, "dual-size", &Brush::m_dual_size);
|
||||
init_slider(m_dual_spacing, "dual-spacing", &Brush::m_dual_spacing);
|
||||
@@ -326,6 +341,9 @@ void NodePanelStroke::init_controls()
|
||||
init_slider(m_dual_opacity, "dual-opacity", &Brush::m_dual_opacity);
|
||||
init_slider(m_dual_flow, "dual-flow", &Brush::m_dual_flow);
|
||||
init_slider(m_dual_rotate, "dual-rotate", &Brush::m_dual_rotate);
|
||||
init_slider(m_pattern_scale, "pattern-scale", &Brush::m_pattern_scale);
|
||||
init_slider(m_pattern_brightness, "pattern-brightness", &Brush::m_pattern_brightness);
|
||||
init_slider(m_pattern_contrast, "pattern-contrast", &Brush::m_pattern_contrast);
|
||||
|
||||
auto curve_cubic = [](float v) { return glm::pow(v, 3.f); };
|
||||
auto curve_quad = [](float v) { return glm::pow(v, 2.f); };
|
||||
@@ -353,6 +371,14 @@ void NodePanelStroke::init_controls()
|
||||
on_stroke_change(this);
|
||||
};
|
||||
|
||||
m_pattern_blend_mode = find<NodeComboBox>("pattern-blend-mode");
|
||||
m_pattern_blend_mode->on_select = [this](Node*, int index) {
|
||||
Canvas::I->m_current_brush->m_pattern_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();
|
||||
|
||||
@@ -363,8 +389,8 @@ void NodePanelStroke::init_controls()
|
||||
App::I.async_start();
|
||||
if (TextureManager::load(path.c_str()))
|
||||
{
|
||||
if (on_texture_changed)
|
||||
on_texture_changed(this, path, "");
|
||||
if (on_pattern_changed)
|
||||
on_pattern_changed(this, path, "");
|
||||
}
|
||||
App::I.async_redraw();
|
||||
App::I.async_end();
|
||||
|
||||
Reference in New Issue
Block a user