Improvements to Gradient2D Editor
This commit is contained in:
parent
64eeb04d2c
commit
39b79bbd1e
2 changed files with 185 additions and 124 deletions
|
|
@ -37,39 +37,48 @@
|
|||
class Button;
|
||||
class EditorSpinSlider;
|
||||
|
||||
class GradientTexture2DEditorRect : public Control {
|
||||
GDCLASS(GradientTexture2DEditorRect, Control);
|
||||
class GradientTexture2DEdit : public Control {
|
||||
GDCLASS(GradientTexture2DEdit, Control);
|
||||
|
||||
enum Handle {
|
||||
HANDLE_NONE,
|
||||
HANDLE_FILL_FROM,
|
||||
HANDLE_FILL_TO
|
||||
HANDLE_FROM,
|
||||
HANDLE_TO
|
||||
};
|
||||
|
||||
Ref<GradientTexture2D> texture;
|
||||
bool snap_enabled = false;
|
||||
float snap_size = 0;
|
||||
int snap_count = 0;
|
||||
|
||||
TextureRect *checkerboard = nullptr;
|
||||
|
||||
Handle handle = HANDLE_NONE;
|
||||
Handle hovered = HANDLE_NONE;
|
||||
Handle grabbed = HANDLE_NONE;
|
||||
Point2 initial_grab_pos;
|
||||
|
||||
Size2 handle_size;
|
||||
Point2 offset;
|
||||
Size2 size;
|
||||
|
||||
Point2 _get_handle_position(const Handle p_handle);
|
||||
void _update_fill_position();
|
||||
Point2 _get_handle_pos(const Handle p_handle);
|
||||
Handle get_handle_at(const Vector2 &p_pos);
|
||||
void set_fill_pos(const Vector2 &p_pos);
|
||||
|
||||
virtual void gui_input(const Ref<InputEvent> &p_event) override;
|
||||
|
||||
void _on_mouse_exited();
|
||||
|
||||
void _draw();
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
void set_texture(Ref<GradientTexture2D> &p_texture);
|
||||
void set_snap_enabled(bool p_snap_enabled);
|
||||
void set_snap_size(float p_snap_size);
|
||||
void set_snap_count(int p_snap_count);
|
||||
|
||||
GradientTexture2DEditorRect();
|
||||
GradientTexture2DEdit();
|
||||
};
|
||||
|
||||
class GradientTexture2DEditor : public VBoxContainer {
|
||||
|
|
@ -79,17 +88,18 @@ class GradientTexture2DEditor : public VBoxContainer {
|
|||
|
||||
Button *reverse_button = nullptr;
|
||||
Button *snap_button = nullptr;
|
||||
EditorSpinSlider *snap_size_edit = nullptr;
|
||||
GradientTexture2DEditorRect *texture_editor_rect = nullptr;
|
||||
EditorSpinSlider *snap_count_edit = nullptr;
|
||||
GradientTexture2DEdit *texture_editor_rect = nullptr;
|
||||
|
||||
void _reverse_button_pressed();
|
||||
void _set_snap_enabled(bool p_enabled);
|
||||
void _set_snap_size(float p_snap_size);
|
||||
void _set_snap_count(int p_snap_count);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
static const int DEFAULT_SNAP;
|
||||
void set_texture(Ref<GradientTexture2D> &p_texture);
|
||||
|
||||
GradientTexture2DEditor();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue