Przeglądaj źródła

Vertical and Horizontal UI sizers, UITree resizes better, made all UI elements sublass UIElement, IDE tree/editor resizing with new UI sizers

Ivan Safrin 13 lat temu
rodzic
commit
059ea5cac4
30 zmienionych plików z 637 dodań i 54 usunięć
  1. 16 2
      IDE/Contents/Include/PolycodeFrame.h
  2. 2 2
      IDE/Contents/Include/PolycodeProjectBrowser.h
  3. BIN
      IDE/Contents/Resources/UIThemes/default/selector.png
  4. 2 2
      IDE/Contents/Resources/UIThemes/default/theme.xml
  5. 40 19
      IDE/Contents/Source/PolycodeFrame.cpp
  6. 3 4
      IDE/Contents/Source/PolycodeProjectBrowser.cpp
  7. 6 0
      Modules/Contents/UI/CMakeLists.txt
  8. 2 1
      Modules/Contents/UI/Include/PolyUIButton.h
  9. 2 1
      Modules/Contents/UI/Include/PolyUICheckBox.h
  10. 2 1
      Modules/Contents/UI/Include/PolyUIColorBox.h
  11. 2 1
      Modules/Contents/UI/Include/PolyUIComboBox.h
  12. 40 0
      Modules/Contents/UI/Include/PolyUIElement.h
  13. 65 0
      Modules/Contents/UI/Include/PolyUIHSizer.h
  14. 2 1
      Modules/Contents/UI/Include/PolyUIImageButton.h
  15. 3 2
      Modules/Contents/UI/Include/PolyUITextInput.h
  16. 3 0
      Modules/Contents/UI/Include/PolyUITree.h
  17. 3 2
      Modules/Contents/UI/Include/PolyUITreeContainer.h
  18. 65 0
      Modules/Contents/UI/Include/PolyUIVSizer.h
  19. 3 0
      Modules/Contents/UI/Include/PolycodeUI.h
  20. 1 1
      Modules/Contents/UI/Source/PolyUIButton.cpp
  21. 1 1
      Modules/Contents/UI/Source/PolyUICheckBox.cpp
  22. 1 1
      Modules/Contents/UI/Source/PolyUIColorBox.cpp
  23. 1 1
      Modules/Contents/UI/Source/PolyUIComboBox.cpp
  24. 37 0
      Modules/Contents/UI/Source/PolyUIElement.cpp
  25. 155 0
      Modules/Contents/UI/Source/PolyUIHSizer.cpp
  26. 1 1
      Modules/Contents/UI/Source/PolyUIImageButton.cpp
  27. 6 6
      Modules/Contents/UI/Source/PolyUITextInput.cpp
  28. 11 0
      Modules/Contents/UI/Source/PolyUITree.cpp
  29. 7 5
      Modules/Contents/UI/Source/PolyUITreeContainer.cpp
  30. 155 0
      Modules/Contents/UI/Source/PolyUIVSizer.cpp

+ 16 - 2
IDE/Contents/Include/PolycodeFrame.h

@@ -31,6 +31,17 @@
 
 using namespace Polycode;
 
+class EditorHolder : public UIElement {
+	public:
+		EditorHolder();
+		~EditorHolder();
+		
+		void Resize(Number width, Number height);
+		
+		PolycodeEditor *currentEditor;
+		
+};
+
 class PolycodeFrame : public ScreenEntity {
 public:
 	
@@ -76,14 +87,17 @@ private:
 	
 	ScreenImage *welcomeImage;	
 	
-	ScreenEntity *editorHolder;
+	EditorHolder *editorHolder;
 	
-	PolycodeEditor *currentEditor;
+
 	vector<PolycodeEditor*> editors;
 	
 	ScreenShape *modalBlocker;
 	UIWindow *modalChild;		
 	
+	UIHSizer *mainSizer;
+	UIVSizer *consoleSizer;
+	
 	UIButton *newProjectButton;
 	UIButton *examplesButton;
 	

+ 2 - 2
IDE/Contents/Include/PolycodeProjectBrowser.h

@@ -48,12 +48,12 @@ class PolycodeProjectBrowserEvent : public Event {
 		
 };
 
-class PolycodeProjectBrowser : public ScreenEntity {
+class PolycodeProjectBrowser : public UIElement {
 public:
 	PolycodeProjectBrowser();
 	~PolycodeProjectBrowser();
 	
-	void Resize(int newWidth, int newHeight);
+	void Resize(Number width, Number height);
 	void addProject(PolycodeProject *project);
 	void removeProject(PolycodeProject *project);
 	

BIN
IDE/Contents/Resources/UIThemes/default/selector.png


+ 2 - 2
IDE/Contents/Resources/UIThemes/default/theme.xml

@@ -20,12 +20,12 @@
 	<uiTreeCellSelectorSkin>selector.png</uiTreeCellSelectorSkin>
 	<uiTreeCellSelectorSkinPadding>4</uiTreeCellSelectorSkinPadding>
 	<uiTreeCellSelectorSkinT>4</uiTreeCellSelectorSkinT>
-	<uiTreeCellSelectorSkinR>0</uiTreeCellSelectorSkinR>
+	<uiTreeCellSelectorSkinR>3</uiTreeCellSelectorSkinR>
 	<uiTreeCellSelectorSkinB>4</uiTreeCellSelectorSkinB>
 	<uiTreeCellSelectorSkinL>0</uiTreeCellSelectorSkinL>
 	
 	<uiTreeContainerSkin>treeBg.png</uiTreeContainerSkin>
-	<uiTreeContainerSkinPadding>2</uiTreeContainerSkinPadding>
+	<uiTreeContainerSkinPadding>0</uiTreeContainerSkinPadding>
 	<uiTreeContainerSkinT>2</uiTreeContainerSkinT>
 	<uiTreeContainerSkinR>2</uiTreeContainerSkinR>
 	<uiTreeContainerSkinB>2</uiTreeContainerSkinB>

+ 40 - 19
IDE/Contents/Source/PolycodeFrame.cpp

@@ -22,6 +22,21 @@
 
 #include "PolycodeFrame.h"
 
+EditorHolder::EditorHolder() : UIElement() {
+	currentEditor = NULL;
+}
+
+EditorHolder::~EditorHolder() {
+
+}
+		
+void EditorHolder::Resize(Number width, Number height) {
+	if(currentEditor) {
+		currentEditor->Resize(width, height);
+	}
+}
+
+
 PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 
 	modalChild = NULL;
@@ -43,12 +58,24 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 	welcomeEntity->addChild(newProjectButton);
 	welcomeEntity->addChild(examplesButton);
 	
-	editorHolder = new ScreenEntity();
-	addChild(editorHolder);
-		
+	mainSizer = new UIHSizer(100,100,200);
+	mainSizer->setPosition(0, 45);
+	addChild(mainSizer);
 	
+			
 	projectBrowser = new PolycodeProjectBrowser();
-	addChild(projectBrowser);
+	mainSizer->addLeftChild(projectBrowser);
+
+	consoleSizer = new UIVSizer(100,100,400);
+	mainSizer->addRightChild(consoleSizer);	
+
+	editorHolder = new EditorHolder();
+	consoleSizer->addTopChild(editorHolder);
+	
+	// REPLACE WITH CONSOLE CLASS
+	UITextInput *textInput = new UITextInput(true, 100, 100);
+	consoleSizer->addBottomChild(textInput);	
+	
 	
 	projectBrowser->treeContainer->getRootNode()->addEventListener(this, UITreeEvent::DRAG_START_EVENT);
 		
@@ -88,7 +115,6 @@ PolycodeFrame::PolycodeFrame() : ScreenEntity() {
 	textInputPopup = new TextInputPopup();
 	textInputPopup->visible = false;
 	
-	currentEditor = NULL;
 	
 	isDragging  = false;
 	dragLabel = new ScreenLabel("NONE", 11, "sans");
@@ -124,13 +150,13 @@ void PolycodeFrame::addEditor(PolycodeEditor *editor) {
 }
 
 void PolycodeFrame::showEditor(PolycodeEditor *editor) {
-	if(currentEditor) {
-		currentEditor->enabled = false;
-		currentEditor = NULL;
+	if(editorHolder->currentEditor) {
+		editorHolder->currentEditor->enabled = false;
+		editorHolder->currentEditor = NULL;
 	}
 	
-	currentEditor = editor;
-	currentEditor->enabled = true;
+	editorHolder->currentEditor = editor;
+	editorHolder->currentEditor->enabled = true;
 	
 	Resize(frameSizeX, frameSizeY);
 }
@@ -151,11 +177,11 @@ void PolycodeFrame::handleEvent(Event *event) {
 		switch(event->getEventCode()) {
 			case InputEvent::EVENT_MOUSEUP:
 				if(isDragging) {
-					if(currentEditor) {
+					if(editorHolder->currentEditor) {
 						InputEvent *inputEvent = (InputEvent*) event;						
 						Number posX = inputEvent->mousePosition.x - editorHolder->getPosition2D().x;
 						Number posY = inputEvent->mousePosition.y - editorHolder->getPosition2D().y;						
-						currentEditor->handleDroppedFile(draggedFile, posX, posY);
+						editorHolder->currentEditor->handleDroppedFile(draggedFile, posX, posY);
 					}
 				}
 				isDragging = false;
@@ -218,15 +244,10 @@ void PolycodeFrame::Resize(int x, int y) {
 	topBarBg->setShapeSize(x, 45);
 	logo->setPosition(x-logo->getWidth()-2, 2);	
 	resizer->setPosition(x-resizer->getWidth()-1, y-resizer->getHeight()-1);	
-	projectBrowser->Resize(200, y-45);
+	mainSizer->Resize(x,y-45);	
 	
 	modalBlocker->setShapeSize(x, y);
-	
-	editorHolder->setPosition(200, 45);
-	
-	if(currentEditor) {
-		currentEditor->Resize(x-200, y-45);
-	}
+		
 	
 	if(this->modalChild) {
 		modalChild->setPosition((x-modalChild->getWidth())/2.0f, (y-modalChild->getHeight())/2.0f);

+ 3 - 4
IDE/Contents/Source/PolycodeProjectBrowser.cpp

@@ -22,7 +22,7 @@
 
 #include "PolycodeProjectBrowser.h"
 
-PolycodeProjectBrowser::PolycodeProjectBrowser() : ScreenEntity() {
+PolycodeProjectBrowser::PolycodeProjectBrowser() : UIElement() {
 	treeContainer = new UITreeContainer("boxIcon.png", L"Projects", 200, 555);
 	treeContainer->getRootNode()->toggleCollapsed();
 	treeContainer->getRootNode()->addEventListener(this, UITreeEvent::SELECTED_EVENT);
@@ -34,7 +34,6 @@ PolycodeProjectBrowser::PolycodeProjectBrowser() : ScreenEntity() {
 	treeContainer->getRootNode()->setUserData((void*) data)	;
 	
 	addChild(treeContainer);		
-	treeContainer->setPosition(0,45);	
 	
 	selectedData = NULL;
 }
@@ -165,6 +164,6 @@ void PolycodeProjectBrowser::parseFolderIntoNode(UITree *node, String spath, Pol
 	
 }
 
-void PolycodeProjectBrowser::Resize(int newWidth, int newHeight) {
-	treeContainer->Resize(newWidth, newHeight);
+void PolycodeProjectBrowser::Resize(Number width, Number height) {
+	treeContainer->Resize(width, height);
 }

+ 6 - 0
Modules/Contents/UI/CMakeLists.txt

@@ -1,7 +1,10 @@
 INCLUDE(PolycodeIncludes)
 
 SET(polycodeUI_SRCS
+    Source/PolyUIElement.cpp
     Source/PolyUIBox.cpp
+    Source/PolyUIHSizer.cpp
+    Source/PolyUIVSizer.cpp
     Source/PolyUIButton.cpp
     Source/PolyUICheckBox.cpp
     Source/PolyUIComboBox.cpp
@@ -21,6 +24,9 @@ SET(polycodeUI_SRCS
 
 SET(polycodeUI_HDRS
     Include/PolycodeUI.h
+    Include/PolyUIElement.h
+    Include/PolyUIHSizer.h
+    Include/PolyUIVSizer.h
     Include/PolyUIBox.h
     Include/PolyUIButton.h
     Include/PolyUICheckBox.h

+ 2 - 1
Modules/Contents/UI/Include/PolyUIButton.h

@@ -27,10 +27,11 @@
 #include "PolyScreenEntity.h"
 #include "PolyUIEvent.h"
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
 
 namespace Polycode {
 
-	class _PolyExport UIButton : public ScreenEntity {
+	class _PolyExport UIButton : public UIElement {
 		public:
 			UIButton(String text, Number width, Number height = 26);
 			~UIButton();		

+ 2 - 1
Modules/Contents/UI/Include/PolyUICheckBox.h

@@ -28,10 +28,11 @@
 #include "PolyScreenEntity.h"
 #include "PolyUIEvent.h"
 #include "PolyFont.h"
+#include "PolyUIElement.h"
 
 namespace Polycode {
 
-	class _PolyExport UICheckBox : public ScreenEntity {
+	class _PolyExport UICheckBox : public UIElement {
 		public:
 			UICheckBox(String caption, bool checked);
 			~UICheckBox();

+ 2 - 1
Modules/Contents/UI/Include/PolyUIColorBox.h

@@ -31,6 +31,7 @@
 #include "PolyUIWindow.h"
 #include "PolyUIHSlider.h"
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
 #include "PolyFont.h"
 
 namespace Polycode {
@@ -84,7 +85,7 @@ namespace Polycode {
 			ScreenShape *mainColorRect;
 	};
 
-	class _PolyExport UIColorBox : public ScreenEntity {
+	class _PolyExport UIColorBox : public UIElement {
 		public:
 			UIColorBox(Color initialColor, Number width, Number height);
 			~UIColorBox();

+ 2 - 1
Modules/Contents/UI/Include/PolyUIComboBox.h

@@ -28,11 +28,12 @@
 #include "PolyScreenEntity.h"
 #include "PolyUIEvent.h"
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
 #include "PolyFont.h"
 
 namespace Polycode {
 
-	class _PolyExport UIComboBoxItem : public ScreenEntity {
+	class _PolyExport UIComboBoxItem : public UIElement {
 		public:
 			UIComboBoxItem(String label, Number comboWidth, Number comboHeight);
 			~UIComboBoxItem();

+ 40 - 0
Modules/Contents/UI/Include/PolyUIElement.h

@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+#include "PolyGlobals.h"
+#include "PolyScreenEntity.h"
+
+namespace Polycode {
+	
+	class _PolyExport UIElement : public ScreenEntity {
+		public:
+			UIElement();
+			~UIElement();
+			
+			virtual void Resize(Number width, Number height);
+			
+		protected:
+			
+	};
+	
+}

+ 65 - 0
Modules/Contents/UI/Include/PolyUIHSizer.h

@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+#include "PolyGlobals.h"
+#include "PolyScreenShape.h"
+#include "PolyUIElement.h"
+
+namespace Polycode {
+	
+	class CoreInput;
+	
+	class _PolyExport UIHSizer : public UIElement {
+		public:
+			UIHSizer(Number width, Number height, Number leftWidth);
+			~UIHSizer();
+			
+			void handleEvent(Event *event);
+			
+			void setLeftWidth(Number width);
+			
+			void addLeftChild(UIElement *element);
+			void addRightChild(UIElement *element);			
+			void Resize(Number width, Number height);
+			
+			void updateSizer();
+			
+		protected:
+		
+			ScreenEntity *childElements;			
+			Number leftWidth;
+			
+			CoreInput *coreInput;
+			
+			bool resizing;
+			Number baseMouseX;
+			Number baseLeftWidth;
+			
+			ScreenShape *separatorHitShape;
+			ScreenShape *separatorBgShape;
+			
+			UIElement *firstElement;
+			UIElement *secondElement;			
+	};
+	
+}

+ 2 - 1
Modules/Contents/UI/Include/PolyUIImageButton.h

@@ -26,10 +26,11 @@
 #include "PolyScreenShape.h"
 #include "PolyScreenEntity.h"
 #include "PolyUIEvent.h"
+#include "PolyUIElement.h"
 
 namespace Polycode {
 
-	class _PolyExport UIImageButton : public ScreenEntity {
+	class _PolyExport UIImageButton : public UIElement {
 		public:
 			UIImageButton(String imageName);
 			~UIImageButton();

+ 3 - 2
Modules/Contents/UI/Include/PolyUITextInput.h

@@ -29,6 +29,7 @@
 #include "PolyScreenEntity.h"
 #include "PolyUIEvent.h"
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
 #include "PolyTimer.h"
 #include "PolyCoreInput.h"
 #include "PolyCore.h"
@@ -38,7 +39,7 @@ using namespace std;
 
 namespace Polycode {
 
-	class _PolyExport UITextInput : public ScreenEntity {
+	class _PolyExport UITextInput : public UIElement {
 		public:
 			UITextInput(bool multiLine, Number width, Number height);
 			~UITextInput();
@@ -61,7 +62,7 @@ namespace Polycode {
 			void deleteSelection();		
 			void selectAll();
 		
-			void Resize(int x, int y);
+			void Resize(Number width, Number height);
 			
 			void setNumberOnly(bool val);
 		

+ 3 - 0
Modules/Contents/UI/Include/PolyUITree.h

@@ -55,6 +55,8 @@ namespace Polycode {
 			UITree *getSelectedNode();
 			void setIcon(String iconFile);
 			void setSelected();
+			
+			void Resize(Number width);
 		
 			int getNumTreeChildren() { return treeChildren.size(); }
 			UITree *getTreeChild(int index) { return treeChildren[index]; }
@@ -75,6 +77,7 @@ namespace Polycode {
 			Number treeOffset;
 			UITree *selectedNode;
 			UITree *parent;
+			Number padding;
 			UIBox *selection;
 		//	UIBox *bgBox;
 			ScreenShape *bgBox;

+ 3 - 2
Modules/Contents/UI/Include/PolyUITreeContainer.h

@@ -24,17 +24,18 @@
 #include "PolyGlobals.h"
 #include "PolyUITree.h"
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
 #include "PolyUIScrollContainer.h"
 
 namespace Polycode {
 	
-	class _PolyExport UITreeContainer : public ScreenEntity {
+	class _PolyExport UITreeContainer : public UIElement {
 	public:
 		UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight);
 		~UITreeContainer();
 		
 		void handleEvent(Event *event);
-		void Resize(int x, int y);
+		void Resize(Number width, Number height);
 		
 		UITree *getRootNode();
 		ScreenEntity *scrollChild;

+ 65 - 0
Modules/Contents/UI/Include/PolyUIVSizer.h

@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+#include "PolyGlobals.h"
+#include "PolyScreenShape.h"
+#include "PolyUIElement.h"
+
+namespace Polycode {
+	
+	class CoreInput;
+	
+	class _PolyExport UIVSizer : public UIElement {
+		public:
+			UIVSizer(Number width, Number height, Number topHeight);
+			~UIVSizer();
+			
+			void handleEvent(Event *event);
+			
+			void setTopHeight(Number height);
+			
+			void addTopChild(UIElement *element);
+			void addBottomChild(UIElement *element);			
+			void Resize(Number width, Number height);
+			
+			void updateSizer();
+			
+		protected:
+		
+			ScreenEntity *childElements;			
+			Number topHeight;
+			
+			CoreInput *coreInput;
+			
+			bool resizing;
+			Number baseMouseY;
+			Number baseTopHeight;
+			
+			ScreenShape *separatorHitShape;
+			ScreenShape *separatorBgShape;
+			
+			UIElement *firstElement;
+			UIElement *secondElement;			
+	};
+	
+}

+ 3 - 0
Modules/Contents/UI/Include/PolycodeUI.h

@@ -21,6 +21,9 @@
  */
 
 #include "PolyUIBox.h"
+#include "PolyUIElement.h"
+#include "PolyUIHSizer.h"
+#include "PolyUIVSizer.h"
 #include "PolyUIButton.h"
 #include "PolyUICheckBox.h"
 #include "PolyUIComboBox.h"

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

@@ -29,7 +29,7 @@
 
 using namespace Polycode;
 
-UIButton::UIButton(String text, Number width, Number height) : ScreenEntity() {
+UIButton::UIButton(String text, Number width, Number height) : UIElement() {
 
 	Config *conf = CoreServices::getInstance()->getConfig();	
 	

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

@@ -28,7 +28,7 @@
 
 using namespace Polycode;
 
-UICheckBox::UICheckBox(String caption, bool checked) : ScreenEntity() {
+UICheckBox::UICheckBox(String caption, bool checked) : UIElement() {
 
 	Config *conf = CoreServices::getInstance()->getConfig();	
 	

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

@@ -368,7 +368,7 @@ void UIColorPicker::Update() {
 	UIWindow::Update();
 }
 
-UIColorBox::UIColorBox(Color initialColor, Number width, Number height) : ScreenEntity() {
+UIColorBox::UIColorBox(Color initialColor, Number width, Number height) : UIElement() {
 
 	Config *conf = CoreServices::getInstance()->getConfig();	
 

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

@@ -28,7 +28,7 @@
 
 using namespace Polycode;
 
-UIComboBoxItem::UIComboBoxItem(String label, Number comboWidth, Number comboHeight) : ScreenEntity() {
+UIComboBoxItem::UIComboBoxItem(String label, Number comboWidth, Number comboHeight) : UIElement() {
 	this->label = label;
 	Config *conf = CoreServices::getInstance()->getConfig();	
 	

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

@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#include "PolyUIElement.h"
+
+using namespace Polycode;
+
+UIElement::UIElement() : ScreenEntity() {
+	setPositionMode(ScreenEntity::POSITION_TOPLEFT);
+}
+
+UIElement::~UIElement() {
+
+}
+
+void UIElement::Resize(Number width, Number height) {
+
+}

+ 155 - 0
Modules/Contents/UI/Source/PolyUIHSizer.cpp

@@ -0,0 +1,155 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+
+#include "PolyUIHSizer.h"
+#include "PolyConfig.h"
+#include "PolyInputEvent.h"
+#include "PolyCoreServices.h"
+#include "PolyCore.h"
+
+using namespace Polycode;
+
+UIHSizer::UIHSizer(Number width, Number height, Number leftWidth) : UIElement() {
+
+	this->width = width;
+	this->height = height;
+	
+	this->leftWidth = leftWidth;
+	
+	separatorBgShape = new ScreenShape(ScreenShape::SHAPE_RECT, 1,height);
+	separatorBgShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
+	separatorBgShape->setColor(0.0, 0.0, 0.0, 1.0);	
+	addChild(separatorBgShape);
+
+	childElements = new ScreenEntity();
+	addChild(childElements);
+	
+	firstElement = NULL;
+	secondElement = NULL;
+	
+	separatorHitShape = new ScreenShape(ScreenShape::SHAPE_RECT, 6,height);
+	separatorHitShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
+	separatorHitShape->setColor(1.0, 0.0, 0.0, 0.5);	
+	addChild(separatorHitShape);
+	
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEUP);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEUP_OUTSIDE);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEOVER);	
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEOUT);		
+	separatorHitShape->visible = false;
+	
+	coreInput = CoreServices::getInstance()->getCore()->getInput();
+	
+	coreInput->addEventListener(this, InputEvent::EVENT_MOUSEMOVE);	
+	
+	separatorHitShape->processInputEvents = true;
+	
+	updateSizer();
+	resizing = false;
+
+}
+
+UIHSizer::~UIHSizer() {
+
+}
+
+void UIHSizer::handleEvent(Event *event) {
+	if(event->getDispatcher() == separatorHitShape) {
+		InputEvent *inputEvent = (InputEvent*)event;
+		switch (event->getEventCode()) {
+			case InputEvent::EVENT_MOUSEDOWN:
+				resizing = true;
+				baseLeftWidth = leftWidth;
+			break;
+			case InputEvent::EVENT_MOUSEUP:
+			case InputEvent::EVENT_MOUSEUP_OUTSIDE:	
+			{
+				resizing = false;			
+			}
+			break;
+			case InputEvent::EVENT_MOUSEOVER:
+				CoreServices::getInstance()->getCore()->setCursor(CURSOR_RESIZE_LEFT_RIGHT);
+			break;
+			case InputEvent::EVENT_MOUSEOUT:
+				CoreServices::getInstance()->getCore()->setCursor(CURSOR_ARROW);
+			break;							
+		}
+	}
+	
+	if(event->getDispatcher() == coreInput) {
+		InputEvent *inputEvent = (InputEvent*)event;
+		switch (event->getEventCode()) {
+			case InputEvent::EVENT_MOUSEMOVE:
+				if(resizing == true) {
+					setLeftWidth(baseLeftWidth + (inputEvent->mousePosition.x-baseMouseX));
+				} else {
+					baseMouseX = inputEvent->mousePosition.x;				
+				}
+			break;		
+		}		
+	}
+}
+
+void UIHSizer::Resize(Number width, Number height) {
+	this->width = width;
+	this->height = height;
+	matrixDirty = true;
+	updateSizer();
+}
+
+void UIHSizer::setLeftWidth(Number width) {
+	leftWidth = width;
+	updateSizer();
+}
+			
+void UIHSizer::addLeftChild(UIElement *element) {
+	childElements->addChild(element);	
+	firstElement = element;
+	updateSizer();
+}
+
+void UIHSizer::addRightChild(UIElement *element) {
+	childElements->addChild(element);
+	secondElement = element;	
+	updateSizer();
+}
+
+void UIHSizer::updateSizer() {
+	if(firstElement) {
+		firstElement->setPosition(0,0);
+		firstElement->Resize(leftWidth, height);
+	}
+	
+	if(secondElement) {
+		secondElement->setPosition(leftWidth+1,0);
+		secondElement->Resize(width-leftWidth-1, height);	
+	}
+
+	separatorBgShape->setShapeSize(1, height);
+	separatorBgShape->setPosition(leftWidth,0);
+
+	
+	separatorHitShape->setShapeSize(6, height);
+	separatorHitShape->setPosition(leftWidth-3,0);
+}

+ 1 - 1
Modules/Contents/UI/Source/PolyUIImageButton.cpp

@@ -28,7 +28,7 @@
 
 using namespace Polycode;
 
-UIImageButton::UIImageButton(String imageName) : ScreenEntity() {
+UIImageButton::UIImageButton(String imageName) : UIElement() {
 	setPositionMode(ScreenEntity::POSITION_TOPLEFT);
 	
 	buttonImage = new ScreenImage(imageName.c_str());

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

@@ -30,7 +30,7 @@
 
 using namespace Polycode;
 
-UITextInput::UITextInput(bool multiLine, Number width, Number height) : ScreenEntity() {
+UITextInput::UITextInput(bool multiLine, Number width, Number height) : UIElement() {
 	this->multiLine = multiLine;
 	
 	isNumberOnly = false;
@@ -289,12 +289,12 @@ void UITextInput::deleteSelection() {
 	dispatchEvent(new UIEvent(), UIEvent::CHANGE_EVENT);	
 }
 
-void UITextInput::Resize(int x, int y) {
-	inputRect->resizeBox(x, y);
-	this->width = x;
-	this->height = y;	
+void UITextInput::Resize(Number width, Number height) {
+	inputRect->resizeBox(width, height);
+	this->width = width;
+	this->height = height;	
 	matrixDirty = true;	
-	setHitbox(x,y);
+	setHitbox(width,height);
 }
 
 int UITextInput::insertLine(bool after) {

+ 11 - 0
Modules/Contents/UI/Source/PolyUITree.cpp

@@ -79,6 +79,7 @@ UITree::UITree(String icon, String text, Number treeWidth, Number treeOffset) :
 	Number sl = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinL");
 	
 	Number padding = conf->getNumericValue("Polycode", "uiTreeCellSelectorSkinPadding");	
+	this->padding = padding;
 	
 	selection = new UIBox(conf->getStringValue("Polycode", "uiTreeCellSelectorSkin"),
 						  st,sr,sb,sl,
@@ -119,6 +120,16 @@ UITree::UITree(String icon, String text, Number treeWidth, Number treeOffset) :
 	refreshTree();
 }
 
+void UITree::Resize(Number width) {
+	treeWidth = width;
+	selection->resizeBox(treeWidth+(padding*2), cellHeight+(padding*2));
+	bgBox->setShapeSize(width, cellHeight);
+	
+	for(int i=0; i < treeChildren.size(); i++) {
+		treeChildren[i]->Resize(width);
+	}
+}
+
 String UITree::getLabelText() {
 	return labelText;
 }

+ 7 - 5
Modules/Contents/UI/Source/PolyUITreeContainer.cpp

@@ -28,7 +28,7 @@
 
 using namespace Polycode;
 
-UITreeContainer::UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight) : ScreenEntity() {
+UITreeContainer::UITreeContainer(String icon, String text, Number treeWidth, Number treeHeight) : UIElement() {
 	
 	Config *conf = CoreServices::getInstance()->getConfig();
 	
@@ -61,14 +61,16 @@ UITreeContainer::UITreeContainer(String icon, String text, Number treeWidth, Num
 	setHitbox(width, height);
 }
 
-void UITreeContainer::Resize(int x, int y) {
-	mainContainer->Resize(x,y);
-	bgBox->resizeBox(x, y);
+void UITreeContainer::Resize(Number width, Number height) {
+	mainContainer->Resize(width,height);
+	bgBox->resizeBox(width, height);
 	mainContainer->setPositionY(0);
 
+
+	rootNode->Resize(width);
 //	width = x;
 	//	height = y;
-	setHitbox(x, y);
+	setHitbox(width, height);
 }
 
 void UITreeContainer::handleEvent(Event *event) {

+ 155 - 0
Modules/Contents/UI/Source/PolyUIVSizer.cpp

@@ -0,0 +1,155 @@
+/*
+ Copyright (C) 2012 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+
+#include "PolyUIVSizer.h"
+#include "PolyConfig.h"
+#include "PolyInputEvent.h"
+#include "PolyCoreServices.h"
+#include "PolyCore.h"
+
+using namespace Polycode;
+
+UIVSizer::UIVSizer(Number width, Number height, Number topHeight) : UIElement() {
+
+	this->width = width;
+	this->height = height;
+	
+	this->topHeight = topHeight;
+	
+	separatorBgShape = new ScreenShape(ScreenShape::SHAPE_RECT, width,1);
+	separatorBgShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
+	separatorBgShape->setColor(0.0, 0.0, 0.0, 1.0);	
+	addChild(separatorBgShape);
+
+	childElements = new ScreenEntity();
+	addChild(childElements);
+	
+	firstElement = NULL;
+	secondElement = NULL;
+	
+	separatorHitShape = new ScreenShape(ScreenShape::SHAPE_RECT, width,6);
+	separatorHitShape->setPositionMode(ScreenEntity::POSITION_TOPLEFT);
+	separatorHitShape->setColor(1.0, 0.0, 0.0, 0.5);	
+	addChild(separatorHitShape);
+	
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEDOWN);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEUP);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEUP_OUTSIDE);
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEOVER);	
+	separatorHitShape->addEventListener(this, InputEvent::EVENT_MOUSEOUT);		
+	separatorHitShape->visible = false;
+	
+	coreInput = CoreServices::getInstance()->getCore()->getInput();
+	
+	coreInput->addEventListener(this, InputEvent::EVENT_MOUSEMOVE);	
+	
+	separatorHitShape->processInputEvents = true;
+	
+	updateSizer();
+	resizing = false;
+
+}
+
+UIVSizer::~UIVSizer() {
+
+}
+
+void UIVSizer::handleEvent(Event *event) {
+	if(event->getDispatcher() == separatorHitShape) {
+		InputEvent *inputEvent = (InputEvent*)event;
+		switch (event->getEventCode()) {
+			case InputEvent::EVENT_MOUSEDOWN:
+				resizing = true;
+				baseTopHeight = topHeight;
+			break;
+			case InputEvent::EVENT_MOUSEUP:
+			case InputEvent::EVENT_MOUSEUP_OUTSIDE:	
+			{
+				resizing = false;			
+			}
+			break;
+			case InputEvent::EVENT_MOUSEOVER:
+				CoreServices::getInstance()->getCore()->setCursor(CURSOR_RESIZE_UP_DOWN);
+			break;
+			case InputEvent::EVENT_MOUSEOUT:
+				CoreServices::getInstance()->getCore()->setCursor(CURSOR_ARROW);
+			break;							
+		}
+	}
+	
+	if(event->getDispatcher() == coreInput) {
+		InputEvent *inputEvent = (InputEvent*)event;
+		switch (event->getEventCode()) {
+			case InputEvent::EVENT_MOUSEMOVE:
+				if(resizing == true) {
+					setTopHeight(baseTopHeight + (inputEvent->mousePosition.y-baseMouseY));
+				} else {
+					baseMouseY = inputEvent->mousePosition.y;
+				}
+			break;		
+		}		
+	}
+}
+
+void UIVSizer::Resize(Number width, Number height) {
+	this->width = width;
+	this->height = height;
+	matrixDirty = true;
+	updateSizer();
+}
+
+void UIVSizer::setTopHeight(Number height) {
+	topHeight = height;
+	updateSizer();
+}
+			
+void UIVSizer::addTopChild(UIElement *element) {
+	childElements->addChild(element);	
+	firstElement = element;
+	updateSizer();
+}
+
+void UIVSizer::addBottomChild(UIElement *element) {
+	childElements->addChild(element);
+	secondElement = element;	
+	updateSizer();
+}
+
+void UIVSizer::updateSizer() {
+	if(firstElement) {
+		firstElement->setPosition(0,0);
+		firstElement->Resize(width, topHeight);
+	}
+	
+	if(secondElement) {
+		secondElement->setPosition(0,topHeight+1);
+		secondElement->Resize(width, height-topHeight-1);	
+	}
+
+	separatorBgShape->setShapeSize(width, 1);
+	separatorBgShape->setPosition(0,topHeight);
+
+	
+	separatorHitShape->setShapeSize(width, 6);
+	separatorHitShape->setPosition(0, topHeight-3);
+}