#include "../../include/gui/SettingsPage.hpp" #include "../../include/gui/GsrPage.hpp" #include "../../include/gui/Label.hpp" #include "../../include/gui/PageStack.hpp" #include "../../include/gui/FileChooser.hpp" #include "../../include/gui/Subsection.hpp" #include "../../include/Theme.hpp" #include "../../include/GsrInfo.hpp" #include "../../include/Utils.hpp" #include #include #include #include #include namespace gsr { enum class AudioTrackType { DEVICE, APPLICATION, APPLICATION_CUSTOM }; SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, Config &config, PageStack *page_stack) : StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()), type(type), config(config), page_stack(page_stack), settings_title_text("Settings", get_theme().title_font) { audio_devices = get_audio_devices(); application_audio = get_application_audio(); auto content_page = std::make_unique(); content_page->add_button("Back", "back", get_color_theme().page_bg_color); content_page->on_click = [page_stack](const std::string &id) { if(id == "back") page_stack->pop(); }; content_page_ptr = content_page.get(); add_widget(std::move(content_page)); add_widgets(gsr_info); add_page_specific_widgets(gsr_info); load(gsr_info); } std::unique_ptr SettingsPage::create_view_radio_button() { auto view_radio_button = std::make_unique(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL); view_radio_button->add_item("Simple view", "simple"); view_radio_button->add_item("Advanced view", "advanced"); view_radio_button->set_horizontal_alignment(Widget::Alignment::CENTER); view_radio_button_ptr = view_radio_button.get(); return view_radio_button; } std::unique_ptr SettingsPage::create_record_area_box(const GsrInfo &gsr_info) { auto record_area_box = std::make_unique(&get_theme().body_font); // TODO: Show options not supported but disable them // TODO: Enable this //if(gsr_info.supported_capture_options.window) // record_area_box->add_item("Window", "window"); if(gsr_info.supported_capture_options.focused) record_area_box->add_item("Follow focused window", "focused"); if(gsr_info.supported_capture_options.screen) record_area_box->add_item("All monitors", "screen"); for(const auto &monitor : gsr_info.supported_capture_options.monitors) { char name[256]; snprintf(name, sizeof(name), "Monitor %s (%dx%d)", monitor.name.c_str(), monitor.size.x, monitor.size.y); record_area_box->add_item(name, monitor.name); } if(gsr_info.supported_capture_options.portal) record_area_box->add_item("Desktop portal", "portal"); record_area_box_ptr = record_area_box.get(); return record_area_box; } std::unique_ptr SettingsPage::create_record_area(const GsrInfo &gsr_info) { auto record_area_list = std::make_unique(List::Orientation::VERTICAL); record_area_list->add_widget(std::make_unique