mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Use a uniform stroke width based on screen size in pixels
This commit is contained in:
parent
b33eaec493
commit
2fc53644bc
@ -218,7 +218,7 @@ public class AnalogStick extends VirtualControllerElement {
|
||||
canvas.drawColor(Color.TRANSPARENT);
|
||||
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(getPercent(getCorrectWidth() / 2, 2));
|
||||
paint.setStrokeWidth(getDefaultStrokeWidth());
|
||||
|
||||
// draw outer circle
|
||||
if (!isPressed() || click_state == CLICK_STATE.SINGLE) {
|
||||
|
@ -146,7 +146,7 @@ public class DigitalButton extends VirtualControllerElement {
|
||||
|
||||
paint.setTextSize(getPercent(getCorrectWidth(), 50));
|
||||
paint.setTextAlign(Paint.Align.CENTER);
|
||||
paint.setStrokeWidth(3);
|
||||
paint.setStrokeWidth(getDefaultStrokeWidth());
|
||||
|
||||
paint.setColor(isPressed() ? pressedColor : getDefaultColor());
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
|
@ -39,7 +39,7 @@ public class DigitalPad extends VirtualControllerElement {
|
||||
|
||||
paint.setTextSize(getPercent(getCorrectWidth(), 20));
|
||||
paint.setTextAlign(Paint.Align.CENTER);
|
||||
paint.setStrokeWidth(3);
|
||||
paint.setStrokeWidth(getDefaultStrokeWidth());
|
||||
|
||||
if (direction == DIGITAL_PAD_DIRECTION_NO_DIRECTION) {
|
||||
// draw no direction rect
|
||||
@ -79,7 +79,7 @@ public class DigitalPad extends VirtualControllerElement {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
canvas.drawRect(
|
||||
getPercent(getWidth(), 66), getPercent(getHeight(), 33),
|
||||
getWidth()-paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
||||
getWidth() - paint.getStrokeWidth(), getPercent(getHeight(), 66),
|
||||
paint
|
||||
);
|
||||
|
||||
@ -89,7 +89,7 @@ public class DigitalPad extends VirtualControllerElement {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
canvas.drawRect(
|
||||
getPercent(getWidth(), 33), getPercent(getHeight(), 66),
|
||||
getPercent(getWidth(), 66), getHeight()-paint.getStrokeWidth(),
|
||||
getPercent(getWidth(), 66), getHeight() - paint.getStrokeWidth(),
|
||||
paint
|
||||
);
|
||||
|
||||
|
@ -9,6 +9,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
@ -75,7 +76,7 @@ public abstract class VirtualControllerElement extends View {
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (currentMode != Mode.Normal) {
|
||||
paint.setColor(configSelectedColor);
|
||||
paint.setStrokeWidth(10);
|
||||
paint.setStrokeWidth(getDefaultStrokeWidth() * 2);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
|
||||
canvas.drawRect(0, 0,
|
||||
@ -138,6 +139,11 @@ public abstract class VirtualControllerElement extends View {
|
||||
configNormalColor : normalColor;
|
||||
}
|
||||
|
||||
protected int getDefaultStrokeWidth() {
|
||||
DisplayMetrics screen = getResources().getDisplayMetrics();
|
||||
return (int)(screen.heightPixels*0.004f);
|
||||
}
|
||||
|
||||
protected void showConfigurationDialog() {
|
||||
try {
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(getContext());
|
||||
|
Loading…
x
Reference in New Issue
Block a user