summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-04-04 16:11:54 +0200
committerGitHub <noreply@github.com>2020-04-04 16:11:54 +0200
commit068a3f8313d8671b5faacc385f8b8fd723be54ed (patch)
tree14c80451eb72abcfc0d8ceb033bc3661a9fe9594
parentea48b403a9e7b8ddb2b814c6ea413bb9f5ed0518 (diff)
parentae34c535905bf433d86ff97a99a711576e97cdb1 (diff)
Merge pull request #37563 from YeldhamDev/float_dock_position
Take borders into account with floating dock initial position/size
-rw-r--r--editor/editor_node.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 205d5f2944..9a905c38d1 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3973,8 +3973,9 @@ void EditorNode::_dock_make_float() {
Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
ERR_FAIL_COND(!dock);
- Size2 dock_size = dock->get_size(); //remember size
- Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position();
+ const Size2i borders = Size2i(4, 4) * EDSCALE;
+ Size2 dock_size = dock->get_size() + borders * 2; //remember size
+ Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders;
print_line("dock pos: " + dock->get_global_position() + " window pos: " + get_tree()->get_root()->get_position());
int dock_index = dock->get_index();
@@ -3988,10 +3989,10 @@ void EditorNode::_dock_make_float() {
window->add_child(p);
MarginContainer *margin = memnew(MarginContainer);
margin->set_anchors_and_margins_preset(Control::PRESET_WIDE);
- margin->add_theme_constant_override("margin_right", 4 * EDSCALE);
- margin->add_theme_constant_override("margin_top", 4 * EDSCALE);
- margin->add_theme_constant_override("margin_left", 4 * EDSCALE);
- margin->add_theme_constant_override("margin_bottom", 4 * EDSCALE);
+ margin->add_theme_constant_override("margin_right", borders.width);
+ margin->add_theme_constant_override("margin_top", borders.height);
+ margin->add_theme_constant_override("margin_left", borders.width);
+ margin->add_theme_constant_override("margin_bottom", borders.height);
window->add_child(margin);
dock->set_anchors_and_margins_preset(Control::PRESET_WIDE);
margin->add_child(dock);