mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 03:52:48 +00:00
Leave a margin around the d-pad so the selection rectangle doesn't draw over the control itself
This commit is contained in:
parent
2806aee0fc
commit
cb6d4a385c
@ -22,6 +22,8 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
public final static int DIGITAL_PAD_DIRECTION_DOWN = 8;
|
public final static int DIGITAL_PAD_DIRECTION_DOWN = 8;
|
||||||
List<DigitalPadListener> listeners = new ArrayList<DigitalPadListener>();
|
List<DigitalPadListener> listeners = new ArrayList<DigitalPadListener>();
|
||||||
|
|
||||||
|
private static final int DPAD_MARGIN = 5;
|
||||||
|
|
||||||
private final Paint paint = new Paint();
|
private final Paint paint = new Paint();
|
||||||
|
|
||||||
public DigitalPad(VirtualController controller, Context context) {
|
public DigitalPad(VirtualController controller, Context context) {
|
||||||
@ -57,7 +59,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
(direction & DIGITAL_PAD_DIRECTION_LEFT) > 0 ? pressedColor : getDefaultColor());
|
(direction & DIGITAL_PAD_DIRECTION_LEFT) > 0 ? pressedColor : getDefaultColor());
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
paint.getStrokeWidth(), getPercent(getHeight(), 33),
|
paint.getStrokeWidth()+DPAD_MARGIN, getPercent(getHeight(), 33),
|
||||||
getPercent(getWidth(), 33), getPercent(getHeight(), 66),
|
getPercent(getWidth(), 33), getPercent(getHeight(), 66),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
@ -68,7 +70,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
(direction & DIGITAL_PAD_DIRECTION_UP) > 0 ? pressedColor : getDefaultColor());
|
(direction & DIGITAL_PAD_DIRECTION_UP) > 0 ? pressedColor : getDefaultColor());
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
getPercent(getWidth(), 33), paint.getStrokeWidth(),
|
getPercent(getWidth(), 33), paint.getStrokeWidth()+DPAD_MARGIN,
|
||||||
getPercent(getWidth(), 66), getPercent(getHeight(), 33),
|
getPercent(getWidth(), 66), getPercent(getHeight(), 33),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
@ -79,7 +81,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
getPercent(getWidth(), 66), getPercent(getHeight(), 33),
|
getPercent(getWidth(), 66), getPercent(getHeight(), 33),
|
||||||
getWidth() - paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
getWidth() - (paint.getStrokeWidth()+DPAD_MARGIN), getPercent(getHeight(), 66),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -89,7 +91,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawRect(
|
canvas.drawRect(
|
||||||
getPercent(getWidth(), 33), getPercent(getHeight(), 66),
|
getPercent(getWidth(), 33), getPercent(getHeight(), 66),
|
||||||
getPercent(getWidth(), 66), getHeight() - paint.getStrokeWidth(),
|
getPercent(getWidth(), 66), getHeight() - (paint.getStrokeWidth()+DPAD_MARGIN),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -101,8 +103,8 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
);
|
);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
paint.getStrokeWidth(), getPercent(getHeight(), 33),
|
paint.getStrokeWidth()+DPAD_MARGIN, getPercent(getHeight(), 33),
|
||||||
getPercent(getWidth(), 33), paint.getStrokeWidth(),
|
getPercent(getWidth(), 33), paint.getStrokeWidth()+DPAD_MARGIN,
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -114,8 +116,8 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
);
|
);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
getPercent(getWidth(), 66), paint.getStrokeWidth(),
|
getPercent(getWidth(), 66), paint.getStrokeWidth()+DPAD_MARGIN,
|
||||||
getWidth() - paint.getStrokeWidth(), getPercent(getHeight(), 33),
|
getWidth() - (paint.getStrokeWidth()+DPAD_MARGIN), getPercent(getHeight(), 33),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -128,7 +130,7 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
getWidth()-paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
getWidth()-paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
||||||
getPercent(getWidth(), 66), getHeight()-paint.getStrokeWidth(),
|
getPercent(getWidth(), 66), getHeight()-(paint.getStrokeWidth()+DPAD_MARGIN),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -140,8 +142,8 @@ public class DigitalPad extends VirtualControllerElement {
|
|||||||
);
|
);
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
getPercent(getWidth(), 33), getHeight()-paint.getStrokeWidth(),
|
getPercent(getWidth(), 33), getHeight()-(paint.getStrokeWidth()+DPAD_MARGIN),
|
||||||
paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
paint.getStrokeWidth()+DPAD_MARGIN, getPercent(getHeight(), 66),
|
||||||
paint
|
paint
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -74,18 +74,18 @@ public abstract class VirtualControllerElement extends View {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
|
onElementDraw(canvas);
|
||||||
|
|
||||||
if (currentMode != Mode.Normal) {
|
if (currentMode != Mode.Normal) {
|
||||||
paint.setColor(configSelectedColor);
|
paint.setColor(configSelectedColor);
|
||||||
paint.setStrokeWidth(getDefaultStrokeWidth() * 2);
|
paint.setStrokeWidth(getDefaultStrokeWidth());
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
|
|
||||||
canvas.drawRect(0, 0,
|
canvas.drawRect(paint.getStrokeWidth(), paint.getStrokeWidth(),
|
||||||
getWidth(), getHeight(),
|
getWidth()-paint.getStrokeWidth(), getHeight()-paint.getStrokeWidth(),
|
||||||
paint);
|
paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
onElementDraw(canvas);
|
|
||||||
|
|
||||||
super.onDraw(canvas);
|
super.onDraw(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user