summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorvolzhs <volzhs@gmail.com>2019-10-25 06:20:52 +0900
committervolzhs <volzhs@gmail.com>2019-10-25 06:20:52 +0900
commitf8e592f60711da2c22f61e3edd4a0b556e00332d (patch)
tree10689235dc042db5db3a72e1ad64350c36b93aae /editor
parent982774e639ad4c98aa9459cd029c505b01fee4a8 (diff)
Make stylebox preview not to expand Inspector panel
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp13
-rw-r--r--editor/plugins/style_box_editor_plugin.h3
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 defc0a40ea..c4a9803ff4 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<StyleBox> &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 d31a28b3e4..fead8e0de8 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> stylebox;
void _sb_changed();
+ void _redraw();
protected:
static void _bind_methods();