17
17
package uk.digitalsquid.droidpad;
19
19
import uk.digitalsquid.droidpad.buttons.Item;
20
import uk.digitalsquid.droidpad.buttons.Item.ScreenInfo;
20
21
import uk.digitalsquid.droidpad.buttons.Layout;
21
22
import uk.digitalsquid.droidpad.buttons.ModeSpec;
22
23
import uk.digitalsquid.droidpad.buttons.Slider;
82
83
parent.sendEvent(layout);
85
private int widthIter;
86
private int heightIter;
88
private int width, height;
90
86
private float scale = 1;
92
88
private static final Paint P_BLACK = new Paint(0xFF000000);
90
private ScreenInfo tmpScreenInfo = new ScreenInfo();
95
93
public void onDraw(Canvas canvas)
97
95
super.onDraw(canvas);
98
96
scale = getResources().getDisplayMetrics().density;
100
width = (int) ((float)canvas.getWidth() / scale);
101
height = (int) ((float)canvas.getHeight() / scale);
98
float width = (float)canvas.getWidth() / scale;
99
float height = (float)canvas.getHeight() / scale;
103
101
canvas.scale(scale, scale);
105
103
canvas.drawRect(0, 0, width, height, P_BLACK);
106
104
if(isInEditMode()) return;
107
widthIter = width / layout.getWidth();
108
heightIter = height / layout.getHeight();
105
float widthIter = width / layout.getWidth();
106
float heightIter = height / layout.getHeight();
108
tmpScreenInfo.set(width, height, widthIter, heightIter, landscape);
110
110
for(Item item : layout) {
111
item.draw(canvas, widthIter, heightIter, landscape);
111
item.draw(canvas, tmpScreenInfo);
121
121
for(Item item : layout) {
122
if(item.pointIsInArea(x, y)) {
122
if(item.pointIsInArea(tmpScreenInfo, x, y)) {
124
item.onMouseOn(x, y);
124
item.onMouseOn(tmpScreenInfo, x, y);
126
126
item.onMouseOff();
127
127
item.resetStickyLock();