aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-31 11:56:36 +0100
committerSven Göthel <[email protected]>2024-01-31 11:56:36 +0100
commit5cf0d370dbc2b1f59102522d40f4875f7d77b1f7 (patch)
tree369a7cff074f9d654e046722d912e5226c7311aa
parentf7458c47338c90db19ef3f0143a268b60b1267a3 (diff)
GraphUI: Only issue Shape.mark*Dirty() if values were updated or data available; JOGL ImageSequence: Add addFrame(GL, TextureFrame), remove*Frame() and isSequenceAnimating()
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java8
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/ImageButton.java4
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java10
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java20
4 files changed, 30 insertions, 12 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 83835a913..45ebbe58c 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/BaseButton.java
@@ -115,9 +115,11 @@ public class BaseButton extends GraphShape {
}
public BaseButton setSize(final float width, final float height) {
- this.width = width;
- this.height = height;
- markShapeDirty();
+ if( this.width != width || this.height != height ) {
+ this.width = width;
+ this.height = height;
+ markShapeDirty();
+ }
return this;
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/ImageButton.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/ImageButton.java
index a6c5bda34..2cb21e268 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/ImageButton.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/ImageButton.java
@@ -61,6 +61,8 @@ public class ImageButton extends TexSeqButton {
setToggleOnColorMod(0.8f, 0.8f, 0.8f, 1f);
}
+ public ImageSequence getImageSequence() { return (ImageSequence)texSeq; }
+
public final void setCurrentIdx(final int idx) {
((ImageSequence)texSeq).setCurrentIdx(idx);
markStateDirty();
@@ -69,7 +71,7 @@ public class ImageButton extends TexSeqButton {
@Override
public void draw(final GL2ES2 gl, final RegionRenderer renderer) {
super.draw(gl, renderer);
- if( !((ImageSequence)texSeq).getManualStepping() ) {
+ if( ((ImageSequence)texSeq).isSequenceAnimating() ) {
markStateDirty(); // keep on going
}
};
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 ae2af3960..b90c7670a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java
@@ -122,10 +122,12 @@ public class Rectangle extends GraphShape {
markShapeDirty();
}
public void setDimension(final float width, final float height, final float lineWidth) {
- this.width = width;
- this.height = height;
- this.lineWidth = lineWidth;
- markShapeDirty();
+ if( this.width != width || this.height != height || this.lineWidth != lineWidth ) {
+ this.width = width;
+ this.height = height;
+ this.lineWidth = lineWidth;
+ markShapeDirty();
+ }
}
public void setBounds(final AABBox abox, final float lineWidth) {
setPosition(abox.getMinX(), abox.getMinY(), abox.getCenter().z());
diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
index b2522ab5b..69a990fde 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/texture/ImageSequence.java
@@ -66,14 +66,23 @@ public class ImageSequence implements TextureSequence {
texWrapST[1] = wrapT;
}
- public final void addFrame(final GL gl, final Texture tex) {
- final TextureSequence.TextureFrame frame = new TextureSequence.TextureFrame(tex);
+ public final TextureSequence.TextureFrame addFrame(final GL gl, final Texture tex) {
+ return addFrame(gl, new TextureSequence.TextureFrame(tex));
+ }
+ public final TextureSequence.TextureFrame addFrame(final GL gl, final TextureSequence.TextureFrame frame) {
frames.add(frame);
- tex.bind(gl);
+ frame.texture.bind(gl);
gl.glTexParameteri(getTextureTarget(), GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]);
gl.glTexParameteri(getTextureTarget(), GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]);
gl.glTexParameteri(getTextureTarget(), GL.GL_TEXTURE_WRAP_S, texWrapST[0]);
gl.glTexParameteri(getTextureTarget(), GL.GL_TEXTURE_WRAP_T, texWrapST[1]);
+ return frame;
+ }
+ public boolean removeFrame(final TextureFrame tex) {
+ return frames.remove(tex);
+ }
+ public void removeAllFrames() {
+ frames.clear();
}
public final void addFrame(final GL gl, final Class<?> context, final String imageResourcePath, final String imageSuffix) throws IOException {
@@ -94,7 +103,10 @@ public class ImageSequence implements TextureSequence {
frameIdx=idx;
}
public final void setManualStepping(final boolean v) { manualStepping = v; }
- public final boolean getManualStepping() { return manualStepping; }
+ public final boolean isManualStepping() { return manualStepping; }
+
+ /** Returns {@code true} if not {@link #isManualStepping()} and {@link #getFrameCount()} > 1 */
+ public final boolean isSequenceAnimating() { return !manualStepping && frames.size() > 1; }
public final TextureSequence.TextureFrame getFrame(final int idx) { return frames.get(idx); }
public void destroy(final GL gl) throws GLException {