Files
panopainter/src/node_panel_brush.h

121 lines
3.6 KiB
C++

#pragma once
#include "node.h"
#include "node_button_custom.h"
#include "node_image.h"
#include "node_stroke_preview.h"
#include "brush.h"
class NodeButtonBrush : public NodeButtonCustom
{
public:
int m_brushID;
bool m_selected = 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;
void set_icon(const char* path);
virtual void draw() override;
};
class NodePanelBrush : public Node
{
std::vector<NodeButtonBrush*> m_brushes;
NodeButtonBrush* m_current = nullptr;
Node* m_container;
public:
std::function<void(Node* target, int id)> on_brush_changed;
std::function<void(Node* target)> on_popup_close;
virtual Node* clone_instantiate() const override;
virtual void init() override;
virtual kEventResult handle_event(Event* e) override;
void handle_click(Node* target);
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);
};
// -----------------------------------------------------------------------
class NodeBrushPresetItem : public NodeButtonCustom
{
public:
std::shared_ptr<Brush> m_brush;
std::string high_path;
std::string thumb_path;
bool m_selected = false;
NodeStrokePreview* m_preview;
NodeImage* m_thumb;
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;
NodeButtonCustom* m_btn_up;
NodeButtonCustom* m_btn_down;
NodeButtonCustom* m_btn_delete;
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, std::shared_ptr<Brush>& brush)> on_brush_changed;
std::function<void(Node* target)> on_popup_close;
virtual Node* clone_instantiate() const override;
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();
};