implemented brush settings switch between pen/erase
This commit is contained in:
@@ -106,4 +106,5 @@ public:
|
||||
void dialog_open();
|
||||
void dialog_export();
|
||||
void dialog_layer_rename();
|
||||
void brush_update();
|
||||
};
|
||||
|
||||
@@ -373,6 +373,12 @@ void App::init_menu_edit()
|
||||
}
|
||||
}
|
||||
|
||||
void App::brush_update()
|
||||
{
|
||||
brushes->set_texture_id(canvas->m_brush.m_tex_id);
|
||||
stroke->set_params(canvas->m_brush);
|
||||
}
|
||||
|
||||
void App::init_menu_layer()
|
||||
{
|
||||
if (auto* menu_file = layout[main_id]->find<NodeButtonCustom>("menu-layers"))
|
||||
|
||||
@@ -139,8 +139,16 @@ void CanvasModePen::leave()
|
||||
|
||||
void CanvasModePen::enter()
|
||||
{
|
||||
if (node)
|
||||
if (m_valid_brush)
|
||||
{
|
||||
node->m_brush = m_brush;
|
||||
App::I.brush_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_brush = node->m_brush;
|
||||
m_valid_brush = true;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -41,6 +41,7 @@ class CanvasModePen : public CanvasMode
|
||||
float m_camera_fov;
|
||||
float m_zoom_canvas = 1.f;
|
||||
float m_zoom_start;
|
||||
bool m_valid_brush = false;
|
||||
ui::Brush m_brush;
|
||||
public:
|
||||
virtual void on_MouseEvent(MouseEvent* me, glm::vec2& loc) override;
|
||||
|
||||
@@ -81,3 +81,18 @@ uint16_t NodePanelBrush::get_texture_id(int index) const
|
||||
{
|
||||
return m_brushes[index]->img->m_tex_id;
|
||||
}
|
||||
|
||||
// select the current brush based on the texture id
|
||||
void NodePanelBrush::set_texture_id(int texid)
|
||||
{
|
||||
if (m_current)
|
||||
m_current->m_selected = false;
|
||||
for (auto b : m_brushes)
|
||||
{
|
||||
if (b->img->m_tex_id == texid)
|
||||
{
|
||||
b->m_selected = true;
|
||||
m_current = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,5 @@ public:
|
||||
void handle_click(Node* target);
|
||||
std::vector<std::string> FindAllBrushes(const std::string& folder);
|
||||
uint16_t get_texture_id(int index) const;
|
||||
void set_texture_id(int texid);
|
||||
};
|
||||
|
||||
@@ -21,18 +21,20 @@ void NodePanelStroke::init()
|
||||
|
||||
void NodePanelStroke::set_params(const ui::Brush &b)
|
||||
{
|
||||
m_tip_size->set_value(b.m_tip_size);
|
||||
m_tip_spacing->set_value(b.m_tip_spacing);
|
||||
m_tip_flow->set_value(b.m_tip_flow);
|
||||
m_tip_opacity->set_value(b.m_tip_opacity);
|
||||
m_tip_angle->set_value(b.m_tip_angle);
|
||||
m_jitter_scale->set_value(b.m_jitter_scale);
|
||||
m_jitter_angle->set_value(b.m_jitter_angle);
|
||||
m_jitter_spread->set_value(b.m_jitter_spread);
|
||||
m_jitter_flow->set_value(b.m_jitter_flow);
|
||||
m_tip_size->m_value.x = b.m_tip_size;
|
||||
m_tip_spacing->m_value.x = b.m_tip_spacing;
|
||||
m_tip_flow->m_value.x = b.m_tip_flow;
|
||||
m_tip_opacity->m_value.x = b.m_tip_opacity;
|
||||
m_tip_angle->m_value.x = b.m_tip_angle;
|
||||
m_jitter_scale->m_value.x = b.m_jitter_scale;
|
||||
m_jitter_angle->m_value.x = b.m_jitter_angle;
|
||||
m_jitter_spread->m_value.x = b.m_jitter_spread;
|
||||
m_jitter_flow->m_value.x = b.m_jitter_flow;
|
||||
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_canvas->m_brush = b;
|
||||
m_canvas->draw_stroke();
|
||||
}
|
||||
|
||||
void NodePanelStroke::init_controls()
|
||||
|
||||
Reference in New Issue
Block a user