Remove the selection rect for nodes that do not require it

This commit is contained in:
Gilles Roudiere
2018-03-08 21:35:41 +01:00
parent 6435894275
commit 72ed1e4244
34 changed files with 427 additions and 248 deletions

View File

@@ -58,47 +58,19 @@ void Node2D::_edit_set_state(const Dictionary &p_state) {
}
void Node2D::_edit_set_position(const Point2 &p_position) {
pos = p_position;
_update_transform();
_change_notify("position");
set_position(p_position);
}
Point2 Node2D::_edit_get_position() const {
return pos;
}
void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
Rect2 r = _edit_get_rect();
Vector2 zero_offset;
if (r.size.x != 0)
zero_offset.x = -r.position.x / r.size.x;
if (r.size.y != 0)
zero_offset.y = -r.position.y / r.size.y;
Size2 new_scale(1, 1);
if (r.size.x != 0)
new_scale.x = p_edit_rect.size.x / r.size.x;
if (r.size.y != 0)
new_scale.y = p_edit_rect.size.y / r.size.y;
Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset; //p_edit_rect.pos - r.pos;
Transform2D postxf;
postxf.set_rotation_and_scale(angle, _scale);
new_pos = postxf.xform(new_pos);
pos += new_pos;
_scale *= new_scale;
_update_transform();
_change_notify("scale");
_change_notify("position");
void Node2D::_edit_set_scale(const Size2 &p_scale) {
set_scale(p_scale);
}
bool Node2D::_edit_use_rect() const {
return true;
Size2 Node2D::_edit_get_scale() const {
return _scale;
}
void Node2D::_edit_set_rotation(float p_rotation) {
@@ -116,6 +88,38 @@ bool Node2D::_edit_use_rotation() const {
return true;
}
void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
ERR_FAIL_COND(!_edit_use_rect());
Rect2 r = _edit_get_rect();
Vector2 zero_offset;
if (r.size.x != 0)
zero_offset.x = -r.position.x / r.size.x;
if (r.size.y != 0)
zero_offset.y = -r.position.y / r.size.y;
Size2 new_scale(1, 1);
if (r.size.x != 0)
new_scale.x = p_edit_rect.size.x / r.size.x;
if (r.size.y != 0)
new_scale.y = p_edit_rect.size.y / r.size.y;
Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset;
Transform2D postxf;
postxf.set_rotation_and_scale(angle, _scale);
new_pos = postxf.xform(new_pos);
pos += new_pos;
_scale *= new_scale;
_update_transform();
_change_notify("scale");
_change_notify("position");
}
void Node2D::_update_xform_values() {
pos = _mat.elements[2];