diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/Button.cpp | 8 | ||||
-rw-r--r-- | src/gui/GlobalSettingsPage.cpp | 47 | ||||
-rw-r--r-- | src/gui/ScreenshotSettingsPage.cpp | 4 | ||||
-rw-r--r-- | src/gui/SettingsPage.cpp | 6 |
4 files changed, 55 insertions, 10 deletions
diff --git a/src/gui/Button.cpp b/src/gui/Button.cpp index 476e679..d8cb85b 100644 --- a/src/gui/Button.cpp +++ b/src/gui/Button.cpp @@ -105,6 +105,10 @@ namespace gsr { border_scale = scale; } + void Button::set_icon_padding_scale(float scale) { + icon_padding_scale = scale; + } + void Button::set_bg_hover_color(mgl::Color color) { bg_hover_color = color; } @@ -127,8 +131,8 @@ namespace gsr { const float widget_height = get_button_height(); - const int padding_icon_top = padding_top_icon_scale * widget_height; - const int padding_icon_bottom = padding_bottom_icon_scale * widget_height; + const int padding_icon_top = padding_top_icon_scale * icon_padding_scale * widget_height; + const int padding_icon_bottom = padding_bottom_icon_scale * icon_padding_scale * widget_height; const float desired_height = widget_height - (padding_icon_top + padding_icon_bottom); sprite.set_height((int)desired_height); diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp index 1b6e07f..1e2a444 100644 --- a/src/gui/GlobalSettingsPage.cpp +++ b/src/gui/GlobalSettingsPage.cpp @@ -70,6 +70,10 @@ namespace gsr { return 0; } + static bool key_is_alpha_numerical(mgl::Keyboard::Key key) { + return key >= mgl::Keyboard::A && key <= mgl::Keyboard::Num9; + } + GlobalSettingsPage::GlobalSettingsPage(Overlay *overlay, const GsrInfo *gsr_info, Config &config, PageStack *page_stack) : StaticPage(mgl::vec2f(get_theme().window_width, get_theme().window_height).floor()), overlay(overlay), @@ -97,13 +101,13 @@ namespace gsr { mgl::Text title_text("Press a key combination to use for the hotkey \"" + hotkey_configure_action_name + "\":", get_theme().title_font); mgl::Text hotkey_text(configure_hotkey_button->get_text(), get_theme().top_bar_font); - mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel or Backspace to remove the hotkey.", get_theme().body_font); + mgl::Text description_text("Alpha-numerical keys can't be used alone in hotkeys, they have to be used one or more of these keys: Alt, Ctrl, Shift and Super.\nPress Esc to cancel or Backspace to remove the hotkey.", get_theme().body_font); const float text_max_width = std::max(title_text.get_bounds().size.x, std::max(hotkey_text.get_bounds().size.x, description_text.get_bounds().size.x)); const float padding_horizontal = int(get_theme().window_height * 0.01f); const float padding_vertical = int(get_theme().window_height * 0.01f); - const mgl::vec2f bg_size = mgl::vec2f(text_max_width + padding_horizontal*2.0f, get_theme().window_height * 0.1f).floor(); + const mgl::vec2f bg_size = mgl::vec2f(text_max_width + padding_horizontal*2.0f, get_theme().window_height * 0.13f).floor(); mgl::Rectangle bg_rect(mgl::vec2f(get_theme().window_width*0.5f - bg_size.x*0.5f, get_theme().window_height*0.5f - bg_size.y*0.5f).floor(), bg_size); bg_rect.set_color(get_color_theme().page_bg_color); window.draw(bg_rect); @@ -114,9 +118,16 @@ namespace gsr { window.draw(tint_rect); title_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - title_text.get_bounds().size.x*0.5f, padding_vertical)).floor()); + description_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - description_text.get_bounds().size.x*0.5f, bg_rect.get_size().y - description_text.get_bounds().size.y - padding_vertical)).floor()); + window.draw(title_text); - hotkey_text.set_position(mgl::vec2f(bg_rect.get_position() + bg_rect.get_size()*0.5f - hotkey_text.get_bounds().size*0.5f).floor()); + const float title_text_bottom = title_text.get_position().y + title_text.get_bounds().size.y; + hotkey_text.set_position( + mgl::vec2f( + bg_rect.get_position().x + bg_rect.get_size().x*0.5f - hotkey_text.get_bounds().size.x*0.5f, + title_text_bottom + (description_text.get_position().y - title_text_bottom) * 0.5f - hotkey_text.get_bounds().size.y*0.5f + ).floor()); window.draw(hotkey_text); const float caret_padding_x = int(0.001f * get_theme().window_height); @@ -124,7 +135,6 @@ namespace gsr { mgl::Rectangle caret_rect(hotkey_text.get_position() + mgl::vec2f(hotkey_text.get_bounds().size.x + caret_padding_x, hotkey_text.get_bounds().size.y*0.5f - caret_size.y*0.5f).floor(), caret_size); window.draw(caret_rect); - description_text.set_position(mgl::vec2f(bg_rect.get_position() + mgl::vec2f(bg_rect.get_size().x*0.5f - description_text.get_bounds().size.x*0.5f, bg_rect.get_size().y - description_text.get_bounds().size.y - padding_vertical)).floor()); window.draw(description_text); }; hotkey_overlay->set_visible(false); @@ -300,6 +310,21 @@ namespace gsr { return list; } + std::unique_ptr<List> GlobalSettingsPage::create_screenshot_region_hotkey_options() { + auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER); + + list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Take a screenshot of a region:", get_color_theme().text_color)); + auto take_screenshot_region_button = std::make_unique<Button>(&get_theme().body_font, "", mgl::vec2f(0.0f, 0.0f), mgl::Color(0, 0, 0, 120)); + take_screenshot_region_button_ptr = take_screenshot_region_button.get(); + list->add_widget(std::move(take_screenshot_region_button)); + + take_screenshot_region_button_ptr->on_click = [this] { + configure_hotkey_start(ConfigureHotkeyType::TAKE_SCREENSHOT_REGION); + }; + + return list; + } + std::unique_ptr<List> GlobalSettingsPage::create_hotkey_control_buttons() { auto list = std::make_unique<List>(List::Orientation::HORIZONTAL, List::Alignment::CENTER); @@ -311,6 +336,7 @@ namespace gsr { config.replay_config.start_stop_hotkey = {mgl::Keyboard::Unknown, 0}; config.replay_config.save_hotkey = {mgl::Keyboard::Unknown, 0}; config.screenshot_config.take_screenshot_hotkey = {mgl::Keyboard::Unknown, 0}; + config.screenshot_config.take_screenshot_region_hotkey = {mgl::Keyboard::Unknown, 0}; config.main_config.show_hide_hotkey = {mgl::Keyboard::Unknown, 0}; load_hotkeys(); overlay->rebind_all_keyboard_hotkeys(); @@ -351,6 +377,7 @@ namespace gsr { list_ptr->add_widget(create_record_hotkey_options()); list_ptr->add_widget(create_stream_hotkey_options()); list_ptr->add_widget(create_screenshot_hotkey_options()); + list_ptr->add_widget(create_screenshot_region_hotkey_options()); list_ptr->add_widget(create_hotkey_control_buttons()); return subsection; } @@ -363,6 +390,7 @@ namespace gsr { list_ptr->add_widget(std::make_unique<Label>(&get_theme().body_font, "Enable controller hotkeys?", get_color_theme().text_color)); list_ptr->add_widget(create_enable_joystick_hotkeys_button()); list_ptr->add_widget(std::make_unique<LineSeparator>(LineSeparator::Orientation::HORIZONTAL, subsection->get_inner_size().x)); + list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_options_texture, get_theme().body_font.get_character_size(), "to show/hide the UI")); list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_up_texture, get_theme().body_font.get_character_size(), "to take a screenshot")); list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_down_texture, get_theme().body_font.get_character_size(), "to save a replay")); list_ptr->add_widget(create_joystick_hotkey_text(&get_theme().ps4_home_texture, &get_theme().ps4_dpad_left_texture, get_theme().body_font.get_character_size(), "to start/stop recording")); @@ -469,6 +497,7 @@ namespace gsr { start_stop_streaming_button_ptr->set_text(config.streaming_config.start_stop_hotkey.to_string()); take_screenshot_button_ptr->set_text(config.screenshot_config.take_screenshot_hotkey.to_string()); + take_screenshot_region_button_ptr->set_text(config.screenshot_config.take_screenshot_region_hotkey.to_string()); show_hide_button_ptr->set_text(config.main_config.show_hide_hotkey.to_string()); } @@ -506,7 +535,7 @@ namespace gsr { if(mgl::Keyboard::key_is_modifier(event.key.code)) { configure_config_hotkey.modifiers |= mgl_modifier_to_hotkey_modifier(event.key.code); configure_hotkey_button->set_text(configure_config_hotkey.to_string()); - } else if(configure_config_hotkey.modifiers != 0) { + } else if(event.key.code != mgl::Keyboard::Unknown && (configure_config_hotkey.modifiers != 0 || !key_is_alpha_numerical(event.key.code))) { configure_config_hotkey.key = event.key.code; configure_hotkey_button->set_text(configure_config_hotkey.to_string()); configure_hotkey_stop_and_save(); @@ -546,6 +575,8 @@ namespace gsr { return start_stop_streaming_button_ptr; case ConfigureHotkeyType::TAKE_SCREENSHOT: return take_screenshot_button_ptr; + case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION: + return take_screenshot_region_button_ptr; case ConfigureHotkeyType::SHOW_HIDE: return show_hide_button_ptr; } @@ -568,6 +599,8 @@ namespace gsr { return &config.streaming_config.start_stop_hotkey; case ConfigureHotkeyType::TAKE_SCREENSHOT: return &config.screenshot_config.take_screenshot_hotkey; + case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION: + return &config.screenshot_config.take_screenshot_region_hotkey; case ConfigureHotkeyType::SHOW_HIDE: return &config.main_config.show_hide_hotkey; } @@ -582,6 +615,7 @@ namespace gsr { &config.record_config.pause_unpause_hotkey, &config.streaming_config.start_stop_hotkey, &config.screenshot_config.take_screenshot_hotkey, + &config.screenshot_config.take_screenshot_region_hotkey, &config.main_config.show_hide_hotkey }; for(ConfigHotkey *config_hotkey : config_hotkeys) { @@ -621,6 +655,9 @@ namespace gsr { case ConfigureHotkeyType::TAKE_SCREENSHOT: hotkey_configure_action_name = "Take a screenshot"; break; + case ConfigureHotkeyType::TAKE_SCREENSHOT_REGION: + hotkey_configure_action_name = "Take a screenshot of a region"; + break; case ConfigureHotkeyType::SHOW_HIDE: hotkey_configure_action_name = "Show/hide UI"; break; diff --git a/src/gui/ScreenshotSettingsPage.cpp b/src/gui/ScreenshotSettingsPage.cpp index fd75660..2dedd86 100644 --- a/src/gui/ScreenshotSettingsPage.cpp +++ b/src/gui/ScreenshotSettingsPage.cpp @@ -40,6 +40,8 @@ namespace gsr { // record_area_box->add_item("Window", "window"); if(capture_options.region) record_area_box->add_item("Region", "region"); + if(!capture_options.monitors.empty()) + record_area_box->add_item(gsr_info->system_info.display_server == DisplayServer::WAYLAND ? "Focused monitor (Experimental on Wayland)" : "Focused monitor", "focused_monitor"); 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); @@ -270,7 +272,7 @@ namespace gsr { }; if(!capture_options.monitors.empty()) - record_area_box_ptr->set_selected_item(capture_options.monitors.front().name); + record_area_box_ptr->set_selected_item("focused_monitor"); else if(capture_options.portal) record_area_box_ptr->set_selected_item("portal"); else if(capture_options.window) diff --git a/src/gui/SettingsPage.cpp b/src/gui/SettingsPage.cpp index be09f54..663e941 100644 --- a/src/gui/SettingsPage.cpp +++ b/src/gui/SettingsPage.cpp @@ -70,6 +70,8 @@ namespace gsr { record_area_box->add_item("Region", "region"); if(capture_options.focused) record_area_box->add_item("Follow focused window", "focused"); + if(!capture_options.monitors.empty()) + record_area_box->add_item(gsr_info->system_info.display_server == DisplayServer::WAYLAND ? "Focused monitor (Experimental on Wayland)" : "Focused monitor", "focused_monitor"); 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); @@ -370,7 +372,7 @@ namespace gsr { std::unique_ptr<List> SettingsPage::create_video_bitrate() { auto video_bitrate_list = std::make_unique<List>(List::Orientation::VERTICAL); - video_bitrate_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Video bitrate (kbps):", get_color_theme().text_color)); + video_bitrate_list->add_widget(std::make_unique<Label>(&get_theme().body_font, "Video bitrate (Kbps):", get_color_theme().text_color)); video_bitrate_list->add_widget(create_video_bitrate_entry()); video_bitrate_list_ptr = video_bitrate_list.get(); return video_bitrate_list; @@ -560,7 +562,7 @@ namespace gsr { video_quality_box_ptr->on_selection_changed("", video_quality_box_ptr->get_selected_id()); if(!capture_options.monitors.empty()) - record_area_box_ptr->set_selected_item(capture_options.monitors.front().name); + record_area_box_ptr->set_selected_item("focused_monitor"); else if(capture_options.portal) record_area_box_ptr->set_selected_item("portal"); else if(capture_options.window) |