option menu: don't subtract nav bar size from width and fix width on 4:3 aspect ratio, don't overscroll when clicking on a category

This commit is contained in:
yugecin 2017-05-29 02:18:25 +02:00
parent 02632deff0
commit 7a51828102
3 changed files with 6 additions and 4 deletions

View File

@ -47,7 +47,7 @@ public class KineticScrolling {
private float totalDelta; private float totalDelta;
/** The maximum and minimum value the position can reach. */ /** The maximum and minimum value the position can reach. */
private float max = Float.MAX_VALUE, min = -Float.MAX_VALUE; public float max = Float.MAX_VALUE, min = -Float.MAX_VALUE;
/** Whether the mouse is currently pressed or not. */ /** Whether the mouse is currently pressed or not. */
private boolean pressed = false; private boolean pressed = false;

View File

@ -467,7 +467,7 @@ public class DisplayContainer implements ErrorDumpable, ResolutionChangedListene
} }
public boolean isWidescreen() { public boolean isWidescreen() {
return width * 1000 / height == 1777; // 16:9 return width * 1000 / height > 1500; // 1777 = 16:9, 1333 = 4:3
} }
@Override @Override

View File

@ -184,11 +184,12 @@ public class OptionsOverlay extends OverlayOpsuState {
public void revalidate() { public void revalidate() {
super.revalidate(); super.revalidate();
targetWidth = Math.max((int) (displayContainer.width * 0.36f), 340); // 0.321f boolean isWidescreen = displayContainer.isWidescreen();
targetWidth = (int) (displayContainer.width * (isWidescreen ? 0.4f : 0.5f));
height = displayContainer.height; height = displayContainer.height;
// calculate positions // calculate positions
float navIconWidthRatio = displayContainer.isWidescreen() ? 0.046875f : 0.065f; float navIconWidthRatio = isWidescreen ? 0.046875f : 0.065f;
// non-widescreen ratio is not accurate // non-widescreen ratio is not accurate
navButtonSize = (int) (displayContainer.width * navIconWidthRatio); navButtonSize = (int) (displayContainer.width * navIconWidthRatio);
navIndicatorSize = navButtonSize / 10; navIndicatorSize = navButtonSize / 10;
@ -869,6 +870,7 @@ public class OptionsOverlay extends OverlayOpsuState {
} }
} }
} }
sectionPosition = Utils.clamp(sectionPosition, (int) scrollHandler.min, (int) scrollHandler.max);
scrollHandler.scrollToPosition(sectionPosition); scrollHandler.scrollToPosition(sectionPosition);
} }