Skip to content

Commit 34f2ab7

Browse files
committed
noClip fix for android 9
1 parent 23f714b commit 34f2ab7

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed

AndroidIDE/AndroidManifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="0.1.4" package="dzaima.aplide">
33
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="28"/>
44
<application android:icon="@mipmap/ic_launcher" android:label="">
5-
<activity android:configChanges="orientation|screenSize" android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
5+
<activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
66
<intent-filter>
77
<action android:name="android.intent.action.MAIN"/>
88
<category android:name="android.intent.category.LAUNCHER"/>

AndroidIDE/PS.pde

+19-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ void psDraw() {
1111
else touches = new FakeTouch[0];
1212
}
1313
void settings() {
14-
//size(540, 830);
15-
size(960, 540);
14+
size(540, 830);
15+
//size(960, 540);
1616
}
1717
1818
import java.awt.datatransfer.*;
@@ -48,6 +48,13 @@ KeyEvent fixKE(KeyEvent e) {
4848
return e;
4949
}
5050
51+
static void beginClip(PGraphics g, float x, float y, float x2, float y2) {
52+
g.clip(x, y, x2, y2);
53+
}
54+
static void endClip(PGraphics g) {
55+
g.noClip();
56+
}
57+
5158
/*/ // ANDROID
5259

5360
import android.content.ClipboardManager;
@@ -131,4 +138,14 @@ KeyEvent fixKE(KeyEvent e) {
131138
, e.getKey(), e.getKeyCode());
132139
}
133140

141+
import processing.a2d.*;
142+
static void beginClip(PGraphics g, float x, float y, float x2, float y2) {
143+
if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.save();
144+
g.clip(x, y, x2, y2);
145+
}
146+
static void endClip(PGraphics g) {
147+
if (g instanceof PGraphicsAndroid2D) ((PGraphicsAndroid2D)g).canvas.restore();
148+
else g.noClip();
149+
}
150+
134151
//*/

AndroidIDE/Plane.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ abstract static class Plane extends Drawable {
4444
}
4545
} else lastDist = 0;
4646
d.pushMatrix();
47+
beginClip(d, x, y, w, h);
4748
d.imageMode(CORNER);
48-
d.clip(x, y, w, h);
4949
d.background(12);
5050

5151
d.stroke(0xff666666);
@@ -117,7 +117,7 @@ abstract static class Plane extends Drawable {
117117

118118
draw();
119119

120-
d.noClip();
120+
endClip(d);
121121
d.popMatrix();
122122
}
123123

AndroidIDE/ROText.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ static class ROText extends Drawable {
1010
int border = 10;
1111
boolean redraw;
1212
void redraw() {
13-
d.clip(x+border, y, w-border*2, h);
13+
beginClip(d, x+border, y, w-border*2, h);
1414
d.fill(#101010);
1515
d.noStroke();
1616
d.rectMode(CORNER);
@@ -27,7 +27,7 @@ static class ROText extends Drawable {
2727
d.text(s, x+border + xoff, y + dy*tsz + yoff);
2828
dy++;
2929
}
30-
d.noClip();
30+
endClip(d);
3131
redraw = false;
3232
}
3333
void tick() {

AndroidIDE/Textarea.pde

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static class APLTextarea extends Drawable implements TextReciever {
5454
history[hptr] = new State(allText(), cx, cy);
5555
saveUndo = false;
5656
}
57-
a.clip(x, y, w, h);
57+
beginClip(d, x, y, w, h);
5858
if (a.mousePressed && smouseIn()) {
5959
yoff+= a.mouseY-a.pmouseY;
6060
xoff+= a.mouseX-a.pmouseX;
@@ -103,7 +103,7 @@ static class APLTextarea extends Drawable implements TextReciever {
103103
d.stroke(th.caret);
104104
d.line(px, tsz*cy + yoff + y, px, tsz*(cy+1) + yoff + y);
105105
}
106-
d.noClip();
106+
endClip(d);
107107
}
108108

109109
ArrayList<String> lines;

AndroidIDE/Textfield.pde

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ static class APLField extends Drawable implements TextReciever {
5151
history[hptr] = new State(allText(), sx, ex);
5252
saveUndo = false;
5353
}
54-
d.clip(x, y, w, h);
54+
beginClip(d, x, y, w, h);
5555
if (pmousePressed && !a.mousePressed && smouseIn() && dist(a.mouseX, a.mouseY, smouseX, smouseY) < 10) {
56-
d. textSize(tsz);
56+
d.textSize(tsz);
5757
sx = constrain(round((a.mouseX-x-xoff)/d.textWidth("H")), 0, line.length());
5858
ex = sx;
5959
tt = 0;
@@ -88,7 +88,7 @@ static class APLField extends Drawable implements TextReciever {
8888
d.rectMode(CORNERS);
8989
d.rect(spx, sy, epx, ey);
9090
}
91-
d.noClip();
91+
endClip(d);
9292
}
9393

9494
String line;

0 commit comments

Comments
 (0)