Merge pull request #8219 from robertdhernandez/Node2D-Canvas-Sync

Node2D/Control variables now update with canvas changes
This commit is contained in:
Andreas Haas 2017-04-03 00:33:40 +02:00 committed by GitHub
commit b49d206a4c
2 changed files with 19 additions and 15 deletions

View file

@ -63,9 +63,10 @@ void Node2D::edit_set_state(const Variant &p_state) {
angle = state[1];
_scale = state[2];
_update_transform();
_change_notify("transform/rot");
_change_notify("transform/scale");
_change_notify("transform/pos");
_change_notify("rotation");
_change_notify("rotation_deg");
_change_notify("scale");
_change_notify("position");
}
void Node2D::edit_set_rect(const Rect2 &p_edit_rect) {
@ -95,15 +96,16 @@ void Node2D::edit_set_rect(const Rect2 &p_edit_rect) {
_scale *= new_scale;
_update_transform();
_change_notify("transform/scale");
_change_notify("transform/pos");
_change_notify("scale");
_change_notify("position");
}
void Node2D::edit_rotate(float p_rot) {
angle += p_rot;
_update_transform();
_change_notify("transform/rot");
_change_notify("rotation");
_change_notify("rotation_deg");
}
void Node2D::_update_xform_values() {
@ -134,7 +136,7 @@ void Node2D::set_position(const Point2 &p_pos) {
((Node2D *)this)->_update_xform_values();
pos = p_pos;
_update_transform();
_change_notify("transform/pos");
_change_notify("position");
}
void Node2D::set_rotation(float p_radians) {
@ -143,7 +145,8 @@ void Node2D::set_rotation(float p_radians) {
((Node2D *)this)->_update_xform_values();
angle = p_radians;
_update_transform();
_change_notify("transform/rot");
_change_notify("rotation");
_change_notify("rotation_deg");
}
void Node2D::set_rotation_in_degrees(float p_degrees) {
@ -169,7 +172,7 @@ void Node2D::set_scale(const Size2 &p_scale) {
if (_scale.y == 0)
_scale.y = CMP_EPSILON;
_update_transform();
_change_notify("transform/scale");
_change_notify("scale");
}
Point2 Node2D::get_position() const {
@ -349,6 +352,7 @@ void Node2D::set_z(int p_z) {
ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX);
z = p_z;
VS::get_singleton()->canvas_item_set_z(get_canvas_item(), z);
_change_notify("z");
}
void Node2D::set_z_as_relative(bool p_enabled) {

View file

@ -1347,12 +1347,12 @@ Control::AnchorType Control::get_anchor(Margin p_margin) const {
void Control::_change_notify_margins() {
// this avoids sending the whole object data again on a change
_change_notify("margin/left");
_change_notify("margin/top");
_change_notify("margin/right");
_change_notify("margin/bottom");
_change_notify("rect/pos");
_change_notify("rect/size");
_change_notify("margin_left");
_change_notify("margin_top");
_change_notify("margin_right");
_change_notify("margin_bottom");
_change_notify("rect_pos");
_change_notify("rect_size");
}
void Control::set_margin(Margin p_margin, float p_value) {