From 7860e68d5cfc615f401b4943d88dca5c1404274f Mon Sep 17 00:00:00 2001 From: dgis Date: Sat, 18 Apr 2020 15:37:31 +0200 Subject: [PATCH] Fix the Overlapping windows not refreshed correctly at the very start (new file). --- ReadMe.txt | 1 - .../calculator/LCDOverlappingView.java | 13 ++++----- .../emulator/calculator/MainScreenView.java | 28 +++++++++++++------ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index 213ad15..4b77804 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -191,7 +191,6 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp/png") are embedded in this a TODO - Anyway that the layout settings (zoom mode, fill screen...) be part of the saved state, rather than being global to the app (Vincent Weber). -- Overlapping windows not refresh correctly at the very start (new file). - Add the name of the file in the toast "State saved". - The clock seems unsynchronized sometimes. - Retain a key by right clicking if it is from a mouse. diff --git a/app/src/main/java/org/emulator/calculator/LCDOverlappingView.java b/app/src/main/java/org/emulator/calculator/LCDOverlappingView.java index 56b5437..3c604a3 100644 --- a/app/src/main/java/org/emulator/calculator/LCDOverlappingView.java +++ b/app/src/main/java/org/emulator/calculator/LCDOverlappingView.java @@ -17,9 +17,7 @@ package org.emulator.calculator; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; -import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; import android.graphics.Rect; import android.preference.PreferenceManager; @@ -34,7 +32,7 @@ import static org.emulator.calculator.MainScreenView.drawPixelBorder; public class LCDOverlappingView extends View { protected static final String TAG = "LCDOverlappingView"; - protected final boolean debug = false; + protected final boolean debug = true; private SharedPreferences sharedPreferences; private Paint paint = new Paint(); @@ -55,14 +53,14 @@ public class LCDOverlappingView extends View { super(context); this.mainScreenView = mainScreenView; - this.mainScreenView.setOnUpdateLayoutListener(this::updateLayout); + this.mainScreenView.setOnUpdateLayoutListener(this::updateLayout); + this.mainScreenView.setOnUpdateDisplayListener(this::postInvalidate); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); - //paint.setFilterBitmap(true); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(1.0f); - paint.setAntiAlias(false); //true); + paint.setAntiAlias(false); DisplayMetrics displayMetrics = new DisplayMetrics(); ((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); @@ -219,7 +217,8 @@ public class LCDOverlappingView extends View { @Override protected void onDraw(Canvas canvas) { - //if(debug) Log.d(TAG, "onDraw()"); + if(debug) + Log.d(TAG, "onDraw()"); if(this.overlappingLCDMode != OVERLAPPING_LCD_MODE_NONE) { int lcdPositionX = NativeLib.getScreenPositionX(); diff --git a/app/src/main/java/org/emulator/calculator/MainScreenView.java b/app/src/main/java/org/emulator/calculator/MainScreenView.java index 7d07f5b..9a81cda 100644 --- a/app/src/main/java/org/emulator/calculator/MainScreenView.java +++ b/app/src/main/java/org/emulator/calculator/MainScreenView.java @@ -37,7 +37,7 @@ import java.util.Set; public class MainScreenView extends PanAndScaleView { protected static final String TAG = "MainScreenView"; - protected final boolean debug = false; + protected final boolean debug = true; private Paint paintFullCalc = new Paint(); private Paint paintLCD = new Paint(); @@ -338,15 +338,21 @@ public class MainScreenView extends PanAndScaleView { } } - private Runnable onUpdateLayoutListener = null; + private Runnable onUpdateLayoutListener = null; - public void setOnUpdateLayoutListener(Runnable onUpdateLayoutListener) { - this.onUpdateLayoutListener = onUpdateLayoutListener; - } + public void setOnUpdateLayoutListener(Runnable onUpdateLayoutListener) { + this.onUpdateLayoutListener = onUpdateLayoutListener; + } + + private Runnable onUpdateDisplayListener = null; + + public void setOnUpdateDisplayListener(Runnable onUpdateDisplayListener) { + this.onUpdateDisplayListener = onUpdateDisplayListener; + } @Override protected void onCustomDraw(Canvas canvas) { - //Log.d(TAG, "onCustomDraw()"); + if (debug) Log.d(TAG, "onCustomDraw()"); canvas.drawColor(getBackgroundColor()); @@ -364,6 +370,9 @@ public class MainScreenView extends PanAndScaleView { @Override public void onDraw(Canvas canvas) { + if (debug) + Log.d(TAG, "onDraw()"); + super.onDraw(canvas); if(usePixelBorders) { @@ -403,10 +412,13 @@ public class MainScreenView extends PanAndScaleView { public void updateCallback(int type, int param1, int param2, String param3, String param4) { switch (type) { case NativeLib.CALLBACK_TYPE_INVALIDATE: - //Log.d(TAG, "PAINT updateCallback() postInvalidate()"); + if (debug) Log.d(TAG, "updateCallback() CALLBACK_TYPE_INVALIDATE postInvalidate()"); postInvalidate(); - break; + if(this.onUpdateDisplayListener != null) + this.onUpdateDisplayListener.run(); + break; case NativeLib.CALLBACK_TYPE_WINDOW_RESIZE: + if (debug) Log.d(TAG, "updateCallback() CALLBACK_TYPE_WINDOW_RESIZE()"); // New Bitmap size if(bitmapMainScreen == null || bitmapMainScreen.getWidth() != param1 || bitmapMainScreen.getHeight() != param2) { if(debug) Log.d(TAG, "updateCallback() Bitmap.createBitmap(x: " + Math.max(1, param1) + ", y: " + Math.max(1, param2) + ")");