diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-19 09:49:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 09:49:52 +0100 |
commit | d8cf3aa5abc446a502e08d9244f5b698174e83e7 (patch) | |
tree | decfbe5ea98a154412f4c0d7aaebe3bf04964383 | |
parent | 6536105af26bb3a6a18369b4647ac479816090b7 (diff) | |
parent | 6d14251b0d77356bb2387440aa3c97bc8c58f59f (diff) |
Merge pull request #33700 from nekomatata/sprite-add-label-overlap
Fixed "Add Sprite..." label overlapping with zoom controls
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 27 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 3 |
2 files changed, 18 insertions, 12 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 13b2b7a6d4..fcbd68a60f 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3971,9 +3971,9 @@ void CanvasItemEditor::_update_scrollbars() { updating_scroll = true; // Move the zoom buttons - Point2 zoom_hb_begin = Point2(5, 5); - zoom_hb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2(); - zoom_hb->set_begin(zoom_hb_begin); + Point2 controls_vb_begin = Point2(5, 5); + controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2(); + controls_vb->set_begin(controls_vb_begin); // Move and resize the scrollbars Size2 size = viewport->get_size(); @@ -5308,6 +5308,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE); scene_tree->add_child(p_editor->get_scene_root()); + controls_vb = memnew(VBoxContainer); + controls_vb->set_begin(Point2(5, 5)); + + zoom_hb = memnew(HBoxContainer); + // Bring the zoom percentage closer to the zoom buttons + zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE)); + controls_vb->add_child(zoom_hb); + viewport = memnew(CanvasItemEditorViewport(p_editor, this)); viewport_scrollable->add_child(viewport); viewport->set_mouse_filter(MOUSE_FILTER_PASS); @@ -5351,11 +5359,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { v_scroll->connect("value_changed", this, "_update_scroll"); v_scroll->hide(); - zoom_hb = memnew(HBoxContainer); - viewport->add_child(zoom_hb); - zoom_hb->set_begin(Point2(5, 5)); - // Bring the zoom percentage closer to the zoom buttons - zoom_hb->add_constant_override("separation", Math::round(-8 * EDSCALE)); + viewport->add_child(controls_vb); zoom_minus = memnew(ToolButton); zoom_hb->add_child(zoom_minus); @@ -5742,8 +5746,6 @@ void CanvasItemEditorViewport::_on_change_type_closed() { } void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { - label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); - label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); bool add_preview = false; for (int i = 0; i < files.size(); i++) { String path = files[i]; @@ -6165,7 +6167,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte label->add_color_override("font_color_shadow", Color(0, 0, 0, 1)); label->add_constant_override("shadow_as_outline", 1 * EDSCALE); label->hide(); - editor->get_gui_base()->add_child(label); + canvas_item_editor->get_controls_container()->add_child(label); label_desc = memnew(Label); label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type")); @@ -6174,7 +6176,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte label_desc->add_constant_override("shadow_as_outline", 1 * EDSCALE); label_desc->add_constant_override("line_spacing", 0); label_desc->hide(); - editor->get_gui_base()->add_child(label_desc); + canvas_item_editor->get_controls_container()->add_child(label_desc); + VS::get_singleton()->canvas_set_disable_scale(true); } diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 3fdf00d611..3ba66c00f9 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -530,6 +530,7 @@ private: void _button_toggle_anchor_mode(bool p_status); + VBoxContainer *controls_vb; HBoxContainer *zoom_hb; void _zoom_on_position(float p_zoom, Point2 p_position = Point2()); void _update_zoom_label(); @@ -627,6 +628,8 @@ public: Control *get_viewport_control() { return viewport; } + Control *get_controls_container() { return controls_vb; } + void update_viewport(); Tool get_current_tool() { return tool; } |