aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java2
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java5
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java91
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPopupMenu.java8
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/GradientBackdrop.java10
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/ImageBackdrop.java16
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/MultiImageBackdrop.java11
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/SolidBackdrop.java12
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/ImageBorder.java20
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java12
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/Insets.java13
11 files changed, 114 insertions, 86 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
index e55c63a..f855cb3 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
@@ -130,7 +130,7 @@ public class InteractManager {
}, new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
if (_spatialTarget != null) {
- _state.getTransform().set(_spatialTarget.getTransform());
+ _state.copyState(_spatialTarget);
}
_inputConsumed.set(false);
offerInputToWidgets(source, inputStates);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java
index b9aaae4..2364e25 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/data/SpatialState.java
@@ -38,6 +38,11 @@ public class SpatialState {
_userData = userData;
}
+ public void copyState(final Spatial source) {
+ _transform.set(source.getTransform());
+ _userData = source.getUserData();
+ }
+
public void applyState(final Spatial target) {
target.setTransform(_transform);
target.setUserData(_userData);
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
index 9cbab74..69ea13f 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIComponent.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -50,7 +50,7 @@ import com.google.common.collect.Maps;
/**
* Base UI class. All UI components/widgets/controls extend this class.
- *
+ *
* TODO: alert/dirty needed for font style changes.
*/
public abstract class UIComponent extends Node implements UIKeyHandler {
@@ -170,7 +170,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Used primarily during rendering to determine how alpha blending should be done.
- *
+ *
* @return true if nothing has been drawn by this component or its ancestors yet that would affect its content area.
*/
public boolean hasVirginContentArea() {
@@ -193,7 +193,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Add a new font style to this component. Will be inherited by children if they do not have the same key.
- *
+ *
* @param styleKey
* style key
* @param styleValue
@@ -206,7 +206,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Removes a font style locally from this component, if present.
- *
+ *
* @param styleKey
* style key
* @return the style value we were mapped to, or null if none (or was mapped to null).
@@ -291,7 +291,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
}
/**
- *
+ *
* @param store
* the object to store our results in. If null, a new Rectangle2 is created and returned.
* @return
@@ -307,7 +307,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
}
/**
- *
+ *
* @param store
* the object to store our results in. If null, a new Rectangle2 is created and returned.
* @return
@@ -323,7 +323,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
}
/**
- *
+ *
* @param store
* the object to store our results in. If null, a new Rectangle2 is created and returned.
* @return the current bounds of this component, in the coordinate space of its parent.
@@ -377,7 +377,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the width and height of this component by forcing the content area to be of a proper size such that when the
* padding, margin and border are added, the total component size match those given.
- *
+ *
* @param width
* the new width of the component
* @param height
@@ -418,7 +418,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the width and height of the content area of this component.
- *
+ *
* @param width
* the new width of the content area
* @param height
@@ -438,7 +438,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the height of the content area of this component to that given, as long as we're between min and max content
* height.
- *
+ *
* @param height
* the new height
*/
@@ -450,7 +450,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the width of the content area of this component to that given, as long as we're between min and max content
* width.
- *
+ *
* @param width
* the new width
*/
@@ -461,7 +461,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the current component height to that given, as long as it would not violate min and max content height.
- *
+ *
* @param height
* the new height
*/
@@ -471,7 +471,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the current component width to that given, as long as it would not violate min and max content width.
- *
+ *
* @param width
* the new width
*/
@@ -495,7 +495,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the maximum content size of this component to the values given.
- *
+ *
* @param width
* @param height
*/
@@ -506,7 +506,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the maximum content width of this component to the value given.
- *
+ *
* @param width
*/
public void setMaximumContentWidth(final int width) {
@@ -515,7 +515,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the maximum content height of this component to the value given.
- *
+ *
* @param height
*/
public void setMaximumContentHeight(final int height) {
@@ -525,7 +525,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the minimum content size of this component to the values given.
- *
+ *
* @param width
* @param height
*/
@@ -536,7 +536,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the minimum content width of this component to the value given.
- *
+ *
* @param width
*/
public void setMinimumContentWidth(final int width) {
@@ -546,7 +546,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the minimum content height of this component to the value given.
- *
+ *
* @param height
*/
public void setMinimumContentHeight(final int height) {
@@ -591,7 +591,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Attempt to force this component to fit in the given rectangle.
- *
+ *
* @param width
* @param height
*/
@@ -832,7 +832,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Sets the screen x,y coordinate of this component's origin (usually its lower left corner.)
- *
+ *
* @param x
* @param y
*/
@@ -876,7 +876,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Set the x,y translation from the lower left corner of our parent's content area to the origin of this component.
- *
+ *
* @param x
* @param y
*/
@@ -887,7 +887,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Set the x translation from the lower left corner of our parent's content area to the origin of this component.
- *
+ *
* @param x
*/
public void setLocalX(final int x) {
@@ -898,7 +898,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Set the y translation from the lower left corner of our parent's content area to the origin of this component.
- *
+ *
* @param y
*/
public void setLocalY(final int y) {
@@ -1009,12 +1009,13 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
vec.set(hudX, hudY, 0);
getWorldTransform().applyInverse(vec);
- final double x = vec.getX() - getMargin().getLeft();
- final double y = vec.getY() - getMargin().getBottom();
+ final Insets margin = getMargin() != null ? getMargin() : Insets.EMPTY;
+ final double x = vec.getX() - margin.getLeft();
+ final double y = vec.getY() - margin.getBottom();
Vector3.releaseTempInstance(vec);
- return x >= 0 && x < getLocalComponentWidth() - getMargin().getLeft() - getMargin().getRight() && y >= 0
- && y < getLocalComponentHeight() - getMargin().getBottom() - getMargin().getTop();
+ return x >= 0 && x < getLocalComponentWidth() - margin.getLeft() - margin.getRight() && y >= 0
+ && y < getLocalComponentHeight() - margin.getBottom() - margin.getTop();
}
/**
@@ -1039,7 +1040,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Allow skipping updating our own world transform.
- *
+ *
* @param recurse
* @param self
*/
@@ -1236,7 +1237,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Set the opacity level of this component.
- *
+ *
* @param opacity
* value in [0,1], where 0 means completely transparent and 1 is completely opaque.
*/
@@ -1289,7 +1290,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Perform any pre-draw operations on this component.
- *
+ *
* @param renderer
*/
protected void predrawComponent(final Renderer renderer) {
@@ -1298,14 +1299,14 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Perform any post-draw operations on this component.
- *
+ *
* @param renderer
*/
protected void postdrawComponent(final Renderer renderer) {}
/**
* Draw this component's contents using the given renderer.
- *
+ *
* @param renderer
*/
protected void drawComponent(final Renderer renderer) {}
@@ -1316,7 +1317,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse cursor enters this component.
- *
+ *
* @param mouseX
* mouse x coordinate.
* @param mouseY
@@ -1329,7 +1330,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
}
/**
- *
+ *
*/
private void scheduleToolTip() {
final UIHud hud = getHud();
@@ -1402,7 +1403,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse cursor leaves this component.
- *
+ *
* @param mouseX
* mouse x coordinate.
* @param mouseY
@@ -1421,7 +1422,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse button is pressed while the cursor is over this component.
- *
+ *
* @param button
* the button that was pressed
* @param state
@@ -1439,7 +1440,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse button is released while the cursor is over this component.
- *
+ *
* @param button
* the button that was released
* @param state
@@ -1457,7 +1458,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse button is pressed and released in close proximity while the cursor is over this component.
- *
+ *
* @param button
* the button that was released
* @param state
@@ -1475,7 +1476,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when a mouse is moved while the cursor is over this component.
- *
+ *
* @param mouseX
* mouse x coordinate.
* @param mouseY
@@ -1501,7 +1502,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when the mouse wheel is moved while the cursor is over this component.
- *
+ *
* @param wheelDx
* the last change of the wheel
* @param state
@@ -1519,7 +1520,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when this component has focus and a key is pressed.
- *
+ *
* @param key
* the key pressed.
* @param the
@@ -1536,7 +1537,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when this component has focus and a key is held down over more than 1 input cycle.
- *
+ *
* @param key
* the key held.
* @param the
@@ -1553,7 +1554,7 @@ public abstract class UIComponent extends Node implements UIKeyHandler {
/**
* Called when this component has focus and a key is released.
- *
+ *
* @param key
* the key released.
* @param the
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPopupMenu.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPopupMenu.java
index f06e1e3..11df42b 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPopupMenu.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPopupMenu.java
@@ -1,8 +1,8 @@
/**
* Copyright (c) 2008-2012 Ardor Labs, Inc.
- *
+ *
* This file is part of Ardor3D.
- *
+ *
* Ardor3D is free software: you can redistribute it and/or modify it under the terms of its license which may be found
* in the accompanying LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -12,6 +12,7 @@ package com.ardor3d.extension.ui;
import java.util.EnumSet;
import com.ardor3d.extension.ui.layout.RowLayout;
+import com.ardor3d.extension.ui.util.Insets;
/**
* A special frame meant to display menu items.
@@ -34,7 +35,8 @@ public class UIPopupMenu extends UIFrame {
if (x + width > displayW) {
setHudX(displayW - width);
} else {
- setHudX(x - getBorder().getLeft());
+ final Insets border = getBorder() != null ? getBorder() : Insets.EMPTY;
+ setHudX(x - border.getLeft());
}
y = y - height;
if (y < 0) {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/GradientBackdrop.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/GradientBackdrop.java
index ad0aab7..ee156ad 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/GradientBackdrop.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/GradientBackdrop.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -11,6 +11,7 @@
package com.ardor3d.extension.ui.backdrop;
import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Transform;
import com.ardor3d.math.Vector3;
@@ -44,7 +45,7 @@ public class GradientBackdrop extends UIBackdrop {
/**
* Construct this back drop, using the given corner colors.
- *
+ *
* @param topLeft
* @param topRight
* @param bottomLeft
@@ -96,8 +97,9 @@ public class GradientBackdrop extends UIBackdrop {
final float pAlpha = UIComponent.getCurrentOpacity();
final Vector3 v = Vector3.fetchTempInstance();
- v.set(comp.getMargin().getLeft() + comp.getBorder().getLeft(), comp.getMargin().getBottom()
- + comp.getBorder().getBottom(), 0);
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ final Insets border = comp.getBorder() != null ? comp.getBorder() : Insets.EMPTY;
+ v.set(margin.getLeft() + border.getLeft(), margin.getBottom() + border.getBottom(), 0);
final Transform t = Transform.fetchTempInstance();
t.set(comp.getWorldTransform());
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/ImageBackdrop.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/ImageBackdrop.java
index 165ffc8..79316bf 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/ImageBackdrop.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/ImageBackdrop.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -14,6 +14,7 @@ import java.util.Arrays;
import com.ardor3d.extension.ui.UIComponent;
import com.ardor3d.extension.ui.util.Alignment;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.extension.ui.util.SubTexUtil;
import com.ardor3d.math.ColorRGBA;
@@ -52,7 +53,7 @@ public class ImageBackdrop extends SolidBackdrop {
/**
* Construct this back drop, using the given image.
- *
+ *
* @param image
*/
public ImageBackdrop(final SubTex image) {
@@ -62,7 +63,7 @@ public class ImageBackdrop extends SolidBackdrop {
/**
* Construct this back drop, using the given image and color.
- *
+ *
* @param image
* the image to draw
* @param color
@@ -83,8 +84,11 @@ public class ImageBackdrop extends SolidBackdrop {
final double width = _dims[2];
final double height = _dims[3];
- x += comp.getMargin().getLeft() + comp.getBorder().getLeft();
- y += comp.getMargin().getBottom() + comp.getBorder().getBottom();
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ final Insets border = comp.getBorder() != null ? comp.getBorder() : Insets.EMPTY;
+
+ x += margin.getLeft() + border.getLeft();
+ y += margin.getBottom() + border.getBottom();
SubTexUtil.drawSubTex(renderer, _image, x, y, width, height, comp.getWorldTransform(), getTintColor());
}
@@ -185,7 +189,7 @@ public class ImageBackdrop extends SolidBackdrop {
/**
* Sets a color to use for tinting the backdrop.
- *
+ *
* @param color
*/
public void setTintColor(final ReadOnlyColorRGBA color) {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/MultiImageBackdrop.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/MultiImageBackdrop.java
index e9b951d..d19c994 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/MultiImageBackdrop.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/MultiImageBackdrop.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -15,6 +15,7 @@ import java.util.Collections;
import java.util.List;
import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.extension.ui.util.SubTexUtil;
import com.ardor3d.extension.ui.util.TransformedSubTex;
import com.ardor3d.math.ColorRGBA;
@@ -38,7 +39,7 @@ public class MultiImageBackdrop extends SolidBackdrop {
/**
* Construct this back drop, using the given backdrop color.
- *
+ *
* @param backDropColor
* the color of the backdrop
*/
@@ -73,9 +74,11 @@ public class MultiImageBackdrop extends SolidBackdrop {
for (final TransformedSubTex entry : _images) {
MultiImageBackdrop.getDimensions(entry, comp, bgwidth, bgheight, store);
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ final Insets border = comp.getBorder() != null ? comp.getBorder() : Insets.EMPTY;
- store[0] += comp.getMargin().getLeft() + comp.getBorder().getLeft();
- store[1] += comp.getMargin().getBottom() + comp.getBorder().getBottom();
+ store[0] += margin.getLeft() + border.getLeft();
+ store[1] += margin.getBottom() + border.getBottom();
SubTexUtil.drawTransformedSubTex(renderer, entry, (int) Math.round(store[0]), (int) Math.round(store[1]),
entry.getWidth(), entry.getHeight(), false, comp.getWorldTransform());
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/SolidBackdrop.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/SolidBackdrop.java
index 362e7fa..000ff64 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/SolidBackdrop.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/backdrop/SolidBackdrop.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -11,6 +11,7 @@
package com.ardor3d.extension.ui.backdrop;
import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.extension.ui.util.UIQuad;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Transform;
@@ -33,7 +34,7 @@ public class SolidBackdrop extends UIBackdrop {
/**
* Construct this backdrop, using the given color.
- *
+ *
* @param color
* the color of the backdrop
*/
@@ -50,7 +51,7 @@ public class SolidBackdrop extends UIBackdrop {
/**
* Set the color of this back drop.
- *
+ *
* @param color
* the color to use
*/
@@ -73,8 +74,9 @@ public class SolidBackdrop extends UIBackdrop {
SolidBackdrop._standin.setDefaultColor(_color);
final Vector3 v = Vector3.fetchTempInstance();
- v.set(comp.getMargin().getLeft() + comp.getBorder().getLeft(), comp.getMargin().getBottom()
- + comp.getBorder().getBottom(), 0);
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ final Insets border = comp.getBorder() != null ? comp.getBorder() : Insets.EMPTY;
+ v.set(margin.getLeft() + border.getLeft(), margin.getBottom() + border.getBottom(), 0);
final Transform t = Transform.fetchTempInstance();
t.set(comp.getWorldTransform());
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/ImageBorder.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/ImageBorder.java
index 070b877..1146ecd 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/ImageBorder.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/ImageBorder.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -11,6 +11,7 @@
package com.ardor3d.extension.ui.border;
import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.extension.ui.util.SubTexUtil;
import com.ardor3d.renderer.Renderer;
@@ -34,7 +35,7 @@ public class ImageBorder extends UIBorder {
/**
* Construct this border using the given edge images. The corners will not be drawn.
- *
+ *
* @param leftEdge
* @param rightEdge
* @param topEdge
@@ -51,7 +52,7 @@ public class ImageBorder extends UIBorder {
/**
* Construct this border using the given edge and side images.
- *
+ *
* @param leftEdge
* @param rightEdge
* @param topEdge
@@ -148,8 +149,9 @@ public class ImageBorder extends UIBorder {
final int borderHeight = UIBorder.getBorderHeight(comp);
// Figure out our bottom left corner
- final double dX = comp.getMargin().getLeft();
- final double dY = comp.getMargin().getBottom();
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ final double dX = margin.getLeft();
+ final double dY = margin.getBottom();
{
// draw bottom - stretched to fit
@@ -197,13 +199,13 @@ public class ImageBorder extends UIBorder {
_topLeftCorner.getWidth(), _topLeftCorner.getHeight(), comp.getWorldTransform());
}
if (_bottomLeftCorner != null) {
- SubTexUtil.drawSubTex(renderer, _bottomLeftCorner, dX, dY, _bottomLeftCorner.getWidth(), _bottomLeftCorner
- .getHeight(), comp.getWorldTransform());
+ SubTexUtil.drawSubTex(renderer, _bottomLeftCorner, dX, dY, _bottomLeftCorner.getWidth(),
+ _bottomLeftCorner.getHeight(), comp.getWorldTransform());
}
if (_topRightCorner != null) {
SubTexUtil.drawSubTex(renderer, _topRightCorner, dX + (borderWidth - _topRightCorner.getWidth()), dY
- + (borderHeight - _topRightCorner.getHeight()), _topRightCorner.getWidth(), _topRightCorner
- .getHeight(), comp.getWorldTransform());
+ + (borderHeight - _topRightCorner.getHeight()), _topRightCorner.getWidth(),
+ _topRightCorner.getHeight(), comp.getWorldTransform());
}
if (_bottomRightCorner != null) {
SubTexUtil.drawSubTex(renderer, _bottomRightCorner, dX + (borderWidth - _bottomRightCorner.getWidth()), dY,
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
index 171c72e..0024bc9 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/border/SolidBorder.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -11,6 +11,7 @@
package com.ardor3d.extension.ui.border;
import com.ardor3d.extension.ui.UIComponent;
+import com.ardor3d.extension.ui.util.Insets;
import com.ardor3d.math.ColorRGBA;
import com.ardor3d.math.Transform;
import com.ardor3d.math.Vector3;
@@ -47,7 +48,7 @@ public class SolidBorder extends UIBorder {
/**
* Construct a border with the given thicknesses. Uses the default colors.
- *
+ *
* @param top
* @param left
* @param bottom
@@ -59,7 +60,7 @@ public class SolidBorder extends UIBorder {
/**
* Construct a border with the given thicknesses and colors
- *
+ *
* @param top
* @param left
* @param bottom
@@ -113,7 +114,7 @@ public class SolidBorder extends UIBorder {
/**
* Sets all of the border colors to the given color.
- *
+ *
* @param solidColor
* new color for all borders
*/
@@ -131,7 +132,8 @@ public class SolidBorder extends UIBorder {
final float pAlpha = UIComponent.getCurrentOpacity();
final Vector3 v = Vector3.fetchTempInstance();
- v.set(comp.getMargin().getLeft(), comp.getMargin().getBottom(), 0);
+ final Insets margin = comp.getMargin() != null ? comp.getMargin() : Insets.EMPTY;
+ v.set(margin.getLeft(), margin.getBottom(), 0);
final Transform t = Transform.fetchTempInstance();
t.set(comp.getWorldTransform());
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/Insets.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/Insets.java
index d9f8fe6..941b707 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/Insets.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/util/Insets.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -16,6 +16,11 @@ package com.ardor3d.extension.ui.util;
*/
public class Insets {
+ /**
+ * 0, 0, 0, 0
+ */
+ public final static Insets EMPTY = new Insets(0, 0, 0, 0);
+
private int _top;
private int _left;
private int _bottom;
@@ -30,7 +35,7 @@ public class Insets {
/**
* Constructs a new insets using the given sizes.
- *
+ *
* @param top
* @param left
* @param bottom
@@ -42,7 +47,7 @@ public class Insets {
/**
* Constructs a new insets using the sizes from the given source.
- *
+ *
* @param source
*/
public Insets(final Insets source) {
@@ -51,7 +56,7 @@ public class Insets {
/**
* Set the size of the sides to the given values.
- *
+ *
* @param top
* @param left
* @param bottom