diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-07-20 11:19:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 11:19:07 +0200 |
commit | 1af58e046e00b62c0de41427fe4097f1e71141fb (patch) | |
tree | 5b8c4cfbc5ec8b16df9e42f9240607b3e02e2b80 | |
parent | 8b1c60c1a324ed3ae2c2d26e58a3040f8542a416 (diff) | |
parent | 8aaa41ec97fc8f6f55a352a43618e7f520b9e99a (diff) |
Merge pull request #50500 from LightningAA/simplify-subviewport-preview-editor-theme
Remove unnecessary `get_editor_theme()` in `SubViewportPreview`
-rw-r--r-- | editor/plugins/sub_viewport_preview_editor_plugin.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/texture_editor_plugin.cpp | 8 |
2 files changed, 4 insertions, 5 deletions
diff --git a/editor/plugins/sub_viewport_preview_editor_plugin.cpp b/editor/plugins/sub_viewport_preview_editor_plugin.cpp index 5fd173cae3..75c47bda2e 100644 --- a/editor/plugins/sub_viewport_preview_editor_plugin.cpp +++ b/editor/plugins/sub_viewport_preview_editor_plugin.cpp @@ -38,6 +38,7 @@ void EditorInspectorPluginSubViewportPreview::parse_begin(Object *p_object) { SubViewport *sub_viewport = Object::cast_to<SubViewport>(p_object); TexturePreview *sub_viewport_preview = memnew(TexturePreview(sub_viewport->get_texture(), false)); + // Otherwise `sub_viewport_preview`'s `texture_display` doesn't update properly when `sub_viewport`'s size changes. sub_viewport->connect("size_changed", callable_mp((CanvasItem *)sub_viewport_preview->get_texture_display(), &CanvasItem::update)); add_custom_control(sub_viewport_preview); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 6ee652098d..4029d6785c 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -37,10 +37,8 @@ TextureRect *TexturePreview::get_texture_display() { } TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { - Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme(); - TextureRect *checkerboard = memnew(TextureRect); - checkerboard->set_texture(theme->get_icon("Checkerboard", "EditorIcons")); + checkerboard->set_texture(get_theme_icon("Checkerboard", "EditorIcons")); checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE); checkerboard->set_texture_repeat(CanvasItem::TEXTURE_REPEAT_ENABLED); checkerboard->set_custom_minimum_size(Size2(0.0, 256.0) * EDSCALE); @@ -70,10 +68,10 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { metadata_label->add_theme_font_size_override("font_size", 16 * EDSCALE); metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); metadata_label->add_theme_constant_override("outline_size", 2 * EDSCALE); - Ref<Font> metadata_label_font = theme->get_font("expression", "EditorFonts"); + Ref<Font> metadata_label_font = get_theme_font("expression", "EditorFonts"); metadata_label->add_theme_font_override("font", metadata_label_font); - // it's okay that these colors are static since the grid color is static too + // It's okay that these colors are static since the grid color is static too. metadata_label->add_theme_color_override("font_color", Color::named("white")); metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); |