Make stylebox preview not to expand Inspector panel
This commit is contained in:
parent
982774e639
commit
f8e592f607
|
@ -64,21 +64,24 @@ void StyleBoxPreview::edit(const Ref<StyleBox> &p_stylebox) {
|
||||||
void StyleBoxPreview::_sb_changed() {
|
void StyleBoxPreview::_sb_changed() {
|
||||||
|
|
||||||
preview->update();
|
preview->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StyleBoxPreview::_redraw() {
|
||||||
if (stylebox.is_valid()) {
|
if (stylebox.is_valid()) {
|
||||||
Size2 ms = stylebox->get_minimum_size() * 4 / 3;
|
preview->draw_style_box(stylebox, preview->get_rect());
|
||||||
ms.height = MAX(ms.height, 150 * EDSCALE);
|
|
||||||
preview->set_custom_minimum_size(ms);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyleBoxPreview::_bind_methods() {
|
void StyleBoxPreview::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
|
ClassDB::bind_method("_sb_changed", &StyleBoxPreview::_sb_changed);
|
||||||
|
ClassDB::bind_method("_redraw", &StyleBoxPreview::_redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleBoxPreview::StyleBoxPreview() {
|
StyleBoxPreview::StyleBoxPreview() {
|
||||||
|
preview = memnew(Control);
|
||||||
preview = memnew(Panel);
|
preview->set_custom_minimum_size(Size2(0, 150 * EDSCALE));
|
||||||
|
preview->connect("draw", this, "_redraw");
|
||||||
add_margin_child(TTR("Preview:"), preview);
|
add_margin_child(TTR("Preview:"), preview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,11 @@ class StyleBoxPreview : public VBoxContainer {
|
||||||
|
|
||||||
GDCLASS(StyleBoxPreview, VBoxContainer);
|
GDCLASS(StyleBoxPreview, VBoxContainer);
|
||||||
|
|
||||||
Panel *preview;
|
Control *preview;
|
||||||
Ref<StyleBox> stylebox;
|
Ref<StyleBox> stylebox;
|
||||||
|
|
||||||
void _sb_changed();
|
void _sb_changed();
|
||||||
|
void _redraw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
Loading…
Reference in New Issue