aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-12 05:36:38 +0100
committerSven Göthel <[email protected]>2024-01-12 05:36:38 +0100
commitfa0703fda03f34468c9c8645a52d13536c366991 (patch)
tree1cf4e80abff8e51f72f5daffdbd4767710ddebfc /src/graphui/classes
parent4bc55e2f2e3603b43d6fdcb9786c61e32a64327f (diff)
GraphUI RangeSlider: Add unitSize param: Size of one unit (element) in sliding direction
Diffstat (limited to 'src/graphui/classes')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java2
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java45
2 files changed, 27 insertions, 20 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
index ee594144a..63a04c0d5 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/MediaPlayer.java
@@ -133,7 +133,7 @@ public class MediaPlayer extends Widget {
{
final float knobScale = 3f;
final float knobHeight = ctrlSliderHeight * knobScale;
- ctrlSlider = new RangeSlider(renderModes, new Vec2f(aratio - knobHeight, ctrlSliderHeight), knobScale, new Vec2f(0, 100), 0);
+ ctrlSlider = new RangeSlider(renderModes, new Vec2f(aratio - knobHeight, ctrlSliderHeight), knobScale, new Vec2f(0, 100), 1, 0);
final float dx = knobHeight / 2f;
final float dy = ( knobHeight - ctrlSliderHeight ) * 0.5f;
ctrlSlider.setPaddding(new Padding(0, dx, ctrlCellHeight-dy, dx));
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java
index 1573c8fb1..dbb3c265f 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangeSlider.java
@@ -51,8 +51,8 @@ import com.jogamp.opengl.util.texture.TextureSequence;
/**
* RangeSlider {@link Widget} either utilizing a simple positional round knob
* or a rectangular page-sized knob.
- * @see #RangeSlider(int, Vec2f, float, Vec2f, float)
- * @see #RangeSlider(int, Vec2f, Vec2f, float, float)
+ * @see #RangeSlider(int, Vec2f, float, Vec2f, float, float)
+ * @see #RangeSlider(int, Vec2f, Vec2f, float, float, float)
*/
public final class RangeSlider extends Widget {
/**
@@ -93,6 +93,7 @@ public final class RangeSlider extends Widget {
private float pageSize;
private float val=0, val_pct=0;
private boolean inverted=false;
+ private float unitSize = 1;
/**
* Constructs a {@link RangeSlider}, i.e. its shapes and controls.
@@ -103,11 +104,12 @@ public final class RangeSlider extends Widget {
* @param size width and height of this slider box. A horizontal slider has width >= height.
* @param knobScale multiple of slider-bar height for {@link #getKnobHeight()}
* @param minMax minimum- and maximum-value of slider
+ * @param unitSize size of one unit (element) in sliding direction
* @param value current value of slider
*/
public RangeSlider(final int renderModes, final Vec2f size, final float knobScale,
- final Vec2f minMax, final float value) {
- this(renderModes, size, knobScale, minMax, Float.NaN, value);
+ final Vec2f minMax, final float unitSize, final float value) {
+ this(renderModes, size, knobScale, minMax, unitSize, Float.NaN, value);
}
/**
* Constructs a {@link RangeSlider}, i.e. its shapes and controls.
@@ -117,17 +119,19 @@ public final class RangeSlider extends Widget {
* @param renderModes Graph's {@link Region} render modes, see {@link GLRegion#create(GLProfile, int, TextureSequence) create(..)}.
* @param size width and height of this slider box. A horizontal slider has width >= height.
* @param minMax minimum- and maximum-value of slider
+ * @param unitSize size of one unit (element) in sliding direction
* @param pageSize size of one virtual-page, triggers rendering mode from knob to rectangle
* @param value current value of slider
*/
public RangeSlider(final int renderModes, final Vec2f size,
- final Vec2f minMax, final float pageSize, final float value) {
- this(renderModes, size, 0, minMax, pageSize, value);
+ final Vec2f minMax, final float unitSize, final float pageSize, final float value) {
+ this(renderModes, size, 0, minMax, unitSize, pageSize, value);
}
private RangeSlider(final int renderModes_, final Vec2f size, final float knobScale,
- final Vec2f minMax, final float pageSz, final float value) {
+ final Vec2f minMax, final float unitSize, final float pageSz, final float value) {
// final int renderModes = ( renderModes_ & ~Region.AA_RENDERING_MASK ) | Region.COLORCHANNEL_RENDERING_BIT;
final int renderModes = renderModes_ & ~(Region.AA_RENDERING_MASK | Region.COLORCHANNEL_RENDERING_BIT);
+ this.unitSize = unitSize;
this.pageSize = pageSz;
this.horizontal = size.x() >= size.y();
barAndKnob = new Group();
@@ -213,15 +217,15 @@ public final class RangeSlider extends Widget {
if( !e.isControlDown() ) {
if( e.getRotation()[1] < 0f ) {
if( inverted ) {
- v++;
+ v+=unitSize;
} else {
- v--;
+ v-=unitSize;
}
} else {
if( inverted ) {
- v--;
+ v-=unitSize;
} else {
- v++;
+ v+=unitSize;
}
}
} else if( !Float.isNaN(pageSize) ){
@@ -277,32 +281,32 @@ public final class RangeSlider extends Widget {
if( keySym == KeyEvent.VK_RIGHT ) {
action = true;
if( inverted ) {
- v--;
+ v-=unitSize;
} else {
- v++;
+ v+=unitSize;
}
} else if( keySym == KeyEvent.VK_LEFT ) {
action = true;
if( inverted ) {
- v++;
+ v+=unitSize;
} else {
- v--;
+ v-=unitSize;
}
}
} else {
if( keySym == KeyEvent.VK_DOWN ) {
action = true;
if( inverted ) {
- v++;
+ v+=unitSize;
} else {
- v--;
+ v-=unitSize;
}
} else if( keySym == KeyEvent.VK_UP ) {
action = true;
if( inverted ) {
- v--;
+ v-=unitSize;
} else {
- v++;
+ v+=unitSize;
}
}
}
@@ -413,6 +417,9 @@ public final class RangeSlider extends Widget {
}
public float getPageSize() { return this.pageSize; }
+ public void setUnitSize(final float v) { this.unitSize = v; }
+ public float getUnitSize() { return this.unitSize; }
+
public RangeSlider setInverted(final boolean v) { inverted = v; return setValue(val); }
/**