diff options
Diffstat (limited to 'editor/editor_audio_buses.cpp')
-rw-r--r-- | editor/editor_audio_buses.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 2180742bbb..b331a39535 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -31,6 +31,7 @@ #include "editor_audio_buses.h" #include "core/io/resource_saver.h" +#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor_node.h" #include "filesystem_dock.h" @@ -87,7 +88,7 @@ void EditorAudioBus::_notification(int p_what) { bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); bypass->add_color_override("icon_color_pressed", bypass_color); - bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); + bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons")); update_bus(); set_process(true); @@ -179,7 +180,7 @@ void EditorAudioBus::_notification(int p_what) { mute->set_icon(get_icon("AudioBusMute", "EditorIcons")); bypass->set_icon(get_icon("AudioBusBypass", "EditorIcons")); - bus_options->set_icon(get_icon("GuiMiniTabMenu", "EditorIcons")); + bus_options->set_icon(get_icon("GuiTabMenu", "EditorIcons")); } break; case NOTIFICATION_MOUSE_EXIT: case NOTIFICATION_DRAG_END: { @@ -321,7 +322,13 @@ void EditorAudioBus::_volume_changed(float p_normalized) { updating_bus = true; - float p_db = this->_normalized_volume_to_scaled_db(p_normalized); + const float p_db = this->_normalized_volume_to_scaled_db(p_normalized); + + if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + // Snap the value when holding Ctrl for easier editing. + // To do so, it needs to be converted back to normalized volume (as the slider uses that unit). + slider->set_value(_scaled_db_to_normalized_volume(Math::round(p_db))); + } UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Audio Bus Volume"), UndoRedo::MERGE_ENDS); @@ -376,14 +383,24 @@ float EditorAudioBus::_scaled_db_to_normalized_volume(float db) { } void EditorAudioBus::_show_value(float slider_value) { - String text = vformat("%10.1f dB", _normalized_volume_to_scaled_db(slider_value)); + float db; + if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + // Display the correct (snapped) value when holding Ctrl + db = Math::round(_normalized_volume_to_scaled_db(slider_value)); + } else { + db = _normalized_volume_to_scaled_db(slider_value); + } + + String text = vformat("%10.1f dB", db); + + slider->set_tooltip(text); audio_value_preview_label->set_text(text); Vector2 slider_size = slider->get_size(); Vector2 slider_position = slider->get_global_position(); float left_padding = 5.0f; float vert_padding = 10.0f; - Vector2 box_position = Vector2(slider_size.x + left_padding, (slider_size.y - vert_padding) * (1.0f - slider_value) - vert_padding); + Vector2 box_position = Vector2(slider_size.x + left_padding, (slider_size.y - vert_padding) * (1.0f - slider->get_value()) - vert_padding); audio_value_preview_box->set_position(slider_position + box_position); audio_value_preview_box->set_size(audio_value_preview_label->get_size()); if (slider->has_focus() && !audio_value_preview_box->is_visible()) { @@ -773,7 +790,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { is_master = p_is_master; hovering_drop = false; - set_tooltip(TTR("Audio Bus, Drag and Drop to rearrange.")); + set_tooltip(TTR("Drag & drop to rearrange.")); VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -1439,7 +1456,7 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const { float width = 0; float height = top_padding + btm_padding; - for (uint8_t i = 0; i < notches.size(); i++) { + for (int i = 0; i < notches.size(); i++) { if (notches[i].render_db_value) { width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB").x); height += font_height; @@ -1473,7 +1490,7 @@ void EditorAudioMeterNotches::_draw_audio_notches() { Ref<Font> font = get_font("font", "Label"); float font_height = font->get_height(); - for (uint8_t i = 0; i < notches.size(); i++) { + for (int i = 0; i < notches.size(); i++) { AudioNotch n = notches[i]; draw_line(Vector2(0, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), Vector2(line_length, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), |