From c5162dbb45e66e7fd25430c9417a8e6a6b78080c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Nov 2024 18:07:01 +0100 Subject: Only show app audio option if using pipewire --- include/GsrInfo.hpp | 1 + include/gui/SettingsPage.hpp | 3 +++ src/GsrInfo.cpp | 2 ++ src/gui/List.cpp | 14 ++++++++++---- src/gui/SettingsPage.cpp | 15 +++++++++++++-- src/gui/Subsection.cpp | 2 +- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/GsrInfo.hpp b/include/GsrInfo.hpp index c3da6d7..cd6292c 100644 --- a/include/GsrInfo.hpp +++ b/include/GsrInfo.hpp @@ -40,6 +40,7 @@ namespace gsr { struct SystemInfo { DisplayServer display_server = DisplayServer::UNKNOWN; + bool supports_app_audio = false; }; enum class GpuVendor { diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp index 6c8a5cb..019de80 100644 --- a/include/gui/SettingsPage.hpp +++ b/include/gui/SettingsPage.hpp @@ -15,6 +15,7 @@ namespace gsr { class PageStack; class ScrollablePage; class Label; + class LineSeparator; class SettingsPage : public StaticPage { public: @@ -146,7 +147,9 @@ namespace gsr { List *video_bitrate_list_ptr = nullptr; List *audio_devices_list_ptr = nullptr; List *audio_devices_section_list_ptr = nullptr; + Label *audio_devices_label_ptr = nullptr; List *application_audio_section_list_ptr = nullptr; + LineSeparator *audio_type_line_sep_ptr = nullptr; CheckBox *merge_audio_tracks_checkbox_ptr = nullptr; RadioButton *audio_type_radio_button_ptr = nullptr; List *application_audio_list_ptr = nullptr; diff --git a/src/GsrInfo.cpp b/src/GsrInfo.cpp index bb410dc..276870b 100644 --- a/src/GsrInfo.cpp +++ b/src/GsrInfo.cpp @@ -21,6 +21,8 @@ namespace gsr { gsr_info->system_info.display_server = DisplayServer::X11; else if(key_value->value == "wayland") gsr_info->system_info.display_server = DisplayServer::WAYLAND; + } else if(key_value->key == "supports_app_audio") { + gsr_info->system_info.supports_app_audio = key_value->value == "yes"; } } diff --git a/src/gui/List.cpp b/src/gui/List.cpp index 510de6b..5294e36 100644 --- a/src/gui/List.cpp +++ b/src/gui/List.cpp @@ -45,6 +45,7 @@ namespace gsr { const mgl::vec2f parent_inner_size = parent_widget ? parent_widget->get_inner_size() : mgl::vec2f(0.0f, 0.0f); const float spacing = floor(spacing_scale * get_theme().window_height); + bool first_visible_widget = true; switch(orientation) { case Orientation::VERTICAL: { for(size_t i = 0; i < widgets.size(); ++i) { @@ -52,8 +53,9 @@ namespace gsr { if(!widget->visible) continue; - if(i > 0) + if(!first_visible_widget) draw_pos.y += spacing; + first_visible_widget = false; const auto widget_size = widget->get_size(); // TODO: Do this parent widget alignment for horizontal alignment and for other types of widget alignment @@ -79,8 +81,9 @@ namespace gsr { if(!widget->visible) continue; - if(i > 0) + if(!first_visible_widget) draw_pos.x += spacing; + first_visible_widget = false; const auto widget_size = widget->get_size(); if(content_alignment == Alignment::CENTER) @@ -145,6 +148,7 @@ namespace gsr { mgl::vec2f size; const float spacing = floor(spacing_scale * get_theme().window_height); + bool first_visible_widget = true; switch(orientation) { case Orientation::VERTICAL: { for(size_t i = 0; i < widgets.size(); ++i) { @@ -152,8 +156,9 @@ namespace gsr { if(!widget->visible) continue; - if(i > 0) + if(!first_visible_widget) size.y += spacing; + first_visible_widget = false; const auto widget_size = widget->get_size(); size.x = std::max(size.x, widget_size.x); @@ -167,8 +172,9 @@ namespace gsr { if(!widget->visible) continue; - if(i > 0) + if(!first_visible_widget) size.x += spacing; + first_visible_widget = false; const auto widget_size = widget->get_size(); size.x += widget_size.x; diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index d3083df..ad7960a 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -238,7 +238,9 @@ namespace gsr { std::unique_ptr SettingsPage::create_audio_device_section() { auto audio_devices_section_list = std::make_unique(List::Orientation::VERTICAL); audio_devices_section_list_ptr = audio_devices_section_list.get(); - audio_devices_section_list->add_widget(std::make_unique