diff --git a/include/frontend.hpp b/include/frontend.hpp index ed1e5ab..18a2c9f 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -76,6 +76,12 @@ private: bool call_blur; bool call_screen_settings_update; }; + struct ResizingScreenData { + sf::Vector2f size; + int *scaling; + int rotation; + const PARData *par; + }; CaptureStatus* capture_status; std::string win_title; sf::RenderWindow m_win; @@ -187,7 +193,7 @@ private: void menu_scaling_change(bool positive); void window_scaling_change(bool positive); void rotation_change(int &value, bool right); - void ratio_change(bool top_priority); + void ratio_change(bool top_priority, bool cycle = false); void bfi_change(); void bottom_pos_change(int new_bottom_pos); bool query_reset_request(); @@ -206,8 +212,8 @@ private: void window_render_call(); void set_position_screens(sf::Vector2f &curr_top_screen_size, sf::Vector2f &curr_bot_screen_size, int offset_x, int offset_y, int max_x, int max_y, bool do_work = true); int prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotation, int width_limit, int height_limit, int other_rotation, const PARData *own_par); - void calc_scaling_resize_screens(sf::Vector2f &own_screen_size, sf::Vector2f &other_screen_size, int &own_scaling, int &other_scaling, int own_rotation, int other_rotation, bool increase, bool mantain, bool set_to_zero, const PARData *own_par, const PARData *other_par); - void prepare_size_ratios(bool top_increase, bool bot_increase); + void calc_scaling_resize_screens(ResizingScreenData *own_screen, ResizingScreenData* other_screen, bool increase, bool mantain, bool set_to_zero, bool cycle); + void prepare_size_ratios(bool top_increase, bool bot_increase, bool cycle = false); int get_fullscreen_offset_x(int top_width, int top_height, int bot_width, int bot_height); int get_fullscreen_offset_y(int top_width, int top_height, int bot_width, int bot_height); void resize_window_and_out_rects(bool do_work = true); diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index f13d375..79d6484 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -554,48 +554,50 @@ int WindowScreen::prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotati return height_ratio; } -void WindowScreen::calc_scaling_resize_screens(sf::Vector2f &own_screen_size, sf::Vector2f &other_screen_size, int &own_scaling, int &other_scaling, int own_rotation, int other_rotation, bool increase, bool mantain, bool set_to_zero, const PARData* own_par, const PARData* other_par) { - int min_other_width = other_screen_size.x; - int min_other_height = other_screen_size.y; - get_par_size(min_other_width, min_other_height, 1, other_par); - int chosen_ratio = prepare_screen_ratio(own_screen_size, own_rotation, min_other_width, min_other_height, other_rotation, own_par); +void WindowScreen::calc_scaling_resize_screens(ResizingScreenData *own_screen, ResizingScreenData* other_screen, bool increase, bool mantain, bool set_to_zero, bool cycle) { + int other_width = other_screen->size.x; + int other_height = other_screen->size.y; + get_par_size(other_width, other_height, 1, other_screen->par); + int chosen_ratio = prepare_screen_ratio(own_screen->size, own_screen->rotation, other_width, other_height, other_screen->rotation, own_screen->par); if(chosen_ratio <= 0) { - chosen_ratio = prepare_screen_ratio(own_screen_size, own_rotation, 0, 0, other_rotation, own_par); + chosen_ratio = prepare_screen_ratio(own_screen->size, own_screen->rotation, 0, 0, other_screen->rotation, own_screen->par); if(chosen_ratio <= 0) chosen_ratio = 0; } - int old_scaling = own_scaling; - if(increase && (chosen_ratio > own_scaling) && (chosen_ratio > 0)) - own_scaling += 1; - else if(mantain && (chosen_ratio >= own_scaling) && (chosen_ratio > 0) && (own_scaling >= 0)) - own_scaling = own_scaling; + int old_scaling = (*own_screen->scaling); + if(increase && (chosen_ratio > (*own_screen->scaling)) && (chosen_ratio > 0)) + (*own_screen->scaling) += 1; + else if(mantain && (chosen_ratio >= (*own_screen->scaling)) && (chosen_ratio > 0) && ((*own_screen->scaling) >= 0)) + (*own_screen->scaling) = (*own_screen->scaling); + else if(cycle && (chosen_ratio <= (*own_screen->scaling)) && ((*other_screen->scaling) == 0)) + (*own_screen->scaling) = 0; else - own_scaling = chosen_ratio; + (*own_screen->scaling) = chosen_ratio; if(set_to_zero) - own_scaling = 0; - int own_height = own_screen_size.y; - int own_width = own_screen_size.x; - get_par_size(own_width, own_height, own_scaling, own_par); - if((increase && ((old_scaling == own_scaling) || (other_scaling == 0)) || (mantain && (other_scaling == 0))) && (own_scaling > 0)) - other_scaling = 0; + (*own_screen->scaling) = 0; + int own_height = own_screen->size.y; + int own_width = own_screen->size.x; + get_par_size(own_width, own_height, (*own_screen->scaling), own_screen->par); + if((increase && ((old_scaling == (*own_screen->scaling)) || ((*other_screen->scaling) == 0)) || (mantain && ((*other_screen->scaling) == 0))) && ((*own_screen->scaling) > 0)) + (*other_screen->scaling) = 0; else - other_scaling = prepare_screen_ratio(other_screen_size, other_rotation, own_width, own_height, own_rotation, other_par); - if(other_scaling < 0) - other_scaling = 0; - if((this->m_stype == ScreenType::JOINT) && ((own_scaling > 0) || ((other_scaling == 0) && (own_scaling == 0)))) { + (*other_screen->scaling) = prepare_screen_ratio(other_screen->size, other_screen->rotation, own_width, own_height, own_screen->rotation, other_screen->par); + if((*other_screen->scaling) < 0) + (*other_screen->scaling) = 0; + if((this->m_stype == ScreenType::JOINT) && (((*own_screen->scaling) > 0) || (((*other_screen->scaling) == 0) && ((*own_screen->scaling) == 0)))) { // Due to size differences, it may be possible that // the chosen screen might be able to increase its // scaling even more without compromising the other one... - int other_height = other_screen_size.y; - int other_width = other_screen_size.x; - get_par_size(other_width, other_height, other_scaling, other_par); - own_scaling = prepare_screen_ratio(own_screen_size, own_rotation, other_width, other_height, other_rotation, own_par); - if(own_scaling < 0) - own_scaling = 0; + other_width = other_screen->size.x; + other_height = other_screen->size.y; + get_par_size(other_width, other_height, *other_screen->scaling, other_screen->par); + (*own_screen->scaling) = prepare_screen_ratio(own_screen->size, own_screen->rotation, other_width, other_height, other_screen->rotation, own_screen->par); + if((*own_screen->scaling) < 0) + (*own_screen->scaling) = 0; } } -void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase) { +void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase, bool cycle) { if(!this->m_info.is_fullscreen) return; @@ -616,10 +618,12 @@ void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase) { bot_increase = false; } bool prioritize_top = (!bot_increase) && (top_increase || (this->m_info.bottom_pos == UNDER_TOP) || (this->m_info.bottom_pos == RIGHT_TOP)); + ResizingScreenData top_screen_resize_data = {.size = top_screen_size, .scaling = &this->m_info.top_scaling, .rotation = this->m_info.top_rotation, .par = this->possible_pars[this->m_info.top_par]}; + ResizingScreenData bot_screen_resize_data = {.size = bot_screen_size, .scaling = &this->m_info.bot_scaling, .rotation = this->m_info.bot_rotation, .par = this->possible_pars[this->m_info.bot_par]}; if(prioritize_top) - calc_scaling_resize_screens(top_screen_size, bot_screen_size, this->m_info.top_scaling, this->m_info.bot_scaling, this->m_info.top_rotation, this->m_info.bot_rotation, top_increase, try_mantain_ratio, this->m_stype == ScreenType::BOTTOM, this->possible_pars[this->m_info.top_par], this->possible_pars[this->m_info.bot_par]); + calc_scaling_resize_screens(&top_screen_resize_data, &bot_screen_resize_data, top_increase, try_mantain_ratio, this->m_stype == ScreenType::BOTTOM, cycle); else - calc_scaling_resize_screens(bot_screen_size, top_screen_size, this->m_info.bot_scaling, this->m_info.top_scaling, this->m_info.bot_rotation, this->m_info.top_rotation, bot_increase, try_mantain_ratio, this->m_stype == ScreenType::TOP, this->possible_pars[this->m_info.bot_par], this->possible_pars[this->m_info.top_par]); + calc_scaling_resize_screens(&bot_screen_resize_data, &top_screen_resize_data, bot_increase, try_mantain_ratio, this->m_stype == ScreenType::TOP, cycle); } int WindowScreen::get_fullscreen_offset_x(int top_width, int top_height, int bot_width, int bot_height) { diff --git a/source/WindowScreen_Menu.cpp b/source/WindowScreen_Menu.cpp index 3b82e55..f261461 100755 --- a/source/WindowScreen_Menu.cpp +++ b/source/WindowScreen_Menu.cpp @@ -240,8 +240,8 @@ void WindowScreen::rotation_change(int &value, bool right) { this->future_operations.call_rotate = true; } -void WindowScreen::ratio_change(bool top_priority) { - this->prepare_size_ratios(top_priority, !top_priority); +void WindowScreen::ratio_change(bool top_priority, bool cycle) { + this->prepare_size_ratios(top_priority, !top_priority, cycle); this->future_operations.call_screen_settings_update = true; } @@ -585,10 +585,22 @@ bool WindowScreen::no_menu_poll(SFEvent &event_data) { case sf::Event::KeyPressed: switch(event_data.code) { case sf::Keyboard::Enter: - this->setup_main_menu(); + if(event_data.is_extra) + this->ratio_change(true, true); + else + this->setup_main_menu(); break; case sf::Keyboard::PageDown: - this->setup_main_menu(); + if(event_data.is_extra) + this->setup_main_menu(); + else + consumed = false; + break; + case sf::Keyboard::PageUp: + if(event_data.is_extra) + this->crop_value_change(this->m_info.crop_kind + 1); + else + consumed = false; break; default: consumed = false;