#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), gsr_info(gsr_info), page_stack(page_stack) { audio_devices = get_audio_devices(); application_audio = get_application_audio(); capture_options = get_supported_capture_options(*gsr_info); 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(); add_page_specific_widgets(); load(); } 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() { auto record_area_box = std::make_unique(&get_theme().body_font); // TODO: Show options not supported but disable them // TODO: Enable this //if(capture_options.window) // record_area_box->add_item("Window", "window"); if(capture_options.focused) record_area_box->add_item("Follow focused window", "focused"); if(capture_options.screen) record_area_box->add_item("All monitors", "screen"); for(const auto &monitor : 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(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() { auto record_area_list = std::make_unique(List::Orientation::VERTICAL); record_area_list->add_widget(std::make_unique