Skip to content

Commit

Permalink
Merge pull request #57863 from Calinou/editor-use-anchors-metadata-no…
Browse files Browse the repository at this point in the history
…-redundant
  • Loading branch information
akien-mga authored Feb 15, 2022
2 parents 6d708df + 7ca843b commit 1d910b1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions editor/plugins/control_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,13 @@ void ControlEditorToolbar::_set_anchors_and_offsets_to_keep_ratio() {
undo_redo->add_do_method(control, "set_anchor", SIDE_BOTTOM, bottom_right_anchor.y, false, true);
undo_redo->add_do_method(control, "set_meta", "_edit_use_anchors_", true);

bool use_anchors = control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_");
const bool use_anchors = control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_");
undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state());
undo_redo->add_undo_method(control, "set_meta", "_edit_use_anchors_", use_anchors);
if (use_anchors) {
undo_redo->add_undo_method(control, "set_meta", "_edit_use_anchors_", true);
} else {
undo_redo->add_undo_method(control, "remove_meta", "_edit_use_anchors_");
}

anchors_mode = true;
anchor_mode_button->set_pressed(anchors_mode);
Expand Down Expand Up @@ -596,7 +600,11 @@ void ControlEditorToolbar::_button_toggle_anchor_mode(bool p_status) {
continue;
}

E->set_meta("_edit_use_anchors_", p_status);
if (p_status) {
E->set_meta("_edit_use_anchors_", true);
} else {
E->remove_meta("_edit_use_anchors_");
}
}

anchors_mode = p_status;
Expand Down

0 comments on commit 1d910b1

Please sign in to comment.