Small adjustments on labels positions

This commit is contained in:
shagr4th 2013-10-06 20:59:25 +02:00
parent 067b23ced8
commit 45d2375873

View file

@ -51,7 +51,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
protected boolean needFlip; protected boolean needFlip;
private short buf []; private short buf [];
private short audiobuf []; private short audiobuf [];
private int currentOrientation; int currentOrientation;
private boolean multiTouch; private boolean multiTouch;
private AudioTrack track; private AudioTrack track;
private TimerTask audioTask; private TimerTask audioTask;
@ -86,6 +86,11 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
int topLeftColor; int topLeftColor;
int topRightColor; int topRightColor;
Paint systemOptionsPaint;
int systemOptions_x;
int systemOptions_y;
boolean systemOptionDisplayed = true;
Paint buttonBorderPaint = new Paint(); Paint buttonBorderPaint = new Paint();
String topLefts [] = new String [MAX_TOUCHES]; String topLefts [] = new String [MAX_TOUCHES];
@ -254,58 +259,94 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
} }
if (drawHeadersAndFooters && topLeft != null) { int tlWidth = 0;
int tlHeight = 0;
int trWidth = 0;
int trHeight = 0;
Paint HeadPurplePaint = regularHeadPurplePaint; Paint HeadPurplePaint = regularHeadPurplePaint;
if (drawHeadersAndFooters && topLeft != null) {
//Paint HeadPurplePaint = regularHeadPurplePaint;
if (topLeft.startsWith("$")) { if (topLeft.startsWith("$")) {
topLeft = topLeft.substring(1); topLeft = topLeft.substring(1);
HeadPurplePaint = asanaHeadPurplePaint; HeadPurplePaint = asanaHeadPurplePaint;
} }
boolean centered = false; //boolean centered = false;
//if (topLeft.startsWith("/")) {
// topLeft = topLeft.substring(1);
// centered = true;
//}
if (topLeft.startsWith("/")) { if (topLeft.startsWith("/")) {
topLeft = topLeft.substring(1); topLeft = topLeft.substring(1);
centered = true;
} }
Rect bounds = new Rect(); Rect bounds = new Rect();
HeadPurplePaint.getTextBounds(topLeft, 0, topLeft.length(), bounds); HeadPurplePaint.getTextBounds(topLeft, 0, topLeft.length(), bounds);
int width = bounds.width(); //int width = bounds.width();
tlWidth = bounds.width();
HeadPurplePaint.getTextBounds("A", 0, 1, bounds); HeadPurplePaint.getTextBounds("A", 0, 1, bounds);
int height = bounds.height(); //int height = bounds.height();
tlHeight = bounds.height();
int cX = centered?(x0 + ((x1 - x0 - width)/2)):x0; //int cX = centered?(x0 + ((x1 - x0 - width)/2)):x0;
backCanvas.drawText(topLeft, cX, height + y0, HeadPurplePaint); //backCanvas.drawText(topLeft, cX, height + y0, HeadPurplePaint);
} }
Paint HeadGreenPaint = regularHeadGreenPaint;
if (drawHeadersAndFooters && topRight != null) { if (drawHeadersAndFooters && topRight != null) {
Paint HeadGreenPaint = regularHeadGreenPaint; //Paint HeadGreenPaint = regularHeadGreenPaint;
if (topRight.startsWith("$")) { if (topRight.startsWith("$")) {
topRight = topRight.substring(1); topRight = topRight.substring(1);
HeadGreenPaint = asanaHeadGreenPaint; HeadGreenPaint = asanaHeadGreenPaint;
} }
boolean centered = false; //boolean centered = false;
//if (topRight.startsWith("/")) {
// topRight = topRight.substring(1);
// centered = true;
//}
if (topRight.startsWith("/")) { if (topRight.startsWith("/")) {
topRight = topRight.substring(1); topRight = topRight.substring(1);
centered = true;
} }
Rect bounds = new Rect(); Rect bounds = new Rect();
HeadGreenPaint.getTextBounds(topRight, 0, topRight.length(), bounds); HeadGreenPaint.getTextBounds(topRight, 0, topRight.length(), bounds);
int width = bounds.width(); //int width = bounds.width();
trWidth = bounds.width();
HeadGreenPaint.getTextBounds("A", 0, 1, bounds); HeadGreenPaint.getTextBounds("A", 0, 1, bounds);
int height = bounds.height(); //int height = bounds.height();
trHeight = bounds.height();
int cX = centered?(x0 + ((x1 - x0 - width)/2)):(x1 - width); //int cX = centered?(x0 + ((x1 - x0 - width)/2)):(x1 - width);
backCanvas.drawText(topRight, cX, height + y0, HeadGreenPaint); //backCanvas.drawText(topRight, cX, height + y0, HeadGreenPaint);
} }
int pad = 0;
if ((tlWidth > 0) && (trWidth > 0)) {
// There is text in top-left and top-right so we calculate a
// suitable width for padding to separate them.
pad = (x1 - x0 - (tlWidth + trWidth)) / 3;
}
int totalWidth = tlWidth + trWidth + pad;
int cX = x0 + ((x1 - x0 - totalWidth)/2);
if (tlWidth > 0) {
backCanvas.drawText(topLeft, cX , tlHeight + y0, HeadPurplePaint);
}
if (trWidth > 0) {
backCanvas.drawText(topRight, cX + tlWidth + pad, trHeight + y0, HeadGreenPaint);
}
if (drawHeadersAndFooters && bottomRight != null) { if (drawHeadersAndFooters && bottomRight != null) {
Rect bounds = new Rect(); Rect bounds = new Rect();
@ -327,7 +368,6 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
if (c != null) { if (c != null) {
if (backBuffer == null) { if (backBuffer == null) {
if (x48.isBitmapSkin()) { if (x48.isBitmapSkin()) {
BitmapFactory.Options opts = new BitmapFactory.Options(); BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false; opts.inScaled = false;
@ -401,12 +441,12 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
null, null, null, null, null, null, null, null, null, null, null, null,
"RAD", null, null, null, null, "PREV", "RAD", null, null, null, null, "PREV",
"UP", "DEF", "NUM", "/PICTURE", "/VIEW", "/SWAP", "UP", "DEF", "NUM", "/PICTURE", "/VIEW", "/SWAP",
" ASIN", " ACOS", " ATAN", " x\u00B2", " 10\u207F", " e\u207F", "ASIN", "ACOS", "ATAN", "x\u00B2", "10\u207F", "e\u207F",
"EQUATION", "EDIT", "PURG", "/CLEAR", "/DROP", "EQUATION", "EDIT", "PURG", "/CLEAR", "/DROP",
"USER", null, null, null, " ( )", "USER", null, null, null, "( )",
null, null, null, null, " [ ]", null, null, null, null, "[ ]",
null, null, null, null, "$\u00AB \u00BB", null, null, null, null, "$\u00AB \u00BB",
" CONT", " =", " ,", " \u03C0", " { }", "CONT", "=", ",", "\u03C0", "{ }",
null, null, null, null, null, null null, null, null, null, null, null
}; };
@ -414,12 +454,12 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
null, null, null, null, null, null, null, null, null, null, null, null,
"POLAR", "/CHARS", "/MODES", "/MEMORY", "/STACK", "MENU", "POLAR", "/CHARS", "/MODES", "/MEMORY", "/STACK", "MENU",
"HOME", "RCL", "UNDO", null, null, null, "HOME", "RCL", "UNDO", null, null, null,
"\u2202 ", "\u222B ", "\u2211 ", "\u207F\u221Ay ", "LOG ", "LN ", "\u2202", "\u222B", "\u2211", "\u207F\u221Ay", "LOG", "LN",
"MATRIX", "CMD", "ARG", null, null, "MATRIX", "CMD", "ARG", null, null,
"ENTRY", "/SOLVE", "/PLOT", "/SYMBOLIC", "# ", "ENTRY", "/SOLVE", "/PLOT", "/SYMBOLIC", "#",
null, "/TIME", "/STAT", "/UNITS", "_ ", null, "/TIME", "/STAT", "/UNITS", "_",
null, "/I/O", "/LIBRARY", "/EQ LIB", "\" \" ", null, "/I/O", "/LIBRARY", "/EQ LIB", "\" \"",
"OFF ", "\u2192 ", "$\u21B5 ", "$\u2221 ", ": : ", "OFF", "\u2192", "$\u21B5", "$\u2221", ": :",
null, null, null, null, null, null null, null, null, null, null, null
}; };
@ -482,6 +522,12 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
asanaFootWhitePaint.setTextSize(asanabuttonTextHeaderSizeDpi); asanaFootWhitePaint.setTextSize(asanabuttonTextHeaderSizeDpi);
asanaFootWhitePaint.setColor(Color.WHITE); asanaFootWhitePaint.setColor(Color.WHITE);
systemOptionsPaint = new Paint();
systemOptionsPaint.setTypeface(regularBold);
systemOptionsPaint.setAntiAlias(antialias);
systemOptionsPaint.setTextSize(regularbuttonTextHeaderSizeDpi);
systemOptionsPaint.setColor(Color.BLACK);
regularHeadGreenPaint = new Paint(); regularHeadGreenPaint = new Paint();
regularHeadGreenPaint.setTypeface(regularBold); regularHeadGreenPaint.setTypeface(regularBold);
regularHeadGreenPaint.setAntiAlias(antialias); regularHeadGreenPaint.setAntiAlias(antialias);
@ -550,6 +596,9 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
menu_key_height = regular_key_height*11/18; menu_key_height = regular_key_height*11/18;
} }
systemOptions_x = lcd_pos_x;
systemOptions_y = (int) (4*lcd_ratio);
icons_coords = new int [][] { { lcd_pos_x, 0 }, {(int)(lcd_pos_x+21*lcd_ratio), 0}, {(int)(lcd_pos_x+45*lcd_ratio), 0}, icons_coords = new int [][] { { lcd_pos_x, 0 }, {(int)(lcd_pos_x+21*lcd_ratio), 0}, {(int)(lcd_pos_x+45*lcd_ratio), 0},
{(int)(lcd_pos_x+67*lcd_ratio), 0}, {(int)(lcd_pos_x+91*lcd_ratio), 0}, {(int)(lcd_pos_x+112*lcd_ratio), 0} }; {(int)(lcd_pos_x+67*lcd_ratio), 0}, {(int)(lcd_pos_x+91*lcd_ratio), 0}, {(int)(lcd_pos_x+112*lcd_ratio), 0} };
int green = Color.rgb(80, 96, 104); int green = Color.rgb(80, 96, 104);
@ -867,6 +916,12 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
c.drawBitmap(annImages[i], icons_coords[i][0], icons_coords[i][1], null); c.drawBitmap(annImages[i], icons_coords[i][0], icons_coords[i][1], null);
} }
if (systemOptionDisplayed) {
c.drawText(getContext().getString(R.string.show_menu), systemOptions_x, systemOptions_y, systemOptionsPaint);
}
} else { } else {
//Log.i("x48", "null canvas !"); //Log.i("x48", "null canvas !");
} }
@ -890,7 +945,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
int actionCode = action & MotionEvent.ACTION_MASK; int actionCode = action & MotionEvent.ACTION_MASK;
int code = -1; int code = -1;
int pointerID = 0; int pointerID = 0;
systemOptionDisplayed = false;
if (multiTouch) { if (multiTouch) {
if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_UP || if( actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_UP ||
actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP ) { actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP ) {
@ -919,14 +974,8 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
} }
} }
if (code == -1 && actionCode == MotionEvent.ACTION_DOWN ) { if (code == -1 && actionCode == MotionEvent.ACTION_DOWN ) {
/*if (x >= menu_button[0] && x <= menu_button[2] && y >= menu_button[1] && y <= menu_button[3]) { ((X48) getContext()).openOptionsMenu();
// call menu
} else if (x >= hidemenu_button[0] && x <= hidemenu_button[2] && y >= hidemenu_button[1] && y <= hidemenu_button[3]) {
// hide menu
} else*/ if (currentOrientation != Configuration.ORIENTATION_LANDSCAPE ) {
((X48) getContext()).changeKeybLite();
return true; return true;
}
} }
if (code > -1) { if (code > -1) {
@ -949,7 +998,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
} }
} }
if (code == -1 && action == MotionEvent.ACTION_DOWN && currentOrientation != Configuration.ORIENTATION_LANDSCAPE ) { if (code == -1 && action == MotionEvent.ACTION_DOWN && currentOrientation != Configuration.ORIENTATION_LANDSCAPE ) {
((X48) getContext()).changeKeybLite(); ((X48) getContext()).openOptionsMenu();
return true; return true;
} }