FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
hybridguimanager.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 // Standard C++ library includes
23 
24 // 3rd party library includes
25 
26 // FIFE includes
27 // These includes are split up in two parts, separated by one empty line
28 // First block: files included from the FIFE root src directory
29 // Second block: files included from the same folder
30 #include "util/log/logger.h"
31 
32 #include "hybridguimanager.h"
33 
34 namespace FIFE {
35 
36  static Logger _log(LM_GUI);
37 
39  }
40 
42  std::vector<IGUIManager*>::iterator currManager(m_guiManagers.begin());
43  std::vector<IGUIManager*>::iterator endManager(m_guiManagers.end());
44 
45  for(; currManager != endManager; ++currManager) {
46  delete (*currManager);
47  }
48 
49  m_guiManagers.clear();
50  }
51 
53  m_guiManagers.push_back(guiManager);
54  }
55 
57  std::vector<IGUIManager*>::iterator currManager(m_guiManagers.begin());
58  std::vector<IGUIManager*>::iterator endManager(m_guiManagers.end());
59 
60  for(; currManager != endManager;) {
61  if((*currManager) == guiManager) {
62  m_guiManagers.erase(currManager);
63  return;
64  }
65 
66  ++currManager;
67  }
68 
69  FL_WARN(_log, LMsg() << "Tyring to remove a non-existing gui manager from a hybrid gui manager.");
70  }
71 
73  //call turn in reverse order because we want prior gui managers to draw on top
74  //of latter ones.
75  std::vector<IGUIManager*>::reverse_iterator currManager(m_guiManagers.rbegin());
76  std::vector<IGUIManager*>::reverse_iterator endManager(m_guiManagers.rend());
77 
78  for(; currManager != endManager; ++currManager) {
79  (*currManager)->turn();
80  }
81  }
82 
83  bool HybridGuiManager::onSdlEvent(SDL_Event& event) {
84 
85  bool consumed = false;
86 
87  std::vector<IGUIManager*>::iterator currManager(m_guiManagers.begin());
88  std::vector<IGUIManager*>::iterator endManager(m_guiManagers.end());
89 
90  for(; currManager != endManager; ++currManager) {
91  consumed = (*currManager)->onSdlEvent(event);
92 
93  if (consumed) {
94  return true;
95  }
96  }
97 
98  return false;
99  }
100 
102  std::vector<IGUIManager*>::iterator currManager(m_guiManagers.begin());
103  std::vector<IGUIManager*>::iterator endManager(m_guiManagers.end());
104 
105  for(; currManager != endManager; ++currManager) {
106  (*currManager)->resizeTopContainer(x, y, width, height);
107  }
108  }
109 }
Definition: modules.h:41
#define FL_WARN(logger, msg)
Definition: logger.h:72
HybridGuiManager()
Constructor.
virtual void resizeTopContainer(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Calls resize top container for each of the gui managers in the queue.
Helper class to create log strings out from separate parts Usage: LMsg("some text") << variable << "...
Definition: logger.h:82
virtual bool onSdlEvent(SDL_Event &event)
Calls onSdlEvent for each gui manager in the hybrid manager&#39;s queue.
static Logger _log(LM_AUDIO)
void addGuiManager(IGUIManager *guiManager)
Adds a gui manager to this hybrid manager.
virtual void turn()
Calls turn for each gui manager in the hybrid manager&#39;s queue.
std::vector< IGUIManager * > m_guiManagers
All gui managers composing this hybrid gui manager.
~HybridGuiManager()
Destructor.
unsigned int uint32_t
Definition: core.h:40
void removeGuiManager(IGUIManager *guiManager)
Removes a gui manager from this hybrid manager.