tab fixes and hack for text with a z coord

This commit is contained in:
benfry
2005-04-19 02:34:51 +00:00
parent fff5b192fd
commit 9940f7aed8
6 changed files with 65 additions and 144 deletions

View File

@@ -325,7 +325,8 @@ public class EditorHeader extends JComponent {
JMenu unhide = new JMenu("Unhide");
ActionListener unhideListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.sketch.unhideCode((String) (e.getActionCommand()));
String which = (String) e.getActionCommand();
editor.sketch.unhideCode(which);
rebuildMenu();
}
};

View File

@@ -515,8 +515,8 @@ public class Sketch {
// TODO maybe gray out the menu on setCurrent(0)
if (current == code[0]) {
Base.showMessage("Can't do that",
"You cannot hide the main " +
".pde file from a sketch\n");
"You cannot hide the main " +
".pde file from a sketch\n");
return;
}
@@ -524,8 +524,8 @@ public class Sketch {
File newFile = new File(current.file.getAbsolutePath() + ".x");
if (!current.file.renameTo(newFile)) {
Base.showWarning("Error",
"Could not hide " +
"\"" + current.file.getName() + "\".", null);
"Could not hide " +
"\"" + current.file.getName() + "\".", null);
return;
}
current.file = newFile;
@@ -549,10 +549,13 @@ public class Sketch {
public void unhideCode(String what) {
//System.out.println("unhide " + e);
int unhideIndex = -1;
//int unhideIndex = -1;
SketchCode unhideCode = null;
for (int i = 0; i < hiddenCount; i++) {
if (hidden[i].name.equals(what)) {
unhideIndex = i;
//unhideIndex = i;
unhideCode = hidden[i];
// remove from the 'hidden' list
for (int j = i; j < hiddenCount-1; j++) {
@@ -562,14 +565,14 @@ public class Sketch {
break;
}
}
if (unhideIndex == -1) {
//if (unhideIndex == -1) {
if (unhideCode == null) {
System.err.println("internal error: could find " + what + " to unhide.");
return;
}
SketchCode unhideCode = hidden[unhideIndex];
if (!unhideCode.file.exists()) {
Base.showMessage("Can't unhide",
"The file \"" + what + "\" no longer exists.");
"The file \"" + what + "\" no longer exists.");
//System.out.println(unhideCode.file);
return;
}
@@ -579,8 +582,8 @@ public class Sketch {
if (!unhideCode.file.renameTo(unhideFile)) {
Base.showMessage("Can't unhide",
"The file \"" + what + "\" could not be" +
"renamed and unhidden.");
"The file \"" + what + "\" could not be" +
"renamed and unhidden.");
return;
}
unhideCode.file = unhideFile;

View File

@@ -402,121 +402,20 @@ public class PFont implements PConstants {
}
//textImpl(c, x, y, z, parent);
if (z != 0) parent.translate(0, 0, z); // TEMPORARY HACK! SLOW!
parent.textImpl(c, x, y, z);
if (z != 0) parent.translate(0, 0, -z); // TEMPORARY HACK! SLOW!
}
/**
* Internal function to draw a character at an x, y, z position.
* This version is called after the textM
*/
/*
protected void textImpl(char c, float x, float y, float z,
PGraphics parent) {
int glyph = index(c);
if (glyph == -1) return;
if (parent.textMode == MODEL) {
float high = (float) height[glyph] / fheight;
float bwidth = (float) width[glyph] / fwidth;
float lextent = (float) leftExtent[glyph] / fwidth;
float textent = (float) topExtent[glyph] / fheight;
float x1 = x + lextent * parent.textSize;
float y1 = y - textent * parent.textSize;
float x2 = x1 + bwidth * parent.textSize;
float y2 = y1 + high * parent.textSize;
boolean savedTint = parent.tint;
int savedTintColor = parent.tintColor;
float savedTintR = parent.tintR;
float savedTintG = parent.tintG;
float savedTintB = parent.tintB;
float savedTintA = parent.tintA;
boolean savedTintAlpha = parent.tintAlpha;
parent.tint = true;
parent.tintColor = parent.fillColor;
parent.tintR = parent.fillR;
parent.tintG = parent.fillG;
parent.tintB = parent.fillB;
parent.tintA = parent.fillA;
parent.tintAlpha = parent.fillAlpha;
parent.imageImpl(images[glyph],
x1, y1, x2, y2, //x2-x1, y2-y1,
0, 0, width[glyph], height[glyph]);
parent.tint = savedTint;
parent.tintColor = savedTintColor;
parent.tintR = savedTintR;
parent.tintG = savedTintG;
parent.tintB = savedTintB;
parent.tintA = savedTintA;
parent.tintAlpha = savedTintAlpha;
} else { // textMode SCREEN
int xx = (int) x + leftExtent[glyph];;
int yy = (int) y - topExtent[glyph];
int x0 = 0;
int y0 = 0;
int w0 = width[glyph];
int h0 = height[glyph];
if ((xx >= parent.width) || (yy >= parent.height) ||
(xx + w0 < 0) || (yy + h0 < 0)) return;
if (xx < 0) {
x0 -= xx;
w0 += xx;
xx = 0;
}
if (yy < 0) {
y0 -= yy;
h0 += yy;
yy = 0;
}
if (xx + w0 > parent.width) {
w0 -= ((xx + w0) - parent.width);
}
if (yy + h0 > parent.height) {
h0 -= ((yy + h0) - parent.height);
}
int fr = parent.fillRi;
int fg = parent.fillGi;
int fb = parent.fillBi;
int fa = parent.fillAi;
int pixels1[] = images[glyph].pixels;
int pixels2[] = parent.pixels;
for (int row = y0; row < y0 + h0; row++) {
for (int col = x0; col < x0 + w0; col++) {
int a1 = (fa * pixels1[row * twidth + col]) >> 8;
int a2 = a1 ^ 0xff;
int p1 = pixels1[row * width[glyph] + col];
int p2 = pixels2[(yy + row-y0)*parent.width + (xx+col-x0)];
pixels2[(yy + row-y0)*parent.width + xx+col-x0] =
(0xff000000 |
(((a1 * fr + a2 * ((p2 >> 16) & 0xff)) & 0xff00) << 8) |
(( a1 * fg + a2 * ((p2 >> 8) & 0xff)) & 0xff00) |
(( a1 * fb + a2 * ( p2 & 0xff)) >> 8));
}
}
}
}
*/
public void text(String str, float x, float y, PGraphics parent) {
text(str, x, y, 0, parent);
}
public void text(String str, float x, float y, float z, PGraphics parent) {
if (z != 0) parent.translate(0, 0, z); // TEMPORARY HACK! SLOW!
int length = str.length();
if (length > textBuffer.length) {
textBuffer = new char[length + 10];
@@ -536,6 +435,7 @@ public class PFont implements PConstants {
if (start < length) {
textLine(start, index, x, y, z, parent);
}
if (z != 0) parent.translate(0, 0, -z); // TEMPORARY HACK! SLOW!
}
@@ -551,7 +451,9 @@ public class PFont implements PConstants {
for (int index = start; index < stop; index++) {
//textImpl(textBuffer[index], x, y, z, parent);
parent.textImpl(textBuffer[index], x, y, z);
//parent.textImpl(textBuffer[index], x, y, z);
// HACK FOR Z COORDINATES.. FIX ME SOON
parent.textImpl(textBuffer[index], x, y, 0); //z);
x += parent.textSize *width(textBuffer[index]);
}
}
@@ -578,6 +480,8 @@ public class PFont implements PConstants {
*/
public void text(String str, float boxX1, float boxY1,
float boxX2, float boxY2, float boxZ, PGraphics parent) {
if (boxZ != 0) parent.translate(0, 0, boxZ); // TEMPORARY HACK! SLOW!
float spaceWidth = width(' ') * parent.textSize;
float runningX = boxX1;
float currentY = boxY1;
@@ -672,6 +576,8 @@ public class PFont implements PConstants {
if ((lineStart < length) && (lineStart != index)) {
textLine(lineStart, index, lineX, currentY, boxZ, parent);
}
if (boxZ != 0) parent.translate(0, 0, -boxZ); // TEMPORARY HACK! SLOW!
}

View File

@@ -1601,6 +1601,8 @@ public class PGraphics extends PImage implements PConstants {
public void text(char c, float x, float y) {
text(c, x, y, 0);
/*
if (textFont != null) {
if (textMode == SCREEN) loadPixels();
textFont.text(c, x, y, this);
@@ -1609,6 +1611,7 @@ public class PGraphics extends PImage implements PConstants {
} else {
throw new RuntimeException("use textFont() before text()");
}
*/
}
@@ -1637,6 +1640,9 @@ public class PGraphics extends PImage implements PConstants {
public void text(String s, float x, float y) {
text(s, x, y, 0);
/*
text(s, x, y, 0);
if (textFont != null) {
if (textMode == SCREEN) loadPixels();
textFont.text(s, x, y, this);
@@ -1644,6 +1650,7 @@ public class PGraphics extends PImage implements PConstants {
} else {
throw new RuntimeException("use textFont() before text()");
}
*/
}
@@ -1680,6 +1687,11 @@ public class PGraphics extends PImage implements PConstants {
* ignored.
*/
public void text(String s, float x1, float y1, float x2, float y2) {
text(s, x1, y1, x2, y2, 0);
}
public void text(String s, float x1, float y1, float x2, float y2, float z) {
if (textFont != null) {
float hradius, vradius;
switch (rectMode) {
@@ -1709,7 +1721,7 @@ public class PGraphics extends PImage implements PConstants {
float temp = y1; y1 = y2; y2 = temp;
}
if (textMode == SCREEN) loadPixels();
textFont.text(s, x1, y1, x2, y2, this);
textFont.text(s, x1, y1, x2, y2, z, this);
if (textMode == SCREEN) updatePixels();
} else {
@@ -1718,11 +1730,6 @@ public class PGraphics extends PImage implements PConstants {
}
public void text(String s, float x1, float y1, float x2, float y2, float z) {
depthErrorXYZ("text");
}
public void text(int num, float x, float y) {
text(String.valueOf(num), x, y);
}

View File

@@ -4,13 +4,16 @@ X simon lighting fixes
X added simon's lighting docs to lights() fxn in javadoc
X set default stroke cap as ROUND
X otherwise smooth() makes points disappear
X hack for text with a z coordinate
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
NOT COMPLETELY NECESSARY BEFORE BETA
_ text() with a z coordinate is now using translate, very slow
_ also puts up a weird error message about translate() in 2D mode
_ fix the flicker in java2d mode
_ not clear what's happening here
_ appears to be much worse (unfinished drawing) on macosx

View File

@@ -40,6 +40,16 @@ file is empty.
the only way to make File>Save As actually save new files, as far as i
can tell, is to Save As once, make at least one change, then Save.
X fix hide/unhide bug... just was dumb code
create a new sketch
create a new tab named "a"
create a new tab named "a_2"
hide tab named "a_2"
hide "a"
unhide "a_2"
unhide "a"
where did "a_2" go ?
pending
_ rename video.Camera to video.Video ? Capture ?
@@ -52,25 +62,6 @@ _ processing vs. flash item on the faq? a "why?" page?
//
"SAVE AS..." BUGS
Is it possible that saving with the 'save' button doesn't pay
attention to where you point at the project folder from prefs? Jeez,
i phrased that horribly. I opened preferences for Processing and made
the default sketchbook location processing-0079/projects. I then put
all my older projects in that project folder. When i opened up an old
file and made changes, i then hit 'save' and quit. I relaunched v79
and opened the aforementioned file, and none of the changes were
there. but they were in v77 project folder.
create a new sketch
create a new tab named "a"
create a new tab named "a_2"
hide tab named "a_2"
hide "a"
unhide "a_2"
unhide "a"
where did "a_2" go ?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -93,6 +84,16 @@ _ doesn't work, try using the class' main() to run it
_ println() can hose the app for the first 20-30 frames
_ need to figure out threading etc
_ not confirmed to be a bug
Is it possible that saving with the 'save' button doesn't pay
attention to where you point at the project folder from prefs? Jeez,
i phrased that horribly. I opened preferences for Processing and made
the default sketchbook location processing-0079/projects. I then put
all my older projects in that project folder. When i opened up an old
file and made changes, i then hit 'save' and quit. I relaunched v79
and opened the aforementioned file, and none of the changes were
there. but they were in v77 project folder.
_ stop() not working very well
_ doesn't seem to actually be stopping things
_ closing window w/o first hitting stop() causes freak out