From 234cc3391eba6be67964e5c98beeecd318b8e779 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 11 Sep 2024 01:49:10 +0200 Subject: Load settings from config file --- src/gui/List.cpp | 4 ++ src/gui/SettingsPage.cpp | 127 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 114 insertions(+), 17 deletions(-) (limited to 'src/gui') diff --git a/src/gui/List.cpp b/src/gui/List.cpp index 81f0e80..510de6b 100644 --- a/src/gui/List.cpp +++ b/src/gui/List.cpp @@ -119,6 +119,10 @@ namespace gsr { widgets.remove(widget); } + void List::clear() { + widgets.clear(); + } + void List::for_each_child_widget(std::function &widget)> callback) { widgets.for_each(callback); } diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index cd5c97d..8304147 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -14,10 +14,11 @@ #include namespace gsr { - SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, const std::vector &audio_devices, std::optional &config, PageStack *page_stack) : + SettingsPage::SettingsPage(Type type, const GsrInfo &gsr_info, std::vector audio_devices, std::optional &config, PageStack *page_stack) : StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()), type(type), config(config), + audio_devices(std::move(audio_devices)), page_stack(page_stack), settings_title_text("Settings", get_theme().title_font) { @@ -30,8 +31,9 @@ namespace gsr { content_page_ptr = content_page.get(); add_widget(std::move(content_page)); - add_widgets(gsr_info, audio_devices); + add_widgets(gsr_info); add_page_specific_widgets(); + load(); } std::unique_ptr SettingsPage::create_view_radio_button() { @@ -133,7 +135,7 @@ namespace gsr { return std::make_unique("Record area", std::move(capture_target_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)); } - std::unique_ptr SettingsPage::create_audio_track_selection_checkbox(const std::vector &audio_devices) { + std::unique_ptr SettingsPage::create_audio_track_selection_checkbox() { auto audio_device_box = std::make_unique(&get_theme().body_font); for(const auto &audio_device : audio_devices) { audio_device_box->add_item(audio_device.description, audio_device.name); @@ -149,26 +151,26 @@ namespace gsr { return remove_audio_track_button; } - std::unique_ptr SettingsPage::create_audio_track(const std::vector &audio_devices) { + std::unique_ptr SettingsPage::create_audio_track() { auto audio_device_list = std::make_unique(List::Orientation::HORIZONTAL, List::Alignment::CENTER); - audio_device_list->add_widget(create_audio_track_selection_checkbox(audio_devices)); + audio_device_list->add_widget(create_audio_track_selection_checkbox()); audio_device_list->add_widget(create_remove_audio_track_button(audio_device_list.get())); return audio_device_list; } - std::unique_ptr