fix(fullscreen): preservar zoom_factor_ de windowed durant transicions a fullscreen
Quan arribava un SDL_EVENT_WINDOW_RESIZED en fullscreen, recalculàvem zoom_factor_ a partir de la mida física i el clampàvem a max_zoom_. Això "consumia" el zoom_factor_ que tenia l'usuari en windowed, així que en tornar a windowed (F3) la mida quedava la del clamp, no la prèvia. Ara, en fullscreen, zoom_factor_ i windowed_*_ es deixen intactes (no participen del càlcul del viewport, que ja és aspect-fit sobre la mida física). En windowed, comportament inalterat.
This commit is contained in:
@@ -277,11 +277,13 @@ auto SDLManager::handleWindowEvent(const SDL_Event& event) -> bool {
|
||||
if (event.type == SDL_EVENT_WINDOW_RESIZED) {
|
||||
SDL_GetWindowSize(finestra_, ¤t_width_, ¤t_height_);
|
||||
|
||||
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH;
|
||||
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM,
|
||||
std::min(new_zoom, max_zoom_));
|
||||
|
||||
// En fullscreen el zoom_factor_ no participa del viewport (aspect-fit
|
||||
// sobre la mida física), així que el preservem amb el valor de
|
||||
// windowed per no perdre'l en tornar a windowed.
|
||||
if (!is_fullscreen_) {
|
||||
float new_zoom = static_cast<float>(current_width_) / Defaults::Window::WIDTH;
|
||||
zoom_factor_ = std::max(Defaults::Window::MIN_ZOOM,
|
||||
std::min(new_zoom, max_zoom_));
|
||||
windowed_width_ = current_width_;
|
||||
windowed_height_ = current_height_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user