summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2021-11-23 16:17:19 +0100
committerkobewi <kobewi4e@gmail.com>2021-11-23 16:17:19 +0100
commit030697e06c6bbbed044f1ad3d6b1b6043ebf5460 (patch)
tree58285400a7a23950a16a234210fb6547de8754d8 /editor/plugins
parentc5ab537617d9461964e67bb135bb0818efe21d58 (diff)
Move container warning to the toaster
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp67
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h10
2 files changed, 1 insertions, 76 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index ecc404f903..1fcbb03e05 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -242,7 +242,7 @@ bool CanvasItemEditor::_is_node_movable(const Node *p_node, bool p_popup_warning
}
if (Object::cast_to<Control>(p_node) && Object::cast_to<Container>(p_node->get_parent())) {
if (p_popup_warning) {
- _popup_warning_temporarily(warning_child_of_container, 3.0);
+ EditorToaster::get_singleton()->popup_str("Children of a container get their position and size determined only by their parent.", EditorToaster::SEVERITY_WARNING);
}
return false;
}
@@ -3665,8 +3665,6 @@ void CanvasItemEditor::_draw_viewport() {
group_button->set_disabled(selection.is_empty());
ungroup_button->set_visible(all_group);
- info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
-
_draw_grid();
_draw_ruler_tool();
_draw_axis();
@@ -3919,11 +3917,6 @@ void CanvasItemEditor::_notification(int p_what) {
anchors_popup->add_icon_item(get_theme_icon(SNAME("ControlAlignWide"), SNAME("EditorIcons")), TTR("Full Rect"), ANCHORS_PRESET_WIDE);
anchor_mode_button->set_icon(get_theme_icon(SNAME("Anchor"), SNAME("EditorIcons")));
-
- info_overlay->get_theme()->set_stylebox("normal", "Label", get_theme_stylebox(SNAME("CanvasItemInfoOverlay"), SNAME("EditorStyles")));
- warning_child_of_container->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor")));
- warning_child_of_container->add_theme_font_override("font", get_theme_font(SNAME("main"), SNAME("EditorFonts")));
- warning_child_of_container->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("main_size"), SNAME("EditorFonts")));
}
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
@@ -4079,34 +4072,6 @@ void CanvasItemEditor::_update_scrollbars() {
updating_scroll = false;
}
-void CanvasItemEditor::_popup_warning_depop(Control *p_control) {
- ERR_FAIL_COND(!popup_temporarily_timers.has(p_control));
-
- Timer *timer = popup_temporarily_timers[p_control];
- timer->queue_delete();
- p_control->hide();
- popup_temporarily_timers.erase(p_control);
- info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
-}
-
-void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const double p_duration) {
- Timer *timer;
- if (!popup_temporarily_timers.has(p_control)) {
- timer = memnew(Timer);
- timer->connect("timeout", callable_mp(this, &CanvasItemEditor::_popup_warning_depop), varray(p_control));
- timer->set_one_shot(true);
- add_child(timer);
-
- popup_temporarily_timers[p_control] = timer;
- } else {
- timer = popup_temporarily_timers[p_control];
- }
-
- timer->start(p_duration);
- p_control->show();
- info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
-}
-
void CanvasItemEditor::_update_scroll(real_t) {
if (updating_scroll) {
return;
@@ -5136,19 +5101,6 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
viewport->update();
}
-void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) {
- ERR_FAIL_COND(!p_control);
-
- p_control->set_h_size_flags(p_control->get_h_size_flags() & ~Control::SIZE_EXPAND_FILL);
- info_overlay->add_child(p_control);
- info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
-}
-
-void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) {
- info_overlay->remove_child(p_control);
- info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
-}
-
void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
ERR_FAIL_COND(!p_control);
@@ -5281,23 +5233,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport->connect("draw", callable_mp(this, &CanvasItemEditor::_draw_viewport));
viewport->connect("gui_input", callable_mp(this, &CanvasItemEditor::_gui_input_viewport));
- info_overlay = memnew(VBoxContainer);
- info_overlay->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT);
- info_overlay->set_offset(SIDE_LEFT, 10);
- info_overlay->set_offset(SIDE_BOTTOM, -15);
- info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN);
- info_overlay->add_theme_constant_override("separation", 10);
- viewport_scrollable->add_child(info_overlay);
-
- // Make sure all labels inside of the container are styled the same.
- Theme *info_overlay_theme = memnew(Theme);
- info_overlay->set_theme(info_overlay_theme);
-
- warning_child_of_container = memnew(Label);
- warning_child_of_container->hide();
- warning_child_of_container->set_text(TTR("Warning: Children of a container get their position and size determined only by their parent."));
- add_control_to_info_overlay(warning_child_of_container);
-
h_scroll = memnew(HScrollBar);
viewport->add_child(h_scroll);
h_scroll->connect("value_changed", callable_mp(this, &CanvasItemEditor::_update_scroll));
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index 286771ee08..b6576b7144 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -235,11 +235,6 @@ private:
PanelContainer *context_menu_container;
HBoxContainer *hbc_context_menu;
- Map<Control *, Timer *> popup_temporarily_timers;
-
- Label *warning_child_of_container;
- VBoxContainer *info_overlay;
-
Transform2D transform;
bool show_grid;
bool show_rulers;
@@ -536,8 +531,6 @@ private:
VSplitContainer *bottom_split;
void _update_context_menu_stylebox();
- void _popup_warning_temporarily(Control *p_control, const double p_duration);
- void _popup_warning_depop(Control *p_control);
void _set_owner_for_node_and_children(Node *p_node, Node *p_owner);
@@ -578,9 +571,6 @@ public:
void add_control_to_menu_panel(Control *p_control);
void remove_control_from_menu_panel(Control *p_control);
- void add_control_to_info_overlay(Control *p_control);
- void remove_control_from_info_overlay(Control *p_control);
-
HSplitContainer *get_palette_split();
VSplitContainer *get_bottom_split();