mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 23:20:26 +09:00
Enhance settings page: add scroll position handling for language changes
This commit is contained in:
@@ -124,7 +124,7 @@ namespace gsr {
|
||||
void recreate_global_hotkeys(std::string_view hotkey_option);
|
||||
void update_led_indicator_after_settings_change();
|
||||
void recreate_frontpage_ui_components();
|
||||
void open_settings_page();
|
||||
void open_settings_page(int scroll_y = 0);
|
||||
void xi_setup();
|
||||
void handle_xi_events();
|
||||
void process_key_bindings(mgl::Event &event);
|
||||
@@ -301,6 +301,7 @@ namespace gsr {
|
||||
bool hide_ui = false;
|
||||
bool reload_ui = false;
|
||||
bool reopen_settings_after_reload = false;
|
||||
int pending_settings_scroll_y = 0;
|
||||
double notification_duration_multiplier = 1.0;
|
||||
ClipboardFile clipboard_file;
|
||||
|
||||
|
||||
@@ -53,7 +53,10 @@ namespace gsr {
|
||||
std::function<void(std::string_view hotkey_option)> on_keyboard_hotkey_changed;
|
||||
std::function<void(std::string_view hotkey_option)> on_joystick_hotkey_changed;
|
||||
std::function<void()> on_page_closed;
|
||||
std::function<void()> on_language_changed;
|
||||
std::function<void(int scroll_y)> on_language_changed;
|
||||
|
||||
int get_scroll_y() const;
|
||||
void set_scroll_y(int y);
|
||||
private:
|
||||
void load_hotkeys();
|
||||
|
||||
@@ -116,6 +119,7 @@ namespace gsr {
|
||||
Button *show_hide_button_ptr = nullptr;
|
||||
RadioButton *notification_speed_button_ptr = nullptr;
|
||||
ComboBox *language_combo_box_ptr = nullptr;
|
||||
ScrollablePage *scrollable_page_ptr = nullptr;
|
||||
|
||||
ConfigHotkey configure_config_hotkey;
|
||||
ConfigureHotkeyType configure_hotkey_type = ConfigureHotkeyType::NONE;
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace gsr {
|
||||
void add_widget(std::unique_ptr<Widget> widget);
|
||||
|
||||
void reset_scroll();
|
||||
int get_scroll_target_y() const { return scroll_target_y; }
|
||||
void set_scroll(int y) { scroll_y = y; scroll_target_y = y; }
|
||||
private:
|
||||
void apply_animation();
|
||||
void limit_scroll(double child_height);
|
||||
|
||||
@@ -935,12 +935,14 @@ namespace gsr {
|
||||
|
||||
if(reload_ui) {
|
||||
const bool reopen_settings = reopen_settings_after_reload;
|
||||
const int settings_scroll_y = pending_settings_scroll_y;
|
||||
reload_ui = false;
|
||||
reopen_settings_after_reload = false;
|
||||
pending_settings_scroll_y = 0;
|
||||
if(visible) {
|
||||
recreate_frontpage_ui_components();
|
||||
if(reopen_settings)
|
||||
open_settings_page();
|
||||
open_settings_page(settings_scroll_y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1518,8 +1520,9 @@ namespace gsr {
|
||||
update_ui_recording_started();
|
||||
}
|
||||
|
||||
void Overlay::open_settings_page() {
|
||||
void Overlay::open_settings_page(int scroll_y) {
|
||||
auto settings_page = std::make_unique<GlobalSettingsPage>(this, &gsr_info, config, &page_stack);
|
||||
settings_page->set_scroll_y(scroll_y);
|
||||
|
||||
settings_page->on_startup_changed = [this](bool enable, int exit_status) {
|
||||
if(exit_status == 0)
|
||||
@@ -1575,7 +1578,8 @@ namespace gsr {
|
||||
stream_dropdown_button_ptr->set_item_description("start", config.streaming_config.start_stop_hotkey.to_string(false, false));
|
||||
};
|
||||
|
||||
settings_page->on_language_changed = [this]() {
|
||||
settings_page->on_language_changed = [this](int scroll_y) {
|
||||
pending_settings_scroll_y = scroll_y;
|
||||
reload_ui = true;
|
||||
reopen_settings_after_reload = true;
|
||||
};
|
||||
@@ -1590,6 +1594,7 @@ namespace gsr {
|
||||
hide_ui = false;
|
||||
reload_ui = false;
|
||||
reopen_settings_after_reload = false;
|
||||
pending_settings_scroll_y = 0;
|
||||
|
||||
mgl_context *context = mgl_get_context();
|
||||
Display *display = (Display*)context->connection;
|
||||
|
||||
@@ -538,7 +538,7 @@ namespace gsr {
|
||||
Translation::instance().load_language(id);
|
||||
config.main_config.language = std::string(id);
|
||||
if(on_language_changed)
|
||||
on_language_changed();
|
||||
on_language_changed(get_scroll_y());
|
||||
return true;
|
||||
};
|
||||
list->add_widget(std::move(combo_box));
|
||||
@@ -611,6 +611,7 @@ namespace gsr {
|
||||
|
||||
void GlobalSettingsPage::add_widgets() {
|
||||
auto scrollable_page = std::make_unique<ScrollablePage>(content_page_ptr->get_inner_size());
|
||||
scrollable_page_ptr = scrollable_page.get();
|
||||
|
||||
auto settings_list = std::make_unique<List>(List::Orientation::VERTICAL);
|
||||
settings_list->set_spacing(0.018f);
|
||||
@@ -626,6 +627,15 @@ namespace gsr {
|
||||
content_page_ptr->add_widget(std::move(scrollable_page));
|
||||
}
|
||||
|
||||
int GlobalSettingsPage::get_scroll_y() const {
|
||||
return scrollable_page_ptr ? scrollable_page_ptr->get_scroll_target_y() : 0;
|
||||
}
|
||||
|
||||
void GlobalSettingsPage::set_scroll_y(int y) {
|
||||
if(scrollable_page_ptr)
|
||||
scrollable_page_ptr->set_scroll(y);
|
||||
}
|
||||
|
||||
void GlobalSettingsPage::on_navigate_away_from_page() {
|
||||
save();
|
||||
if(on_page_closed)
|
||||
|
||||
Reference in New Issue
Block a user