From f8e592f60711da2c22f61e3edd4a0b556e00332d Mon Sep 17 00:00:00 2001 From: volzhs Date: Fri, 25 Oct 2019 06:20:52 +0900 Subject: [PATCH] Make stylebox preview not to expand Inspector panel --- editor/plugins/style_box_editor_plugin.cpp | 13 ++++++++----- editor/plugins/style_box_editor_plugin.h | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index defc0a40ea3..c4a9803ff43 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -64,21 +64,24 @@ void StyleBoxPreview::edit(const Ref &p_stylebox) { void StyleBoxPreview::_sb_changed() { preview->update(); +} + +void StyleBoxPreview::_redraw() { if (stylebox.is_valid()) { - Size2 ms = stylebox->get_minimum_size() * 4 / 3; - ms.height = MAX(ms.height, 150 * EDSCALE); - preview->set_custom_minimum_size(ms); + preview->draw_style_box(stylebox, preview->get_rect()); } } void StyleBoxPreview::_bind_methods() { ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed); + ClassDB::bind_method("_redraw", &StyleBoxPreview::_redraw); } StyleBoxPreview::StyleBoxPreview() { - - preview = memnew(Panel); + preview = memnew(Control); + preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE)); + preview->connect("draw", this, "_redraw"); add_margin_child(TTR("Preview:"), preview); } diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index d31a28b3e4c..fead8e0de8f 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -41,10 +41,11 @@ class StyleBoxPreview : public VBoxContainer { GDCLASS(StyleBoxPreview, VBoxContainer); - Panel *preview; + Control *preview; Ref stylebox; void _sb_changed(); + void _redraw(); protected: static void _bind_methods();