Quellcode durchsuchen

Added 2D Scene implementation, fixed UI module to work with the new system, made clipping planes be defined by camera

Ivan Safrin vor 12 Jahren
Ursprung
Commit
03b6f5b4ac
36 geänderte Dateien mit 231 neuen und 235 gelöschten Zeilen
  1. BIN
      Assets/UIThemes.pak
  2. BIN
      Assets/UIThemes/default/textfield.png
  3. 8 1
      Core/Contents/Include/PolyCamera.h
  4. 9 7
      Core/Contents/Include/PolyEntity.h
  5. 0 2
      Core/Contents/Include/PolyImage.h
  6. 11 8
      Core/Contents/Include/PolyScene.h
  7. 1 1
      Core/Contents/Include/PolySceneImage.h
  8. 15 0
      Core/Contents/Source/PolyCamera.cpp
  9. 34 20
      Core/Contents/Source/PolyEntity.cpp
  10. 1 2
      Core/Contents/Source/PolyGLRenderer.cpp
  11. 0 51
      Core/Contents/Source/PolyImage.cpp
  12. 7 0
      Core/Contents/Source/PolyLabel.cpp
  13. 28 15
      Core/Contents/Source/PolyScene.cpp
  14. 19 18
      Core/Contents/Source/PolySceneImage.cpp
  15. 7 7
      Core/Contents/Source/PolySceneLabel.cpp
  16. 0 11
      Core/Contents/Source/PolySceneMesh.cpp
  17. 1 0
      Core/Contents/Source/PolyScenePrimitive.cpp
  18. 1 1
      Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp
  19. 5 10
      Modules/Contents/UI/Source/PolyUIBox.cpp
  20. 4 4
      Modules/Contents/UI/Source/PolyUIButton.cpp
  21. 2 2
      Modules/Contents/UI/Source/PolyUICheckBox.cpp
  22. 2 2
      Modules/Contents/UI/Source/PolyUIColorBox.cpp
  23. 5 5
      Modules/Contents/UI/Source/PolyUIComboBox.cpp
  24. 1 0
      Modules/Contents/UI/Source/PolyUIElement.cpp
  25. 5 5
      Modules/Contents/UI/Source/PolyUIHScrollBar.cpp
  26. 11 11
      Modules/Contents/UI/Source/PolyUIHSizer.cpp
  27. 2 2
      Modules/Contents/UI/Source/PolyUIHSlider.cpp
  28. 3 2
      Modules/Contents/UI/Source/PolyUIImageButton.cpp
  29. 2 2
      Modules/Contents/UI/Source/PolyUIMenuBar.cpp
  30. 11 11
      Modules/Contents/UI/Source/PolyUIScrollContainer.cpp
  31. 16 16
      Modules/Contents/UI/Source/PolyUITextInput.cpp
  32. 2 2
      Modules/Contents/UI/Source/PolyUITree.cpp
  33. 4 4
      Modules/Contents/UI/Source/PolyUITreeContainer.cpp
  34. 8 8
      Modules/Contents/UI/Source/PolyUIVScrollBar.cpp
  35. 2 2
      Modules/Contents/UI/Source/PolyUIVSizer.cpp
  36. 4 3
      Modules/Contents/UI/Source/PolyUIWindow.cpp

BIN
Assets/UIThemes.pak


BIN
Assets/UIThemes/default/textfield.png


+ 8 - 1
Core/Contents/Include/PolyCamera.h

@@ -71,6 +71,8 @@ namespace Polycode {
 			* @param orthoSizeY Height of the orthographic frustum (defaults to 1.0)				
 			*/			
 			void setOrthoMode(bool mode, Number orthoSizeX = 1.0, Number orthoSizeY = 1.0);
+
+			void setOrthoSize(Number orthoSizeX, Number orthoSizeY);
 			
 			/**
 			* Returns true if camera is in orthographic projection mode.
@@ -102,6 +104,8 @@ namespace Polycode {
 			*/			
 			Number getFOV();
 			
+			void setClippingPlanes(Number nearClipPlane, Number farClipPlane);
+			
 			void setParentScene(Scene *parentScene);
 			
 			void doCameraTransform();
@@ -160,7 +164,10 @@ namespace Polycode {
 		
 			Number orthoSizeX;
 			Number orthoSizeY;
-					
+			
+			Number nearClipPlane;
+			Number farClipPlane;
+								
 			Number exposureLevel;
 			bool orthoMode;
 			Number fov;

+ 9 - 7
Core/Contents/Include/PolyEntity.h

@@ -634,9 +634,11 @@ namespace Polycode {
 			String getEntityProp(const String& propName);
 			void setEntityProp(const String& propName, const String& propValue);
 			
+			void setInverseY(bool val);
+			bool getInverseY();
+			
 			void doUpdates();				
 			virtual Matrix4 buildPositionMatrix();
-			virtual void adjustMatrixForChildren();
 			void setRenderer(Renderer *renderer);						
 			
 			
@@ -713,9 +715,6 @@ namespace Polycode {
 			bool hasFocus;
 			bool focusable;
 			
-			Number width;
-			Number height;
-			
 			void setDragLimits(Rectangle rect) {}
 			void clearDragLimits() {}
 			bool isDragged() { return dragged; }
@@ -726,8 +725,8 @@ namespace Polycode {
 			void setHitbox(Number width, Number height) {}
 			
 			void focusChild(Entity *child) {}
-			void focusNextChild();
-			bool isFocusable();
+			void focusNextChild() {}
+			bool isFocusable() {}
 			
 			Vector2 getScreenPosition() const { return Vector2(); }
 
@@ -735,9 +734,13 @@ namespace Polycode {
 			bool hitTest(Vector2 v) const { return false; }
 
 			bool snapToPixels;
+			
 			//@}		
 		protected:
 		
+			void adjustMatrixForChildren();
+		
+			Number yAdjust;
 			std::vector<String> *tags;
 		
 			void checkTransformSetters();
@@ -758,7 +761,6 @@ namespace Polycode {
 			bool lockMatrix;
 			bool matrixDirty;
 			Matrix4 transformMatrix;		
-			Number matrixAdj;		
 			Entity *parentEntity;
 		
 			Renderer *renderer;

+ 0 - 2
Core/Contents/Include/PolyImage.h

@@ -244,8 +244,6 @@ namespace Polycode {
 		
 			int getType() const { return imageType; }
 			
-			void writeBMP(const String& fileName) const;
-			
 			/**
 			* Returns the width of the image.
 			*/			

+ 11 - 8
Core/Contents/Include/PolyScene.h

@@ -46,14 +46,15 @@ namespace Polycode {
 	public:
 		
 		/**
-		* Default constructor.
+		* Default constructor. Defaults to type Scene::SCENE_3D
 		*/
 		Scene();
 		/**
 		* Default constructor with options. 
+		* @param sceneType Type of scene to create. Can be Scene::SCENE_2D, Scene::SCENE_3D or Scene::SCENE_2D_TOPLEFT
 		* @param virtualScene If this flag is set to true, the scene is not rendered to the screen. Use this if you want to render the scene only to a texture.
 		*/		
-		Scene(bool virtualScene);
+		Scene(int sceneType, bool virtualScene = false);
 		virtual ~Scene();
 		
 		/**
@@ -139,12 +140,6 @@ namespace Polycode {
 				
 		int getNumLights();
 		SceneLight *getLight(int index);
-				
-		static const unsigned int ENTITY_MESH = 0;
-		static const unsigned int ENTITY_LIGHT = 1;			
-		static const unsigned int ENTITY_CAMERA = 2;			
-		static const unsigned int ENTITY_ENTITY = 3;
-		static const unsigned int ENTITY_COLLMESH = 4;
 		
 		/**
 		* Scene clear color
@@ -176,10 +171,16 @@ namespace Polycode {
 		*/
 		bool ownsChildren;
 		
+		static const int SCENE_3D = 0;
+		static const int SCENE_2D = 1;
+		static const int SCENE_2D_TOPLEFT = 2;
+						
 		Entity rootEntity;
 		
 	protected:
 		
+		void initScene(int sceneType, bool virtualScene);
+		
 		bool hasLightmaps;
 		
 		Renderer *renderer;
@@ -196,5 +197,7 @@ namespace Polycode {
 		Number fogStartDepth;
 		Number fogEndDepth;
 		
+		int sceneType;
+		
 	};
 }

+ 1 - 1
Core/Contents/Include/PolySceneImage.h

@@ -74,7 +74,7 @@ namespace Polycode {
 		* @param width Width of the display rectangle.
 		* @param height Height of the display rectangle.
 		*/				
-		void setImageCoordinates(Number x, Number y, Number width, Number height);
+		void setImageCoordinates(Number x, Number y, Number width, Number height, Number realWidth=-1, Number realHeight=-1);
 
 		/**
 		* Returns the image width.

+ 15 - 0
Core/Contents/Source/PolyCamera.cpp

@@ -44,6 +44,8 @@ Camera::Camera(Scene *parentScene) : Entity() {
 	_hasFilterShader = false;	
 	fovSet = false;
 	frustumCulling = true;
+	nearClipPlane = 1.0;
+	farClipPlane = 1000.0;
 }
 
 Camera::~Camera() {	
@@ -55,6 +57,12 @@ Camera::~Camera() {
 	delete zBufferSceneTexture;
 }
 
+void Camera::setClippingPlanes(Number nearClipPlane, Number farClipPlane) {
+	this->nearClipPlane = nearClipPlane;
+	this->farClipPlane = farClipPlane;	
+}
+
+
 void Camera::setExposureLevel(Number level) {
 	exposureLevel = level;
 }
@@ -89,6 +97,11 @@ bool Camera::isSphereInFrustum(Vector3 pos, Number fRadius) {
     return true;
 }
 
+void Camera::setOrthoSize(Number orthoSizeX, Number orthoSizeY) {
+	this->orthoSizeX = orthoSizeX;
+	this->orthoSizeY = orthoSizeY;
+}
+
 void Camera::setOrthoMode(bool mode, Number orthoSizeX, Number orthoSizeY) {
 	this->orthoSizeX = orthoSizeX;
 	this->orthoSizeY = orthoSizeY;
@@ -381,6 +394,8 @@ void Camera::drawFilter(Texture *targetTexture, Number targetTextureWidth, Numbe
 
 void Camera::doCameraTransform() {
 
+	CoreServices::getInstance()->getRenderer()->setClippingPlanes(nearClipPlane, farClipPlane);
+
 	if(fovSet)
 			CoreServices::getInstance()->getRenderer()->setFOV(fov);
 	CoreServices::getInstance()->getRenderer()->setExposureLevel(exposureLevel);

+ 34 - 20
Core/Contents/Source/PolyEntity.cpp

@@ -41,7 +41,6 @@ Entity::Entity() : EventDispatcher() {
 	color.setColor(1.0f,1.0f,1.0f,1.0f);
 	parentEntity = NULL;
 	matrixDirty = true;
-	matrixAdj = 1.0f;
 	billboardMode = false;
 	billboardRoll = false;
 	billboardIgnoreScale = false;
@@ -63,6 +62,7 @@ Entity::Entity() : EventDispatcher() {
 	hasFocus = false;
 	snapToPixels = false;
 	tags = NULL;
+	yAdjust = 1.0;
 	positionMode = POSITION_CENTER;
 }
 
@@ -304,20 +304,33 @@ Vector3 Entity::getChildCenter() const {
 	return childCenter;
 }
 
+void Entity::setInverseY(bool val) {
+	if(val) {
+		yAdjust = -1.0;
+	} else {
+		yAdjust = 1.0;	
+	}
+	for(int i=0; i < children.size(); i++) {
+		children[i]->setInverseY(val);
+	}
+}
 
-Matrix4 Entity::buildPositionMatrix() {
+bool Entity::getInverseY() {
+	return (yAdjust == -1.0);
+}
 
+Matrix4 Entity::buildPositionMatrix() {
 	Matrix4 posMatrix;
 	switch(positionMode) {
 		case POSITION_TOPLEFT:
-			posMatrix.m[3][0] = (position.x+floor(bBox.x/2.0f)*scale.x)*matrixAdj;
-			posMatrix.m[3][1] = (position.y+floor(bBox.y/2.0f)*scale.y)*matrixAdj;
-			posMatrix.m[3][2] = position.z*matrixAdj;			
+			posMatrix.m[3][0] = (position.x+(bBox.x/2.0f)*scale.x);
+			posMatrix.m[3][1] = (position.y+(bBox.y/2.0f)*scale.y) * yAdjust;
+			posMatrix.m[3][2] = position.z;			
 		break;
 		case POSITION_CENTER:
-			posMatrix.m[3][0] = position.x*matrixAdj;
-			posMatrix.m[3][1] = position.y*matrixAdj;
-			posMatrix.m[3][2] = position.z*matrixAdj;
+			posMatrix.m[3][0] = position.x;
+			posMatrix.m[3][1] = position.y * yAdjust;
+			posMatrix.m[3][2] = position.z;
 		break;
 	}
 
@@ -331,6 +344,16 @@ Matrix4 Entity::buildPositionMatrix() {
 	return posMatrix;
 }
 
+void Entity::adjustMatrixForChildren() {
+	if(positionMode == POSITION_TOPLEFT) {
+		if(snapToPixels) {
+			renderer->translate2D(-floor(bBox.x/2.0f), floor(bBox.y/2.0f));			
+		} else {
+			renderer->translate2D(-bBox.x/2.0f, bBox.y/2.0f);	
+		}
+	}
+}
+
 void Entity::rebuildTransformMatrix() {
 	if(lockMatrix)
 		return;
@@ -401,7 +424,7 @@ Vector3 Entity::getCompoundScale() const {
 
 Matrix4 Entity::getConcatenatedRollMatrix() const {
 	Quaternion q;
-	q.createFromAxisAngle(0.0f, 0.0f, 1.0f, _rotation.roll*matrixAdj);
+	q.createFromAxisAngle(0.0f, 0.0f, 1.0f, _rotation.roll);
 	Matrix4 transformMatrix = q.createMatrix();	
 	
 	if(parentEntity != NULL) 
@@ -519,6 +542,7 @@ void Entity::setRenderer(Renderer *renderer) {
 void Entity::addEntity(Entity *newChild) {
 	newChild->setRenderer(renderer);
 	newChild->setParentEntity(this);
+	newChild->setInverseY(getInverseY());
 	children.push_back(newChild);	
 }
 
@@ -533,16 +557,6 @@ void Entity::dirtyMatrix(bool val) {
 	matrixDirty = val;
 }
 
-void Entity::adjustMatrixForChildren() {
-	if(positionMode == POSITION_TOPLEFT) {
-		if(snapToPixels) {
-			renderer->translate2D((int)-floor(bBox.x/2.0f),(int)floor(bBox.y/2.0f));			
-		} else {
-			renderer->translate2D(-bBox.x/2.0f, -bBox.y/2.0f);	
-		}
-	}
-}
-
 void Entity::setRotationQuat(Number w, Number x, Number y, Number z) {
 	rotationQuat.w = w;
 	rotationQuat.x = x;
@@ -669,7 +683,7 @@ void Entity::setDepth(Number depth) {
 }
 
 Number Entity::getWidth() const {
-	return bBox.z;
+	return bBox.x;
 }
 
 Number Entity::getHeight() const {

+ 1 - 2
Core/Contents/Source/PolyGLRenderer.cpp

@@ -95,7 +95,6 @@ OpenGLRenderer::OpenGLRenderer() : Renderer() {
 void OpenGLRenderer::setClippingPlanes(Number nearPlane_, Number farPlane_) {
 	nearPlane = nearPlane_;
 	farPlane = farPlane_;
-	Resize(xRes,yRes);
 }
 
 bool OpenGLRenderer::Init() {
@@ -515,7 +514,7 @@ void OpenGLRenderer::setOrthoMode(Number xSize, Number ySize, bool centered) {
 	if(centered) {
 		glOrtho(-xSize*0.5,xSize*0.5,-ySize*0.5,ySize*0.5,nearPlane,farPlane);		
 	} else {
-		glOrtho(0.0f,xSize,ySize,0,nearPlane,farPlane);
+		glOrtho(0.0f,xSize,0,ySize,nearPlane,farPlane);
 	}
 	glGetDoublev( GL_PROJECTION_MATRIX, sceneProjectionMatrixOrtho);
 		

+ 0 - 51
Core/Contents/Source/PolyImage.cpp

@@ -193,13 +193,6 @@ void Image::perlinNoise(int seed, bool alpha) {
 	}
 }
 
-void Image::writeBMP(const String& fileName) const {
-//	SDL_Surface *image;
-//	image = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x0000FF, 0x00FF00, 0xFF0000, 0x000000);
-//	memcpy(image->pixels,imageData,width * height * 4);
-//	SDL_SaveBMP(image, fileName.c_str());
-}
-
 void Image::fillRect(int x, int y, int w, int h, Color col) {
 	for(int i=0; i < w; i++) {
 		for(int j=0; j < h; j++) {
@@ -564,50 +557,6 @@ void Image::fastBlurVert(int blurSize) {
 void Image::fastBlur(int blurSize) {
 	fastBlurHor(blurSize);
 	fastBlurVert(blurSize);
-/*
-	unsigned char *blurImage = (unsigned char*)malloc(width*height*4);
-
-	int total_r;
-	int total_g;
-	int total_b;
-	int total_a;	
-	
-	unsigned int *imageData32 = (unsigned int*)imageData;
-	unsigned char *pixel;
-	int amt;	
-		
-	for (int y = 0; y < height; y++) {
-		for (int x = 0; x < width; x++) {
-                total_r = 0;
-				total_g = 0;
-				total_b = 0;
-				total_a = 0;
-				amt = 0;
-				for (int ky = -blurSize; ky <= blurSize; ky++) {
-					for (int kx = -blurSize; kx <= blurSize ; kx++) {
-						if(x+kx+((y+ky)*width) > 0 && x+kx+((y+ky)*width) < width*height) {
-							pixel = (unsigned char*)&(imageData32[(x+kx)+((y+ky)*width)]);
-							total_r += pixel[0];
-							total_g += pixel[1];
-							total_b += pixel[2];
-							total_a += pixel[3];
-							amt++;
-						}
-					}
-				}
-				
-//				Logger::log("%d / %d = %d\n",total_r, amt, (total_r/amt));
-				blurImage[((x+(y*width))*4)] = (total_r/amt);
-				blurImage[((x+(y*width))*4)+1] = (total_g / amt);
-				blurImage[((x+(y*width))*4)+2] = (total_b / amt);
-				blurImage[((x+(y*width))*4)+3] = (total_a / amt);
-				
-            }
-        }
-
-	imageData = (char*)blurImage;
-//	free(imageData32);
-*/
 }
 
 void Image::swap(int *v1, int *v2) {

+ 7 - 0
Core/Contents/Source/PolyLabel.cpp

@@ -420,6 +420,13 @@ void Label::setText(const String& text) {
 	unsigned int textWidth = (bbox.xMax -  bbox.xMin)+1;
 	unsigned int textHeight = (bbox.yMax -  bbox.yMin)+1;
 	
+	if(textWidth % 2 ){
+		textWidth++;
+	}
+	if(textHeight % 2 ){
+		textHeight++;
+	}
+	
 	baseLineOffset = bbox.yMin;
 	xAdjustOffset = bbox.xMin;
 	baseLineAdjust = bbox.yMax;

+ 28 - 15
Core/Contents/Source/PolyScene.cpp

@@ -32,29 +32,23 @@
 #include "PolyResourceManager.h"
 #include "PolySceneLight.h"
 #include "PolySceneMesh.h"
+#include "PolyCore.h"
 #include "PolySceneManager.h"
 
 using std::vector;
 using namespace Polycode;
 
 Scene::Scene() : EventDispatcher() {
-	defaultCamera = new Camera(this);
-	activeCamera = defaultCamera;
-	fogEnabled = false;
-	lightingEnabled = false;
-	enabled = true;
-	isSceneVirtual = false;
-	hasLightmaps = false;
-	clearColor.setColor(0.13f,0.13f,0.13f,1.0f); 
-	ambientColor.setColor(0.0,0.0,0.0,1.0);
-	useClearColor = false;
-	ownsChildren = false;
-	renderer = CoreServices::getInstance()->getRenderer();
-	rootEntity.setRenderer(renderer);
-	CoreServices::getInstance()->getSceneManager()->addScene(this);	
+	initScene(SCENE_3D, false);
+}
+
+Scene::Scene(int sceneType, bool virtualScene) : EventDispatcher() {
+	initScene(sceneType, virtualScene);
 }
 
-Scene::Scene(bool virtualScene) : EventDispatcher() {
+void Scene::initScene(int sceneType, bool virtualScene) {
+
+	this->sceneType = sceneType;
 	defaultCamera = new Camera(this);
 	activeCamera = defaultCamera;	
 	fogEnabled = false;
@@ -71,6 +65,22 @@ Scene::Scene(bool virtualScene) : EventDispatcher() {
 	if (!isSceneVirtual) {
 		CoreServices::getInstance()->getSceneManager()->addScene(this);
 	}
+	
+	switch(sceneType) {
+		case SCENE_2D:
+			defaultCamera->setClippingPlanes(-100.0, 100.0);
+			defaultCamera->setOrthoMode(true, CoreServices::getInstance()->getCore()->getXRes(),CoreServices::getInstance()->getCore()->getYRes());	
+		break;
+		case SCENE_2D_TOPLEFT:
+			defaultCamera->setClippingPlanes(-100.0, 100.0);
+			defaultCamera->setOrthoMode(true, 0,0);
+			defaultCamera->topLeftOrtho = true;
+			rootEntity.setInverseY(true);
+		break;
+		case SCENE_3D:
+			defaultCamera->setClippingPlanes(1.0, 1000.0);
+		break;		
+	}
 }
 
 void Scene::setActiveCamera(Camera *camera) {
@@ -98,6 +108,9 @@ bool Scene::isEnabled() {
 }
 
 void Scene::Update() {
+	if(sceneType == SCENE_2D_TOPLEFT) {
+		rootEntity.position.y = -CoreServices::getInstance()->getCore()->getYRes();
+	}
 	rootEntity.doUpdates();
 }
 

+ 19 - 18
Core/Contents/Source/PolySceneImage.cpp

@@ -43,7 +43,7 @@ SceneImage::SceneImage(const String& fileName) : ScenePrimitive(ScenePrimitive::
 	imageHeight = texture->getHeight();
 
 	setWidth(texture->getWidth());
-	setHeight(texture->getHeight());	
+	setHeight(texture->getHeight());
 	setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, getWidth(), getHeight());
 
 	setPositionMode(POSITION_TOPLEFT);
@@ -89,17 +89,22 @@ void SceneImage::applyClone(Entity *clone, bool deepClone, bool ignoreEditorOnly
 	//ScreenShape::applyClone(clone, deepClone, ignoreEditorOnly);
 }
 
-void SceneImage::setImageCoordinates(Number x, Number y, Number width, Number height) {
+void SceneImage::setImageCoordinates(Number x, Number y, Number width, Number height, Number realWidth, Number realHeight) {
 	Vertex *vertex;
+	
 	Number pixelSizeX = 1/imageWidth;
 	Number pixelSizeY = 1/imageHeight;
 
-	setWidth(width);
-	setHeight(height);
-		
-	Number whalf = floor(width/2.0f);
-	Number hhalf = floor(height/2.0f);	
+	if(realWidth == -1)
+		realWidth = width;
+	if(realHeight == -1)
+		realHeight = height;
 
+
+	setWidth(realWidth);
+	setHeight(realHeight);	
+	setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, getWidth(), getHeight());	
+		
 	Number xFloat = x * pixelSizeX;
 	Number yFloat = 1 - (y * pixelSizeY);
 	Number wFloat = width * pixelSizeX;
@@ -107,26 +112,22 @@ void SceneImage::setImageCoordinates(Number x, Number y, Number width, Number he
 
 	Polygon *imagePolygon = mesh->getPolygon(0);	
 	vertex = imagePolygon->getVertex(0);
-	vertex->set(-whalf,-hhalf,0);
-	vertex->setTexCoord(xFloat, yFloat);
+	vertex->setTexCoord(xFloat, yFloat - hFloat);
 
 	vertex = imagePolygon->getVertex(1);
-	vertex->set(-whalf+width,-hhalf,0);
-	vertex->setTexCoord(xFloat + wFloat, yFloat);
+	vertex->setTexCoord(xFloat + wFloat, yFloat - hFloat);
 
 	vertex = imagePolygon->getVertex(2);
-	vertex->set(-whalf+width,-hhalf+height,0);
-	vertex->setTexCoord(xFloat + wFloat, yFloat - hFloat);
+	vertex->setTexCoord(xFloat + wFloat, yFloat);
 
-	vertex = imagePolygon->getVertex(3);	
-	vertex->set(-whalf,-hhalf+height,0);	
-	vertex->setTexCoord(xFloat, yFloat - hFloat);
+	vertex = imagePolygon->getVertex(3);		
+	vertex->setTexCoord(xFloat, yFloat);
 
 	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
-	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;	
+	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;
+	
 	rebuildTransformMatrix();
 	matrixDirty = true;
-
 }
 
 Number SceneImage::getImageWidth() const {

+ 7 - 7
Core/Contents/Source/PolySceneLabel.cpp

@@ -34,7 +34,8 @@ using namespace Polycode;
 SceneLabel::SceneLabel(const String& fontName, const String& text, int size, Number scale, int amode, bool premultiplyAlpha) : ScenePrimitive(ScenePrimitive::TYPE_VPLANE, 1, 1) {
 	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	this->labelScale = scale;
-	positionAtBaseline = true;
+	positionAtBaseline = false;
+	setPositionMode(Entity::POSITION_TOPLEFT);	
 	updateFromLabel();
 }
 
@@ -42,7 +43,8 @@ SceneLabel::SceneLabel(const String& text, int size, const String& fontName, int
 
 	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	this->labelScale = 1.0;
-	positionAtBaseline = true;
+	positionAtBaseline = false;
+	setPositionMode(Entity::POSITION_TOPLEFT);		
 	updateFromLabel();
 }
 			
@@ -71,15 +73,13 @@ void SceneLabel::updateFromLabel() {
 		localShaderOptions->addTexture("diffuse", texture);	
 	}
 
-	delete mesh;
-	mesh = new Mesh(Mesh::QUAD_MESH);
-	mesh->createVPlane(label->getWidth()*labelScale,label->getHeight()*labelScale);
+
+	setPrimitiveOptions(type, label->getWidth()*labelScale,label->getHeight()*labelScale);
 	
 	bBox.x = label->getWidth()*labelScale;
 	bBox.y = label->getHeight()*labelScale;
 	bBox.z = 0;
 	
-	
 	if(useVertexBuffer)
 		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);
 	
@@ -90,7 +90,7 @@ void SceneLabel::updateFromLabel() {
 
 void SceneLabel::Render() {
 	if(positionAtBaseline) {
-		CoreServices::getInstance()->getRenderer()->translate2D(0.0, -label->getBaselineAdjust() + label->getSize());
+		CoreServices::getInstance()->getRenderer()->translate2D(0.0, -label->getBaselineAdjust() + label->getSize() + (getHeight()/2.0));
 	}
 	ScenePrimitive::Render();
 }

+ 0 - 11
Core/Contents/Source/PolySceneMesh.cpp

@@ -295,16 +295,5 @@ void SceneMesh::Render() {
 	
 	if(showVertexNormals) {	
 		renderer->setTexture(NULL);
-		/*
-		for(int i=0; i < mesh->getPolygonCount(); i++) {
-			Polygon *polygon = mesh->getPolygon(i);			
-			unsigned int vCount = polygon->getVertexCount();
-			for(int j=0; j < vCount; j++) {
-				Vertex *vert = polygon->getVertex(j);
-				Vector3 norm = *vert->normal;				
-				CoreServices::getInstance()->getRenderer()->draw3DLine(*vert, norm, 0.4f, Color(0.0f,0.7f,1.0f,0.5f));				
-			}
-		}
-		 */
 	}	
 }

+ 1 - 0
Core/Contents/Source/PolyScenePrimitive.cpp

@@ -38,6 +38,7 @@ ScenePrimitive::ScenePrimitive(int type, Number v1, Number v2, Number v3,Number
 }
 
 void ScenePrimitive::recreatePrimitive() {	
+	mesh->clearMesh();
 	switch(type) {
 		case TYPE_PLANE:
 			mesh->createPlane(v1,v2);

+ 1 - 1
Modules/Contents/3DPhysics/Source/PolyCollisionScene.cpp

@@ -26,7 +26,7 @@ THE SOFTWARE.
 
 using namespace Polycode;
 
-CollisionScene::CollisionScene(Vector3 size, bool virtualScene, bool deferInitCollision) : Scene(virtualScene), world(NULL), collisionConfiguration(NULL), dispatcher(NULL), axisSweep(NULL) {
+CollisionScene::CollisionScene(Vector3 size, bool virtualScene, bool deferInitCollision) : Scene(0, virtualScene), world(NULL), collisionConfiguration(NULL), dispatcher(NULL), axisSweep(NULL) {
 	if(!deferInitCollision) {
 		initCollisionScene(size);
 	}

+ 5 - 10
Modules/Contents/UI/Source/PolyUIBox.cpp

@@ -52,34 +52,29 @@ UIBox::UIBox(String imageFile, Number t, Number r, Number b, Number l, Number bo
 	brImage->setPosition(boxWidth-r, boxHeight-b);	
 	
 	centerImage = new SceneImage(imageFile);
-	centerImage->setImageCoordinates(l,t,centerImage->getWidth()-l-r, centerImage->getHeight()-t-b);
+	centerImage->setImageCoordinates(l,t,centerImage->getWidth()-l-r, centerImage->getHeight()-t-b, boxWidth-l-r, boxHeight-t-b);
 	addChild(centerImage);	
 	centerImage->setPosition(l,t);	
-	centerImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, boxHeight-t-b);
 	
 	tImage = new SceneImage(imageFile);
-	tImage->setImageCoordinates(l,0,tImage->getWidth()-l-r,t);
+	tImage->setImageCoordinates(l,0,tImage->getWidth()-l-r,t, boxWidth-l-r, t);
 	addChild(tImage);
 	tImage->setPosition(l,0);	
-	tImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, t);
 
 	bImage = new SceneImage(imageFile);
-	bImage->setImageCoordinates(l,bImage->getHeight()-b,bImage->getWidth()-l-r,b);
+	bImage->setImageCoordinates(l,bImage->getHeight()-b,bImage->getWidth()-l-r,b, boxWidth-l-r, b);
 	addChild(bImage);
 	bImage->setPosition(l,boxHeight-b);	
-	bImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, b);
 
 	lImage = new SceneImage(imageFile);
-	lImage->setImageCoordinates(0,t,l,lImage->getHeight()-t-b);
+	lImage->setImageCoordinates(0,t,l,lImage->getHeight()-t-b, l, boxHeight-t-b);
 	addChild(lImage);
 	lImage->setPosition(0,t);	
-	lImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, l, boxHeight-t-b);
 
 	rImage = new SceneImage(imageFile);
-	rImage->setImageCoordinates(rImage->getWidth()-r,t,r,rImage->getHeight()-t-b);
+	rImage->setImageCoordinates(rImage->getWidth()-r,t,r,rImage->getHeight()-t-b, r, boxHeight-t-b);
 	addChild(rImage);
 	rImage->setPosition(boxWidth-r,t);	
-	rImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, r, boxHeight-t-b);	
 	
 	this->t = t;
 	this->r = r;

+ 4 - 4
Modules/Contents/UI/Source/PolyUIButton.cpp

@@ -77,8 +77,8 @@ UIButton::UIButton(String text, Number width, Number height) : UIElement() {
 	labelYPos = labelOffsetY;
 	buttonLabel->setPosition(labelXPos,labelYPos);
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	focusable = true;
 	
 	buttonRect->processInputEvents = true;
@@ -88,8 +88,8 @@ UIButton::UIButton(String text, Number width, Number height) : UIElement() {
 void UIButton::Resize(Number width, Number height) {
 	buttonRect->resizeBox(width, height);
 	buttonFocusedRect->resizeBox(width, height);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	
 	labelXPos = floor((width-buttonLabel->getWidth())/2.0f) + labelOffsetX;

+ 2 - 2
Modules/Contents/UI/Source/PolyUICheckBox.cpp

@@ -65,8 +65,8 @@ UICheckBox::UICheckBox(String caption, bool checked) : UIElement() {
 	captionLabel->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	captionLabel->processInputEvents = true;
 	
-	height = buttonImageUnchecked->getHeight();
-	width = buttonImageUnchecked->getWidth() + captionLabel->getWidth() + checkboxTextOffsetX;
+	setHeight(buttonImageUnchecked->getHeight());
+	setWidth(buttonImageUnchecked->getWidth() + captionLabel->getWidth() + checkboxTextOffsetX);
 }
 
 String UICheckBox::getCaptionLabel() {

+ 2 - 2
Modules/Contents/UI/Source/PolyUIColorBox.cpp

@@ -455,8 +455,8 @@ UIColorBox::UIColorBox(UIColorPicker *colorPicker, Color initialColor, Number wi
 	colorPicker->addEventListener(this, Event::CHANGE_EVENT);	
 	colorPicker->addEventListener(this, Event::CANCEL_EVENT);
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	selectedColor = initialColor;
 	colorShape->color = selectedColor;	

+ 5 - 5
Modules/Contents/UI/Source/PolyUIComboBox.cpp

@@ -96,15 +96,15 @@ UIComboBox::UIComboBox(UIGlobalMenu *globalMenu, Number comboWidth) : UIElement(
 	bgBox->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);	
 	bgBox->processInputEvents = true;	
 				
-	this->width = comboWidth;
-	this->height = comboHeight;
+	setWidth(comboWidth);
+	setHeight(comboHeight);
 }
 
 void UIComboBox::Resize(Number width, Number height) {
 	this->comboWidth = width;
 	bgBox->resizeBox(width, comboHeight);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);	
 	matrixDirty = true;	
 	dropDownImage->setPosition(comboWidth - dropDownImage->getWidth() - dropDownX,dropDownY);	
 }
@@ -145,7 +145,7 @@ UIComboBoxItem *UIComboBox::getSelectedItem() {
 
 void UIComboBox::toggleDropDown() {
 	Vector2 screenPos = this->getScreenPosition();
-	dropDownMenu = globalMenu->showMenu(screenPos.x, screenPos.y, width);
+	dropDownMenu = globalMenu->showMenu(screenPos.x, screenPos.y, getWidth());
 	
 	for(int i=0; i < items.size(); i++) {
 		dropDownMenu->addOption(items[i]->label, String::IntToString(i));

+ 1 - 0
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -27,6 +27,7 @@ using namespace Polycode;
 UIElement::UIElement() : Entity() {
 	setPositionMode(Entity::POSITION_TOPLEFT);
 	processInputEvents = true;
+	depthTest = false;	
 }
 
 UIElement::UIElement(Number width, Number height) : Entity() {

+ 5 - 5
Modules/Contents/UI/Source/PolyUIHScrollBar.cpp

@@ -83,8 +83,8 @@ UIHScrollBar::UIHScrollBar(Number width, Number height, Number initialRatio) : U
 	
 	lastPositionX = handleBox->getPosition().x;
 	
-	this->height = height;
-	this->width = width;	
+	setHeight(height);
+	setWidth(width);	
 }
 
 void UIHScrollBar::Update() {
@@ -107,15 +107,15 @@ void UIHScrollBar::Update() {
 }
 
 void UIHScrollBar::setHandleRatio(Number newRatio) {
-	scrollHandleWidth = width*newRatio;	
+	scrollHandleWidth = getWidth()*newRatio;	
 	
 	if(scrollHandleWidth < minHandleSize)
 		scrollHandleWidth = minHandleSize;
 	
-	dragRectWidth = width-(padding*2)-scrollHandleWidth;	
+	dragRectWidth = getWidth()-(padding*2)-scrollHandleWidth;	
 	
 	handleBox->resizeBox(scrollHandleWidth, handleBox->getHeight());
-	handleBox->setDragLimits(Rectangle(padding,padding,dragRectWidth, height-(padding*2)-(height-(padding*2))));	
+	handleBox->setDragLimits(Rectangle(padding,padding,dragRectWidth, getHeight()-(padding*2)-(getHeight()-(padding*2))));	
 	
 	if(enabled && handleBox->getPosition().x > dragRectWidth) {
 		handleBox->setPositionX(dragRectWidth);

+ 11 - 11
Modules/Contents/UI/Source/PolyUIHSizer.cpp

@@ -160,33 +160,33 @@ void UIHSizer::updateSizer() {
 	
 		if(firstElement) {
 			firstElement->setPosition(0,0);
-			firstElement->Resize(mainWidth, height);
+			firstElement->Resize(mainWidth, getHeight());
 		}	
 		if(secondElement) {
 			secondElement->setPosition(mainWidth+1,0);
-			secondElement->Resize(width-mainWidth-1, height);	
+			secondElement->Resize(getWidth()-mainWidth-1, getHeight());	
 		}
 
-		separatorBgShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 1, height);
+		separatorBgShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 1, getHeight());
 		separatorBgShape->setPosition(mainWidth,0);
-		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, height);
+		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, getHeight());
 		separatorHitShape->setPosition(mainWidth-4,0);
 		
 	} else {
 	
 		if(firstElement) {
 			firstElement->setPosition(0,0);
-			firstElement->Resize(width-mainWidth, height);
+			firstElement->Resize(getWidth()-mainWidth, getHeight());
 		}	
 		if(secondElement) {
-			secondElement->setPosition(width-mainWidth+1,0);
-			secondElement->Resize(mainWidth-1, height);	
+			secondElement->setPosition(getWidth()-mainWidth+1,0);
+			secondElement->Resize(mainWidth-1, getHeight());	
 		}
 
-		separatorBgShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 1, height);
-		separatorBgShape->setPosition(width-mainWidth,0);
-		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, height);
-		separatorHitShape->setPosition(width-mainWidth-4,0);
+		separatorBgShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 1, getHeight());
+		separatorBgShape->setPosition(getWidth()-mainWidth,0);
+		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, getHeight());
+		separatorHitShape->setPosition(getWidth()-mainWidth-4,0);
 	
 	}
 }

+ 2 - 2
Modules/Contents/UI/Source/PolyUIHSlider.cpp

@@ -109,8 +109,8 @@ Number UIHSlider::getSliderValue() {
 
 void UIHSlider::Resize(Number width, Number height) {
 	bgRect->resizeBox(width, bgHeight);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	sliderWidth = width;
 	gripRect->setDragLimits(Rectangle(0,floor(bgHeight/2.0),width,0));	

+ 3 - 2
Modules/Contents/UI/Source/PolyUIImageButton.cpp

@@ -33,6 +33,7 @@ UIImageButton::UIImageButton(String imageName) : UIElement() {
 	
 	buttonImage = new SceneImage(imageName.c_str());
 	addChild(buttonImage);
+	buttonImage->depthTest = false;
 	
 	buttonRect = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, buttonImage->getWidth(),buttonImage->getHeight(),0,0);
 	buttonRect->setColor(1,1,1,0);
@@ -46,8 +47,8 @@ UIImageButton::UIImageButton(String imageName) : UIElement() {
 	buttonRect->processInputEvents = true;
 	pressedDown = false;
 	
-	width = buttonRect->getWidth();
-	height = buttonRect->getHeight();	
+	setWidth(buttonRect->getWidth());
+	setHeight(buttonRect->getHeight());	
 }
 
 void UIImageButton::handleEvent(Event *event) {

+ 2 - 2
Modules/Contents/UI/Source/PolyUIMenuBar.cpp

@@ -39,7 +39,7 @@ UIMenuBarEntry::UIMenuBarEntry(String name): UIElement() {
 	
 	label = new SceneLabel(name, 14, "sans");
 	setWidth(label->getLabel()->getTextWidth() + 20);
-	bg = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, width, 25);
+	bg = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, getWidth(), 25);
 	bg->setPositionMode(Entity::POSITION_TOPLEFT);
 	addChild(bg);
 	bg->color.setColorHex(0xce5a1600);
@@ -88,7 +88,7 @@ UIMenuBarEntry *UIMenuBar::addMenuBarEntry(String name) {
 	entries.push_back(newEntry);
 	addChild(newEntry);
 	newEntry->setPosition(entryOffset, 0);
-	entryOffset += newEntry->width;
+	entryOffset += newEntry->getWidth();
 
 	newEntry->bg->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	newEntry->bg->addEventListener(this, InputEvent::EVENT_MOUSEUP);

+ 11 - 11
Modules/Contents/UI/Source/PolyUIScrollContainer.cpp

@@ -40,8 +40,8 @@ UIScrollContainer::UIScrollContainer(Entity *scrolledEntity, bool hScroll, bool
 	hasVScroll = vScroll;	
 	
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	Number uiScrollPanePadding = conf->getNumericValue("Polycode", "uiScrollPanePadding");			
 	
@@ -76,8 +76,8 @@ UIScrollContainer::UIScrollContainer(Entity *scrolledEntity, bool hScroll, bool
 }
 
 void UIScrollContainer::Resize(Number width, Number height) {
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	
 	vScrollBar->Resize(height);
@@ -115,11 +115,11 @@ void UIScrollContainer::setContentSize(Number newContentWidth, Number newContent
 	contentHeight = newContentHeight;
 	contentWidth = newContentWidth;
 	
-	vScrollBar->setHandleRatio(height / newContentHeight);	
-	hScrollBar->setHandleRatio(width / newContentWidth);	
+	vScrollBar->setHandleRatio(getHeight() / newContentHeight);	
+	hScrollBar->setHandleRatio(getWidth() / newContentWidth);	
 	
 	if(hasVScroll) {
-		if((height / newContentHeight) >= 1) {
+		if((getHeight() / newContentHeight) >= 1) {
 			vScrollBar->enabled = false;
 			vScrollBar->scrollTo(0);
 		} else {
@@ -128,7 +128,7 @@ void UIScrollContainer::setContentSize(Number newContentWidth, Number newContent
 	}
 	
 	if(hasHScroll) {
-		if((width / newContentWidth) >= 1) {
+		if((getWidth() / newContentWidth) >= 1) {
 			hScrollBar->enabled = false;
 			hScrollBar->scrollTo(0);			
 		} else {
@@ -164,13 +164,13 @@ void UIScrollContainer::scrollHorizontal(Number amount) {
 
 void UIScrollContainer::Update() {
 	Vector2 pos = getScreenPosition();
-	scissorBox.setRect(pos.x, pos.y, width, height);
+	scissorBox.setRect(pos.x, pos.y, getWidth(), getHeight());
 }
 
 void UIScrollContainer::handleEvent(Event *event) {
 	if(event->getDispatcher() == vScrollBar) {
 		if(event->getEventCode() == Event::CHANGE_EVENT) {
-			scrollChild->setPositionY(floor(((-contentHeight+height) )*vScrollBar->getScrollValue()));
+			scrollChild->setPositionY(floor(((-contentHeight+getHeight()) )*vScrollBar->getScrollValue()));
 			if(scrollChild->getPosition().y > 0)
 				scrollChild->setPositionY(0);
 				dispatchEvent(new Event(), Event::CHANGE_EVENT);
@@ -179,7 +179,7 @@ void UIScrollContainer::handleEvent(Event *event) {
 	
 	if(event->getDispatcher() == hScrollBar) {
 		if(event->getEventCode() == Event::CHANGE_EVENT) {
-			scrollChild->setPositionX(floor(((-contentWidth+width) )*hScrollBar->getScrollValue()));
+			scrollChild->setPositionX(floor(((-contentWidth+getWidth()) )*hScrollBar->getScrollValue()));
 			if(scrollChild->getPosition().x > 0)
 				scrollChild->setPositionX(0);
 				dispatchEvent(new Event(), Event::CHANGE_EVENT);			

+ 16 - 16
Modules/Contents/UI/Source/PolyUITextInput.cpp

@@ -177,8 +177,8 @@ UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElemen
 	blinkTimer->addEventListener(this, Timer::EVENT_TRIGGER);
 
 	focusable = true;
-	this->width = width;
-	this->height = rectHeight;
+	setWidth(width);
+	setHeight(rectHeight);
 	setHitbox(width, rectHeight);
 	
 	scrollContainer = NULL;
@@ -366,7 +366,7 @@ void UITextInput::updateSelectionRects() {
 		selectorRectBottom->visible = true;		
 		Number bottomSize = bufferLines[0]->getLabel()->getTextWidthForString(bottomLine.substr(0,colEnd)) ; 
 		if(bottomSize < 0)
-			bottomSize = this->width-padding;
+			bottomSize = this->getWidth()-padding;
 		Number bottomHeight = lineHeight+lineSpacing;
 		
 		if(bottomSize < 4) {
@@ -379,7 +379,7 @@ void UITextInput::updateSelectionRects() {
 		if(lineEnd != lineStart+1) {
 			// need filler
 			selectorRectMiddle->visible = true;		
-			Number midSize = this->width-padding;
+			Number midSize = this->getWidth()-padding;
 			Number midHeight = 0;			
 			for(int i=lineStart+1; i < lineEnd;i++) {
 				midHeight += lineHeight+lineSpacing;
@@ -669,7 +669,7 @@ void UITextInput::doMultilineResize() {
 			realLineOffset = wordWrapLines[bufferOffset].actualLineNumber;
 		}
 		
-		if(width != lastResizeWidth) {	
+		if(getWidth() != lastResizeWidth) {	
 			updateWordWrap(0, lines.size()-1);
 		}
 		
@@ -680,11 +680,11 @@ void UITextInput::doMultilineResize() {
 		restructLines();		
 		readjustBuffer();
 		if(lineNumbersEnabled) {
-			lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, height);
+			lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, getHeight());
 		}
 	}
 	
-	lastResizeWidth = width;
+	lastResizeWidth = getWidth();
 		
 	didMultilineResize = true;
 	
@@ -699,8 +699,8 @@ void UITextInput::Resize(Number width, Number height) {
 	didMultilineResize = false;
 	
 	inputRect->resizeBox(width, height);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	
 	if(multiLine) {
@@ -845,15 +845,15 @@ void UITextInput::restructLines() {
 	}
 	
 	if(multiLine && lineNumbersEnabled) {
-		lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, height);
+		lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, getHeight());
 	}
 	
 	if(scrollContainer) {
-		scrollContainer->setContentSize(width,  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
+		scrollContainer->setContentSize(getWidth(),  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
 	}	
 	
 	if(multiLine) {
-		inputRect->setHitbox(width - scrollContainer->getVScrollWidth(), height);
+		inputRect->setHitbox(getWidth() - scrollContainer->getVScrollWidth(), getHeight());
 	}	
 	
 }
@@ -1588,7 +1588,7 @@ void UITextInput::showCurrentLineIfOffscreen() {
 		return;
 		
 	int bufferOffset = -linesContainer->position.y/ ( lineHeight+lineSpacing);	
-	int heightInLines = (height / ( lineHeight+lineSpacing)) + 1;
+	int heightInLines = (getHeight() / ( lineHeight+lineSpacing)) + 1;
 			
 	if(lines[actualLineOffset].wordWrapLineIndex > bufferOffset && lines[actualLineOffset].wordWrapLineIndex < bufferOffset + heightInLines) {
 	
@@ -1658,7 +1658,7 @@ void UITextInput::showLine(unsigned int lineNumber, bool top) {
 		return;
 	}
 	
-	scrollContainer->setContentSize(width,  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
+	scrollContainer->setContentSize(getWidth(),  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
 
 	if(top) {
 		scrollContainer->setScrollValue(0.0, ((((offsetLineNumber) * ((lineHeight+lineSpacing)))) + padding)/(scrollContainer->getContentSize().y-scrollContainer->getHeight()));
@@ -2226,7 +2226,7 @@ std::vector<TextColorPair> UITextInput::makeWordWrapBuffer(LineInfo *lineInfo, S
 	String text = lineInfo->text;
 	std::vector<TextColorPair> retVec;
 	
-	if(bufferLines[0]->getLabel()->getTextWidthForString(text) < width - decoratorOffset - padding) {
+	if(bufferLines[0]->getLabel()->getTextWidthForString(text) < getWidth() - decoratorOffset - padding) {
 			return retVec;
 	}		
 	
@@ -2246,7 +2246,7 @@ std::vector<TextColorPair> UITextInput::makeWordWrapBuffer(LineInfo *lineInfo, S
 	
 		for(int i=0; i < parts.size(); i++) {
 			String _checkString = checkString + parts[i].text;
-			if(bufferLines[0]->getLabel()->getTextWidthForString(indentPrefix+_checkString) > width - decoratorOffset - padding) {
+			if(bufferLines[0]->getLabel()->getTextWidthForString(indentPrefix+_checkString) > getWidth() - decoratorOffset - padding) {
 				if(retVec.size() == 0) {
 					TextColorPair pair;
 					pair.text = checkString;

+ 2 - 2
Modules/Contents/UI/Source/PolyUITree.cpp

@@ -266,8 +266,8 @@ void UITree::refreshTree() {
 		}
 		treeHeight = offset - cellHeight;
 	}
-	height = treeHeight + cellHeight;
-	width = treeWidth;
+	setHeight(treeHeight + cellHeight);
+	setWidth(treeWidth);
 	
 	selection->visible = selected;
 	dispatchEvent(new UITreeEvent(), UITreeEvent::NEED_REFRESH_EVENT);	

+ 4 - 4
Modules/Contents/UI/Source/PolyUITreeContainer.cpp

@@ -59,11 +59,11 @@ UITreeContainer::UITreeContainer(String icon, String text, Number treeWidth, Num
 	mainContainer = new UIScrollContainer(scrollChild, false, true, treeWidth-conf->getNumericValue("Polycode", "uiScrollDefaultSize"), treeHeight);
 	addChild(mainContainer);
 	
-	width = treeWidth;
-	height = treeHeight;
-	setHitbox(width, height);
+	setWidth(treeWidth);
+	setHeight(treeHeight);
+	setHitbox(getWidth(), getHeight());
 	
-	Resize(width, height);
+	Resize(getWidth(), getHeight());
 
 	CoreServices::getInstance()->getCore()->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
 	this->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);

+ 8 - 8
Modules/Contents/UI/Source/PolyUIVScrollBar.cpp

@@ -85,17 +85,17 @@ UIVScrollBar::UIVScrollBar(Number width, Number height, Number initialRatio) : U
 	
 	lastPositionY = handleBox->getPosition().y;
 	
-	this->height = height;
-	this->width = width;	
+	setHeight(height);
+	setWidth(width);	
 	
 	tickSize = 0.01;
 }
 
 void UIVScrollBar::Resize(int newHeight) {
-	bgBox->resizeBox(width, newHeight);
+	bgBox->resizeBox(getWidth(), newHeight);
 	setHeight(newHeight);
-	dragRectHeight = height-(padding*2)-scrollHandleHeight;	
-	handleBox->setDragLimits(Rectangle(padding,padding,width-(padding*2)-(width-(padding*2)), dragRectHeight));	
+	dragRectHeight = getHeight()-(padding*2)-scrollHandleHeight;	
+	handleBox->setDragLimits(Rectangle(padding,padding,getWidth()-(padding*2)-(getWidth()-(padding*2)), dragRectHeight));	
 }
 
 void UIVScrollBar::Update() {
@@ -130,14 +130,14 @@ void UIVScrollBar::Scroll(Number amount) {
 }
 
 void UIVScrollBar::setHandleRatio(Number newRatio) {
-	scrollHandleHeight = height*newRatio;	
+	scrollHandleHeight = getHeight()*newRatio;	
 	
 	if(scrollHandleHeight < minHandleSize)
 		scrollHandleHeight = minHandleSize;
 
-	dragRectHeight = height-(padding*2)-scrollHandleHeight;	
+	dragRectHeight = getHeight()-(padding*2)-scrollHandleHeight;	
 	handleBox->resizeBox(handleBox->getWidth(), scrollHandleHeight);
-	handleBox->setDragLimits(Rectangle(padding,padding,width-(padding*2)-(width-(padding*2)), dragRectHeight));	
+	handleBox->setDragLimits(Rectangle(padding,padding,getWidth()-(padding*2)-(getWidth()-(padding*2)), dragRectHeight));	
 	
 	if(enabled && handleBox->getPosition().y > dragRectHeight) {
 		handleBox->setPositionY(dragRectHeight);

+ 2 - 2
Modules/Contents/UI/Source/PolyUIVSizer.cpp

@@ -129,8 +129,8 @@ void UIVSizer::handleEvent(Event *event) {
 }
 
 void UIVSizer::Resize(Number width, Number height) {
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;
 	updateSizer();
 	UIElement::Resize(width, height);

+ 4 - 3
Modules/Contents/UI/Source/PolyUIWindow.cpp

@@ -72,6 +72,7 @@ UIWindow::UIWindow(String windowName, Number width, Number height) : Entity(), w
 	titleLabel->setPosition(conf->getNumericValue("Polycode", "uiWindowTitleX"),conf->getNumericValue("Polycode", "uiWindowTitleY"));
 	addChild(titleLabel);
 	titleLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiWindowFontColor"));
+	titleLabel->positionAtBaseline = false;
 		
 	closeBtn = new UIImageButton(conf->getStringValue("Polycode", "uiWindowCloseIcon"));
 	addChild(closeBtn);
@@ -85,8 +86,8 @@ UIWindow::UIWindow(String windowName, Number width, Number height) : Entity(), w
 	titlebarRect->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	closeBtn->addEventListener(this, UIEvent::CLICK_EVENT);
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	setHitbox(width, height);
 	
 	focusable = true;
@@ -106,7 +107,7 @@ void UIWindow::setWindowSize(Number w, Number h) {
 	windowRect->resizeBox(w, h);
 	setWidth(w);
 	setHeight(h);	
-	closeBtn->setPosition(width-closeBtn->getWidth()-closeIconX, closeIconY);	
+	closeBtn->setPosition(getWidth()-closeBtn->getWidth()-closeIconX, closeIconY);	
 	matrixDirty = true;
 }