implement brush presets save and restore from file, fix stencil nullptr, limit preview stroke max size

This commit is contained in:
2019-01-23 16:53:58 +01:00
parent e26fcf1163
commit 879be9d4fe
17 changed files with 282 additions and 65 deletions

View File

@@ -46,11 +46,9 @@ public:
class NodeBrushPresetItem : public NodeButtonCustom
{
public:
int m_brushID;
std::shared_ptr<Brush> m_brush;
std::string high_path;
std::string thumb_path;
uint16_t high_id;
bool m_selected = false;
NodeStrokePreview* m_preview;
NodeImage* m_thumb;
@@ -62,16 +60,57 @@ public:
class NodePanelBrushPreset : public Node
{
std::vector<NodeBrushPresetItem*> m_brushes;
NodeButtonBrush* m_current = nullptr;
NodeBrushPresetItem* m_current = nullptr;
Node* m_container;
NodeButtonCustom* m_btn_add;
NodeButtonCustom* m_btn_save;
struct header_t {
char magic[4]{ 'P', 'P', 'P', 'R' };
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;
glm::vec4 m_tip_color{ 0, 0, 0, 1 };
float m_tip_size = 0;
float m_tip_spacing = 0;
float m_tip_flow = 0;
float m_tip_opacity = 0;
float m_tip_angle = 0;
float m_tip_mix = 0;
float m_tip_stencil = 0;
float m_tip_wet = 0;
float m_tip_noise = 0;
float m_tip_hue = 0;
float m_tip_sat = 0;
float m_tip_val = 0;
bool m_tip_angle_follow = false;
bool m_tip_flow_pressure = false;
bool m_tip_size_pressure = false;
bool m_tip_hue_pressure = false;
bool m_tip_sat_pressure = false;
bool m_tip_val_pressure = false;
float m_jitter_scale = 0;
float m_jitter_angle = 0;
float m_jitter_spread = 0;
float m_jitter_flow = 0;
float m_jitter_hue = 0;
float m_jitter_sat = 0;
float m_jitter_val = 0;
int m_blend_mode = 0;
};
public:
std::function<void(Node* target, int id)> on_brush_changed;
std::function<void(Node* target, std::shared_ptr<Brush>& brush)> on_brush_changed;
virtual Node* clone_instantiate() const override;
virtual void init() override;
void handle_click(Node* target);
uint16_t get_texture_id(int index) const;
std::string get_texture_path(int index) const;
std::shared_ptr<Brush> get_brush(int index) const;
int get_brush_id(int index) const;
bool save();
bool restore();
};