Skip to content

Commit

Permalink
Fix compute resolutions in Canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Jan 20, 2024
1 parent 3374392 commit 6f389b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions app/src/main/java/javax/microedition/lcdui/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,23 +330,23 @@ public void updateSize() {
}
}

if (virtualWidth > 0) {
if (virtualHeight > 0) {
if (settings.screenWidth > 0) {
if (settings.screenHeight > 0) {
// the width and height of the canvas are strictly set
width = virtualWidth;
height = virtualHeight;
width = settings.screenWidth;
height = settings.screenHeight;
} else {
// only the canvas width is set
// height is selected by the ratio of the real screen
width = virtualWidth;
height = scaledDisplayHeight * virtualWidth / scaledDisplayWidth;
width = settings.screenWidth;
height = scaledDisplayHeight * settings.screenWidth / scaledDisplayWidth;
}
} else {
if (virtualHeight > 0) {
if (settings.screenHeight > 0) {
// only the canvas height is set
// width is selected by the ratio of the real screen
width = scaledDisplayWidth * virtualHeight / scaledDisplayHeight;
height = virtualHeight;
width = scaledDisplayWidth * settings.screenHeight / scaledDisplayHeight;
height = settings.screenHeight;
} else {
// nothing is set - screen-sized canvas
width = scaledDisplayWidth;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/javax/microedition/lcdui/Displayable.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public abstract class Displayable {
private static final int TICKER_SHOW = 1;
private static final int TICKER_HIDE = 2;

protected static int virtualWidth;
protected static int virtualHeight;
private static int virtualWidth;
private static int virtualHeight;

final ArrayList<Command> commands = new ArrayList<>();
CommandListener listener;
Expand Down

0 comments on commit 6f389b4

Please sign in to comment.