refactor Brush to be used in shared_ptr
This commit is contained in:
@@ -128,39 +128,27 @@ void App::init_sidebar()
|
||||
|
||||
// if (canvas)
|
||||
// {
|
||||
// Canvas::I->m_current_brush.m_tip_color = color->m_color;
|
||||
// Canvas::I->m_current_brush->m_tip_color = color->m_color;
|
||||
// stroke->m_canvas->draw_stroke();
|
||||
// }
|
||||
|
||||
//brushes->on_brush_changed = [this](Node* target, int index) {
|
||||
// Canvas::I->m_current_brush.m_tex_id = brushes->get_texture_id(index);
|
||||
// Canvas::I->m_current_brush.id = brushes->get_brush_id(index);
|
||||
// stroke->m_preview->draw_stroke();
|
||||
//};
|
||||
presets->on_brush_changed = [this](Node* target, int index) {
|
||||
auto b = presets->get_brush(index);
|
||||
// don't change some params
|
||||
b.m_tip_size = Canvas::I->m_current_brush.m_tip_size;
|
||||
b.m_tip_color = Canvas::I->m_current_brush.m_tip_color;
|
||||
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;
|
||||
stroke->m_preview->draw_stroke();
|
||||
};
|
||||
|
||||
color->on_color_changed = [this](Node* target, glm::vec4 color) {
|
||||
Canvas::I->m_current_brush.m_tip_color = color;
|
||||
Canvas::I->m_current_brush->m_tip_color = color;
|
||||
};
|
||||
//
|
||||
// stroke->on_stroke_change = [this](Node*target) {
|
||||
// if (canvas)
|
||||
// canvas->m_brush = stroke->m_canvas->m_brush;
|
||||
// };
|
||||
stroke->on_brush_changed = [this](Node* target, int brush_id, uint16_t brush_tex) {
|
||||
Canvas::I->m_current_brush.m_tex_id = brush_tex;
|
||||
Canvas::I->m_current_brush.id = brush_id;
|
||||
stroke->on_brush_changed = [this](Node* target, const std::string& path) {
|
||||
Canvas::I->m_current_brush->load_texture(path);
|
||||
stroke->m_preview->draw_stroke();
|
||||
};
|
||||
stroke->on_stencil_changed = [this](Node*target, uint16_t id) {
|
||||
Canvas::I->m_current_brush.m_tex_stencil_id = id;
|
||||
stroke->on_stencil_changed = [this](Node*target, const std::string& path) {
|
||||
Canvas::I->m_current_brush->load_stencil(path);
|
||||
stroke->m_preview->draw_stroke();
|
||||
};
|
||||
|
||||
@@ -263,7 +251,7 @@ void App::init_sidebar()
|
||||
panels->fix_scroll();
|
||||
button->set_color(panels->get_child_index(color.get()) == -1 ? color_button_normal : color_button_hlight);
|
||||
// auto pick = layout[main_id]->add_child<NodeColorPicker>();
|
||||
// pick->m_color_cur->m_color = Canvas::I->m_current_brush.m_tip_color;
|
||||
// pick->m_color_cur->m_color = Canvas::I->m_current_brush->m_tip_color;
|
||||
};
|
||||
}
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-layer"))
|
||||
@@ -395,7 +383,7 @@ void App::init_toolbar_draw()
|
||||
if (auto* button = layout[main_id]->find<NodeButtonCustom>("btn-bucket"))
|
||||
{
|
||||
button->on_click = [this](Node*) {
|
||||
canvas->m_canvas->clear(Canvas::I->m_current_brush.m_tip_color);
|
||||
canvas->m_canvas->clear(Canvas::I->m_current_brush->m_tip_color);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -689,7 +677,7 @@ void App::init_menu_about()
|
||||
|
||||
void App::brush_update()
|
||||
{
|
||||
// brushes->select_brush(canvas->m_brush.id);
|
||||
// brushes->select_brush(canvas->m_brush->id);
|
||||
// stroke->set_params(canvas->m_brush);
|
||||
}
|
||||
|
||||
@@ -826,17 +814,6 @@ void App::initLayout()
|
||||
version_label->set_text(g_version);
|
||||
}
|
||||
|
||||
Brush b;
|
||||
int br_idx = stroke->m_brush_popup->find_brush("Round-Hard");
|
||||
b.m_tex_id = stroke->m_brush_popup->get_texture_id(br_idx);
|
||||
b.id = stroke->m_brush_popup->get_brush_id(br_idx);
|
||||
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;
|
||||
stroke->m_brush_thumb->set_image(stroke->m_brush_popup->get_thumb_path(br_idx));
|
||||
|
||||
brush_update();
|
||||
|
||||
TextureManager::load("data/paper.jpg");
|
||||
|
||||
Reference in New Issue
Block a user