Project

General

Profile

SO3Engine
SO3WebNavigatorWidgetFactory.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
33#include "SO3Renderer/SO3Root.h"
34#if SO3_WEB_NAVIGATOR_BUILD == 1
35
36namespace SO3
37{
38
39SWebNavigatorWidgetFactory::SWebNavigatorWidgetFactory(const ScolWindowHandle& scolWindowHandle, const std::string& firstPartition) : SWidgetFactory(SO3_WEB_NAVIGATOR_WIDGET_TYPE)
40{
41 // Register as Ogre frame listener
42 Ogre::Root::getSingleton().addFrameListener(this);
43}
44
46{
47 // Unregister.
48 Ogre::Root::getSingleton().removeFrameListener(this);
49}
50
51SWidget* SWebNavigatorWidgetFactory::CreateWidgetImpl(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& width, const unsigned short& height, SViewPort* targetViewport, const unsigned int& widgetZOrder)
52{
53 SWebNavigatorWidget* newWebNavigator = new SWebNavigatorWidget(targetScene, widgetName, xPos, yPos, width, height, targetViewport, widgetZOrder);
54 webNavigatorList.insert(newWebNavigator);
55 return newWebNavigator;
56}
57
58SWidget* SWebNavigatorWidgetFactory::CreateWidgetImpl(SScene* targetScene, const std::string& widgetName, const int& xPos, const int& yPos, const unsigned short& width, const unsigned short& height, SViewPort* targetViewport)
59{
60 SWebNavigatorWidget* newWebNavigator = new SWebNavigatorWidget(targetScene, widgetName, xPos, yPos, width, height, targetViewport);
61 webNavigatorList.insert(newWebNavigator);
62 return newWebNavigator;
63}
64
65SWidget* SWebNavigatorWidgetFactory::CreateWidgetImpl(SScene* targetScene, const std::string& widgetName, const unsigned short& width, const unsigned short& height, SMaterial* targetMaterial, const unsigned short& targetTechnique, const unsigned short& targetPass, const unsigned short& targetTextureUnit)
66{
67 SWebNavigatorWidget* newWebNavigator = new SWebNavigatorWidget(targetScene, widgetName, width, height, targetMaterial, targetTechnique, targetPass, targetTextureUnit);
68 webNavigatorList.insert(newWebNavigator);
69 return newWebNavigator;
70}
71
73{
74 if(existingWidget)
75 {
76 SWebNavigatorWidget* existingWebNavigatorWidget = static_cast<SWebNavigatorWidget*> (existingWidget);
77 webNavigatorList.erase(existingWebNavigatorWidget);
78 delete(existingWidget);
79 existingWidget = 0;
80 }
81}
82
83bool SWebNavigatorWidgetFactory::frameStarted(const Ogre::FrameEvent& evt)
84{
85 // Update all managed widgets
86 WebNavigatorList::iterator iWebNavigatorList = webNavigatorList.begin();
87 while(iWebNavigatorList != webNavigatorList.end())
88 {
89 (*iWebNavigatorList)->Update(false);
90 iWebNavigatorList++;
91 }
92 return true;
93}
94
95
96}
97
98#endif
std::string firstPartition(((packdir) SCgetExtra("FirstPack")) ->path)
virtual SWidget * CreateWidgetImpl(SScene *targetScene, const std::string &widgetName, const int &xPos, const int &yPos, const unsigned short &width, const unsigned short &height, SViewPort *targetViewport, const unsigned int &widgetZOrder)
SWebNavigatorWidgetFactory(const ScolWindowHandle &scolWindowHandle, const std::string &firstPartition)
virtual bool frameStarted(const Ogre::FrameEvent &evt)
virtual void DeleteWidgetImpl(SWidget *existingWidget)