aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/shapes
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/shapes')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java18
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java25
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java8
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java20
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java12
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java7
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java15
7 files changed, 57 insertions, 48 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java
index 7c1997d2d..a4d0ee67a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java
@@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.ui.GraphShape;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLProfile;
/**
* An abstract GraphUI base filled button {@link GraphShape},
@@ -97,10 +99,15 @@ public class BaseButton extends GraphShape {
}
@Override
- protected void addShapeToRegion() {
- addBaseShapeToRegion(0f);
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
+ final OutlineShape shape = createBaseShape(0f);
+ updateGLRegion(glp, gl, null, shape);
+ region.addOutlineShape(shape, null, rgbaColor);
+ box.resize(shape.getBounds());
+ setRotationPivot( box.getCenter() );
}
- protected OutlineShape addBaseShapeToRegion(final float zOffset) {
+
+ protected OutlineShape createBaseShape(final float zOffset) {
final OutlineShape shape = new OutlineShape();
if(corner == 0.0f) {
createSharpOutline(shape, zOffset);
@@ -109,11 +116,8 @@ public class BaseButton extends GraphShape {
}
shape.setIsQuadraticNurbs();
shape.setSharpness(oshapeSharpness);
- region.addOutlineShape(shape, null, rgbaColor);
- box.resize(shape.getBounds());
- setRotationPivot( box.getCenter() );
if( DEBUG_DRAW ) {
- System.err.println("GraphShape.RoundButton: Added Shape: "+shape+", "+box);
+ System.err.println("GraphShape.RoundButton: Shape: "+shape+", "+box);
}
return shape;
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java
index a19a58003..3473c2c68 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java
@@ -31,8 +31,8 @@ import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.TextRegionUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.ui.GraphShape;
@@ -97,20 +97,17 @@ public class Button extends BaseButton {
}
@Override
- protected GLRegion createGLRegion(final GLProfile glp) {
- final int[] vertIndexCount = { 0, 0 };
- final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() {
- @Override
- public final void visit(final char symbol, final Font.Glyph glyph) {
- Region.countOutlineShape(glyph.getShape(), vertIndexCount);
- } };
- this.label.getFont().processString(visitor, this.label.getText());
- return GLRegion.create(glp, renderModes, null, 16+vertIndexCount[0], 16+vertIndexCount[1]);
- }
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
+ final OutlineShape shape = createBaseShape( FloatUtil.isZero(labelZOffset) ? 0f : -labelZOffset );
+ box.resize(shape.getBounds());
+ setRotationPivot( box.getCenter() );
- @Override
- protected void addShapeToRegion() {
- addBaseShapeToRegion( FloatUtil.isZero(labelZOffset) ? 0f : -labelZOffset );
+ // Sum Region buffer size of base-shape + text
+ final int[/*2*/] vertIndexCount = Region.countOutlineShape(shape, new int[2]);
+ TextRegionUtil.countStringRegion(label.getFont(), label.getText(), vertIndexCount);
+ updateGLRegion(glp, gl, null, vertIndexCount[0], vertIndexCount[1]);
+
+ region.addOutlineShape(shape, null, rgbaColor);
// Precompute text-box size .. guessing pixelSize
final float lw = box.getWidth() * ( 1f - spacingX ) ;
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java
index f0c6b1369..bd088c90e 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/CrossHair.java
@@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.ui.GraphShape;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLProfile;
/**
* A GraphUI Crosshair {@link GraphShape}
@@ -58,7 +60,7 @@ public class CrossHair extends GraphShape {
}
@Override
- protected void addShapeToRegion() {
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
final OutlineShape shape = new OutlineShape();
final float lwh = lineWidth/2f;
@@ -87,9 +89,11 @@ public class CrossHair extends GraphShape {
shape.setIsQuadraticNurbs();
shape.setSharpness(oshapeSharpness);
- region.addOutlineShape(shape, null, rgbaColor);
+ updateGLRegion(glp, gl, null, shape);
+ region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
+ setRotationPivot( box.getCenter() );
}
@Override
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java
index 568270073..dd4398c63 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/GlyphShape.java
@@ -36,6 +36,7 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.Font.Glyph;
import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.graph.ui.GraphShape;
+import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.math.Vec3f;
import com.jogamp.opengl.math.geom.AABBox;
@@ -52,6 +53,8 @@ import com.jogamp.opengl.util.texture.TextureSequence;
public class GlyphShape extends GraphShape {
private final char symbol;
private final Glyph glyph;
+ private final int regionVertCount;
+ private final int regionIdxCount;
private final Vec3f origPos;
/**
@@ -71,6 +74,9 @@ public class GlyphShape extends GraphShape {
if( glyph.isWhiteSpace() || null == glyph.getShape() ) {
setEnabled(false);
}
+ final int[/*2*/] vertIndexCount = Region.countOutlineShape(glyph.getShape(), new int[2]);
+ regionVertCount = vertIndexCount[0];
+ regionIdxCount = vertIndexCount[1];
}
/**
@@ -82,13 +88,7 @@ public class GlyphShape extends GraphShape {
* @param y the intended unscaled Y position of this Glyph, e.g. if part of a string - otherwise use zero.
*/
public GlyphShape(final int renderModes, final Font font, final char symbol, final float x, final float y) {
- super(renderModes);
- this.symbol = symbol;
- this.glyph = font.getGlyph( font.getGlyphID(symbol) );
- this.origPos = new Vec3f(x, y, 0f);
- if( glyph.isWhiteSpace() || null == glyph.getShape() ) {
- setEnabled(false);
- }
+ this(renderModes, symbol, font.getGlyph( font.getGlyphID(symbol) ), x, y);
}
/** Returns the char symbol to be rendered. */
@@ -181,7 +181,7 @@ public class GlyphShape extends GraphShape {
}
@Override
- protected void addShapeToRegion() {
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
final OutlineShape shape = glyph.getShape();
box.reset();
if( null != shape ) {
@@ -191,9 +191,11 @@ public class GlyphShape extends GraphShape {
// but keep the underline (decline) intact!
tmp.setToTranslation(-sbox.getMinX(), -sbox.getMinY() + glyph.getBounds().getMinY());
shape.setSharpness(oshapeSharpness);
+
+ updateGLRegion(glp, gl, null, regionVertCount, regionIdxCount);
region.addOutlineShape(shape, tmp, rgbaColor);
- setRotationPivot( sbox.getCenter() );
box.resize(tmp.transform(sbox, new AABBox()));
+ setRotationPivot( box.getCenter() );
}
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java
index 50b53e6f5..c270903d9 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Label.java
@@ -31,8 +31,8 @@ import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.graph.curve.OutlineShape;
-import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.TextRegionUtil;
import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.Font.Glyph;
import com.jogamp.graph.geom.plane.AffineTransform;
@@ -190,11 +190,6 @@ public class Label extends GraphShape {
}
}
- @Override
- protected GLRegion createGLRegion(final GLProfile glp) {
- return GLRegion.create(glp, getRenderModes(), null, font, text);
- }
-
private final Font.GlyphVisitor glyphVisitor = new Font.GlyphVisitor() {
@Override
public void visit(final char symbol, final Glyph glyph, final AffineTransform t) {
@@ -208,7 +203,10 @@ public class Label extends GraphShape {
};
@Override
- protected void addShapeToRegion() {
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
+ final int[] vertIndCount = TextRegionUtil.countStringRegion(font, text, new int[2]);
+ updateGLRegion(glp, gl, null, vertIndCount[0], vertIndCount[1]);
+
AABBox fbox = font.getGlyphBounds(text, tempT2, tempT3);
tempT1.setToScale(fontScale, fontScale);
tempT1.translate(-fbox.getMinX(), -fbox.getMinY(), tempT2); // enforce bottom-left origin @ 0/0 for good drag-zoom experience
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java
index dd6a272cb..d11e3bdb1 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java
@@ -29,6 +29,8 @@ package com.jogamp.graph.ui.shapes;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.ui.GraphShape;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLProfile;
/**
* A GraphUI Rectangle {@link GraphShape}
@@ -58,7 +60,7 @@ public class Rectangle extends GraphShape {
}
@Override
- protected void addShapeToRegion() {
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
final OutlineShape shape = new OutlineShape();
final float x1 = 0f;
final float y1 = 0f;
@@ -88,8 +90,11 @@ public class Rectangle extends GraphShape {
}
shape.setIsQuadraticNurbs();
shape.setSharpness(oshapeSharpness);
+
+ updateGLRegion(glp, gl, null, shape);
region.addOutlineShape(shape, null, rgbaColor);
box.resize(shape.getBounds());
+ setRotationPivot( box.getCenter() );
}
@Override
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
index 4768b4974..86cff4dae 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/TexSeqButton.java
@@ -27,10 +27,10 @@
*/
package com.jogamp.graph.ui.shapes;
+import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLProfile;
import com.jogamp.graph.curve.OutlineShape;
import com.jogamp.graph.curve.Region;
-import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.ui.GraphShape;
import com.jogamp.opengl.util.texture.TextureSequence;
@@ -53,15 +53,14 @@ public abstract class TexSeqButton extends BaseButton {
this.texSeq = texSeq;
}
- @Override
- protected GLRegion createGLRegion(final GLProfile glp) {
- return GLRegion.create(glp, getRenderModes(), texSeq);
- }
-
public final TextureSequence getTextureSequence() { return this.texSeq; }
@Override
- protected void addShapeToRegion() {
- addBaseShapeToRegion( 0f );
+ protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
+ final OutlineShape shape = createBaseShape(0f);
+ updateGLRegion(glp, gl, texSeq, shape);
+ region.addOutlineShape(shape, null, rgbaColor);
+ box.resize(shape.getBounds());
+ setRotationPivot( box.getCenter() );
}
}