aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/LineSeparator.cpp2
-rw-r--r--src/gui/RadioButton.cpp47
-rw-r--r--src/gui/SettingsPage.cpp25
3 files changed, 55 insertions, 19 deletions
diff --git a/src/gui/LineSeparator.cpp b/src/gui/LineSeparator.cpp
index 637c84f..040a75a 100644
--- a/src/gui/LineSeparator.cpp
+++ b/src/gui/LineSeparator.cpp
@@ -16,7 +16,7 @@ namespace gsr {
};
}
- LineSeparator::LineSeparator(Type type, float width) : type(type), width(width) {
+ LineSeparator::LineSeparator(Orientation orientation, float width) : orientation(orientation), width(width) {
}
diff --git a/src/gui/RadioButton.cpp b/src/gui/RadioButton.cpp
index 8c937c6..061d811 100644
--- a/src/gui/RadioButton.cpp
+++ b/src/gui/RadioButton.cpp
@@ -14,7 +14,7 @@ namespace gsr {
static const float spacing_scale = 0.007f;
static const float border_scale = 0.0015f;
- RadioButton::RadioButton(mgl::Font *font) : font(font) {
+ RadioButton::RadioButton(mgl::Font *font, Orientation orientation) : font(font), orientation(orientation) {
}
@@ -44,7 +44,14 @@ namespace gsr {
return false;
}
- draw_pos.x += item_size.x + spacing_scale * get_theme().window_height;
+ switch(orientation) {
+ case Orientation::VERTICAL:
+ draw_pos.y += item_size.y + spacing_scale * get_theme().window_height;
+ break;
+ case Orientation::HORIZONTAL:
+ draw_pos.x += item_size.x + spacing_scale * get_theme().window_height;
+ break;
+ }
}
}
return true;
@@ -85,7 +92,14 @@ namespace gsr {
item.text.set_position((draw_pos + item_size * 0.5f - item.text.get_bounds().size * 0.5f).floor());
window.draw(item.text);
- draw_pos.x += item_size.x + spacing_scale * get_theme().window_height;
+ switch(orientation) {
+ case Orientation::VERTICAL:
+ draw_pos.y += item_size.y + spacing_scale * get_theme().window_height;
+ break;
+ case Orientation::HORIZONTAL:
+ draw_pos.x += item_size.x + spacing_scale * get_theme().window_height;
+ break;
+ }
}
}
@@ -98,13 +112,32 @@ namespace gsr {
const int padding_left = padding_left_scale * get_theme().window_height;
const int padding_right = padding_right_scale * get_theme().window_height;
- size = { 0.0f, font->get_character_size() + (float)padding_top + (float)padding_bottom };
+ size = { 0.0f, 0.0f };
for(Item &item : items) {
const mgl::vec2f bounds = item.text.get_bounds().size;
- size.x += bounds.x + padding_left + padding_right;
+ switch(orientation) {
+ case Orientation::VERTICAL:
+ size.x = std::max(size.x, bounds.x + padding_left + padding_right);
+ size.y += bounds.y + padding_top + padding_bottom;
+ break;
+ case Orientation::HORIZONTAL:
+ size.x += bounds.x + padding_left + padding_right;
+ size.y = font->get_character_size() + (float)padding_top + (float)padding_bottom;
+ break;
+ }
}
- if(items.size() > 1)
- size.x += (items.size() - 1) * spacing_scale * get_theme().window_height;
+
+ if(items.size() > 1) {
+ switch(orientation) {
+ case Orientation::VERTICAL:
+ size.y += (items.size() - 1) * spacing_scale * get_theme().window_height;
+ break;
+ case Orientation::HORIZONTAL:
+ size.x += (items.size() - 1) * spacing_scale * get_theme().window_height;
+ break;
+ }
+ }
+
dirty = false;
}
diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp
index 083fec5..7f50363 100644
--- a/src/gui/SettingsPage.cpp
+++ b/src/gui/SettingsPage.cpp
@@ -42,7 +42,7 @@ namespace gsr {
}
std::unique_ptr<RadioButton> SettingsPage::create_view_radio_button() {
- auto view_radio_button = std::make_unique<RadioButton>(&get_theme().body_font);
+ auto view_radio_button = std::make_unique<RadioButton>(&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);
@@ -228,7 +228,7 @@ namespace gsr {
}
std::unique_ptr<RadioButton> SettingsPage::create_audio_type_button() {
- auto audio_type_radio_button = std::make_unique<RadioButton>(&get_theme().body_font);
+ auto audio_type_radio_button = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::HORIZONTAL);
audio_type_radio_button->add_item("Audio devices", "audio_devices");
audio_type_radio_button->add_item("Application audio", "app_audio");
audio_type_radio_button_ptr = audio_type_radio_button.get();
@@ -321,10 +321,10 @@ namespace gsr {
auto audio_section = std::make_unique<Subsection>("Audio", std::move(audio_device_section_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f));
audio_device_section_list_ptr->add_widget(create_audio_type_button());
- audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Type::HORIZONTAL, audio_section->get_inner_size().x));
+ audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, audio_section->get_inner_size().x));
audio_device_section_list_ptr->add_widget(create_audio_device_section());
audio_device_section_list_ptr->add_widget(create_application_audio_section());
- //audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Type::HORIZONTAL, audio_section->get_inner_size().x));
+ //audio_device_section_list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, audio_section->get_inner_size().x));
audio_device_section_list_ptr->add_widget(create_merge_audio_tracks_checkbox());
audio_device_section_list_ptr->add_widget(create_audio_codec());
return audio_section;
@@ -646,10 +646,13 @@ namespace gsr {
return replay_time_list;
}
- std::unique_ptr<CheckBox> SettingsPage::create_start_replay_on_startup() {
- auto checkbox = std::make_unique<CheckBox>(&get_theme().body_font, "Turn on replay automatically");
- start_replay_automatically_ptr = checkbox.get();
- return checkbox;
+ std::unique_ptr<RadioButton> SettingsPage::create_start_replay_automatically() {
+ auto radiobutton = std::make_unique<RadioButton>(&get_theme().body_font, RadioButton::Orientation::VERTICAL);
+ radiobutton->add_item("Don't turn on replay automatically", "dont_turn_on_automatically");
+ radiobutton->add_item("Turn on replay at system startup", "turn_on_at_system_startup");
+ radiobutton->add_item("Turn on replay when starting a fullscreen application", "turn_on_at_fullscreen");
+ turn_on_replay_automatically_mode_ptr = radiobutton.get();
+ return radiobutton;
}
std::unique_ptr<CheckBox> SettingsPage::create_save_replay_in_game_folder() {
@@ -685,7 +688,7 @@ namespace gsr {
settings_list_ptr->add_widget(std::make_unique<Subsection>("File info", std::move(file_info_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
auto general_list = std::make_unique<List>(List::Orientation::VERTICAL);
- general_list->add_widget(create_start_replay_on_startup());
+ general_list->add_widget(create_start_replay_automatically());
general_list->add_widget(create_save_replay_in_game_folder());
settings_list_ptr->add_widget(std::make_unique<Subsection>("General", std::move(general_list), mgl::vec2f(settings_scrollable_page_ptr->get_inner_size().x, 0.0f)));
@@ -1015,7 +1018,7 @@ namespace gsr {
void SettingsPage::load_replay() {
load_common(config.replay_config.record_options);
- start_replay_automatically_ptr->set_checked(config.replay_config.start_replay_automatically);
+ turn_on_replay_automatically_mode_ptr->set_selected_item(config.replay_config.turn_on_replay_automatically_mode);
save_replay_in_game_folder_ptr->set_checked(config.replay_config.save_video_in_game_folder);
show_replay_started_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_started_notifications);
show_replay_stopped_notification_checkbox_ptr->set_checked(config.replay_config.show_replay_stopped_notifications);
@@ -1142,7 +1145,7 @@ namespace gsr {
void SettingsPage::save_replay() {
save_common(config.replay_config.record_options);
- config.replay_config.start_replay_automatically = start_replay_automatically_ptr->is_checked();
+ config.replay_config.turn_on_replay_automatically_mode = turn_on_replay_automatically_mode_ptr->get_selected_id();
config.replay_config.save_video_in_game_folder = save_replay_in_game_folder_ptr->is_checked();
config.replay_config.show_replay_started_notifications = show_replay_started_notification_checkbox_ptr->is_checked();
config.replay_config.show_replay_stopped_notifications = show_replay_stopped_notification_checkbox_ptr->is_checked();