43 #include "UI/uimanager.h"
44 #include "UI/screen.h"
45 #include "UI/textureatlas.h"
46 #include "UI/mousehoverstrategy.h"
47 #include "UI/brutestrategy.h"
48 #include "UI/layoutstrategy.h"
50 #include "UI/button.h"
51 #include "UI/checkbox.h"
52 #include "UI/dropdownlist.h"
53 #include "UI/editbox.h"
54 #include "UI/gridcontainer.h"
55 #include "UI/horizontalcontainer.h"
56 #include "UI/horizontalscrollbar.h"
57 #include "UI/linelist.h"
58 #include "UI/listbox.h"
59 #include "UI/menubutton.h"
60 #include "UI/menuentry.h"
61 #include "UI/radiobutton.h"
62 #include "UI/scrollbar.h"
63 #include "UI/spinner.h"
64 #include "UI/tabset.h"
65 #include "UI/verticalcontainer.h"
66 #include "UI/verticalscrollbar.h"
67 #include "UI/widget.h"
68 #include "UI/window.h"
70 #include "Graphics/gamewindow.h"
71 #include "Graphics/viewport.h"
72 #include "Graphics/cameramanager.h"
74 #include "Graphics/graphicsmanager.h"
75 #include "Graphics/scenemanager.h"
78 #include "exception.h"
81 #include <OgreMatrix4.h>
82 #include <OgreRenderSystem.h>
83 #include <OgreRenderOperation.h>
84 #include <OgreHardwareBufferManager.h>
85 #include <OgreHardwareVertexBuffer.h>
86 #include <OgreRenderQueueListener.h>
125 Ogre::Vector3 Position;
126 Ogre::ColourValue Colour;
136 MediumVertices.clear();
137 HighVertices.clear();
142 return LowVertices.size() + MediumVertices.size() + HighVertices.size();
147 this->LowVertices.insert(this->LowVertices.end(),OtherData.LowVertices.begin(),OtherData.LowVertices.end());
148 this->MediumVertices.insert(this->MediumVertices.end(),OtherData.MediumVertices.begin(),OtherData.MediumVertices.end());
149 this->HighVertices.insert(this->HighVertices.end(),OtherData.HighVertices.begin(),OtherData.HighVertices.end());
154 if( Index < LowVertices.size() )
155 return LowVertices[Index];
156 else if( Index < LowVertices.size() + MediumVertices.size() )
157 return MediumVertices[Index - LowVertices.size()];
158 else if( Index < LowVertices.size() + MediumVertices.size() + HighVertices.size() )
159 return HighVertices[Index - (LowVertices.size() + MediumVertices.size())];
175 Ogre::RenderOperation RenderOp;
176 Ogre::RenderSystem* RenderSys;
177 Ogre::HardwareVertexBufferSharedPtr VertexBuffer;
179 void renderQueueStarted(Ogre::uint8,
const Ogre::String&,
bool&) { }
180 void renderQueueEnded(Ogre::uint8 queueGroupId,
const Ogre::String& invocation,
bool& repeatThisInvocation)
182 if( this->RenderSys->_getViewport() != this->ParentScreen->
GetViewport()->
GetOgreViewport() || queueGroupId != Ogre::RENDER_QUEUE_OVERLAY )
197 MouseHitPosition(-1,-1),
200 GameViewport(WindowViewport),
203 Orientation(Mezzanine::OM_Degree_0)
212 this->
SID->RenderSys = Ogre::Root::getSingletonPtr()->getRenderSystem();
213 this->
SID->ParentScreen =
this;
231 MouseHitPosition(-1,-1),
235 Orientation(Mezzanine::OM_Degree_0)
240 this->
SID->RenderSys = Ogre::Root::getSingletonPtr()->getRenderSystem();
241 this->
SID->ParentScreen =
this;
270 if( SceneMan )
return SceneMan;
280 return (*WidFactIt).second;
289 std::pair<WidgetIterator,Boolean> InsertReturn = this->
Widgets.insert( std::pair<String,Widget*>(WidgetName,ToInsert) );
290 if( !InsertReturn.second )
297 this->
SID->RenderSys->_setWorldMatrix( Ogre::Matrix4::IDENTITY );
298 this->
SID->RenderSys->_setProjectionMatrix( Ogre::Matrix4::IDENTITY );
299 this->
SID->RenderSys->_setViewMatrix( Ogre::Matrix4::IDENTITY );
307 this->
SID->RenderOp.vertexData = OGRE_NEW Ogre::VertexData;
308 this->
SID->RenderOp.vertexData->vertexStart = 0;
310 Ogre::VertexDeclaration* VertexDecl = this->
SID->RenderOp.vertexData->vertexDeclaration;
314 VertexDecl->addElement(0,0,Ogre::VET_FLOAT3,Ogre::VES_POSITION);
315 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3);
318 VertexDecl->addElement(0,Offset,Ogre::VET_FLOAT4,Ogre::VES_DIFFUSE);
319 Offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT4);
322 VertexDecl->addElement(0,Offset,Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES);
324 this->
SID->VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
325 VertexDecl->getVertexSize(0),
327 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
330 this->
SID->RenderOp.vertexData->vertexBufferBinding->setBinding(0,this->
SID->VertexBuffer);
331 this->
SID->RenderOp.operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
332 this->
SID->RenderOp.useIndexes =
false;
337 OGRE_DELETE this->
SID->RenderOp.vertexData;
338 this->
SID->RenderOp.vertexData = 0;
339 this->
SID->VertexBuffer.setNull();
344 if( this->
SID->VertexBuffer.isNull() )
347 if(RequestedSize > this->
SID->VertexBuffer->getNumVertices() )
350 Whole NewVertexBufferSize = 1;
351 while(NewVertexBufferSize < RequestedSize)
352 NewVertexBufferSize <<= 1;
354 this->
SID->VertexBuffer = Ogre::HardwareBufferManager::getSingletonPtr()->createVertexBuffer(
355 this->
SID->RenderOp.vertexData->vertexDeclaration->getVertexSize(0),
357 Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE,
359 this->
SID->RenderOp.vertexData->vertexStart = 0;
360 this->
SID->RenderOp.vertexData->vertexBufferBinding->setBinding(0,this->
SID->VertexBuffer);
383 {
return Renderable::RT_Screen; }
391 if( this->
ActDims.
Size != CurrentSize || ( this->InverseSize.X == 0.0 || this->InverseSize.Y == 0.0 ) ) {
405 {
return this->
UIMan; }
469 delete (*FactIt).second;
478 delete (*FactIt).second;
537 if( WidIt != this->
Widgets.end() )
return (*WidIt).second;
550 if( WidIt != this->
Widgets.end() )
556 (*FactIt).second->DestroyWidget( ToBeDestroyed );
566 (*FactIt).second->DestroyWidget( (*ChildIt) );
777 {
return this->
SID->RenderSys->getHorizontalTexelOffset(); }
780 {
return this->
SID->RenderSys->getVerticalTexelOffset(); }
822 if( !PropertiesNode.
Empty() ) {
825 Whole ViewZOrder = 0;
829 if( !CurrAttrib.
Empty() )
832 CurrAttrib = PropertiesNode.
GetAttribute(
"WindowTitle");
833 if( !CurrAttrib.
Empty() )
834 WindowTitle = CurrAttrib.
AsString();
836 CurrAttrib = PropertiesNode.
GetAttribute(
"ViewportZOrder");
837 if( !CurrAttrib.
Empty() )
838 ViewZOrder = CurrAttrib.
AsWhole();
842 if( !VertexTransformNode.
Empty() )
846 if( !ScaleNode.
Empty() )
849 if( !WindowTitle.empty() ) {
852 if( NamedWindow != NULL ) {
902 Boolean Force =
false;
907 else if(this->
Orientation == Mezzanine::OM_Degree_180)
909 else if(this->
Orientation == Mezzanine::OM_Degree_270)
917 size_t KnownVertexCount = this->
SID->RenderOp.vertexData->vertexCount;
918 if(this->
SID->RenderOp.vertexData->vertexCount) {
921 MyObject.RenderStart = 0;
922 MyObject.RenderEnd = KnownVertexCount;
931 if(CurrVertAtlas.empty()) {
934 if(CurrVertAtlas != CurrAtlas) {
935 CurrAtlas = CurrVertAtlas;
937 this->
SID->RenderSys->_setTexture(0,
true,TextureUse);
941 this->
SID->RenderSys->_render(this->
SID->RenderOp);
960 for( X = Begin ; X < End ; X++ )
962 RenderData[X].Vert.Position.X = ( ( RenderData[X].Vert.Position.X * this->
InverseSize.
X ) * 2 ) - 1;
963 RenderData[X].Vert.Position.Y = ( ( RenderData[X].Vert.Position.Y * this->
InverseSize.
Y ) * -2 ) + 1;
967 for( X = Begin ; X < End ; X++ )
968 RenderData[X].Vert.Position = this->VertexTransform * RenderData[X].Vert.Position;
977 Whole KnownVertexCount = 0;
985 KnownVertexCount = TempVertexCache.
Size();
986 this->
_Transform(TempVertexCache,0,KnownVertexCount);
990 Vertex* WriteIterator = (
Vertex*) this->
SID->VertexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
991 for(
Whole Index = 0 ; Index < TempVertexCache.
Size() ; ++Index )
993 if( TempVertexCache[Index].Atlas.empty() ) {
996 if( TempVertexCache[Index].Atlas != CurrentName ) {
998 MyObject.RenderEnd = Index;
1001 MyObject.Atlas = TempVertexCache[Index].Atlas;
1002 MyObject.RenderStart = Index;
1003 CurrentName = TempVertexCache[Index].Atlas;
1011 const Vertex& NewVertex = TempVertexCache[Index].Vert;
1012 *WriteIterator++ = NewVertex;
1014 MyObject.RenderEnd = KnownVertexCount;
1015 MyObject.Atlas = CurrentName;
1018 this->
SID->VertexBuffer->unlock();
1019 this->
SID->RenderOp.vertexData->vertexCount = KnownVertexCount;
1021 this->
Dirty =
false;