JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TexSeqButton.java
Go to the documentation of this file.
1/**
2 * Copyright 2014-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.graph.ui.shapes;
29
30import com.jogamp.opengl.GL2ES2;
31import com.jogamp.opengl.GLProfile;
32import com.jogamp.graph.curve.OutlineShape;
33import com.jogamp.graph.curve.Region;
34import com.jogamp.graph.ui.GraphShape;
35import com.jogamp.math.Vec4f;
36import com.jogamp.opengl.util.texture.TextureSequence;
37
38/**
39 * An abstract GraphUI {@link TextureSequence} {@link BaseButton} {@link GraphShape}.
40 * <p>
41 * GraphUI is GPU based and resolution independent.
42 * </p>
43 * <p>
44 * This button is rendered with a round oval shape.
45 * To render it rectangular, {@link #setCorner(float)} to zero.
46 * </p>
47 */
48public abstract class TexSeqButton extends BaseButton {
49 protected final TextureSequence texSeq;
50
51 public TexSeqButton(final int renderModes, final float width,
52 final float height, final TextureSequence texSeq) {
54 this.texSeq = texSeq;
55 }
56
57 public final TextureSequence getTextureSequence() { return this.texSeq; }
58
59 /**
60 * See {@link TextureSequence#setARatioAdjustment(boolean)}.
61 * @return this instance for chaining
62 */
63 public TexSeqButton setARatioAdjustment(final boolean v) {
64 if( useARatioAdjustment() != v ) {
67 }
68 return this;
69 }
70 /**
71 * See {@link TextureSequence#useARatioAdjustment()}.
72 */
73 public boolean useARatioAdjustment() { return texSeq.useARatioAdjustment(); }
74
75 /**
76 * See {@link TextureSequence#setARatioLetterbox(boolean, Vec4f)}.
77 * @param v new value for {@link #useARatioLetterbox()}
78 * @param backColor optional background color for added letter-box space, defaults to transparent zero
79 * @return this instance for chaining
80 */
81 public TexSeqButton setARatioLetterbox(final boolean v, final Vec4f backColor) {
82 if( useARatioLetterbox() != v ) {
83 texSeq.setARatioLetterbox(v, backColor);
85 }
86 return this;
87 }
88 /**
89 * See {@link TextureSequence#useARatioLetterbox()}.
90 */
91 public boolean useARatioLetterbox() { return texSeq.useARatioLetterbox(); }
92
93 /** See {@link TextureSequence#getARatioLetterboxBackColor()}. */
95
96 @Override
97 protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
98 final OutlineShape shape = createBaseShape(0f);
99 resetGLRegion(glp, gl, texSeq, shape);
100 region.addOutlineShape(shape, null, rgbaColor);
101 box.resize(shape.getBounds());
103 }
104}
A Generic shape objects which is defined by a list of Outlines.
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
Definition: Region.java:62
final void addOutlineShape(final OutlineShape shape, final AffineTransform t, final Vec4f rgbaColor)
Add the given OutlineShape to this region with the given optional AffineTransform.
Definition: Region.java:616
static final int COLORTEXTURE_RENDERING_BIT
Rendering-Mode bit for Region.
Definition: Region.java:161
final void resetGLRegion(final GLProfile glp, final GL2ES2 gl, final TextureSequence colorTexSeq, int vertexCount, int indexCount)
Reset the GLRegion and reserving its buffers to have a free capacity for vertexCount and indexCount e...
final void markShapeDirty()
Marks the shape dirty, causing next draw() to recreate the Graph shape and reset the region.
Definition: Shape.java:688
final Vec4f rgbaColor
Default base-color w/o color channel, will be modulated w/ pressed- and toggle color.
Definition: Shape.java:261
final Shape setRotationPivot(final float px, final float py, final float pz)
Set unscaled rotation origin, aka pivot.
Definition: Shape.java:620
An abstract GraphUI filled base button GraphShape, usually used as a backdrop or base shape for more ...
Definition: BaseButton.java:50
OutlineShape createBaseShape(final float zOffset)
An abstract GraphUI TextureSequence BaseButton GraphShape.
TexSeqButton(final int renderModes, final float width, final float height, final TextureSequence texSeq)
Vec4f getARatioLetterboxBackColor()
See TextureSequence#getARatioLetterboxBackColor().
void addShapeToRegion(final GLProfile glp, final GL2ES2 gl)
TexSeqButton setARatioLetterbox(final boolean v, final Vec4f backColor)
See TextureSequence#setARatioLetterbox(boolean, Vec4f).
boolean useARatioAdjustment()
See TextureSequence#useARatioAdjustment().
TexSeqButton setARatioAdjustment(final boolean v)
See TextureSequence#setARatioAdjustment(boolean).
final TextureSequence getTextureSequence()
boolean useARatioLetterbox()
See TextureSequence#useARatioLetterbox().
4D Vector based upon four float components.
Definition: Vec4f.java:37
final AABBox resize(final AABBox newBox)
Resize the AABBox to encapsulate another AABox.
Definition: AABBox.java:274
final Vec3f getCenter()
Returns computed center of this AABBox of getLow() and getHigh().
Definition: AABBox.java:737
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
Protocol for texture sequences, like animations, movies, etc.
void setARatioLetterbox(final boolean v, Vec4f backColor)
Toggles useARatioLetterbox().
boolean useARatioLetterbox()
Returns whether useARatioAdjustment() shall add letter-box space to match aspect-ratio,...
Vec4f getARatioLetterboxBackColor()
Returns useARatioLetterbox() background color for added letter-box space, defaults to transparent zer...
boolean useARatioAdjustment()
Returning true indicates texture correction for aspect-ratio in the shader.
void setARatioAdjustment(final boolean v)
Toggles useARatioLetterbox().