2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
/* polygon_2d_editor_plugin.h */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2018-01-01 13:40:08 +00:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-06-18 12:46:12 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-07-07 20:44:21 +00:00
|
|
|
#ifndef POLYGON_2D_EDITOR_PLUGIN_H
|
|
|
|
#define POLYGON_2D_EDITOR_PLUGIN_H
|
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
#include "editor/plugins/abstract_polygon_2d_editor.h"
|
2014-07-07 20:44:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
*/
|
2017-09-06 16:41:14 +00:00
|
|
|
class Polygon2DEditor : public AbstractPolygon2DEditor {
|
2014-07-07 20:44:21 +00:00
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
GDCLASS(Polygon2DEditor, AbstractPolygon2DEditor);
|
2014-07-07 20:44:21 +00:00
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
MODE_EDIT_UV = MODE_CONT,
|
2014-07-07 20:44:21 +00:00
|
|
|
UVEDIT_POLYGON_TO_UV,
|
|
|
|
UVEDIT_UV_TO_POLYGON,
|
|
|
|
UVEDIT_UV_CLEAR
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum UVMode {
|
2018-02-22 20:38:33 +00:00
|
|
|
UV_MODE_CREATE,
|
2014-07-07 20:44:21 +00:00
|
|
|
UV_MODE_EDIT_POINT,
|
|
|
|
UV_MODE_MOVE,
|
|
|
|
UV_MODE_ROTATE,
|
|
|
|
UV_MODE_SCALE,
|
2018-02-25 15:06:30 +00:00
|
|
|
UV_MODE_ADD_SPLIT,
|
|
|
|
UV_MODE_REMOVE_SPLIT,
|
2014-07-07 20:44:21 +00:00
|
|
|
UV_MODE_MAX
|
|
|
|
};
|
|
|
|
|
2018-02-25 15:06:30 +00:00
|
|
|
ToolButton *uv_edit_mode[3];
|
2018-02-22 20:38:33 +00:00
|
|
|
Ref<ButtonGroup> uv_edit_group;
|
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
Polygon2D *node;
|
2014-07-07 20:44:21 +00:00
|
|
|
|
|
|
|
UVMode uv_mode;
|
|
|
|
AcceptDialog *uv_edit;
|
2018-02-25 15:06:30 +00:00
|
|
|
ToolButton *uv_button[UV_MODE_MAX];
|
2015-09-28 03:06:06 +00:00
|
|
|
ToolButton *b_snap_enable;
|
|
|
|
ToolButton *b_snap_grid;
|
2014-07-07 20:44:21 +00:00
|
|
|
Control *uv_edit_draw;
|
|
|
|
HSlider *uv_zoom;
|
|
|
|
SpinBox *uv_zoom_value;
|
|
|
|
HScrollBar *uv_hscroll;
|
|
|
|
VScrollBar *uv_vscroll;
|
|
|
|
MenuButton *uv_menu;
|
2017-01-12 21:27:27 +00:00
|
|
|
TextureRect *uv_icon_zoom;
|
2014-07-07 20:44:21 +00:00
|
|
|
|
|
|
|
Vector2 uv_draw_ofs;
|
|
|
|
float uv_draw_zoom;
|
2017-01-07 21:25:37 +00:00
|
|
|
PoolVector<Vector2> uv_prev;
|
2018-02-22 20:38:33 +00:00
|
|
|
PoolVector<Vector2> uv_create_uv_prev;
|
|
|
|
PoolVector<Vector2> uv_create_poly_prev;
|
2018-02-25 15:06:30 +00:00
|
|
|
PoolVector<int> splits_prev;
|
|
|
|
|
2018-02-22 20:38:33 +00:00
|
|
|
Vector2 uv_create_to;
|
2014-07-07 20:44:21 +00:00
|
|
|
int uv_drag_index;
|
|
|
|
bool uv_drag;
|
2018-02-22 20:38:33 +00:00
|
|
|
bool uv_create;
|
2018-02-25 15:06:30 +00:00
|
|
|
bool split_create;
|
2014-07-07 20:44:21 +00:00
|
|
|
UVMode uv_move_current;
|
|
|
|
Vector2 uv_drag_from;
|
|
|
|
bool updating_uv_scroll;
|
|
|
|
|
|
|
|
AcceptDialog *error;
|
|
|
|
|
|
|
|
ToolButton *button_uv;
|
|
|
|
|
2015-09-28 03:06:06 +00:00
|
|
|
bool use_snap;
|
|
|
|
bool snap_show_grid;
|
|
|
|
Vector2 snap_offset;
|
|
|
|
Vector2 snap_step;
|
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
virtual void _menu_option(int p_option);
|
|
|
|
|
2014-07-07 20:44:21 +00:00
|
|
|
void _uv_scroll_changed(float);
|
2017-05-20 15:38:03 +00:00
|
|
|
void _uv_input(const Ref<InputEvent> &p_input);
|
2014-07-07 20:44:21 +00:00
|
|
|
void _uv_draw();
|
|
|
|
void _uv_mode(int p_mode);
|
|
|
|
|
2015-09-28 03:06:06 +00:00
|
|
|
void _set_use_snap(bool p_use);
|
|
|
|
void _set_show_grid(bool p_show);
|
|
|
|
void _set_snap_off_x(float p_val);
|
|
|
|
void _set_snap_off_y(float p_val);
|
|
|
|
void _set_snap_step_x(float p_val);
|
|
|
|
void _set_snap_step_y(float p_val);
|
|
|
|
|
2018-02-22 20:38:33 +00:00
|
|
|
void _uv_edit_mode_select(int p_mode);
|
|
|
|
|
2014-07-07 20:44:21 +00:00
|
|
|
protected:
|
2017-09-06 16:41:14 +00:00
|
|
|
virtual Node2D *_get_node() const;
|
|
|
|
virtual void _set_node(Node *p_polygon);
|
|
|
|
|
|
|
|
virtual Vector2 _get_offset(int p_idx) const;
|
|
|
|
|
2014-07-07 20:44:21 +00:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2015-09-28 03:06:06 +00:00
|
|
|
|
|
|
|
Vector2 snap_point(Vector2 p_target) const;
|
|
|
|
|
2014-07-07 20:44:21 +00:00
|
|
|
public:
|
|
|
|
Polygon2DEditor(EditorNode *p_editor);
|
|
|
|
};
|
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
class Polygon2DEditorPlugin : public AbstractPolygon2DEditorPlugin {
|
2014-07-07 20:44:21 +00:00
|
|
|
|
2017-09-06 16:41:14 +00:00
|
|
|
GDCLASS(Polygon2DEditorPlugin, AbstractPolygon2DEditorPlugin);
|
2014-07-07 20:44:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Polygon2DEditorPlugin(EditorNode *p_node);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // POLYGON_2D_EDITOR_PLUGIN_H
|