save brushes settings

This commit is contained in:
2019-02-03 14:36:48 +01:00
parent d8728344c4
commit c2d526dec9
7 changed files with 207 additions and 68 deletions

View File

@@ -9,12 +9,13 @@
class NodeButtonBrush : public NodeButtonCustom
{
public:
//int m_brushID;
bool m_selected = false;
// whether the brush is a system default
// or user imported so it can be deleted from file
bool m_user_brush = false;
std::string brush_name;
std::string high_path;
std::string thumb_path;
//uint16_t high_id;
NodeImage* img;
virtual Node* clone_instantiate() const override;
virtual void init() override;
@@ -24,13 +25,26 @@ public:
class NodePanelBrush : public Node
{
//std::vector<NodeButtonBrush*> m_brushes;
// brushes that are marked as deleted but file still exists
std::vector<std::string> m_deleted;
NodeButtonBrush* m_current = nullptr;
NodeScroll* m_container;
NodeButtonCustom* m_btn_add;
NodeButtonCustom* m_btn_up;
NodeButtonCustom* m_btn_down;
NodeButtonCustom* m_btn_remove;
struct header_t {
char magic[5]{ 'P', 'P', 'B', 'R', 0 };
uint16_t version = 0;
uint16_t brushes = 0;
uint16_t deleted = 0;
};
struct item_t {
int m_name_len = 0;
int m_high_len = 0;
int m_thumb_len = 0;
bool m_deleted = false;
};
public:
std::function<void(Node* target, int index)> on_brush_changed;
std::function<void(Node* target)> on_popup_close;
@@ -41,7 +55,8 @@ public:
int find_brush(const std::string& name) const;
std::string get_texture_path(int index) const;
std::string get_thumb_path(int index) const;
//void select_brush(int brush_id);
bool save();
bool restore();
};
// -----------------------------------------------------------------------
@@ -58,12 +73,10 @@ public:
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual void draw() override;
virtual ~NodeBrushPresetItem();
};
class NodePanelBrushPreset : public Node
{
//std::vector<NodeBrushPresetItem*> m_brushes;
NodeBrushPresetItem* m_current = nullptr;
Node* m_container;
NodeButtonCustom* m_btn_add;
@@ -72,17 +85,15 @@ class NodePanelBrushPreset : public Node
NodeButtonCustom* m_btn_delete;
NodeButtonCustom* m_btn_save;
struct header_t {
char magic[4]{ 'P', 'P', 'P', 'R' };
char magic[5]{ 'P', 'P', 'P', 'R', 0 };
uint16_t version = 0;
uint16_t count = 0;
};
struct item_t {
int m_name_len;
int m_brush_path_len;
int m_brush_thumb_path_len;
int m_stencil_path_len;
//std::shared_ptr<Texture2D> m_tip_texture;
//std::shared_ptr<Texture2D> m_stencil_texture;
int m_name_len = 0;
int m_brush_path_len = 0;
int m_brush_thumb_path_len = 0;
int m_stencil_path_len = 0;
glm::vec4 m_tip_color{ 0, 0, 0, 1 };
float m_tip_size = 0;
float m_tip_spacing = 0;
@@ -118,7 +129,6 @@ public:
virtual void init() override;
virtual kEventResult handle_event(Event* e) override;
void handle_click(Node* target);
std::shared_ptr<Brush> get_brush(int index) const;
bool save();
bool restore();
};