mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 14:45:57 +01:00
Added brush prefabs to PaintToolsPropertyInspector.
This commit is contained in:
parent
884fae4847
commit
8c8dc051cb
@ -33,10 +33,10 @@ SOFTWARE.
|
||||
class BrushPrefabs {
|
||||
public:
|
||||
enum Type {
|
||||
V_LINE = 0,
|
||||
H_LINE,
|
||||
RECT,
|
||||
RECT = 0,
|
||||
CIRCLE,
|
||||
H_LINE,
|
||||
V_LINE,
|
||||
};
|
||||
|
||||
static PoolVector2iArray get_brush(const Type type, int size);
|
||||
|
@ -25,8 +25,12 @@ SOFTWARE.
|
||||
#include "scene/gui/box_container.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/flow_container.h"
|
||||
#include "scene/gui/texture_button.h"
|
||||
|
||||
#include "scene/resources/style_box.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "../../paint_icons/icons.h"
|
||||
#include "../../bush_prefabs.h"
|
||||
|
||||
#include "../../nodes/paint_canvas.h"
|
||||
#include "../../nodes/paint_node.h"
|
||||
@ -61,6 +65,15 @@ void PaintToolsPropertyInspector::add_button(int id, const String &hint, const S
|
||||
_grid->add_child(button);
|
||||
}
|
||||
|
||||
void PaintToolsPropertyInspector::add_brush_prefab(int id, const Ref<Texture> &normal_texture, const Ref<Texture> &hover_texture) {
|
||||
TextureButton *brush_button = memnew(TextureButton);
|
||||
brush_button->set_normal_texture(normal_texture);
|
||||
brush_button->set_hover_texture(hover_texture);
|
||||
brush_button->set_custom_minimum_size(Size2(25, 25));
|
||||
brush_button->connect("pressed", this, "_on_brush_prefab_button_pressed", varray(id));
|
||||
_brush_prefabs->add_child(brush_button);
|
||||
}
|
||||
|
||||
void PaintToolsPropertyInspector::_on_paint_node_selected(Node *p_paint_node) {
|
||||
PaintCanvas *paint_canvas = Object::cast_to<PaintCanvas>(p_paint_node);
|
||||
|
||||
@ -99,6 +112,14 @@ PaintToolsPropertyInspector::PaintToolsPropertyInspector() {
|
||||
add_button(PaintCanvas::TOOL_COLORPICKER, "Colorpicker", "ColorPick", "EditorIcons");
|
||||
add_button(PaintCanvas::TOOL_CUT, "Cut", "ActionCut", "EditorIcons");
|
||||
add_button(PaintCanvas::TOOL_PASTECUT, "Pastecut", "ActionCopy", "EditorIcons");
|
||||
|
||||
_brush_prefabs = memnew(HFlowContainer);
|
||||
box_container->add_child(_brush_prefabs);
|
||||
|
||||
add_brush_prefab(BrushPrefabs::RECT, PaintIcons::make_icon_brush_rect_png(), PaintIcons::make_icon_brush_rect_hovered_png());
|
||||
add_brush_prefab(BrushPrefabs::CIRCLE, PaintIcons::make_icon_brush_circle_png(), PaintIcons::make_icon_brush_circle_hovered_png());
|
||||
add_brush_prefab(BrushPrefabs::V_LINE, PaintIcons::make_icon_brush_v_line_png(), PaintIcons::make_icon_brush_v_line_hovered_png());
|
||||
add_brush_prefab(BrushPrefabs::H_LINE, PaintIcons::make_icon_brush_h_line_png(), PaintIcons::make_icon_brush_h_line_hovered_png());
|
||||
}
|
||||
|
||||
PaintToolsPropertyInspector::~PaintToolsPropertyInspector() {
|
||||
@ -139,7 +160,16 @@ void PaintToolsPropertyInspector::_on_tool_changed() {
|
||||
}
|
||||
}
|
||||
|
||||
void PaintToolsPropertyInspector::_on_brush_prefab_button_pressed(const int id) {
|
||||
PaintCanvas *paint_canvas = Object::cast_to<PaintCanvas>(ObjectDB::get_instance(_paint_canvas));
|
||||
|
||||
ERR_FAIL_COND(!paint_canvas);
|
||||
|
||||
paint_canvas->set_brush_prefab(id);
|
||||
}
|
||||
|
||||
void PaintToolsPropertyInspector::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("on_button_toggled"), &PaintToolsPropertyInspector::on_button_toggled);
|
||||
ClassDB::bind_method(D_METHOD("_on_tool_changed"), &PaintToolsPropertyInspector::_on_tool_changed);
|
||||
ClassDB::bind_method(D_METHOD("_on_brush_prefab_button_pressed"), &PaintToolsPropertyInspector::_on_brush_prefab_button_pressed);
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "paint_custom_property_inspector.h"
|
||||
#include "core/object/object_id.h"
|
||||
#include "core/object/reference.h"
|
||||
#include "paint_custom_property_inspector.h"
|
||||
|
||||
class HFlowContainer;
|
||||
class PaintNode;
|
||||
@ -38,6 +38,7 @@ class PaintToolsPropertyInspector : public PaintCustomPropertyInspector {
|
||||
|
||||
public:
|
||||
void add_button(int id, const String &hint, const String &icon, const String &theme_type);
|
||||
void add_brush_prefab(int id, const Ref<Texture> &normal_texture, const Ref<Texture> &hover_texture);
|
||||
|
||||
void _on_paint_node_selected(Node *paint_node);
|
||||
|
||||
@ -47,10 +48,12 @@ public:
|
||||
protected:
|
||||
void on_button_toggled(bool on, int id);
|
||||
void _on_tool_changed();
|
||||
void _on_brush_prefab_button_pressed(const int id);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
HFlowContainer *_grid;
|
||||
HFlowContainer *_brush_prefabs;
|
||||
|
||||
ObjectID _paint_canvas;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user