You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Code simplifications
CanvasItemEditor: - p_result == ADD_MOVE is always true in this switch-clause - both parts of the if-else-clause do the same thing and simplified an affine_inverse call ControlEditorToolbar: - private function ControlEditorToolbar::_anchor_to_position is used nowhere. Looks like copy and paste from CanvasItemEditor::_anchor_to_position ScrollContainer: - screen_is_touchscreen is always true, because otherwise the function already returned TextLine: - both parts of the if-else-clause do the same thing and simplified return statement
This commit is contained in:
@@ -928,9 +928,7 @@ void CanvasItemEditor::_add_node_pressed(int p_result) {
|
|||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
case ADD_MOVE: {
|
case ADD_MOVE: {
|
||||||
if (p_result == ADD_MOVE) {
|
|
||||||
nodes_to_move = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
nodes_to_move = EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list();
|
||||||
}
|
|
||||||
if (nodes_to_move.is_empty()) {
|
if (nodes_to_move.is_empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1731,22 +1729,16 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
|
|||||||
|
|
||||||
drag_to = transform.affine_inverse().xform(m->get_position());
|
drag_to = transform.affine_inverse().xform(m->get_position());
|
||||||
|
|
||||||
Transform2D xform = ci->get_global_transform_with_canvas().affine_inverse();
|
Transform2D xform = ci->get_global_transform_with_canvas();
|
||||||
|
|
||||||
Point2 drag_to_snapped_begin;
|
Point2 drag_to_snapped_begin;
|
||||||
Point2 drag_to_snapped_end;
|
Point2 drag_to_snapped_end;
|
||||||
|
|
||||||
// last call decides which snapping lines are drawn
|
drag_to_snapped_end = snap_point(xform.xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
||||||
if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP || drag_type == DRAG_TOP_LEFT) {
|
drag_to_snapped_begin = snap_point(xform.xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
||||||
drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
|
||||||
drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
|
||||||
} else {
|
|
||||||
drag_to_snapped_begin = snap_point(xform.affine_inverse().xform(current_begin) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
|
||||||
drag_to_snapped_end = snap_point(xform.affine_inverse().xform(current_end) + (drag_to - drag_from), SNAP_NODE_ANCHORS | SNAP_NODE_PARENT | SNAP_OTHER_NODES | SNAP_GRID | SNAP_PIXEL, 0, ci);
|
|
||||||
}
|
|
||||||
|
|
||||||
Point2 drag_begin = xform.xform(drag_to_snapped_begin);
|
Point2 drag_begin = xform.affine_inverse().xform(drag_to_snapped_begin);
|
||||||
Point2 drag_end = xform.xform(drag_to_snapped_end);
|
Point2 drag_end = xform.affine_inverse().xform(drag_to_snapped_end);
|
||||||
|
|
||||||
// Horizontal resize
|
// Horizontal resize
|
||||||
if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP_LEFT || drag_type == DRAG_BOTTOM_LEFT) {
|
if (drag_type == DRAG_LEFT || drag_type == DRAG_TOP_LEFT || drag_type == DRAG_BOTTOM_LEFT) {
|
||||||
|
|||||||
@@ -810,19 +810,6 @@ void ControlEditorToolbar::_container_flags_selected(int p_flags, bool p_vertica
|
|||||||
undo_redo->commit_action();
|
undo_redo->commit_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 ControlEditorToolbar::_anchor_to_position(const Control *p_control, Vector2 anchor) {
|
|
||||||
ERR_FAIL_COND_V(!p_control, Vector2());
|
|
||||||
|
|
||||||
Transform2D parent_transform = p_control->get_transform().affine_inverse();
|
|
||||||
Rect2 parent_rect = p_control->get_parent_anchorable_rect();
|
|
||||||
|
|
||||||
if (p_control->is_layout_rtl()) {
|
|
||||||
return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x - parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
|
|
||||||
} else {
|
|
||||||
return parent_transform.xform(parent_rect.position + Vector2(parent_rect.size.x * anchor.x, parent_rect.size.y * anchor.y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 ControlEditorToolbar::_position_to_anchor(const Control *p_control, Vector2 position) {
|
Vector2 ControlEditorToolbar::_position_to_anchor(const Control *p_control, Vector2 position) {
|
||||||
ERR_FAIL_COND_V(!p_control, Vector2());
|
ERR_FAIL_COND_V(!p_control, Vector2());
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ class ControlEditorToolbar : public HBoxContainer {
|
|||||||
void _anchor_mode_toggled(bool p_status);
|
void _anchor_mode_toggled(bool p_status);
|
||||||
void _container_flags_selected(int p_flags, bool p_vertical);
|
void _container_flags_selected(int p_flags, bool p_vertical);
|
||||||
|
|
||||||
Vector2 _anchor_to_position(const Control *p_control, Vector2 anchor);
|
|
||||||
Vector2 _position_to_anchor(const Control *p_control, Vector2 position);
|
Vector2 _position_to_anchor(const Control *p_control, Vector2 position);
|
||||||
bool _is_node_locked(const Node *p_node);
|
bool _is_node_locked(const Node *p_node);
|
||||||
List<Control *> _get_edited_controls();
|
List<Control *> _get_edited_controls();
|
||||||
|
|||||||
@@ -182,14 +182,12 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||||||
drag_accum = Vector2();
|
drag_accum = Vector2();
|
||||||
last_drag_accum = Vector2();
|
last_drag_accum = Vector2();
|
||||||
drag_from = Vector2(prev_h_scroll, prev_v_scroll);
|
drag_from = Vector2(prev_h_scroll, prev_v_scroll);
|
||||||
drag_touching = screen_is_touchscreen;
|
drag_touching = true;
|
||||||
drag_touching_deaccel = false;
|
drag_touching_deaccel = false;
|
||||||
beyond_deadzone = false;
|
beyond_deadzone = false;
|
||||||
time_since_motion = 0;
|
time_since_motion = 0;
|
||||||
if (drag_touching) {
|
|
||||||
set_physics_process_internal(true);
|
set_physics_process_internal(true);
|
||||||
time_since_motion = 0;
|
time_since_motion = 0;
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (drag_touching) {
|
if (drag_touching) {
|
||||||
|
|||||||
@@ -317,11 +317,7 @@ float TextLine::get_width() const {
|
|||||||
|
|
||||||
Size2 TextLine::get_size() const {
|
Size2 TextLine::get_size() const {
|
||||||
const_cast<TextLine *>(this)->_shape();
|
const_cast<TextLine *>(this)->_shape();
|
||||||
if (TS->shaped_text_get_orientation(rid) == TextServer::ORIENTATION_HORIZONTAL) {
|
return TS->shaped_text_get_size(rid);
|
||||||
return Size2(TS->shaped_text_get_size(rid).x, TS->shaped_text_get_size(rid).y);
|
|
||||||
} else {
|
|
||||||
return Size2(TS->shaped_text_get_size(rid).x, TS->shaped_text_get_size(rid).y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float TextLine::get_line_ascent() const {
|
float TextLine::get_line_ascent() const {
|
||||||
|
|||||||
Reference in New Issue
Block a user