Skip to content

Commit 33fb876

Browse files
committed
Merge pull request godotengine#101321 from YeldhamDev/project_manager_warn_silence
Change print warnings to config ones for popups that need transparency
2 parents d83598e + 5c63646 commit 33fb876

File tree

9 files changed

+82
-17
lines changed

9 files changed

+82
-17
lines changed

main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2540,7 +2540,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
25402540
GLOBAL_DEF_BASIC("internationalization/locale/include_text_server_data", false);
25412541

25422542
OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", true);
2543-
OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false);
2543+
OS::get_singleton()->_allow_layered = GLOBAL_DEF_RST("display/window/per_pixel_transparency/allowed", false);
25442544

25452545
#ifdef TOOLS_ENABLED
25462546
if (editor || project_manager) {

scene/gui/menu_button.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) {
204204
disable_shortcuts = p_disabled;
205205
}
206206

207+
#ifdef TOOLS_ENABLED
208+
PackedStringArray MenuButton::get_configuration_warnings() const {
209+
PackedStringArray warnings = Button::get_configuration_warnings();
210+
warnings.append_array(popup->get_configuration_warnings());
211+
return warnings;
212+
}
213+
#endif
214+
207215
MenuButton::MenuButton(const String &p_text) :
208216
Button(p_text) {
209217
set_flat(true);

scene/gui/menu_button.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ class MenuButton : public Button {
7171
void set_item_count(int p_count);
7272
int get_item_count() const;
7373

74+
#ifdef TOOLS_ENABLED
75+
PackedStringArray get_configuration_warnings() const override;
76+
#endif
77+
7478
MenuButton(const String &p_text = String());
7579
~MenuButton();
7680
};

scene/gui/option_button.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,14 @@ void OptionButton::set_disable_shortcuts(bool p_disabled) {
582582
disable_shortcuts = p_disabled;
583583
}
584584

585+
#ifdef TOOLS_ENABLED
586+
PackedStringArray OptionButton::get_configuration_warnings() const {
587+
PackedStringArray warnings = Button::get_configuration_warnings();
588+
warnings.append_array(popup->get_configuration_warnings());
589+
return warnings;
590+
}
591+
#endif
592+
585593
OptionButton::OptionButton(const String &p_text) :
586594
Button(p_text) {
587595
set_toggle_mode(true);

scene/gui/option_button.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ class OptionButton : public Button {
143143

144144
void set_disable_shortcuts(bool p_disabled);
145145

146+
#ifdef TOOLS_ENABLED
147+
PackedStringArray get_configuration_warnings() const override;
148+
#endif
149+
146150
OptionButton(const String &p_text = String());
147151
~OptionButton();
148152
};

scene/gui/popup.cpp

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#include "popup.h"
3232

33+
#ifdef TOOLS_ENABLED
34+
#include "core/config/project_settings.h"
35+
#endif
3336
#include "scene/gui/panel.h"
3437
#include "scene/resources/style_box_flat.h"
3538
#include "scene/theme/theme_db.h"
@@ -221,6 +224,21 @@ Popup::Popup() {
221224
Popup::~Popup() {
222225
}
223226

227+
#ifdef TOOLS_ENABLED
228+
PackedStringArray PopupPanel::get_configuration_warnings() const {
229+
PackedStringArray warnings = Popup::get_configuration_warnings();
230+
231+
if (!DisplayServer::get_singleton()->is_window_transparency_available() && !GLOBAL_GET("display/window/subwindows/embed_subwindows")) {
232+
Ref<StyleBoxFlat> sb = theme_cache.panel_style;
233+
if (sb.is_valid() && (sb->get_shadow_size() > 0 || sb->get_corner_radius(CORNER_TOP_LEFT) > 0 || sb->get_corner_radius(CORNER_TOP_RIGHT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_LEFT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_RIGHT) > 0)) {
234+
warnings.push_back(RTR("The current theme style has shadows and/or rounded corners for popups, but those won't display correctly if \"display/window/per_pixel_transparency/allowed\" isn't enabled in the Project Settings, nor if it isn't supported."));
235+
}
236+
}
237+
238+
return warnings;
239+
}
240+
#endif
241+
224242
void PopupPanel::_input_from_window(const Ref<InputEvent> &p_event) {
225243
if (p_event.is_valid()) {
226244
if (!get_flag(FLAG_POPUP)) {
@@ -341,15 +359,6 @@ void PopupPanel::_update_child_rects() const {
341359

342360
void PopupPanel::_notification(int p_what) {
343361
switch (p_what) {
344-
case NOTIFICATION_ENTER_TREE: {
345-
if (!Engine::get_singleton()->is_editor_hint() && !DisplayServer::get_singleton()->is_window_transparency_available() && !is_embedded()) {
346-
Ref<StyleBoxFlat> sb = theme_cache.panel_style;
347-
if (sb.is_valid() && (sb->get_shadow_size() > 0 || sb->get_corner_radius(CORNER_TOP_LEFT) > 0 || sb->get_corner_radius(CORNER_TOP_RIGHT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_LEFT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_RIGHT) > 0)) {
348-
WARN_PRINT_ONCE("The current theme styles PopupPanel to have shadows and/or rounded corners, but those won't display correctly if 'display/window/per_pixel_transparency/allowed' isn't enabled in the Project Settings, nor if it isn't supported.");
349-
}
350-
}
351-
} break;
352-
353362
case NOTIFICATION_THEME_CHANGED: {
354363
panel->add_theme_style_override(SceneStringName(panel), theme_cache.panel_style);
355364

@@ -358,6 +367,10 @@ void PopupPanel::_notification(int p_what) {
358367
}
359368

360369
_update_child_rects();
370+
371+
#ifdef TOOLS_ENABLED
372+
update_configuration_warnings();
373+
#endif
361374
} break;
362375

363376
case Control::NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
@@ -410,4 +423,8 @@ PopupPanel::PopupPanel() {
410423
panel = memnew(Panel);
411424
panel->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
412425
add_child(panel, false, INTERNAL_MODE_FRONT);
426+
427+
#ifdef TOOLS_ENABLED
428+
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp((Node *)this, &Node::update_configuration_warnings));
429+
#endif
413430
}

scene/gui/popup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class PopupPanel : public Popup {
101101
virtual Size2 _get_contents_minimum_size() const override;
102102

103103
public:
104+
#ifdef TOOLS_ENABLED
105+
PackedStringArray get_configuration_warnings() const override;
106+
#endif
107+
104108
PopupPanel();
105109
};
106110

scene/gui/popup_menu.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,6 @@ void PopupMenu::_notification(int p_what) {
11061106
if (system_menu_id != NativeMenu::INVALID_MENU_ID) {
11071107
bind_global_menu();
11081108
}
1109-
1110-
if (!Engine::get_singleton()->is_editor_hint() && !DisplayServer::get_singleton()->is_window_transparency_available() && !is_embedded()) {
1111-
Ref<StyleBoxFlat> sb = theme_cache.panel_style;
1112-
if (sb.is_valid() && (sb->get_shadow_size() > 0 || sb->get_corner_radius(CORNER_TOP_LEFT) > 0 || sb->get_corner_radius(CORNER_TOP_RIGHT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_LEFT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_RIGHT) > 0)) {
1113-
WARN_PRINT_ONCE("The current theme styles PopupMenu to have shadows and/or rounded corners, but those won't display correctly if 'display/window/per_pixel_transparency/allowed' isn't enabled in the Project Settings, nor if it isn't supported.");
1114-
}
1115-
}
11161109
} break;
11171110

11181111
case NOTIFICATION_EXIT_TREE: {
@@ -1129,6 +1122,10 @@ void PopupMenu::_notification(int p_what) {
11291122
_update_shadow_offsets();
11301123
}
11311124

1125+
#ifdef TOOLS_ENABLED
1126+
update_configuration_warnings();
1127+
#endif
1128+
11321129
[[fallthrough]];
11331130
}
11341131
case NOTIFICATION_TRANSLATION_CHANGED: {
@@ -2709,6 +2706,21 @@ String PopupMenu::get_tooltip(const Point2 &p_pos) const {
27092706
return items[over].tooltip;
27102707
}
27112708

2709+
#ifdef TOOLS_ENABLED
2710+
PackedStringArray PopupMenu::get_configuration_warnings() const {
2711+
PackedStringArray warnings = Popup::get_configuration_warnings();
2712+
2713+
if (!DisplayServer::get_singleton()->is_window_transparency_available() && !GLOBAL_GET("display/window/subwindows/embed_subwindows")) {
2714+
Ref<StyleBoxFlat> sb = theme_cache.panel_style;
2715+
if (sb.is_valid() && (sb->get_shadow_size() > 0 || sb->get_corner_radius(CORNER_TOP_LEFT) > 0 || sb->get_corner_radius(CORNER_TOP_RIGHT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_LEFT) > 0 || sb->get_corner_radius(CORNER_BOTTOM_RIGHT) > 0)) {
2716+
warnings.push_back(RTR("The current theme style has shadows and/or rounded corners for popups, but those won't display correctly if \"display/window/per_pixel_transparency/allowed\" isn't enabled in the Project Settings, nor if it isn't supported."));
2717+
}
2718+
}
2719+
2720+
return warnings;
2721+
}
2722+
#endif
2723+
27122724
void PopupMenu::add_autohide_area(const Rect2 &p_area) {
27132725
autohide_areas.push_back(p_area);
27142726
}
@@ -3027,6 +3039,10 @@ PopupMenu::PopupMenu() {
30273039
add_child(minimum_lifetime_timer, false, INTERNAL_MODE_FRONT);
30283040

30293041
property_helper.setup_for_instance(base_property_helper, this);
3042+
3043+
#ifdef TOOLS_ENABLED
3044+
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp((Node *)this, &Node::update_configuration_warnings));
3045+
#endif
30303046
}
30313047

30323048
PopupMenu::~PopupMenu() {

scene/gui/popup_menu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ class PopupMenu : public Popup {
356356

357357
virtual String get_tooltip(const Point2 &p_pos) const;
358358

359+
#ifdef TOOLS_ENABLED
360+
PackedStringArray get_configuration_warnings() const override;
361+
#endif
362+
359363
void add_autohide_area(const Rect2 &p_area);
360364
void clear_autohide_areas();
361365

0 commit comments

Comments
 (0)