diff options
| author | StapleButter <thetotalworm@gmail.com> | 2017-10-30 05:08:04 +0100 | 
|---|---|---|
| committer | StapleButter <thetotalworm@gmail.com> | 2017-10-30 05:08:04 +0100 | 
| commit | f4e7e2f62a3eb69a988689e5c25bee72bcc3bffb (patch) | |
| tree | dda09443c88dfff53a5125a77b284ebb15eba33e /src/libui_sdl | |
| parent | c9082cd50d448bcdd7999c09fe047be4c1cb2e85 (diff) | |
fix aspect ratio code
Diffstat (limited to 'src/libui_sdl')
| -rw-r--r-- | src/libui_sdl/main.cpp | 29 | 
1 files changed, 15 insertions, 14 deletions
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index cea9f41..83b3bdf 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -397,28 +397,29 @@ void OnAreaResize(uiAreaHandler* handler, uiArea* area, int width, int height)          // top then bottom          int widthreq; -        int possibleheight; +        int startY = 0;          if (sizemode == 0) // even          {              widthreq = (height * screenW) / (screenH*2); +            if (widthreq > width) +            { +                int newheight = (width * height) / widthreq; +                startY = (height - newheight) / 2; +                widthreq = width; +                height = newheight; +            }          }          else // emph. top/bottom          {              widthreq = ((height - screenH) * screenW) / screenH; -        } - -        int startY; -        if (widthreq > width) -        { -            possibleheight = (width * height) / widthreq; -            startY = (height - possibleheight) / 2; -            widthreq = width; -        } -        else -        { -            possibleheight = height; -            startY = 0; +            if (widthreq > width) +            { +                int newheight = ((width * (height - screenH)) / widthreq) + screenH; +                startY = (height - newheight) / 2; +                widthreq = width; +                height = newheight; +            }          }          if (sizemode == 2)  |