summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorTetane <stephane.roussel.fr@gmail.com>2023-04-28 20:10:04 +0200
committerRĂ©mi Verschelde <rverschelde@gmail.com>2023-05-12 12:07:00 +0200
commite68e2fad25eaba112bee37234be89d1bb5829869 (patch)
tree39e91955f29dde7347109452a5634a47b8358689 /editor
parenta07ad181ab71e374082fa37cea6b399bd4c8092d (diff)
Use a SubViewport for CanvasItem inspector preview
(cherry picked from commit d3792a237331f56efdb36b1753f171ddc99629db)
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/material_editor_plugin.cpp12
-rw-r--r--editor/plugins/material_editor_plugin.h2
2 files changed, 13 insertions, 1 deletions
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index 36c143ca8d..32d237e411 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -157,9 +157,19 @@ void MaterialEditor::_button_pressed(Node *p_button) {
MaterialEditor::MaterialEditor() {
// canvas item
+ vc_2d = memnew(SubViewportContainer);
+ vc_2d->set_stretch(true);
+ add_child(vc_2d);
+ vc_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
+
+ viewport_2d = memnew(SubViewport);
+ vc_2d->add_child(viewport_2d);
+ viewport_2d->set_disable_input(true);
+ viewport_2d->set_transparent_background(true);
+
layout_2d = memnew(HBoxContainer);
layout_2d->set_alignment(BoxContainer::ALIGNMENT_CENTER);
- add_child(layout_2d);
+ viewport_2d->add_child(layout_2d);
layout_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
rect_instance = memnew(ColorRect);
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 63ee053b1d..7a610d860c 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -50,6 +50,8 @@ class MaterialEditor : public Control {
Vector2 rot;
+ SubViewportContainer *vc_2d = nullptr;
+ SubViewport *viewport_2d = nullptr;
HBoxContainer *layout_2d = nullptr;
ColorRect *rect_instance = nullptr;