Browse Source

Merge pull request #35303 from timothyqiu/hidpi-anitreeplayer

Fixes AnimationTreePlayer editor UI on HiDPI
Rémi Verschelde 5 years ago
parent
commit
e8dc581bfc
1 changed files with 8 additions and 6 deletions
  1. 8 6
      editor/plugins/animation_tree_player_editor_plugin.cpp

+ 8 - 6
editor/plugins/animation_tree_player_editor_plugin.cpp

@@ -34,6 +34,7 @@
 #include "core/os/input.h"
 #include "core/os/input.h"
 #include "core/os/keyboard.h"
 #include "core/os/keyboard.h"
 #include "core/project_settings.h"
 #include "core/project_settings.h"
+#include "editor/editor_scale.h"
 #include "scene/gui/menu_button.h"
 #include "scene/gui/menu_button.h"
 #include "scene/gui/panel.h"
 #include "scene/gui/panel.h"
 #include "scene/main/viewport.h"
 #include "scene/main/viewport.h"
@@ -923,17 +924,18 @@ void AnimationTreePlayerEditor::_notification(int p_what) {
 				_draw_cos_line(source, dest, col);
 				_draw_cos_line(source, dest, col);
 			}
 			}
 
 
+			const Ref<Font> f = get_font("font", "Label");
+			const Point2 status_offset = Point2(5, 25) * EDSCALE + Point2(0, f->get_ascent());
+
 			switch (anim_tree->get_last_error()) {
 			switch (anim_tree->get_last_error()) {
 
 
 				case AnimationTreePlayer::CONNECT_OK: {
 				case AnimationTreePlayer::CONNECT_OK: {
 
 
-					Ref<Font> f = get_font("font", "Label");
-					f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
+					f->draw(get_canvas_item(), status_offset, TTR("Animation tree is valid."), Color(0, 1, 0.6, 0.8));
 				} break;
 				} break;
 				default: {
 				default: {
 
 
-					Ref<Font> f = get_font("font", "Label");
-					f->draw(get_canvas_item(), Point2(5, 25 + f->get_ascent()), TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
+					f->draw(get_canvas_item(), status_offset, TTR("Animation tree is invalid."), Color(1, 0.6, 0.0, 0.8));
 				} break;
 				} break;
 			}
 			}
 
 
@@ -1300,7 +1302,7 @@ AnimationTreePlayerEditor::AnimationTreePlayerEditor() {
 	p->connect("id_pressed", this, "_add_menu_item");
 	p->connect("id_pressed", this, "_add_menu_item");
 
 
 	play_button = memnew(Button);
 	play_button = memnew(Button);
-	play_button->set_position(Point2(25, 0));
+	play_button->set_position(Point2(25, 0) * EDSCALE);
 	play_button->set_size(Point2(25, 15));
 	play_button->set_size(Point2(25, 15));
 	add_child(play_button);
 	add_child(play_button);
 	play_button->set_toggle_mode(true);
 	play_button->set_toggle_mode(true);
@@ -1439,7 +1441,7 @@ AnimationTreePlayerEditorPlugin::AnimationTreePlayerEditorPlugin(EditorNode *p_n
 
 
 	editor = p_node;
 	editor = p_node;
 	anim_tree_editor = memnew(AnimationTreePlayerEditor);
 	anim_tree_editor = memnew(AnimationTreePlayerEditor);
-	anim_tree_editor->set_custom_minimum_size(Size2(0, 300));
+	anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
 
 
 	button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
 	button = editor->add_bottom_panel_item(TTR("AnimationTree"), anim_tree_editor);
 	button->hide();
 	button->hide();