Fix the Overlapping windows not refreshed correctly at the very start (new file).

This commit is contained in:
dgis 2020-04-18 15:37:31 +02:00
parent 30310af532
commit 7860e68d5c
3 changed files with 26 additions and 16 deletions

View file

@ -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.

View file

@ -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();
@ -56,13 +54,13 @@ public class LCDOverlappingView extends View {
this.mainScreenView = mainScreenView;
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();

View file

@ -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();
@ -344,9 +344,15 @@ public class MainScreenView extends PanAndScaleView {
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();
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) + ")");