Browse Source

Added ScriptGUIPanel
Also markdown version of the license

Marko Pintera 11 years ago
parent
commit
63f189dd7b

+ 0 - 1
BansheeEditor/Source/BsGUIFoldout.cpp

@@ -6,7 +6,6 @@
 #include "BsBuiltinResources.h"
 #include "BsBuiltinResources.h"
 #include "BsGUIWidget.h"
 #include "BsGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIWidget.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {

+ 35 - 0
License/BansheeLicense.md

@@ -0,0 +1,35 @@
+By downloading, using, modifying or distributing Banshee Project as a whole or in part you agree to the terms of this license. This license applies to all Banshee Project distributions (source, binary and others) and as such applies to all files within those distributions. 
+
+You may freely use, modify and redistribute Banshee for personal or commercial use, as long as you acknowledge in your product that you are using the Banshee Project under the terms stated by the license.
+
+Certain Banshee distributions come with a set of third party libraries or tools, either in source or binary form. Those libraries come with their own licenses do not fall under the Banshee license.
+
+This license was inspired by BSD and FreeType licenses.
+
+The Banshee Project is copyright (C) 2014 by Marko Pintera.
+# Banshee License
+## License Grant
+Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the Software and accompanying documentation covered by this license to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software. The License does not grant you any title or ownership in the Licensed Technology.
+## Attribution
+You must acknowledge the use of the Software in any derivative works or if you are redistributing the Software in any form. 
+
+Any redistribution of source code, original or altered must include this license in its original form. Any modifications to the source code must be noted in the derivative works documentation.
+
+Any derivative work or work using any part of Banshee Project in binary form must include a clearly visible Banshee Engine Logo during application start up. Optionally, if displaying the logo is not feasible due to technical constraints a textual credit line may be displayed in another location with a special permission from the Author.
+## Third Party Software
+The Software includes Third Party Software components. Those components may include separate software licenses or requirements. Those components are not covered by this License.
+## Disclaimer
+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 particular purpose, title or non-infringement. In no event shall the copyright holders or anyone distributing the Software be liable for any damages or other liability, whether in contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
+## Definitions
+“Author” means the original creator and copyright holder of the Software, Marko Pintera.
+
+“Banshee Engine Logo” means the image asset provided as Exhibit A.
+
+“Licensed Technology” means the Software source code, machine-executable code, documentation, tools, assets and any other files that are considered part of the “Banshee Project”.
+
+“Software” means the original set of files created and distributed as “Banshee Project” by the Author.
+
+“Third Party Software” means any third party components used by the Software, either in source or machine-executable code format and any assets they might include.
+
+## Exhibits
+Exhibit A - Banshee Engine Logo – Included with this license text as BansheeLogo.png.

+ 32 - 0
SBansheeEditor/Include/BsGUIPanelContainer.h

@@ -0,0 +1,32 @@
+#pragma once
+
+#include "BsScriptEditorPrerequisites.h"
+#include "BsGUIElementContainer.h"
+#include "BsScriptGUIPanel.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BED_EXPORT GUIPanelContainer : public GUIElementContainer
+	{
+		struct PrivatelyConstruct {};
+
+	public:
+		static const String& getGUITypeName();
+
+		static GUIPanelContainer* create(const ScriptGUIPanel& guiPanel, const GUIOptions& layoutOptions);
+		static GUIPanelContainer* create(const ScriptGUIPanel& guiPanel);
+
+		GUIPanelContainer(const PrivatelyConstruct& dummy, const ScriptGUIPanel& guiPanel, const GUILayoutOptions& layoutOptions);
+
+		void setPanel(const ScriptGUIPanel& guiPanel) { mGUIPanel = &guiPanel; }
+
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
+			RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+
+		Vector2I _getOptimalSize() const;
+	protected:
+		virtual ~GUIPanelContainer();
+
+		const ScriptGUIPanel* mGUIPanel;
+	};
+}

+ 2 - 0
SBansheeEditor/SBansheeEditor.vcxproj

@@ -226,12 +226,14 @@
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClInclude Include="Include\BsGUIPanelContainer.h" />
     <ClInclude Include="Include\BsScriptEditorPrerequisites.h" />
     <ClInclude Include="Include\BsScriptEditorPrerequisites.h" />
     <ClInclude Include="Include\BsScriptEditorWindow.h" />
     <ClInclude Include="Include\BsScriptEditorWindow.h" />
     <ClInclude Include="Include\BsScriptGUIFoldout.h" />
     <ClInclude Include="Include\BsScriptGUIFoldout.h" />
     <ClInclude Include="Include\BsScriptGUIIntField.h" />
     <ClInclude Include="Include\BsScriptGUIIntField.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClCompile Include="Source\BsGUIPanelContainer.cpp" />
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp" />
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp" />
     <ClCompile Include="Source\BsScriptEditorWindow.cpp" />
     <ClCompile Include="Source\BsScriptEditorWindow.cpp" />
     <ClCompile Include="Source\BsScriptGUIFoldout.cpp" />
     <ClCompile Include="Source\BsScriptGUIFoldout.cpp" />

+ 6 - 0
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -27,6 +27,9 @@
     <ClInclude Include="Include\BsScriptGUIIntField.h">
     <ClInclude Include="Include\BsScriptGUIIntField.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIPanelContainer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
@@ -41,5 +44,8 @@
     <ClCompile Include="Source\BsScriptGUIIntField.cpp">
     <ClCompile Include="Source\BsScriptGUIIntField.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIPanelContainer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 61 - 0
SBansheeEditor/Source/BsGUIPanelContainer.cpp

@@ -0,0 +1,61 @@
+#include "BsGUIPanelContainer.h"
+#include "BsGUIArea.h"
+#include "BsGUILayout.h"
+#include "BsGUIWidget.h"
+#include "BsScriptGUIArea.h"
+
+namespace BansheeEngine
+{
+	GUIPanelContainer::GUIPanelContainer(const PrivatelyConstruct& dummy, const ScriptGUIPanel& guiPanel, const GUILayoutOptions& layoutOptions)
+		:GUIElementContainer(layoutOptions), mGUIPanel(&guiPanel)
+	{
+
+	}
+
+	GUIPanelContainer::~GUIPanelContainer()
+	{
+
+	}
+
+	GUIPanelContainer* GUIPanelContainer::create(const ScriptGUIPanel& guiPanel, const GUIOptions& layoutOptions)
+	{
+		return bs_new<GUIPanelContainer>(PrivatelyConstruct(), guiPanel, GUILayoutOptions::create(layoutOptions));
+	}
+
+	GUIPanelContainer* GUIPanelContainer::create(const ScriptGUIPanel& guiPanel)
+	{
+		return bs_new<GUIPanelContainer>(PrivatelyConstruct(), guiPanel, GUILayoutOptions::create());
+	}
+
+	void GUIPanelContainer::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
+		RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	{
+		const Vector<ScriptGUIArea*> areas = mGUIPanel->getAreas();
+
+		for (auto& scriptArea : areas)
+		{
+			GUIArea* area = scriptArea->getInternalValue();
+
+			if (area->x() != x || area->y() != y)
+				area->setPosition(x, y);
+
+			if (area->width() != width || area->height() != height)
+				area->setSize(width, height);
+
+			// We want to force the layout update right away otherwise it might get delayed until next frame.
+			// (Since we are currently in a middle of a layout update its possible this area was already processed)
+			area->_update();
+		}
+	}
+
+	Vector2I GUIPanelContainer::_getOptimalSize() const
+	{
+		return Vector2I(0, 0);
+	}
+
+	const String& GUIPanelContainer::getGUITypeName()
+	{
+		static String typeName = "GUIAreaContainer";
+		return typeName;
+	}
+}

+ 2 - 0
SBansheeEngine/Include/BsScriptGUIPanel.h

@@ -20,6 +20,8 @@ namespace BansheeEngine
 		void registerArea(ScriptGUIArea* area);
 		void registerArea(ScriptGUIArea* area);
 		void unregisterArea(ScriptGUIArea* area);
 		void unregisterArea(ScriptGUIArea* area);
 
 
+		const Vector<ScriptGUIArea*>& getAreas() const { return mAreas; }
+
 	protected:
 	protected:
 		ScriptGUIPanel(MonoObject* instance);
 		ScriptGUIPanel(MonoObject* instance);