summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java4
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java45
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java4
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java73
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java2
5 files changed, 71 insertions, 57 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
index 4cd5cd49b..86869b5a6 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/FontView01.java
@@ -161,7 +161,7 @@ public class FontView01 {
final int cellCount = gridCols * gridRows;
final float gridSize = gridCols > gridRows ? 1f/gridCols : 1f/gridRows;
System.err.println("Grid "+gridCols+" x "+gridRows+", "+cellCount+" cells, gridSize "+gridSize);
- final Group mainGrid = new Group(new GridLayout(gridCols, gridSize, gridSize, new Padding(gridSize*0.1f, gridSize*0.1f)));
+ final Group mainGrid = new Group(new GridLayout(gridCols, gridSize, gridSize, new Padding(gridSize*0.05f, gridSize*0.05f)));
final Group glyphCont = new Group();
{
@@ -175,7 +175,7 @@ public class FontView01 {
glyphInfo.setColor(0.1f, 0.1f, 0.1f, 1.0f);
infoCont.addShape(glyphInfo);
}
- final Group infoGrid = new Group(new GridLayout(1/2f, 1/2f, new Padding(1/2f*0.01f, 1/2f*0.01f), 2));
+ final Group infoGrid = new Group(new GridLayout(1/2f, 1/2f, new Padding(1/2f*0.005f, 1/2f*0.005f), 2));
infoGrid.addShape(glyphCont);
infoGrid.addShape(infoCont);
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
index 68ee8da94..001f585fd 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo11.java
@@ -40,8 +40,6 @@ import com.jogamp.graph.ui.Shape;
import com.jogamp.graph.ui.layout.GridLayout;
import com.jogamp.graph.ui.layout.Padding;
import com.jogamp.graph.ui.shapes.Button;
-import com.jogamp.graph.ui.shapes.GLButton;
-import com.jogamp.newt.event.MouseEvent;
import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
@@ -83,7 +81,7 @@ public class UISceneDemo11 {
final Font font = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_LIGHT, FontSet.STYLE_SERIF);
System.err.println("Font: "+font.getFullFamilyName());
- final Group groupA0 = new Group(new GridLayout(2, 1f, 1/2f, new Padding(0.1f, 0.1f)));
+ final Group groupA0 = new Group(new GridLayout(2, 1f, 1/2f, new Padding(0.05f, 0.05f)));
{
groupA0.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1f/2f).setCorner(0f).setDragAndResizeable(false) );
groupA0.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f).setCorner(0f).setDragAndResizeable(false) );
@@ -204,45 +202,4 @@ public class UISceneDemo11 {
window.destroy();
}
}
-
- static Shape makeGLButton(final float sw, final float sh, final Font font, final int renderModes) {
- final GearsES2 gears = new GearsES2(0);
- gears.setVerbose(false);
- gears.setClearColor(new float[] { 0.9f, 0.9f, 0.9f, 1f } );
- final boolean[] animate = { true };
- new Thread(new Runnable() {
- @Override
- public void run() {
- System.err.println("Gears Anim: Waiting");
- try {
- gears.waitForInit(true);
- } catch (final InterruptedException e) { }
- System.err.println("Gears Anim: Started");
- while( gears.isInit() ) {
- if( animate[0] ) {
- final float ry = ( gears.getRotY() + 1 ) % 360;
- gears.setRotY(ry);
- }
- try {
- Thread.sleep(15);
- } catch (final InterruptedException e) { }
- }
- System.err.println("Gears Anim: End");
- }
- }).start();
- final int texUnit = 1;
- final GLButton b = new GLButton(renderModes, sw,
- sh, texUnit, gears, false /* useAlpha */);
- b.setToggleable(true);
- b.setToggle(true); // toggle == true -> animation
- b.setAnimate(true);
- b.addMouseListener(new Shape.MouseGestureAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- b.setAnimate( b.isToggleOn() );
- animate[0] = b.getAnimate();
- } } );
- return b;
- }
-
}
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
index 143b40651..735192715 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UISceneDemo20.java
@@ -384,12 +384,12 @@ public class UISceneDemo20 implements GLEventListener {
final float buttonLWidth = buttonXSizeNorm;
final float buttonLHeight = buttonLWidth / 2.5f;
- buttonsLeft.setLayout(new GridLayout(buttonLWidth, buttonLHeight, new Padding(buttonLWidth*0.1f, buttonLHeight*0.5f), 7));
+ buttonsLeft.setLayout(new GridLayout(buttonLWidth, buttonLHeight, new Padding(buttonLHeight*0.25f, buttonLWidth*0.05f), 7));
final float buttonRWidth = 2f*buttonLWidth;
final float buttonRHeight = 2f*buttonLHeight;
- buttonsRight.setLayout(new GridLayout(1, buttonRWidth, buttonRHeight, new Padding(buttonLWidth*0.1f, buttonLHeight*0.5f)));
+ buttonsRight.setLayout(new GridLayout(1, buttonRWidth, buttonRHeight, new Padding(buttonLHeight*0.25f, buttonLWidth*0.05f)));
System.err.println("Button Size: "+buttonLWidth+" x "+buttonLHeight);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java b/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java
index f4b35e723..52c46bc3a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/layout/Padding.java
@@ -27,23 +27,80 @@
*/
package com.jogamp.graph.ui.layout;
+import com.jogamp.opengl.math.FloatUtil;
+
/**
- * GraphUI Padding of cells, e.g. {@link GridLayout}.
+ * GraphUI CSS property Padding, space belonging to the element.
+ *
+ * The CSS padding properties are used to generate space around an element's content, inside of any defined borders.
*/
public class Padding {
- public final float left, right, bottom, top;
+ /** Top value */
+ public final float top;
+ /** Right value */
+ public final float right;
+ /** Bottom value */
+ public final float bottom;
+ /** Left value */
+ public final float left;
+ /**
+ * Ctor w/ zero values
+ */
public Padding() {
- left = 0f; right = 0f; bottom = 0f; top = 0f;
+ top = 0f; right = 0f; bottom = 0f; left = 0f;
+ }
+
+ /**
+ * Ctor
+ * @param top top value
+ * @param right right value
+ * @param bottom bottom value
+ * @param left left value
+ */
+ public Padding(final float top, final float right, final float bottom, final float left) {
+ this.top = top; this.right = right; this.bottom = bottom; this.left = left;
}
- public Padding(final float width, final float height) {
- left = width/2f; right = width/2f; bottom = height/2f; top = height/2f;
+
+ /**
+ * Ctor
+ * @param top top value
+ * @param rl right and left value
+ * @param bottom bottom value
+ */
+ public Padding(final float top, final float rl, final float bottom) {
+ this.top = top; this.right = rl; this.bottom = bottom; this.left = rl;
+ }
+
+ /**
+ * Ctor
+ * @param tb top and bottom value
+ * @param rl right and left value
+ */
+ public Padding(final float tb, final float rl) {
+ this.top = tb; this.right = rl; this.bottom = tb; this.left = rl;
}
- public Padding(final float left, final float right, final float bottom, final float top) {
- this.left = left; this.right = right; this.bottom = bottom; this.top = top;
+
+ /**
+ * Ctor
+ * @param trbl top, right, bottom and left value
+ */
+ public Padding(final float trbl) {
+ this.top = trbl; this.right = trbl; this.bottom = trbl; this.left = trbl;
}
+
+ /** Return width of horizontal values top + right. */
public float width() { return left + right; }
+
+ /** Return height of vertical values bottom + top. */
public float height() { return bottom + top; }
+
+ public boolean zeroSumWidth() { return FloatUtil.isZero( width() ); };
+
+ public boolean zeroSumHeight() { return FloatUtil.isZero( height() ); };
+
+ public boolean zeroSumSize() { return zeroSumWidth() && zeroSumHeight(); }
+
@Override
- public String toString() { return "Padding[l "+left+", r "+right+", b "+bottom+", t "+top+"]"; }
+ public String toString() { return "Padding[t "+top+", r "+right+", b "+bottom+", l "+left+"]"; }
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
index d1792d7ba..e18649cfa 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/FontViewListener01.java
@@ -122,7 +122,7 @@ public class FontViewListener01 implements GLEventListener {
final float gridSize = gridCols > gridRows ? 1f/gridCols : 1f/gridRows;
System.err.println("Reshape Grid "+gridCols+" x "+gridRows+", "+cellCount+" cells, gridSize "+gridSize);
- grid = new Group(new GridLayout(gridCols, gridSize, gridSize, new Padding(gridSize*0.1f, gridSize*0.1f)));
+ grid = new Group(new GridLayout(gridCols, gridSize, gridSize, new Padding(gridSize*0.05f, gridSize*0.05f)));
scene.addShape(grid);
for(int i=0; i<cellCount; ++i) {