Improve the Overlapping window source position when Background/Offset is not (0,0) and add the pixel border.

This commit is contained in:
dgis 2020-04-15 23:29:42 +02:00
parent 6343695d7e
commit 30310af532
6 changed files with 79 additions and 33 deletions

View file

@ -68,6 +68,10 @@ Version 1.8beta3 (2020-04-XX)
- Intercept the ESC keyboard key to allow the use of the BACK soft key.
- Add LCD pixel borders.
- Add support for the dark theme.
- Fix issues with Linux build (Fix #11).
- Remove the non loadable file from the MRU file list (Fix #13).
- Hide the menu [Default KML script folder] when the default is already displayed (Fix #5).
- Fix: Overlapping window source position when Background/Offset is not (0,0).
Version 1.7 (2019-12-12)
@ -186,6 +190,8 @@ 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

@ -33,7 +33,7 @@ NOTES
But it works exactly like with Windows. If you can write in the ROM file,
it should save the content of port 2 in the ROM file with Android too.
To save the port 2 in the HP49/50 with Emu48 for Android:
* copy "real50g-lc.kml", "real50g-lc.png", "keyb4950.kmi", "rom.49g" in a FOLDER of your Android device,
* copy "real50g-lc.kml", "real50g-lc.png", "keyb4950.kmi", "rom.49g" in a FOLDER of your Android device,
* in the menu:
- touch "New..." to create a new device
- or touch "Change KML Script..." to change the current KML script and ROM location
@ -52,11 +52,26 @@ NOT WORKING YET
- Serial Ports (Wire or Ir)
LINKS
- Original Emu48 for Windows from Christoph Giesselink and Sébastien Carlier: https://hp.giesselink.com/emu48.htm
- Emu48+ for Windows from Eric Rechlin and Cyrille de Brebission: https://www.hpcalc.org/details/6523
- Droid48 Reader app: https://play.google.com/store/apps/details?id=com.drehersoft.droid48reader or https://www.hpcalc.org/details/7366
- Smart Charlemagne (HP48SX Skins for Android): https://www.hpmuseum.org/forum/thread-14197-post-125336.html or https://www.hpcalc.org/details/9115
- The Museum of HP Calculators Forum: https://www.hpmuseum.org/forum/thread-12540.html
CHANGES
Version 1.8beta2 (2019-12-19)
Version 1.8beta3 (2020-04-XX)
- Intercept the ESC keyboard key to allow the use of the BACK soft key.
- Add LCD pixel borders.
- Add support for the dark theme.
- Fix issues with Linux build (Fix #11).
- Remove the non loadable file from the MRU file list (Fix #13).
- Hide the menu [Default KML script folder] when the default is already displayed (Fix #5).
- Fix: Overlapping window source position when Background/Offset is not (0,0).
Version 1.7 (2019-12-12)

View file

@ -1120,10 +1120,10 @@ JNIEXPORT jint JNICALL Java_org_emulator_calculator_NativeLib_getState(JNIEnv *e
}
JNIEXPORT jint JNICALL Java_org_emulator_calculator_NativeLib_getScreenPositionX(JNIEnv *env, jobject thisz) {
return nLcdX;
return nLcdX - nBackgroundX;
}
JNIEXPORT jint JNICALL Java_org_emulator_calculator_NativeLib_getScreenPositionY(JNIEnv *env, jobject thisz) {
return nLcdY;
return nLcdY - nBackgroundY;
}
JNIEXPORT jint JNICALL Java_org_emulator_calculator_NativeLib_getScreenWidth(JNIEnv *env, jobject thisz) {
return 131*nLcdZoom*nGdiXZoom;

View file

@ -29,6 +29,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import static org.emulator.calculator.MainScreenView.drawPixelBorder;
public class LCDOverlappingView extends View {
protected static final String TAG = "LCDOverlappingView";
@ -47,6 +49,7 @@ public class LCDOverlappingView extends View {
private MainScreenView mainScreenView;
private boolean viewSized = false;
private boolean firstTime = true;
private boolean usePixelBorders = true;
public LCDOverlappingView(Context context, MainScreenView mainScreenView) {
super(context);
@ -56,8 +59,10 @@ public class LCDOverlappingView extends View {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
paint.setFilterBitmap(true);
paint.setAntiAlias(true);
//paint.setFilterBitmap(true);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1.0f);
paint.setAntiAlias(false); //true);
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
@ -217,11 +222,19 @@ public class LCDOverlappingView extends View {
//if(debug) Log.d(TAG, "onDraw()");
if(this.overlappingLCDMode != OVERLAPPING_LCD_MODE_NONE) {
int x = NativeLib.getScreenPositionX();
int y = NativeLib.getScreenPositionY();
srcBitmapCopy.set(x, y, x + NativeLib.getScreenWidth(), y + NativeLib.getScreenHeight());
int lcdPositionX = NativeLib.getScreenPositionX();
int lcdPositionY = NativeLib.getScreenPositionY();
srcBitmapCopy.set(lcdPositionX, lcdPositionY, lcdPositionX + NativeLib.getScreenWidth(), lcdPositionY + NativeLib.getScreenHeight());
dstBitmapCopy.set(0, 0, getWidth(), getHeight());
canvas.drawBitmap(mainScreenView.getBitmap(), srcBitmapCopy, dstBitmapCopy, paint);
if(usePixelBorders) {
int lcdWidthNative = NativeLib.getScreenWidthNative();
if(lcdWidthNative > 0) {
int lcdHeightNative = NativeLib.getScreenHeightNative();
drawPixelBorder(canvas, lcdWidthNative, lcdHeightNative, 0.0f, 0.0f, getWidth(), getHeight(), paint);
}
}
}
}
@ -364,4 +377,9 @@ public class LCDOverlappingView extends View {
this.updateLayout();
}
}
public void setUsePixelBorders(boolean usePixelBorders) {
this.usePixelBorders = usePixelBorders;
postInvalidate();
}
}

View file

@ -367,35 +367,40 @@ public class MainScreenView extends PanAndScaleView {
super.onDraw(canvas);
if(usePixelBorders) {
int lcdPositionX = NativeLib.getScreenPositionX();
int lcdPositionY = NativeLib.getScreenPositionY();
int lcdWidth = NativeLib.getScreenWidth();
int lcdHeight = NativeLib.getScreenHeight();
int lcdWidthNative = NativeLib.getScreenWidthNative();
int lcdHeightNative = NativeLib.getScreenHeightNative();
if(lcdWidthNative > 0) {
int lcdHeightNative = NativeLib.getScreenHeightNative();
int lcdPositionX = NativeLib.getScreenPositionX();
int lcdPositionY = NativeLib.getScreenPositionY();
int lcdWidth = NativeLib.getScreenWidth();
int lcdHeight = NativeLib.getScreenHeight();
float screenPositionX = lcdPositionX * viewScaleFactorX + viewPanOffsetX;
float screenPositionY = lcdPositionY * viewScaleFactorY + viewPanOffsetY;
float screenWidth = lcdWidth * viewScaleFactorX;
float screenHeight = lcdHeight * viewScaleFactorY;
// Draw the LCD grid lines without antialiasing to emulate the genuine pixels borders
int lcdBackgroundColor = 0xFF000000 | NativeLib.getLCDBackgroundColor();
paintLCD.setColor(lcdBackgroundColor);
float stepX = screenWidth / lcdWidthNative;
for(int x = 0; x < lcdWidthNative; x++) {
float screenX = screenPositionX + x * stepX;
canvas.drawLine(screenX, screenPositionY, screenX, screenPositionY + screenHeight, paintLCD);
float screenPositionX = lcdPositionX * viewScaleFactorX + viewPanOffsetX;
float screenPositionY = lcdPositionY * viewScaleFactorY + viewPanOffsetY;
float screenWidth = lcdWidth * viewScaleFactorX;
float screenHeight = lcdHeight * viewScaleFactorY;
drawPixelBorder(canvas, lcdWidthNative, lcdHeightNative, screenPositionX, screenPositionY, screenWidth, screenHeight, paintLCD);
}
float stepY = screenHeight / lcdHeightNative;
for(int y = 0; y < lcdHeightNative; y++) {
float screenY = screenPositionY + y * stepY;
canvas.drawLine(screenPositionX, screenY, screenPositionX + screenWidth, screenY, paintLCD);
}
}
}
public void updateCallback(int type, int param1, int param2, String param3, String param4) {
static void drawPixelBorder(Canvas canvas, int lcdWidthNative, int lcdHeightNative, float screenPositionX, float screenPositionY, float screenWidth, float screenHeight, Paint paintLCD) {
// Draw the LCD grid lines without antialiasing to emulate the genuine pixels borders
int lcdBackgroundColor = 0xFF000000 | NativeLib.getLCDBackgroundColor();
paintLCD.setColor(lcdBackgroundColor);
float stepX = screenWidth / lcdWidthNative;
for (int x = 0; x < lcdWidthNative; x++) {
float screenX = screenPositionX + x * stepX;
canvas.drawLine(screenX, screenPositionY, screenX, screenPositionY + screenHeight, paintLCD);
}
float stepY = screenHeight / lcdHeightNative;
for (int y = 0; y < lcdHeightNative; y++) {
float screenY = screenPositionY + y * stepY;
canvas.drawLine(screenPositionX, screenY, screenPositionX + screenWidth, screenY, paintLCD);
}
}
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()");

View file

@ -1584,7 +1584,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
lcdOverlappingView.setOverlappingLCDMode(overlappingLCDMode);
break;
case "settings_lcd_pixel_borders":
mainScreenView.setUsePixelBorders(sharedPreferences.getBoolean("settings_lcd_pixel_borders", false));
boolean usePixelBorders = sharedPreferences.getBoolean("settings_lcd_pixel_borders", false);
mainScreenView.setUsePixelBorders(usePixelBorders);
lcdOverlappingView.setUsePixelBorders(usePixelBorders);
break;
case "settings_hide_bar":
case "settings_hide_bar_status":