aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/Shape.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-20 22:00:11 +0200
committerSven Gothel <[email protected]>2023-04-20 22:00:11 +0200
commit2aae33b94cea15b2fc0c54479277611c67cdaf13 (patch)
treee1956d8361fd1ef6860c50f0a0aa8aab6b5ce612 /src/graphui/classes/com/jogamp/graph/ui/Shape.java
parentc21082a5d7caf0ae6e29144358b4b4a1eafec019 (diff)
GraphUI GraphShape: createGLRegion() -> updateGLRegion(), called by addShapeToRegion() impl to utilize OutlineShape -> GLRegion ctor w/ proper buffer-size
This way we avoid unnecessary buffer growth and allow creation of 'always' fitting buffer sizes. +++ Update or freshly create the GLRegion, while allocating its buffers with given initial `vertexCount` and `indexCount`. Method shall be invoked by the addShapeToRegion(GLProfile, GL2ES2) implementation before actually adding the OutlineShape to the GLRegion. addShapeToRegion(GLProfile, GL2ES2) is capable to determine initial `vertexCount` and `indexCount` buffer sizes, as it composes the OutlineShapes to be added. updateGLRegion(GLProfile, GL2ES2, TextureSequence, OutlineShape) maybe used for convenience. In case GLRegion is `null`, a new instance is being created. In case the GLRegion already exists, it will be either cleared if the GL2ES2 `gl` instance is not `null` or earmarked for deletion at a later time and a new instance is being created.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/Shape.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index a8e3196c9..5ef40a57f 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -53,7 +53,7 @@ import com.jogamp.opengl.math.geom.AABBox;
import com.jogamp.opengl.util.PMVMatrix;
/**
- * Generic UI Shape, potentially using a Graph via {@link GraphShape} or other means of representing content.
+ * Generic Shape, potentially using a Graph via {@link GraphShape} or other means of representing content.
* <p>
* A shape includes the following build-in user-interactions
* - drag shape w/ 1-pointer click, see {@link #setDraggable(boolean)}
@@ -136,7 +136,8 @@ public abstract class Shape {
private boolean resizable = true;
private boolean interactive = true;
private boolean enabled = true;
- private float dbgbox_thickness = 0f; // fractional thickness of bounds, 0f for no debug box
+ private float border_thickness = 0f;
+ protected final Vec4f borderColor = new Vec4f(0.75f, 0.75f, 0.75f, 1.0f);
private ArrayList<MouseGestureListener> mouseListeners = new ArrayList<MouseGestureListener>();
private Listener onMoveListener = null;
@@ -158,17 +159,18 @@ public abstract class Shape {
public final Shape setEnabled(final boolean v) { enabled = v; return this; }
/**
- * Sets the {@link #getBounds()} fractional thickness of the debug box ranging [0..1], zero for no debug box (default).
- * @param v fractional thickness of {@link #getBounds()} ranging [0..1], zero for no debug box
+ * Sets the thickness of the debug box, zero for no border (default).
+ * @param v border thickness, zero for no debug box
*/
- public final Shape setDebugBox(final float v) {
- dbgbox_thickness = Math.min(1f, Math.max(0f, v));
+ public final Shape setBorder(final float v) {
+ border_thickness = Math.max(0f, v);
return this;
}
- /** Returns true if a debug box has been enabled via {@link #setDebugBox(float)}. */
- public final boolean hasDebugBox() { return !FloatUtil.isZero(dbgbox_thickness); }
- /** Returns the fractional thickness of the debug box ranging [0..1], see {@link #setDebugBox(float)}. */
- public final float getDebugBox() { return dbgbox_thickness; }
+ /** Returns true if a border has been enabled via {@link #setBorder(float)}. */
+ public final boolean hasBorder() { return !FloatUtil.isZero(border_thickness); }
+
+ /** Returns the border thickness, see {@link #setBorder(float)}. */
+ public final float getBorderThickness() { return border_thickness; }
/**
* Clears all data and reset all states as if this instance was newly created
@@ -760,9 +762,7 @@ public abstract class Shape {
return this.winToShapeCoord(scene.getPMVMatrixSetup(), scene.getViewport(), glWinX, glWinY, pmv, objPos);
}
- public Vec4f getColor() {
- return rgbaColor;
- }
+ public Vec4f getColor() { return rgbaColor; }
/**
* Set base color.
@@ -776,6 +776,17 @@ public abstract class Shape {
}
/**
+ * Set base color.
+ * <p>
+ * Default base-color w/o color channel, will be modulated w/ pressed- and toggle color
+ * </p>
+ */
+ public final Shape setColor(final Vec4f c) {
+ this.rgbaColor.set(c);
+ return this;
+ }
+
+ /**
* Set pressed color.
* <p>
* Default pressed color-factor w/o color channel, modulated base-color. 0.75 * 1.2 = 0.9
@@ -808,6 +819,20 @@ public abstract class Shape {
return this;
}
+ public Vec4f getBorderColor() { return borderColor; }
+
+ /** Set border color. */
+ public final Shape setBorderColor(final float r, final float g, final float b, final float a) {
+ this.borderColor.set(r, g, b, a);
+ return this;
+ }
+
+ /** Set border color. */
+ public final Shape setBorderColor(final Vec4f c) {
+ this.borderColor.set(c);
+ return this;
+ }
+
@Override
public final String toString() {
return getClass().getSimpleName()+"["+getSubString()+"]";