소스 검색

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

Ivan Safrin 12 년 전
부모
커밋
03b6f5b4ac
36개의 변경된 파일231개의 추가작업 그리고 235개의 파일을 삭제
  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)				
 			* @param orthoSizeY Height of the orthographic frustum (defaults to 1.0)				
 			*/			
 			*/			
 			void setOrthoMode(bool mode, Number orthoSizeX = 1.0, Number orthoSizeY = 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.
 			* Returns true if camera is in orthographic projection mode.
@@ -102,6 +104,8 @@ namespace Polycode {
 			*/			
 			*/			
 			Number getFOV();
 			Number getFOV();
 			
 			
+			void setClippingPlanes(Number nearClipPlane, Number farClipPlane);
+			
 			void setParentScene(Scene *parentScene);
 			void setParentScene(Scene *parentScene);
 			
 			
 			void doCameraTransform();
 			void doCameraTransform();
@@ -160,7 +164,10 @@ namespace Polycode {
 		
 		
 			Number orthoSizeX;
 			Number orthoSizeX;
 			Number orthoSizeY;
 			Number orthoSizeY;
-					
+			
+			Number nearClipPlane;
+			Number farClipPlane;
+								
 			Number exposureLevel;
 			Number exposureLevel;
 			bool orthoMode;
 			bool orthoMode;
 			Number fov;
 			Number fov;

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

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

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

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

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

@@ -46,14 +46,15 @@ namespace Polycode {
 	public:
 	public:
 		
 		
 		/**
 		/**
-		* Default constructor.
+		* Default constructor. Defaults to type Scene::SCENE_3D
 		*/
 		*/
 		Scene();
 		Scene();
 		/**
 		/**
 		* Default constructor with options. 
 		* 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.
 		* @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();
 		virtual ~Scene();
 		
 		
 		/**
 		/**
@@ -139,12 +140,6 @@ namespace Polycode {
 				
 				
 		int getNumLights();
 		int getNumLights();
 		SceneLight *getLight(int index);
 		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
 		* Scene clear color
@@ -176,10 +171,16 @@ namespace Polycode {
 		*/
 		*/
 		bool ownsChildren;
 		bool ownsChildren;
 		
 		
+		static const int SCENE_3D = 0;
+		static const int SCENE_2D = 1;
+		static const int SCENE_2D_TOPLEFT = 2;
+						
 		Entity rootEntity;
 		Entity rootEntity;
 		
 		
 	protected:
 	protected:
 		
 		
+		void initScene(int sceneType, bool virtualScene);
+		
 		bool hasLightmaps;
 		bool hasLightmaps;
 		
 		
 		Renderer *renderer;
 		Renderer *renderer;
@@ -196,5 +197,7 @@ namespace Polycode {
 		Number fogStartDepth;
 		Number fogStartDepth;
 		Number fogEndDepth;
 		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 width Width of the display rectangle.
 		* @param height Height 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.
 		* Returns the image width.

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

@@ -44,6 +44,8 @@ Camera::Camera(Scene *parentScene) : Entity() {
 	_hasFilterShader = false;	
 	_hasFilterShader = false;	
 	fovSet = false;
 	fovSet = false;
 	frustumCulling = true;
 	frustumCulling = true;
+	nearClipPlane = 1.0;
+	farClipPlane = 1000.0;
 }
 }
 
 
 Camera::~Camera() {	
 Camera::~Camera() {	
@@ -55,6 +57,12 @@ Camera::~Camera() {
 	delete zBufferSceneTexture;
 	delete zBufferSceneTexture;
 }
 }
 
 
+void Camera::setClippingPlanes(Number nearClipPlane, Number farClipPlane) {
+	this->nearClipPlane = nearClipPlane;
+	this->farClipPlane = farClipPlane;	
+}
+
+
 void Camera::setExposureLevel(Number level) {
 void Camera::setExposureLevel(Number level) {
 	exposureLevel = level;
 	exposureLevel = level;
 }
 }
@@ -89,6 +97,11 @@ bool Camera::isSphereInFrustum(Vector3 pos, Number fRadius) {
     return true;
     return true;
 }
 }
 
 
+void Camera::setOrthoSize(Number orthoSizeX, Number orthoSizeY) {
+	this->orthoSizeX = orthoSizeX;
+	this->orthoSizeY = orthoSizeY;
+}
+
 void Camera::setOrthoMode(bool mode, Number orthoSizeX, Number orthoSizeY) {
 void Camera::setOrthoMode(bool mode, Number orthoSizeX, Number orthoSizeY) {
 	this->orthoSizeX = orthoSizeX;
 	this->orthoSizeX = orthoSizeX;
 	this->orthoSizeY = orthoSizeY;
 	this->orthoSizeY = orthoSizeY;
@@ -381,6 +394,8 @@ void Camera::drawFilter(Texture *targetTexture, Number targetTextureWidth, Numbe
 
 
 void Camera::doCameraTransform() {
 void Camera::doCameraTransform() {
 
 
+	CoreServices::getInstance()->getRenderer()->setClippingPlanes(nearClipPlane, farClipPlane);
+
 	if(fovSet)
 	if(fovSet)
 			CoreServices::getInstance()->getRenderer()->setFOV(fov);
 			CoreServices::getInstance()->getRenderer()->setFOV(fov);
 	CoreServices::getInstance()->getRenderer()->setExposureLevel(exposureLevel);
 	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);
 	color.setColor(1.0f,1.0f,1.0f,1.0f);
 	parentEntity = NULL;
 	parentEntity = NULL;
 	matrixDirty = true;
 	matrixDirty = true;
-	matrixAdj = 1.0f;
 	billboardMode = false;
 	billboardMode = false;
 	billboardRoll = false;
 	billboardRoll = false;
 	billboardIgnoreScale = false;
 	billboardIgnoreScale = false;
@@ -63,6 +62,7 @@ Entity::Entity() : EventDispatcher() {
 	hasFocus = false;
 	hasFocus = false;
 	snapToPixels = false;
 	snapToPixels = false;
 	tags = NULL;
 	tags = NULL;
+	yAdjust = 1.0;
 	positionMode = POSITION_CENTER;
 	positionMode = POSITION_CENTER;
 }
 }
 
 
@@ -304,20 +304,33 @@ Vector3 Entity::getChildCenter() const {
 	return childCenter;
 	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;
 	Matrix4 posMatrix;
 	switch(positionMode) {
 	switch(positionMode) {
 		case POSITION_TOPLEFT:
 		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;
 		break;
 		case POSITION_CENTER:
 		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;
 		break;
 	}
 	}
 
 
@@ -331,6 +344,16 @@ Matrix4 Entity::buildPositionMatrix() {
 	return posMatrix;
 	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() {
 void Entity::rebuildTransformMatrix() {
 	if(lockMatrix)
 	if(lockMatrix)
 		return;
 		return;
@@ -401,7 +424,7 @@ Vector3 Entity::getCompoundScale() const {
 
 
 Matrix4 Entity::getConcatenatedRollMatrix() const {
 Matrix4 Entity::getConcatenatedRollMatrix() const {
 	Quaternion q;
 	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();	
 	Matrix4 transformMatrix = q.createMatrix();	
 	
 	
 	if(parentEntity != NULL) 
 	if(parentEntity != NULL) 
@@ -519,6 +542,7 @@ void Entity::setRenderer(Renderer *renderer) {
 void Entity::addEntity(Entity *newChild) {
 void Entity::addEntity(Entity *newChild) {
 	newChild->setRenderer(renderer);
 	newChild->setRenderer(renderer);
 	newChild->setParentEntity(this);
 	newChild->setParentEntity(this);
+	newChild->setInverseY(getInverseY());
 	children.push_back(newChild);	
 	children.push_back(newChild);	
 }
 }
 
 
@@ -533,16 +557,6 @@ void Entity::dirtyMatrix(bool val) {
 	matrixDirty = 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) {
 void Entity::setRotationQuat(Number w, Number x, Number y, Number z) {
 	rotationQuat.w = w;
 	rotationQuat.w = w;
 	rotationQuat.x = x;
 	rotationQuat.x = x;
@@ -669,7 +683,7 @@ void Entity::setDepth(Number depth) {
 }
 }
 
 
 Number Entity::getWidth() const {
 Number Entity::getWidth() const {
-	return bBox.z;
+	return bBox.x;
 }
 }
 
 
 Number Entity::getHeight() const {
 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_) {
 void OpenGLRenderer::setClippingPlanes(Number nearPlane_, Number farPlane_) {
 	nearPlane = nearPlane_;
 	nearPlane = nearPlane_;
 	farPlane = farPlane_;
 	farPlane = farPlane_;
-	Resize(xRes,yRes);
 }
 }
 
 
 bool OpenGLRenderer::Init() {
 bool OpenGLRenderer::Init() {
@@ -515,7 +514,7 @@ void OpenGLRenderer::setOrthoMode(Number xSize, Number ySize, bool centered) {
 	if(centered) {
 	if(centered) {
 		glOrtho(-xSize*0.5,xSize*0.5,-ySize*0.5,ySize*0.5,nearPlane,farPlane);		
 		glOrtho(-xSize*0.5,xSize*0.5,-ySize*0.5,ySize*0.5,nearPlane,farPlane);		
 	} else {
 	} else {
-		glOrtho(0.0f,xSize,ySize,0,nearPlane,farPlane);
+		glOrtho(0.0f,xSize,0,ySize,nearPlane,farPlane);
 	}
 	}
 	glGetDoublev( GL_PROJECTION_MATRIX, sceneProjectionMatrixOrtho);
 	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) {
 void Image::fillRect(int x, int y, int w, int h, Color col) {
 	for(int i=0; i < w; i++) {
 	for(int i=0; i < w; i++) {
 		for(int j=0; j < h; j++) {
 		for(int j=0; j < h; j++) {
@@ -564,50 +557,6 @@ void Image::fastBlurVert(int blurSize) {
 void Image::fastBlur(int blurSize) {
 void Image::fastBlur(int blurSize) {
 	fastBlurHor(blurSize);
 	fastBlurHor(blurSize);
 	fastBlurVert(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) {
 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 textWidth = (bbox.xMax -  bbox.xMin)+1;
 	unsigned int textHeight = (bbox.yMax -  bbox.yMin)+1;
 	unsigned int textHeight = (bbox.yMax -  bbox.yMin)+1;
 	
 	
+	if(textWidth % 2 ){
+		textWidth++;
+	}
+	if(textHeight % 2 ){
+		textHeight++;
+	}
+	
 	baseLineOffset = bbox.yMin;
 	baseLineOffset = bbox.yMin;
 	xAdjustOffset = bbox.xMin;
 	xAdjustOffset = bbox.xMin;
 	baseLineAdjust = bbox.yMax;
 	baseLineAdjust = bbox.yMax;

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

@@ -32,29 +32,23 @@
 #include "PolyResourceManager.h"
 #include "PolyResourceManager.h"
 #include "PolySceneLight.h"
 #include "PolySceneLight.h"
 #include "PolySceneMesh.h"
 #include "PolySceneMesh.h"
+#include "PolyCore.h"
 #include "PolySceneManager.h"
 #include "PolySceneManager.h"
 
 
 using std::vector;
 using std::vector;
 using namespace Polycode;
 using namespace Polycode;
 
 
 Scene::Scene() : EventDispatcher() {
 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);
 	defaultCamera = new Camera(this);
 	activeCamera = defaultCamera;	
 	activeCamera = defaultCamera;	
 	fogEnabled = false;
 	fogEnabled = false;
@@ -71,6 +65,22 @@ Scene::Scene(bool virtualScene) : EventDispatcher() {
 	if (!isSceneVirtual) {
 	if (!isSceneVirtual) {
 		CoreServices::getInstance()->getSceneManager()->addScene(this);
 		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) {
 void Scene::setActiveCamera(Camera *camera) {
@@ -98,6 +108,9 @@ bool Scene::isEnabled() {
 }
 }
 
 
 void Scene::Update() {
 void Scene::Update() {
+	if(sceneType == SCENE_2D_TOPLEFT) {
+		rootEntity.position.y = -CoreServices::getInstance()->getCore()->getYRes();
+	}
 	rootEntity.doUpdates();
 	rootEntity.doUpdates();
 }
 }
 
 

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

@@ -43,7 +43,7 @@ SceneImage::SceneImage(const String& fileName) : ScenePrimitive(ScenePrimitive::
 	imageHeight = texture->getHeight();
 	imageHeight = texture->getHeight();
 
 
 	setWidth(texture->getWidth());
 	setWidth(texture->getWidth());
-	setHeight(texture->getHeight());	
+	setHeight(texture->getHeight());
 	setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, getWidth(), getHeight());
 	setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, getWidth(), getHeight());
 
 
 	setPositionMode(POSITION_TOPLEFT);
 	setPositionMode(POSITION_TOPLEFT);
@@ -89,17 +89,22 @@ void SceneImage::applyClone(Entity *clone, bool deepClone, bool ignoreEditorOnly
 	//ScreenShape::applyClone(clone, deepClone, 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;
 	Vertex *vertex;
+	
 	Number pixelSizeX = 1/imageWidth;
 	Number pixelSizeX = 1/imageWidth;
 	Number pixelSizeY = 1/imageHeight;
 	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 xFloat = x * pixelSizeX;
 	Number yFloat = 1 - (y * pixelSizeY);
 	Number yFloat = 1 - (y * pixelSizeY);
 	Number wFloat = width * pixelSizeX;
 	Number wFloat = width * pixelSizeX;
@@ -107,26 +112,22 @@ void SceneImage::setImageCoordinates(Number x, Number y, Number width, Number he
 
 
 	Polygon *imagePolygon = mesh->getPolygon(0);	
 	Polygon *imagePolygon = mesh->getPolygon(0);	
 	vertex = imagePolygon->getVertex(0);
 	vertex = imagePolygon->getVertex(0);
-	vertex->set(-whalf,-hhalf,0);
-	vertex->setTexCoord(xFloat, yFloat);
+	vertex->setTexCoord(xFloat, yFloat - hFloat);
 
 
 	vertex = imagePolygon->getVertex(1);
 	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 = 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::VERTEX_DATA_ARRAY] = true;
-	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;	
+	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;
+	
 	rebuildTransformMatrix();
 	rebuildTransformMatrix();
 	matrixDirty = true;
 	matrixDirty = true;
-
 }
 }
 
 
 Number SceneImage::getImageWidth() const {
 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) {
 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);
 	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	this->labelScale = scale;
 	this->labelScale = scale;
-	positionAtBaseline = true;
+	positionAtBaseline = false;
+	setPositionMode(Entity::POSITION_TOPLEFT);	
 	updateFromLabel();
 	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);
 	label = new Label(CoreServices::getInstance()->getFontManager()->getFontByName(fontName), text, size, amode, premultiplyAlpha);
 	this->labelScale = 1.0;
 	this->labelScale = 1.0;
-	positionAtBaseline = true;
+	positionAtBaseline = false;
+	setPositionMode(Entity::POSITION_TOPLEFT);		
 	updateFromLabel();
 	updateFromLabel();
 }
 }
 			
 			
@@ -71,15 +73,13 @@ void SceneLabel::updateFromLabel() {
 		localShaderOptions->addTexture("diffuse", texture);	
 		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.x = label->getWidth()*labelScale;
 	bBox.y = label->getHeight()*labelScale;
 	bBox.y = label->getHeight()*labelScale;
 	bBox.z = 0;
 	bBox.z = 0;
 	
 	
-	
 	if(useVertexBuffer)
 	if(useVertexBuffer)
 		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);
 		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);
 	
 	
@@ -90,7 +90,7 @@ void SceneLabel::updateFromLabel() {
 
 
 void SceneLabel::Render() {
 void SceneLabel::Render() {
 	if(positionAtBaseline) {
 	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();
 	ScenePrimitive::Render();
 }
 }

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

@@ -295,16 +295,5 @@ void SceneMesh::Render() {
 	
 	
 	if(showVertexNormals) {	
 	if(showVertexNormals) {	
 		renderer->setTexture(NULL);
 		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() {	
 void ScenePrimitive::recreatePrimitive() {	
+	mesh->clearMesh();
 	switch(type) {
 	switch(type) {
 		case TYPE_PLANE:
 		case TYPE_PLANE:
 			mesh->createPlane(v1,v2);
 			mesh->createPlane(v1,v2);

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

@@ -26,7 +26,7 @@ THE SOFTWARE.
 
 
 using namespace Polycode;
 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) {
 	if(!deferInitCollision) {
 		initCollisionScene(size);
 		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);	
 	brImage->setPosition(boxWidth-r, boxHeight-b);	
 	
 	
 	centerImage = new SceneImage(imageFile);
 	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);	
 	addChild(centerImage);	
 	centerImage->setPosition(l,t);	
 	centerImage->setPosition(l,t);	
-	centerImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, boxHeight-t-b);
 	
 	
 	tImage = new SceneImage(imageFile);
 	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);
 	addChild(tImage);
 	tImage->setPosition(l,0);	
 	tImage->setPosition(l,0);	
-	tImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, t);
 
 
 	bImage = new SceneImage(imageFile);
 	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);
 	addChild(bImage);
 	bImage->setPosition(l,boxHeight-b);	
 	bImage->setPosition(l,boxHeight-b);	
-	bImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, boxWidth-l-r, b);
 
 
 	lImage = new SceneImage(imageFile);
 	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);
 	addChild(lImage);
 	lImage->setPosition(0,t);	
 	lImage->setPosition(0,t);	
-	lImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, l, boxHeight-t-b);
 
 
 	rImage = new SceneImage(imageFile);
 	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);
 	addChild(rImage);
 	rImage->setPosition(boxWidth-r,t);	
 	rImage->setPosition(boxWidth-r,t);	
-	rImage->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, r, boxHeight-t-b);	
 	
 	
 	this->t = t;
 	this->t = t;
 	this->r = r;
 	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;
 	labelYPos = labelOffsetY;
 	buttonLabel->setPosition(labelXPos,labelYPos);
 	buttonLabel->setPosition(labelXPos,labelYPos);
 	
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	focusable = true;
 	focusable = true;
 	
 	
 	buttonRect->processInputEvents = true;
 	buttonRect->processInputEvents = true;
@@ -88,8 +88,8 @@ UIButton::UIButton(String text, Number width, Number height) : UIElement() {
 void UIButton::Resize(Number width, Number height) {
 void UIButton::Resize(Number width, Number height) {
 	buttonRect->resizeBox(width, height);
 	buttonRect->resizeBox(width, height);
 	buttonFocusedRect->resizeBox(width, height);
 	buttonFocusedRect->resizeBox(width, height);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	matrixDirty = true;	
 	
 	
 	labelXPos = floor((width-buttonLabel->getWidth())/2.0f) + labelOffsetX;
 	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->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	captionLabel->processInputEvents = true;
 	captionLabel->processInputEvents = true;
 	
 	
-	height = buttonImageUnchecked->getHeight();
-	width = buttonImageUnchecked->getWidth() + captionLabel->getWidth() + checkboxTextOffsetX;
+	setHeight(buttonImageUnchecked->getHeight());
+	setWidth(buttonImageUnchecked->getWidth() + captionLabel->getWidth() + checkboxTextOffsetX);
 }
 }
 
 
 String UICheckBox::getCaptionLabel() {
 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::CHANGE_EVENT);	
 	colorPicker->addEventListener(this, Event::CANCEL_EVENT);
 	colorPicker->addEventListener(this, Event::CANCEL_EVENT);
 	
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	
 	selectedColor = initialColor;
 	selectedColor = initialColor;
 	colorShape->color = selectedColor;	
 	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->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);	
 	bgBox->processInputEvents = true;	
 	bgBox->processInputEvents = true;	
 				
 				
-	this->width = comboWidth;
-	this->height = comboHeight;
+	setWidth(comboWidth);
+	setHeight(comboHeight);
 }
 }
 
 
 void UIComboBox::Resize(Number width, Number height) {
 void UIComboBox::Resize(Number width, Number height) {
 	this->comboWidth = width;
 	this->comboWidth = width;
 	bgBox->resizeBox(width, comboHeight);
 	bgBox->resizeBox(width, comboHeight);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);	
 	matrixDirty = true;	
 	matrixDirty = true;	
 	dropDownImage->setPosition(comboWidth - dropDownImage->getWidth() - dropDownX,dropDownY);	
 	dropDownImage->setPosition(comboWidth - dropDownImage->getWidth() - dropDownX,dropDownY);	
 }
 }
@@ -145,7 +145,7 @@ UIComboBoxItem *UIComboBox::getSelectedItem() {
 
 
 void UIComboBox::toggleDropDown() {
 void UIComboBox::toggleDropDown() {
 	Vector2 screenPos = this->getScreenPosition();
 	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++) {
 	for(int i=0; i < items.size(); i++) {
 		dropDownMenu->addOption(items[i]->label, String::IntToString(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() {
 UIElement::UIElement() : Entity() {
 	setPositionMode(Entity::POSITION_TOPLEFT);
 	setPositionMode(Entity::POSITION_TOPLEFT);
 	processInputEvents = true;
 	processInputEvents = true;
+	depthTest = false;	
 }
 }
 
 
 UIElement::UIElement(Number width, Number height) : Entity() {
 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;
 	lastPositionX = handleBox->getPosition().x;
 	
 	
-	this->height = height;
-	this->width = width;	
+	setHeight(height);
+	setWidth(width);	
 }
 }
 
 
 void UIHScrollBar::Update() {
 void UIHScrollBar::Update() {
@@ -107,15 +107,15 @@ void UIHScrollBar::Update() {
 }
 }
 
 
 void UIHScrollBar::setHandleRatio(Number newRatio) {
 void UIHScrollBar::setHandleRatio(Number newRatio) {
-	scrollHandleWidth = width*newRatio;	
+	scrollHandleWidth = getWidth()*newRatio;	
 	
 	
 	if(scrollHandleWidth < minHandleSize)
 	if(scrollHandleWidth < minHandleSize)
 		scrollHandleWidth = minHandleSize;
 		scrollHandleWidth = minHandleSize;
 	
 	
-	dragRectWidth = width-(padding*2)-scrollHandleWidth;	
+	dragRectWidth = getWidth()-(padding*2)-scrollHandleWidth;	
 	
 	
 	handleBox->resizeBox(scrollHandleWidth, handleBox->getHeight());
 	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) {
 	if(enabled && handleBox->getPosition().x > dragRectWidth) {
 		handleBox->setPositionX(dragRectWidth);
 		handleBox->setPositionX(dragRectWidth);

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

@@ -160,33 +160,33 @@ void UIHSizer::updateSizer() {
 	
 	
 		if(firstElement) {
 		if(firstElement) {
 			firstElement->setPosition(0,0);
 			firstElement->setPosition(0,0);
-			firstElement->Resize(mainWidth, height);
+			firstElement->Resize(mainWidth, getHeight());
 		}	
 		}	
 		if(secondElement) {
 		if(secondElement) {
 			secondElement->setPosition(mainWidth+1,0);
 			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);
 		separatorBgShape->setPosition(mainWidth,0);
-		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, height);
+		separatorHitShape->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, 8, getHeight());
 		separatorHitShape->setPosition(mainWidth-4,0);
 		separatorHitShape->setPosition(mainWidth-4,0);
 		
 		
 	} else {
 	} else {
 	
 	
 		if(firstElement) {
 		if(firstElement) {
 			firstElement->setPosition(0,0);
 			firstElement->setPosition(0,0);
-			firstElement->Resize(width-mainWidth, height);
+			firstElement->Resize(getWidth()-mainWidth, getHeight());
 		}	
 		}	
 		if(secondElement) {
 		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) {
 void UIHSlider::Resize(Number width, Number height) {
 	bgRect->resizeBox(width, bgHeight);
 	bgRect->resizeBox(width, bgHeight);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	matrixDirty = true;	
 	sliderWidth = width;
 	sliderWidth = width;
 	gripRect->setDragLimits(Rectangle(0,floor(bgHeight/2.0),width,0));	
 	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());
 	buttonImage = new SceneImage(imageName.c_str());
 	addChild(buttonImage);
 	addChild(buttonImage);
+	buttonImage->depthTest = false;
 	
 	
 	buttonRect = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, buttonImage->getWidth(),buttonImage->getHeight(),0,0);
 	buttonRect = new ScenePrimitive(ScenePrimitive::TYPE_VPLANE, buttonImage->getWidth(),buttonImage->getHeight(),0,0);
 	buttonRect->setColor(1,1,1,0);
 	buttonRect->setColor(1,1,1,0);
@@ -46,8 +47,8 @@ UIImageButton::UIImageButton(String imageName) : UIElement() {
 	buttonRect->processInputEvents = true;
 	buttonRect->processInputEvents = true;
 	pressedDown = false;
 	pressedDown = false;
 	
 	
-	width = buttonRect->getWidth();
-	height = buttonRect->getHeight();	
+	setWidth(buttonRect->getWidth());
+	setHeight(buttonRect->getHeight());	
 }
 }
 
 
 void UIImageButton::handleEvent(Event *event) {
 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");
 	label = new SceneLabel(name, 14, "sans");
 	setWidth(label->getLabel()->getTextWidth() + 20);
 	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);
 	bg->setPositionMode(Entity::POSITION_TOPLEFT);
 	addChild(bg);
 	addChild(bg);
 	bg->color.setColorHex(0xce5a1600);
 	bg->color.setColorHex(0xce5a1600);
@@ -88,7 +88,7 @@ UIMenuBarEntry *UIMenuBar::addMenuBarEntry(String name) {
 	entries.push_back(newEntry);
 	entries.push_back(newEntry);
 	addChild(newEntry);
 	addChild(newEntry);
 	newEntry->setPosition(entryOffset, 0);
 	newEntry->setPosition(entryOffset, 0);
-	entryOffset += newEntry->width;
+	entryOffset += newEntry->getWidth();
 
 
 	newEntry->bg->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	newEntry->bg->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	newEntry->bg->addEventListener(this, InputEvent::EVENT_MOUSEUP);
 	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;	
 	hasVScroll = vScroll;	
 	
 	
 	
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	
 	Number uiScrollPanePadding = conf->getNumericValue("Polycode", "uiScrollPanePadding");			
 	Number uiScrollPanePadding = conf->getNumericValue("Polycode", "uiScrollPanePadding");			
 	
 	
@@ -76,8 +76,8 @@ UIScrollContainer::UIScrollContainer(Entity *scrolledEntity, bool hScroll, bool
 }
 }
 
 
 void UIScrollContainer::Resize(Number width, Number height) {
 void UIScrollContainer::Resize(Number width, Number height) {
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	
 	
 	
 	
 	vScrollBar->Resize(height);
 	vScrollBar->Resize(height);
@@ -115,11 +115,11 @@ void UIScrollContainer::setContentSize(Number newContentWidth, Number newContent
 	contentHeight = newContentHeight;
 	contentHeight = newContentHeight;
 	contentWidth = newContentWidth;
 	contentWidth = newContentWidth;
 	
 	
-	vScrollBar->setHandleRatio(height / newContentHeight);	
-	hScrollBar->setHandleRatio(width / newContentWidth);	
+	vScrollBar->setHandleRatio(getHeight() / newContentHeight);	
+	hScrollBar->setHandleRatio(getWidth() / newContentWidth);	
 	
 	
 	if(hasVScroll) {
 	if(hasVScroll) {
-		if((height / newContentHeight) >= 1) {
+		if((getHeight() / newContentHeight) >= 1) {
 			vScrollBar->enabled = false;
 			vScrollBar->enabled = false;
 			vScrollBar->scrollTo(0);
 			vScrollBar->scrollTo(0);
 		} else {
 		} else {
@@ -128,7 +128,7 @@ void UIScrollContainer::setContentSize(Number newContentWidth, Number newContent
 	}
 	}
 	
 	
 	if(hasHScroll) {
 	if(hasHScroll) {
-		if((width / newContentWidth) >= 1) {
+		if((getWidth() / newContentWidth) >= 1) {
 			hScrollBar->enabled = false;
 			hScrollBar->enabled = false;
 			hScrollBar->scrollTo(0);			
 			hScrollBar->scrollTo(0);			
 		} else {
 		} else {
@@ -164,13 +164,13 @@ void UIScrollContainer::scrollHorizontal(Number amount) {
 
 
 void UIScrollContainer::Update() {
 void UIScrollContainer::Update() {
 	Vector2 pos = getScreenPosition();
 	Vector2 pos = getScreenPosition();
-	scissorBox.setRect(pos.x, pos.y, width, height);
+	scissorBox.setRect(pos.x, pos.y, getWidth(), getHeight());
 }
 }
 
 
 void UIScrollContainer::handleEvent(Event *event) {
 void UIScrollContainer::handleEvent(Event *event) {
 	if(event->getDispatcher() == vScrollBar) {
 	if(event->getDispatcher() == vScrollBar) {
 		if(event->getEventCode() == Event::CHANGE_EVENT) {
 		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)
 			if(scrollChild->getPosition().y > 0)
 				scrollChild->setPositionY(0);
 				scrollChild->setPositionY(0);
 				dispatchEvent(new Event(), Event::CHANGE_EVENT);
 				dispatchEvent(new Event(), Event::CHANGE_EVENT);
@@ -179,7 +179,7 @@ void UIScrollContainer::handleEvent(Event *event) {
 	
 	
 	if(event->getDispatcher() == hScrollBar) {
 	if(event->getDispatcher() == hScrollBar) {
 		if(event->getEventCode() == Event::CHANGE_EVENT) {
 		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)
 			if(scrollChild->getPosition().x > 0)
 				scrollChild->setPositionX(0);
 				scrollChild->setPositionX(0);
 				dispatchEvent(new Event(), Event::CHANGE_EVENT);			
 				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);
 	blinkTimer->addEventListener(this, Timer::EVENT_TRIGGER);
 
 
 	focusable = true;
 	focusable = true;
-	this->width = width;
-	this->height = rectHeight;
+	setWidth(width);
+	setHeight(rectHeight);
 	setHitbox(width, rectHeight);
 	setHitbox(width, rectHeight);
 	
 	
 	scrollContainer = NULL;
 	scrollContainer = NULL;
@@ -366,7 +366,7 @@ void UITextInput::updateSelectionRects() {
 		selectorRectBottom->visible = true;		
 		selectorRectBottom->visible = true;		
 		Number bottomSize = bufferLines[0]->getLabel()->getTextWidthForString(bottomLine.substr(0,colEnd)) ; 
 		Number bottomSize = bufferLines[0]->getLabel()->getTextWidthForString(bottomLine.substr(0,colEnd)) ; 
 		if(bottomSize < 0)
 		if(bottomSize < 0)
-			bottomSize = this->width-padding;
+			bottomSize = this->getWidth()-padding;
 		Number bottomHeight = lineHeight+lineSpacing;
 		Number bottomHeight = lineHeight+lineSpacing;
 		
 		
 		if(bottomSize < 4) {
 		if(bottomSize < 4) {
@@ -379,7 +379,7 @@ void UITextInput::updateSelectionRects() {
 		if(lineEnd != lineStart+1) {
 		if(lineEnd != lineStart+1) {
 			// need filler
 			// need filler
 			selectorRectMiddle->visible = true;		
 			selectorRectMiddle->visible = true;		
-			Number midSize = this->width-padding;
+			Number midSize = this->getWidth()-padding;
 			Number midHeight = 0;			
 			Number midHeight = 0;			
 			for(int i=lineStart+1; i < lineEnd;i++) {
 			for(int i=lineStart+1; i < lineEnd;i++) {
 				midHeight += lineHeight+lineSpacing;
 				midHeight += lineHeight+lineSpacing;
@@ -669,7 +669,7 @@ void UITextInput::doMultilineResize() {
 			realLineOffset = wordWrapLines[bufferOffset].actualLineNumber;
 			realLineOffset = wordWrapLines[bufferOffset].actualLineNumber;
 		}
 		}
 		
 		
-		if(width != lastResizeWidth) {	
+		if(getWidth() != lastResizeWidth) {	
 			updateWordWrap(0, lines.size()-1);
 			updateWordWrap(0, lines.size()-1);
 		}
 		}
 		
 		
@@ -680,11 +680,11 @@ void UITextInput::doMultilineResize() {
 		restructLines();		
 		restructLines();		
 		readjustBuffer();
 		readjustBuffer();
 		if(lineNumbersEnabled) {
 		if(lineNumbersEnabled) {
-			lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, height);
+			lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, getHeight());
 		}
 		}
 	}
 	}
 	
 	
-	lastResizeWidth = width;
+	lastResizeWidth = getWidth();
 		
 		
 	didMultilineResize = true;
 	didMultilineResize = true;
 	
 	
@@ -699,8 +699,8 @@ void UITextInput::Resize(Number width, Number height) {
 	didMultilineResize = false;
 	didMultilineResize = false;
 	
 	
 	inputRect->resizeBox(width, height);
 	inputRect->resizeBox(width, height);
-	this->width = width;
-	this->height = height;	
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;	
 	matrixDirty = true;	
 	
 	
 	if(multiLine) {
 	if(multiLine) {
@@ -845,15 +845,15 @@ void UITextInput::restructLines() {
 	}
 	}
 	
 	
 	if(multiLine && lineNumbersEnabled) {
 	if(multiLine && lineNumbersEnabled) {
-		lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, height);
+		lineNumberBg->setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, decoratorOffset, getHeight());
 	}
 	}
 	
 	
 	if(scrollContainer) {
 	if(scrollContainer) {
-		scrollContainer->setContentSize(width,  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
+		scrollContainer->setContentSize(getWidth(),  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
 	}	
 	}	
 	
 	
 	if(multiLine) {
 	if(multiLine) {
-		inputRect->setHitbox(width - scrollContainer->getVScrollWidth(), height);
+		inputRect->setHitbox(getWidth() - scrollContainer->getVScrollWidth(), getHeight());
 	}	
 	}	
 	
 	
 }
 }
@@ -1588,7 +1588,7 @@ void UITextInput::showCurrentLineIfOffscreen() {
 		return;
 		return;
 		
 		
 	int bufferOffset = -linesContainer->position.y/ ( lineHeight+lineSpacing);	
 	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) {
 	if(lines[actualLineOffset].wordWrapLineIndex > bufferOffset && lines[actualLineOffset].wordWrapLineIndex < bufferOffset + heightInLines) {
 	
 	
@@ -1658,7 +1658,7 @@ void UITextInput::showLine(unsigned int lineNumber, bool top) {
 		return;
 		return;
 	}
 	}
 	
 	
-	scrollContainer->setContentSize(width,  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
+	scrollContainer->setContentSize(getWidth(),  (((wordWrapLines.size()+1) * ((lineHeight+lineSpacing)))) + padding);
 
 
 	if(top) {
 	if(top) {
 		scrollContainer->setScrollValue(0.0, ((((offsetLineNumber) * ((lineHeight+lineSpacing)))) + padding)/(scrollContainer->getContentSize().y-scrollContainer->getHeight()));
 		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;
 	String text = lineInfo->text;
 	std::vector<TextColorPair> retVec;
 	std::vector<TextColorPair> retVec;
 	
 	
-	if(bufferLines[0]->getLabel()->getTextWidthForString(text) < width - decoratorOffset - padding) {
+	if(bufferLines[0]->getLabel()->getTextWidthForString(text) < getWidth() - decoratorOffset - padding) {
 			return retVec;
 			return retVec;
 	}		
 	}		
 	
 	
@@ -2246,7 +2246,7 @@ std::vector<TextColorPair> UITextInput::makeWordWrapBuffer(LineInfo *lineInfo, S
 	
 	
 		for(int i=0; i < parts.size(); i++) {
 		for(int i=0; i < parts.size(); i++) {
 			String _checkString = checkString + parts[i].text;
 			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) {
 				if(retVec.size() == 0) {
 					TextColorPair pair;
 					TextColorPair pair;
 					pair.text = checkString;
 					pair.text = checkString;

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

@@ -266,8 +266,8 @@ void UITree::refreshTree() {
 		}
 		}
 		treeHeight = offset - cellHeight;
 		treeHeight = offset - cellHeight;
 	}
 	}
-	height = treeHeight + cellHeight;
-	width = treeWidth;
+	setHeight(treeHeight + cellHeight);
+	setWidth(treeWidth);
 	
 	
 	selection->visible = selected;
 	selection->visible = selected;
 	dispatchEvent(new UITreeEvent(), UITreeEvent::NEED_REFRESH_EVENT);	
 	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);
 	mainContainer = new UIScrollContainer(scrollChild, false, true, treeWidth-conf->getNumericValue("Polycode", "uiScrollDefaultSize"), treeHeight);
 	addChild(mainContainer);
 	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);
 	CoreServices::getInstance()->getCore()->getInput()->addEventListener(this, InputEvent::EVENT_KEYDOWN);
 	this->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	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;
 	lastPositionY = handleBox->getPosition().y;
 	
 	
-	this->height = height;
-	this->width = width;	
+	setHeight(height);
+	setWidth(width);	
 	
 	
 	tickSize = 0.01;
 	tickSize = 0.01;
 }
 }
 
 
 void UIVScrollBar::Resize(int newHeight) {
 void UIVScrollBar::Resize(int newHeight) {
-	bgBox->resizeBox(width, newHeight);
+	bgBox->resizeBox(getWidth(), newHeight);
 	setHeight(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() {
 void UIVScrollBar::Update() {
@@ -130,14 +130,14 @@ void UIVScrollBar::Scroll(Number amount) {
 }
 }
 
 
 void UIVScrollBar::setHandleRatio(Number newRatio) {
 void UIVScrollBar::setHandleRatio(Number newRatio) {
-	scrollHandleHeight = height*newRatio;	
+	scrollHandleHeight = getHeight()*newRatio;	
 	
 	
 	if(scrollHandleHeight < minHandleSize)
 	if(scrollHandleHeight < minHandleSize)
 		scrollHandleHeight = minHandleSize;
 		scrollHandleHeight = minHandleSize;
 
 
-	dragRectHeight = height-(padding*2)-scrollHandleHeight;	
+	dragRectHeight = getHeight()-(padding*2)-scrollHandleHeight;	
 	handleBox->resizeBox(handleBox->getWidth(), 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) {
 	if(enabled && handleBox->getPosition().y > dragRectHeight) {
 		handleBox->setPositionY(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) {
 void UIVSizer::Resize(Number width, Number height) {
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	matrixDirty = true;
 	matrixDirty = true;
 	updateSizer();
 	updateSizer();
 	UIElement::Resize(width, height);
 	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"));
 	titleLabel->setPosition(conf->getNumericValue("Polycode", "uiWindowTitleX"),conf->getNumericValue("Polycode", "uiWindowTitleY"));
 	addChild(titleLabel);
 	addChild(titleLabel);
 	titleLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiWindowFontColor"));
 	titleLabel->color.setColorHexFromString(conf->getStringValue("Polycode", "uiWindowFontColor"));
+	titleLabel->positionAtBaseline = false;
 		
 		
 	closeBtn = new UIImageButton(conf->getStringValue("Polycode", "uiWindowCloseIcon"));
 	closeBtn = new UIImageButton(conf->getStringValue("Polycode", "uiWindowCloseIcon"));
 	addChild(closeBtn);
 	addChild(closeBtn);
@@ -85,8 +86,8 @@ UIWindow::UIWindow(String windowName, Number width, Number height) : Entity(), w
 	titlebarRect->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	titlebarRect->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
 	closeBtn->addEventListener(this, UIEvent::CLICK_EVENT);
 	closeBtn->addEventListener(this, UIEvent::CLICK_EVENT);
 	
 	
-	this->width = width;
-	this->height = height;
+	setWidth(width);
+	setHeight(height);
 	setHitbox(width, height);
 	setHitbox(width, height);
 	
 	
 	focusable = true;
 	focusable = true;
@@ -106,7 +107,7 @@ void UIWindow::setWindowSize(Number w, Number h) {
 	windowRect->resizeBox(w, h);
 	windowRect->resizeBox(w, h);
 	setWidth(w);
 	setWidth(w);
 	setHeight(h);	
 	setHeight(h);	
-	closeBtn->setPosition(width-closeBtn->getWidth()-closeIconX, closeIconY);	
+	closeBtn->setPosition(getWidth()-closeBtn->getWidth()-closeIconX, closeIconY);	
 	matrixDirty = true;
 	matrixDirty = true;
 }
 }