diff --git a/data/layout.xml b/data/layout.xml index 82c3d06..d0b8a5c 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -87,8 +87,9 @@ - + + diff --git a/src/node_panel_brush.cpp b/src/node_panel_brush.cpp index 72c9792..0fc8ffb 100644 --- a/src/node_panel_brush.cpp +++ b/src/node_panel_brush.cpp @@ -343,6 +343,7 @@ void NodeBrushPresetItem::init() color_normal = glm::vec4(.3, .3, .3, 1); m_color = color_normal; m_thumb = find("thumb"); + m_caption_size = find("caption-size"); m_preview = find("canvas"); m_preview->m_min_flow = 1.f; } @@ -367,20 +368,7 @@ void NodePanelBrushPreset::init() m_container = find("brushes"); m_btn_add = find("btn-add"); m_btn_add->on_click = [this] (Node*) { - NodeBrushPresetItem* brush = new NodeBrushPresetItem; - m_container->add_child(brush); - brush->init(); - brush->create(); - brush->loaded(); - brush->thumb_path = Canvas::I->m_current_brush->m_brush_thumb_path; - brush->high_path = Canvas::I->m_current_brush->m_brush_path; - brush->m_brush = std::make_shared(*Canvas::I->m_current_brush); - //brush->m_brush->m_tip_size = .05f; - brush->m_preview->m_brush = brush->m_brush; - brush->m_preview->draw_stroke(); - brush->m_thumb->m_use_mipmaps = true; - brush->m_thumb->set_image(brush->m_brush->m_brush_thumb_path); - brush->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1); + add_brush(std::make_shared(*Canvas::I->m_current_brush)); save(); }; m_btn_up = find("btn-up"); @@ -691,6 +679,7 @@ bool NodePanelBrushPreset::restore() brush->m_brush = b; brush->m_preview->m_brush = b; brush->m_preview->draw_stroke(); + brush->m_caption_size->set_text_format("%d", (int)b->m_tip_size); brush->m_thumb->set_image(brush->m_brush->m_brush_thumb_path); brush->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1); } @@ -716,5 +705,6 @@ void NodePanelBrushPreset::add_brush(std::shared_ptr brush) b->m_preview->draw_stroke(); b->m_thumb->m_use_mipmaps = true; b->m_thumb->set_image(brush->m_brush_thumb_path); + b->m_caption_size->set_text_format("%d", (int)brush->m_tip_size); b->on_click = std::bind(&NodePanelBrushPreset::handle_click, this, std::placeholders::_1); } diff --git a/src/node_panel_brush.h b/src/node_panel_brush.h index b3feb07..9d92bbe 100644 --- a/src/node_panel_brush.h +++ b/src/node_panel_brush.h @@ -5,6 +5,7 @@ #include "node_stroke_preview.h" #include "brush.h" #include "node_scroll.h" +#include "node_text.h" class NodeButtonBrush : public NodeButtonCustom { @@ -72,6 +73,7 @@ public: bool m_selected = false; NodeStrokePreview* m_preview; NodeImage* m_thumb; + NodeText* m_caption_size; virtual Node* clone_instantiate() const override; virtual void init() override; virtual void draw() override;