summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-30 10:56:58 +0200
committerGitHub <noreply@github.com>2019-08-30 10:56:58 +0200
commit04e4c3a8d38ab623b1ea7ce6dc60f0a7a03484ef (patch)
tree79662e73319669b9a8d4a55b43a72178da9234fd
parente0dc066ec09236f1286800074cdcc0a254799168 (diff)
parentef9f234d2ba5289a84832974e54ea7ace9806717 (diff)
Merge pull request #31767 from Calinou/tweak-editor-window-dim
Tweak the editor window dimming intensity, remove dim fade animation
-rw-r--r--editor/editor_node.cpp59
-rw-r--r--editor/editor_node.h9
-rw-r--r--editor/project_manager.cpp2
3 files changed, 9 insertions, 61 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 635f6d4fc7..7574951e2c 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2632,11 +2632,8 @@ void EditorNode::_exit_editor() {
resource_preview->stop(); //stop early to avoid crashes
_save_docks();
- // Dim the editor window while it's quitting to make it clearer that it's busy.
- // No transition is applied, as the effect needs to be visible immediately
- float c = 0.4f;
- Color dim_color = Color(c, c, c);
- gui_base->set_modulate(dim_color);
+ // Dim the editor window while it's quitting to make it clearer that it's busy
+ dim_editor(true, true);
get_tree()->quit();
}
@@ -5133,46 +5130,12 @@ void EditorNode::_open_imported() {
load_scene(open_import_request, true, false, true, true);
}
-void EditorNode::dim_editor(bool p_dimming) {
- static int dim_count = 0;
- bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup");
- if (p_dimming) {
- if (dim_ui && dim_count == 0) {
- _start_dimming(true);
- }
- dim_count++;
- } else {
- if (dim_count == 1) {
- _start_dimming(false);
- }
- if (dim_count > 0) {
- dim_count--;
- } else {
- ERR_PRINT("Undimmed before dimming!");
- }
- }
-}
-
-void EditorNode::_start_dimming(bool p_dimming) {
- _dimming = p_dimming;
- _dim_time = 0.0f;
- _dim_timer->start();
-}
-
-void EditorNode::_dim_timeout() {
-
- _dim_time += _dim_timer->get_wait_time();
- float wait_time = 0.08f;
- float c = 0.4f;
-
- Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c);
- Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1);
-
- if (_dim_time + _dim_timer->get_wait_time() >= wait_time) {
- gui_base->set_modulate(final);
- _dim_timer->stop();
+void EditorNode::dim_editor(bool p_dimming, bool p_force_dim) {
+ // Dimming can be forced regardless of the editor setting, which is useful when quitting the editor
+ if ((p_force_dim || EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup")) && p_dimming) {
+ gui_base->set_modulate(Color(0.5, 0.5, 0.5));
} else {
- gui_base->set_modulate(base.linear_interpolate(final, _dim_time / wait_time));
+ gui_base->set_modulate(Color(1, 1, 1));
}
}
@@ -5356,7 +5319,6 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported);
ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported);
- ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout);
ClassDB::bind_method("_copy_warning", &EditorNode::_copy_warning);
@@ -6687,13 +6649,6 @@ EditorNode::EditorNode() {
waiting_for_first_scan = true;
- _dimming = false;
- _dim_time = 0.0f;
- _dim_timer = memnew(Timer);
- _dim_timer->set_wait_time(0.01666f);
- _dim_timer->connect("timeout", this, "_dim_timeout");
- add_child(_dim_timer);
-
print_handler.printfunc = _print_handler;
print_handler.userdata = this;
add_print_handler(&print_handler);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 61bbb7b86d..54bcf14c1b 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -633,13 +633,6 @@ private:
static int build_callback_count;
static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
- bool _dimming;
- float _dim_time;
- Timer *_dim_timer;
-
- void _start_dimming(bool p_dimming);
- void _dim_timeout();
-
void _license_tree_selected();
void _update_update_spinner();
@@ -849,7 +842,7 @@ public:
void save_scene_list(Vector<String> p_scene_filenames);
void restart_editor();
- void dim_editor(bool p_dimming);
+ void dim_editor(bool p_dimming, bool p_force_dim = false);
void edit_current() { _edit_current(); };
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 98335c8367..c6e3dc1e32 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1754,7 +1754,7 @@ void ProjectManager::_dim_window() {
// Dim the project manager window while it's quitting to make it clearer that it's busy.
// No transition is applied, as the effect needs to be visible immediately
- float c = 0.4f;
+ float c = 0.5f;
Color dim_color = Color(c, c, c);
gui_base->set_modulate(dim_color);
}