Spinning Topp Logo BlackTopp Studios
inc
uimanager.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _uiuimanager_cpp
41 #define _uiuimanager_cpp
42 
43 #include "UI/uimanager.h"
44 #include "UI/textureatlashandler.h"
45 #include "UI/textureatlas.h"
46 #include "UI/hotkeyhandler.h"
47 #include "UI/actionhandler.h"
48 #include "UI/screen.h"
49 #include "UI/button.h"
50 #include "UI/widget.h"
51 #include "UI/glyph.h"
52 
53 // includes for the creation and destruction of the global parser
54 #include "UI/defaultmarkupparser.h"
55 
56 #include "Graphics/graphicsmanager.h"
57 #include "Graphics/viewport.h"
58 #include "Input/inputmanager.h"
59 #include "Input/mouse.h"
61 #include "eventmanager.h"
62 
63 #include "MathTools/mathtools.h"
64 #include "timer.h"
65 #include "entresol.h"
66 
67 #include <Ogre.h>
68 
69 namespace Mezzanine
70 {
71  template<> UI::UIManager* Singleton<UI::UIManager>::SingletonPtr = NULL;
72 
73  namespace UI
74  {
75  ///////////////////////////////////////////////////////////////////////////////
76  // WidgetUpdateWorkUnit Methods
77 
79  { }
80 
82  { return *this; }
83 
85  TargetManager(Target) { }
86 
88  { }
89 
90  ///////////////////////////////////////////////////////////////////////////////
91  // Utility
92 
94  { this->TargetManager->UpdateScreens(); }
95 
96  ///////////////////////////////////////////////////////////////////////////////
97  // UIManager Methods
98 
99  const String UIManager::ImplementationName = "DefaultUIManager";
100  const ManagerBase::ManagerType UIManager::InterfaceType = ManagerBase::MT_UIManager;
101 
103  HoveredWidget(NULL),
104  WidgetFocus(NULL),
105 
106  WidgetUpdateWork(NULL),
107  ThreadResources(NULL),
108 
109  ButtonAutoRegister(false),
110  MouseMoved(false)
111  {
112  Resource::ResourceManager::GetSingletonPtr()->CreateAssetGroup("UI");
113  this->AtlasHandler = new TextureAtlasHandler();
114  this->HKHandler = new HotKeyHandler();
115  //this->ActHandler = new ActionHandler();
116 
117  // Parser Work
118  MarkupParser* DefaultParser = new DefaultMarkupParser();
119  this->RegisterMarkupParser(DefaultParser->GetName(),DefaultParser);
120  this->RegisterMarkupParser("",DefaultParser);
121 
122  this->WidgetUpdateWork = new WidgetUpdateWorkUnit(this);
123  }
124 
125  UIManager::UIManager(const XML::Node& XMLNode) :
126  HoveredWidget(NULL),
127  WidgetFocus(NULL),
128 
129  WidgetUpdateWork(NULL),
130  ThreadResources(NULL),
131 
132  ButtonAutoRegister(false),
133  MouseMoved(false)
134  {
135  /// @todo This class currently doesn't initialize anything from XML, if that changes this constructor needs to be expanded.
136  Resource::ResourceManager::GetSingletonPtr()->CreateAssetGroup("UI");
137  this->AtlasHandler = new TextureAtlasHandler();
138  this->HKHandler = new HotKeyHandler();
139  //this->ActHandler = new ActionHandler();
140 
141  // Parser Work
142  MarkupParser* DefaultParser = new DefaultMarkupParser();
143  this->RegisterMarkupParser(DefaultParser->GetName(),DefaultParser);
144  this->RegisterMarkupParser("",DefaultParser);
145 
146  this->WidgetUpdateWork = new WidgetUpdateWorkUnit(this);
147  }
148 
150  {
151  this->Deinitialize();
152  this->DestroyAllScreens();
153  this->DestroyAllMarkupParsers();
154 
155  delete this->AtlasHandler;
156  this->AtlasHandler = NULL;
157 
158  delete this->HKHandler;
159  this->HKHandler = NULL;
160 
161  delete this->WidgetUpdateWork;
162  this->WidgetUpdateWork = NULL;
163  }
164 
166  {
167  if( Code.IsKeyboardEvent() )
168  this->HandlePreFocusKeyboardInput( Code );
169  else if( Code.IsMouseEvent() )
170  this->HandlePreFocusMouseInput( Code );
171  else if( Code.IsControllerEvent() )
172  this->HandlePreFocusControllerInput( Code );
173  /// @todo If other devices are added, appropriate functions should be added to this class, and called here.
174  }
175 
177  {
178  if( Code.IsKeyboardEvent() )
179  this->HandlePostFocusKeyboardInput( Code );
180  else if( Code.IsMouseEvent() )
181  this->HandlePostFocusMouseInput( Code );
182  else if( Code.IsControllerEvent() )
183  this->HandlePostFocusControllerInput( Code );
184  /// @todo If other devices are added, appropriate functions should be added to this class, and called here.
185  }
186 
188  {
189 
190  }
191 
193  {
194  // Perform our simple checks for the focus switching/locking
195  if( Code.IsMouseButton() ) {
196  if( Input::BUTTON_PRESSING == Code.GetMetaValue() ) {
197  this->SwitchFocus(HoveredWidget);
198 
199  // If we got a valid focus, there is more work to be done.
200  if( this->WidgetFocus ) {
201  // Regardless of it has changed, lock the focus.
202  if( !this->FocusIsLocked() ) {
203  this->WidgetFocus->_OnFocusLocked();
204  this->FocusLockCode = Code;
205  }
206  }
207  }else if( Input::BUTTON_LIFTING == Code.GetMetaValue() ) {
208  if( this->WidgetFocus ) {
209  // Check the code to see if we're releasing the focus lock.
210  if( this->FocusLockCode.GetCode() == Code.GetCode() && this->FocusLockCode.GetDeviceIndex() == Code.GetDeviceIndex() ) {
211  this->WidgetFocus->_OnFocusUnlocked();
212  this->WidgetFocus->_OnMouseDragEnd();
214  }
215  }
216  }
217  }
218 
219  // Perform the check for dragging
220  if( this->FocusIsLocked() && this->MouseMoved ) {
221  if( !this->WidgetFocus->IsDragged() ) {
223  }
224  }
225  }
226 
228  {
229  /// @todo There is currently nothing that the UI system as a whole needs controller inputs.
230  /// Perhaps when we implement consoles this should be expanded, maybe even sooner then that.
231  }
232 
234  {
235 
236  }
237 
239  {
240  if( Code.IsMouseMotionEvent() )
241  {
242 
243  }
244  }
245 
247  {
248  /// @todo There is currently nothing that the UI system as a whole needs controller inputs.
249  /// Perhaps when we implement consoles this should be expanded, maybe even sooner then that.
250  }
251 
253  {
254  // Check if the focus is changing at all
255  if( this->WidgetFocus != NewFocus && !this->FocusIsLocked() )
256  {
257  // If we already have a focus, drop it
258  if( this->WidgetFocus )
259  this->WidgetFocus->_OnFocusLost();
260 
261  // Assign the new focus
262  this->WidgetFocus = NewFocus;
263 
264  // If the new focus is valid, notify it of it's new status
265  if( this->WidgetFocus )
266  this->WidgetFocus->_OnFocusGained();
267 
268  // Acknowledge the focus was changed
269  return true;
270  }
271  // Nothing changed
272  return false;
273  }
274 
276  {
277  return ( Input::KEY_UNKNOWN != FocusLockCode.GetCode() );
278  }
279 
280  ///////////////////////////////////////////////////////////////////////////////
281  // Texture Atlas Management
282 
283  void UIManager::LoadMTA(const String& Name, const String& Group)
284  { this->AtlasHandler->LoadAtlasFromFile(Name,Group); }
285 
287  { return this->AtlasHandler->GetAtlas(AtlasName); }
288 
290  { return this->AtlasHandler->GetAtlasExcept(AtlasName); }
291 
293  { this->AtlasHandler->DestroyAtlas(ToBeDestroyed); }
294 
296  { this->AtlasHandler->DestroyAllAtlases(); }
297 
298  ///////////////////////////////////////////////////////////////////////////////
299  // Screen Management
300 
301  Screen* UIManager::CreateScreen(const String& ScreenName, const String& Atlas, Graphics::Viewport* WindowViewport, const UInt16 ZOrder)
302  {
303  Screen* MezzScreen = new Screen(ScreenName,Atlas,WindowViewport,this);
304  MezzScreen->_SetZOrder(ZOrder);
305 
306  for( ScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
307  {
308  if( (*ScreenIt)->GetZOrder() > ZOrder ) {
309  this->Screens.insert(ScreenIt,MezzScreen);
310  return MezzScreen;
311  }
312  }
313  this->Screens.push_back(MezzScreen);
314  return MezzScreen;
315  }
316 
317  Screen* UIManager::GetScreen(const String& Name) const
318  {
319  for( ConstScreenIterator it = this->Screens.begin() ; it != this->Screens.end() ; it++ )
320  {
321  if ( Name == (*it)->GetName() ) {
322  Screen* MezzScreen = (*it);
323  return MezzScreen;
324  }
325  }
326  return 0;
327  }
328 
329  Screen* UIManager::GetScreen(const Whole& Index) const
330  {
331  return this->Screens[Index];
332  }
333 
335  {
336  return this->Screens.size();
337  }
338 
340  {
341  for( ScreenIterator it = this->Screens.begin() ; it != this->Screens.end() ; it++ )
342  {
343  if( Screen == (*it) ) {
344  delete (*it);
345  this->Screens.erase(it);
346  return;
347  }
348  }
349  }
350 
352  {
353  for( ScreenIterator it = this->Screens.begin() ; it != this->Screens.end() ; it++ )
354  {
355  delete (*it);
356  }
357  this->Screens.clear();
358  }
359 
361  {
362  for( ScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
363  {
364  if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt) != Exclude ) {
365  (*ScreenIt)->Show();
366  }
367  }
368  }
369 
371  {
372  for( ScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
373  {
374  if( (*ScreenIt) != Exclude ) {
375  (*ScreenIt)->Show();
376  }
377  }
378  }
379 
381  {
382  for( ScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
383  {
384  if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt) != Exclude ) {
385  (*ScreenIt)->Hide();
386  }
387  }
388  }
389 
391  {
392  for( ScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
393  {
394  if( (*ScreenIt) != Exclude ) {
395  (*ScreenIt)->Hide();
396  }
397  }
398  }
399 
401  {
402  for( ConstScreenIterator ScreenIt = this->Screens.begin() ; ScreenIt != this->Screens.end() ; ++ScreenIt )
403  {
404  if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt)->IsVisible() ) {
405  return (*ScreenIt);
406  }
407  }
408  return NULL;
409  }
410 
412  {
413  for( ConstReverseScreenIterator ScreenIt = this->Screens.rbegin() ; ScreenIt != this->Screens.rend() ; ++ScreenIt )
414  {
415  if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt)->IsVisible() ) {
416  return (*ScreenIt);
417  }
418  }
419  return NULL;
420  }
421 
422  ///////////////////////////////////////////////////////////////////////////////
423  // HotKey and Activation Management
424 
425  void UIManager::BindHotKey(const Input::MetaCode& HotKey, Button* BoundButton)
426  {
427  this->HKHandler->BindHotKey(HotKey,BoundButton);
428  }
429 
430  void UIManager::UnbindHotKey(const Input::MetaCode& HotKey, Button* BoundButton)
431  {
432  this->HKHandler->UnbindHotKey(HotKey,BoundButton);
433  }
434 
435  ///////////////////////////////////////////////////////////////////////////////
436  // Activation Management
437 
439  { this->ButtonAutoRegister = Enable; }
440 
442  { return this->ButtonAutoRegister; }
443 
445  {
446  for( InputIterator It = this->AutoRegisterCodes.begin() ; It != this->AutoRegisterCodes.end() ; It++ )
447  {
448  if( (*It) == Code )
449  return;
450  }
451  this->AutoRegisterCodes.push_back(Code);
452  }
453 
455  {
456  for( InputIterator It = this->AutoRegisterCodes.begin() ; It != this->AutoRegisterCodes.end() ; It++ )
457  {
458  if( (*It) == Code ) {
459  this->AutoRegisterCodes.erase(It);
460  return;
461  }
462  }
463  }
464 
466  { this->AutoRegisterCodes.clear(); }
467 
469  { return this->AutoRegisterCodes; }
470 
471  ///////////////////////////////////////////////////////////////////////////////
472  // MarkupParser Management
473 
474  void UIManager::RegisterMarkupParser(const String& ParserName, MarkupParser* ToAdd)
475  {
476  MarkupParserIterator MarkupIt = this->MarkupParsers.find(ParserName);
477  if( MarkupIt != this->MarkupParsers.end() ) {
478  MEZZ_EXCEPTION(ExceptionBase::II_DUPLICATE_IDENTITY_EXCEPTION,"A MarkupParser with the name \"" + ParserName + "\" is already registered.");
479  }else{
480  this->MarkupParsers.insert( std::pair<String,UI::MarkupParser*>(ParserName,ToAdd) );
481  }
482  }
483 
485  {
486  ConstMarkupParserIterator MarkupIt = this->MarkupParsers.find(ParserName);
487  return ( MarkupIt != this->MarkupParsers.end() );
488  }
489 
491  {
492  ConstMarkupParserIterator MarkupIt = this->MarkupParsers.find(ParserName);
493  if( MarkupIt != this->MarkupParsers.end() ) return (*MarkupIt).second;
494  else return NULL;
495  }
496 
498  {
499  MarkupParserIterator MarkupIt = this->MarkupParsers.find(ParserName);
500  if( MarkupIt != this->MarkupParsers.end() )
501  this->MarkupParsers.erase(MarkupIt);
502  }
503 
505  {
506  this->MarkupParsers.clear();
507  }
508 
509  void UIManager::DestroyMarkupParser(const String& ParserName)
510  {
511  MarkupParserIterator MarkupIt = this->MarkupParsers.find(ParserName);
512  if( MarkupIt != this->MarkupParsers.end() ) {
513  delete (*MarkupIt).second;
514  this->MarkupParsers.erase(MarkupIt);
515  }
516  }
517 
519  {
520  // Since we inserted the default parser into this container under two names, we need to remove one to prevent a double delete.
521  this->UnregisterMarkupParser("");
522  for( MarkupParserIterator MarkupIt = this->MarkupParsers.begin() ; MarkupIt != this->MarkupParsers.end() ; ++MarkupIt )
523  { delete (*MarkupIt).second; }
524  this->MarkupParsers.clear();
525  }
526 
527  ///////////////////////////////////////////////////////////////////////////////
528  // Fetch Methods
529 
531  { return this->HoveredWidget; }
532 
534  { return this->WidgetFocus; }
535 
537  { return this->AtlasHandler; }
538 
539  ///////////////////////////////////////////////////////////////////////////////
540  // Utility
541 
543  {
544  switch( Code.GetCode() )
545  {
546  case Input::MOUSEHORIZONTAL:
547  case Input::MOUSEVERTICAL:
548  {
549  this->MouseMoved = true;
550  break;
551  }
552  default: /* Do Nothing */ break;
553  }
554 
555  this->InjectedInputs.push_back(Code);
556  }
557 
559  {
560  for( ReverseScreenIterator ScreenIt = this->Screens.rbegin() ; ScreenIt != this->Screens.rend() ; ++ScreenIt )
561  {
562  Widget* Result = (*ScreenIt)->FindHoveredWidget(Point);
563  if( Result != NULL ) {
564  return Result;
565  }
566  }
567  return NULL;
568  }
569 
571  {
572  return (HoveredWidget || WidgetFocus);
573  }
574 
576  {
577  TextureAtlas* TheAtlas = AtlasHandler->GetAtlas(Atlas);
578  if(NULL == TheAtlas)
579  {
580  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Attempting to access TextureAtlas \"" + Atlas + "\", which does not exist or is not loaded.");
581  }
582  TextureAtlas::FontDataContainer& Fonts = TheAtlas->GetFonts();
583  String LargerMatch, SmallerMatch;
584  Real LargerHeight = 0;
585  Real SmallerHeight = 0;
586  Real LargerMatchDiff = 1000000.0;
587  Real SmallerMatchDiff = 1000000.0;
588  Real RequestedHeight = (Real)Height;
589 
590  for( TextureAtlas::FontDataIterator it = Fonts.begin() ; it != Fonts.end() ; it++ )
591  {
592  Real Diff = 0.0;
593  if((*it).second->GetLineHeight() > RequestedHeight)
594  {
595  Diff = (*it).second->GetLineHeight() - RequestedHeight;
596  if(Diff < LargerMatchDiff)
597  {
598  LargerMatch = (*it).first;
599  LargerHeight = (*it).second->GetLineHeight();
600  LargerMatchDiff = Diff;
601  continue;
602  }
603  }else{
604  Diff = RequestedHeight - (*it).second->GetLineHeight();
605  if(Diff < SmallerMatchDiff)
606  {
607  SmallerMatch = (*it).first;
608  SmallerHeight = (*it).second->GetLineHeight();
609  SmallerMatchDiff = Diff;
610  continue;
611  }
612  }
613  }
614 
615  Real Scale = 1;
616  if(!LargerMatch.empty())
617  {
618  Scale = RequestedHeight / LargerHeight;
619  return FontResult(LargerMatch,Scale);
620  }else{
621  Scale = RequestedHeight / SmallerHeight;
622  return FontResult(SmallerMatch,Scale);
623  }
624  }
625 
627  {
628  Input::Mouse* SysMouse = Input::InputManager::GetSingletonPtr()->GetSystemMouse();
629 
630  // Tell all screens to check if the veiwport dimensions have changed
631  for( ScreenIterator ScIt = this->Screens.begin() ; ScIt != this->Screens.end() ; ++ScIt )
632  (*ScIt)->CheckViewportSize();
633 
634  // Inject input delta's from the input system
635  const MetaCodeContainer& Inputs = Input::InputManager::GetSingletonPtr()->GetInputDeltas();
636  // InjectedInputs.insert(InjectedInputs.end(),Inputs.begin(),Inputs.end()); // Commented because we want to use "InjectInput()" so we can filter the codes.
637  for( ConstMetaCodeIterator MCIt = Inputs.begin() ; MCIt != Inputs.end() ; ++MCIt )
638  this->InjectInput( (*MCIt) );
639 
640  // Get the hovered quad based on mouse position
641  // We don't care what is hovered so much if the mouse hasn't moved, or is hidden due to relative mode.
642  if( this->MouseMoved && !SysMouse->GetRelativeMode() ) {
643  Widget* TempWidget = this->CheckWidgetUnderPoint(SysMouse->GetHoveredViewport(),SysMouse->GetViewportPosition());
644  if( TempWidget != this->HoveredWidget )
645  {
646  if( this->HoveredWidget ) {
647  this->HoveredWidget->_OnMouseExit();
648  }
649 
650  this->HoveredWidget = TempWidget;
651 
652  if( this->HoveredWidget ) {
653  this->HoveredWidget->_OnMouseEnter();
654  }
655  }
656  }
657 
658  // Check the focus to see if it's still visible. If it isn't, attempt to pass focus to the next available parent.
659  if( this->WidgetFocus && !this->WidgetFocus->GetVisible() ) {
660  // Clear the focus lock
661  if( this->FocusIsLocked() ) {
662  this->WidgetFocus->_OnFocusUnlocked();
664  }
665 
666  // Find the next available parent
667  Widget* PassedFocus = this->WidgetFocus;
668  do{
669  PassedFocus = ( PassedFocus->GetParent()->IsWidget() ? static_cast<Widget*>(PassedFocus->GetParent()) : NULL );
670  }while( PassedFocus != NULL && !PassedFocus->GetVisible() );
671 
672  // Switch the focus, even if it is NULL
673  this->SwitchFocus(PassedFocus);
674  }
675 
676  // Look at and process all injected inputs accordingly
677  for( InputIterator InIt = this->InjectedInputs.begin() ; InIt != this->InjectedInputs.end() ; ++InIt )
678  {
679  // Allow our pre processes to get first dibs.
680  this->HandlePreFocusInput( (*InIt) );
681 
682  // Allow the focus to consume the input if it needs/wants to.
683  if( this->WidgetFocus && this->WidgetFocus->_HandleInput( (*InIt) ) )
684  continue;
685 
686  // If the focus doesn't consume the input, we pass it back to the system.
687  this->HandlePostFocusInput( (*InIt) );
688  }
689  this->MouseMoved = false;
690  this->InjectedInputs.clear();
691  }
692 
694  {
695  if( !this->Initialized ) {
696  this->TheEntresol->GetScheduler().AddWorkUnitMain( this->WidgetUpdateWork, "WidgetUpdateWork" );
698  if( InputMan )
699  this->WidgetUpdateWork->AddDependency( InputMan->GetDeviceUpdateWork() );
700 
701  this->Initialized = true;
702  }
703  }
704 
706  {
707  if( this->Initialized ) {
710 
711  this->Initialized = false;
712  }
713  }
714 
716  {
717  return this->WidgetUpdateWork;
718  }
719 
720  ///////////////////////////////////////////////////////////////////////////////
721  // Type Identifier Methods
722 
724  { return UIManager::InterfaceType; }
725 
728 
729  ///////////////////////////////////////////////////////////////////////////////
730  // DefaultUIManagerFactory Methods
731 
733  { }
734 
736  { }
737 
740 
742  { return UIManager::InterfaceType; }
743 
745  {
746  if( UIManager::SingletonValid() ) {
747  /// @todo Add something to log a warning that the manager exists and was requested to be constructed when we have a logging manager set up.
749  }else return new UIManager();
750  }
751 
753  {
754  if( UIManager::SingletonValid() ) {
755  /// @todo Add something to log a warning that the manager exists and was requested to be constructed when we have a logging manager set up.
757  }else return new UIManager(XMLNode);
758  }
759 
761  { delete ToBeDestroyed; }
762  }//UI
763 }//Mezzanine
764 
765 #endif
Widget * WidgetFocus
A pointer to the widget that is currently holding the focus.
Definition: uimanager.h:168
virtual void AddDependency(iWorkUnit *NewDependency)
Force this WorkUnit to Start after another has completed.
Definition: workunit.cpp:99
Screen * GetScreen(const String &Name) const
Gets a screen by name.
Definition: uimanager.cpp:317
Thrown when duplicates of teh same identity string exist.
Definition: exception.h:95
void HandlePreFocusMouseInput(const Input::MetaCode &Code)
Handles mouse processes prior to the update of the main focus.
Definition: uimanager.cpp:192
Screen * GetHighestVisibleScreenOnViewport(Graphics::Viewport *WindowViewport) const
Gets the highest ZOrder screen that is visible on a viewport.
Definition: uimanager.cpp:411
InputContainer::iterator InputIterator
Iterator type for Input::MetaCode instances stored by this class.
Definition: uimanager.h:136
Boole GetRelativeMode()
Gets whether or not relative mode is enabled.
Definition: mouse.cpp:261
Boole IsControllerEvent() const
Does this MetaCode Represent a state of a Controller Event.
Definition: metacode.cpp:349
MarkupParserContainer::iterator MarkupParserIterator
Iterator type for MarkupParser instances stored by this class.
Definition: uimanager.h:120
TextureAtlas * GetAtlas(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Definition: uimanager.cpp:286
WidgetUpdateWorkUnit & operator=(const WidgetUpdateWorkUnit &Other)
Protected assignment operator. THIS IS NOT ALLOWED.
Definition: uimanager.cpp:81
Screen * CreateScreen(const String &ScreenName, const String &Atlas, Graphics::Viewport *WindowViewport, const UInt16 ZOrder)
Creates an internal HUD screen.
Definition: uimanager.cpp:301
virtual void _OnFocusLost()
Self logic to be executed when focus is removed from this widget.
Definition: widget.cpp:496
void DestroyMarkupParser(const String &ParserName)
Removes and destroys a MarkupParser from this manager.
Definition: uimanager.cpp:509
Boole IsMarkupParserRegistered(const String &ParserName) const
Checks to see if a MarkupParser has already been registsered under a specific name.
Definition: uimanager.cpp:484
virtual Boole _HandleInput(const Input::MetaCode &Code)
Handles input passed to this widget.
Definition: widget.cpp:540
This class represents the mouse input device.
Definition: mouse.h:60
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
FontResult SuggestGlyphIndex(const Whole &Height, const String &Atlas)
Suggests a glyph index based on the desired actual height.
Definition: uimanager.cpp:575
virtual void AddWorkUnitMain(iWorkUnit *MoreWork, const String &WorkUnitName)
Add a normal Mezzanine::Threading::iWorkUnit to this For fcheduling.
void HandlePreFocusKeyboardInput(const Input::MetaCode &Code)
Handles keyboard processes prior to the update of the main focus.
Definition: uimanager.cpp:187
const InputContainer & GetAutoRegisteredCodes() const
Gets the list of codes that will be auto-registered with each UI button.
Definition: uimanager.cpp:468
ManagerType
A listing of Manager Types.
Definition: managerbase.h:65
UIManager * TargetManager
A pointer to the manager this work unit is processing.
Definition: uimanager.h:78
Boole ButtonAutoRegisterEnabled() const
Gets whether or not the ButtonAutoRegister feature is enabled.
Definition: uimanager.cpp:441
static const ManagerBase::ManagerType InterfaceType
A ManagerType enum value used to describe the type of interface/functionality this manager provides...
Definition: uimanager.h:145
Widget * GetHoveredWidget() const
Gets the Widget the mouse is hovering over.
Definition: uimanager.cpp:530
TextureAtlas * GetAtlasExcept(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Definition: uimanager.cpp:289
Widget * CheckWidgetUnderPoint(Graphics::Viewport *VP, const Vector2 &Point)
Searches all visable screens and layers to see if a Widget is under the given point.
Definition: uimanager.cpp:558
Int32 GetDeviceIndex() const
Gets the currently set device index.
Definition: metacode.cpp:256
void RemoveAllAutoRegisterCodes()
Removes all auto-registering input codes.
Definition: uimanager.cpp:465
virtual void RemoveWorkUnitMain(iWorkUnit *LessWork)
Remove a WorkUnit from the main pool of WorkUnits (and not from the groups of Affinity or MonpolyWork...
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
WidgetUpdateWorkUnit(const WidgetUpdateWorkUnit &Other)
Protected copy constructor. THIS IS NOT ALLOWED.
Definition: uimanager.cpp:78
void ShowAllScreens(Screen *Exclude=NULL)
Shows all screens owned by this manager.
Definition: uimanager.cpp:370
virtual ManagerType GetInterfaceType() const
This returns the type of this manager.
Definition: uimanager.cpp:723
WidgetUpdateWorkUnit * WidgetUpdateWork
The work unit that updates all of the widgets in the UI system.
Definition: uimanager.h:177
UIManager()
Class Constructor.
Definition: uimanager.cpp:102
virtual String GetImplementationTypeName() const
This Allows any manager name to be sent to a stream. Primarily used for logging.
Definition: uimanager.cpp:726
TextureAtlasHandler * AtlasHandler
A pointer to the class responsible for Atlas tasks in the UI system.
Definition: uimanager.h:171
Threading::FrameScheduler & GetScheduler()
Gets the core structure responsible for scheduling work in the Entresol main loop.
Definition: entresol.cpp:495
This is a collection of smaller textures packed into a larger texture, intended to increase UI perfor...
Definition: textureatlas.h:71
void LoadAtlasFromFile(const String &Name, const String &Group="UI")
Loads a Mezzanine Texture Atlas file for use with UI::Screen's.
void DestroyAllScreens()
Deletes all screens stored in this manager.
Definition: uimanager.cpp:351
static const String ImplementationName
A String containing the name of this manager implementation.
Definition: uimanager.h:143
HotKeyHandler * HKHandler
A pointer to the class responsible for HotKey tasks in the UI system.
Definition: uimanager.h:174
Boole ButtonAutoRegister
Stores whether or not newly created buttons will have activation codes binded to them automatically...
Definition: uimanager.h:183
ManagerBase::ManagerType GetManagerType() const
Gets the type of manager that is created by this factory.
Definition: uimanager.cpp:741
void SetNullValues()
Sets all the values of this MetaCode to Null values.
Definition: metacode.cpp:259
UI::TextureAtlas * GetAtlas(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
void LoadMTA(const String &Name, const String &Group="UI")
Loads a Mezzanine Texture Atlas file for use with Screens.
Definition: uimanager.cpp:283
std::vector< Input::MetaCode > InputContainer
Basic container type for Input::MetaCode storage by this class.
Definition: uimanager.h:134
void InjectInput(const Input::MetaCode &Code)
Injects a metacode into this manager, allowing the UI system to be aware of it.
Definition: uimanager.cpp:542
void UnregisterMarkupParser(const String &ParserName)
Removes a MarkupParser from this manager.
Definition: uimanager.cpp:497
This is the manager responsible for the handling of input devices and events.
Definition: inputmanager.h:128
ScreenContainer Screens
A container storing all the Screens created in the UI system.
Definition: uimanager.h:152
UI::TextureAtlas * GetAtlasExcept(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Int32 GetMetaValue() const
This Returns the MetaValue.
Definition: metacode.cpp:250
void BindHotKey(const Input::MetaCode &HotKey, Button *BoundButton)
Binds a key to a button.
Definition: uimanager.cpp:425
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
Input::MetaCode FocusLockCode
Stores the Input that locked the current focus.
Definition: uimanager.h:162
A thread specific collection of double-buffered and algorithm specific resources. ...
EntresolManager * CreateManager(const NameValuePairList &Params)
Creates a manager of the type represented by this factory.
Definition: uimanager.cpp:744
void RegisterMarkupParser(const String &ParserName, MarkupParser *ToAdd)
Registers a new MarkupParser with this Manager. method will thrown a "II_DUPLICATE_IDENTITY_EXCEPTION...
Definition: uimanager.cpp:474
ScreenContainer::const_reverse_iterator ConstReverseScreenIterator
Const Reverse Iterator type for Screen instances stored by this class.
Definition: uimanager.h:132
static Boole SingletonValid()
Checks to see if the singleton pointer is valid.
Definition: singleton.h:110
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
static ResourceManager * GetSingletonPtr()
Fetches a pointer to the singleton.
Definition: singleton.h:97
This class is for creating and managing viewports within a game window.
Definition: viewport.h:65
void DestroyManager(EntresolManager *ToBeDestroyed)
Destroys a Manager created by this factory.
Definition: uimanager.cpp:760
This is the base class for all managers that do no describe properties of a single world...
void HandlePostFocusInput(const Input::MetaCode &Code)
Handles UI processing after the update of the main focus.
Definition: uimanager.cpp:176
Boole FocusIsLocked() const
Gets whether or not the systems current focus is locked.
Definition: uimanager.cpp:275
void HideAllScreens(Screen *Exclude=NULL)
Hides all screens owned by this manager.
Definition: uimanager.cpp:390
ScreenContainer::const_iterator ConstScreenIterator
Const Iterator type for Screen instances stored by this class.
Definition: uimanager.h:128
void EnableButtonAutoRegister(Boole Enable)
Enables whether or not to automatically set the activation key or button for UI buttons.
Definition: uimanager.cpp:438
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
void HandlePreFocusInput(const Input::MetaCode &Code)
Handles UI processing prior to the update of the main focus.
Definition: uimanager.cpp:165
void DestroyAllAtlases()
Destroys all loaded texture atlases.
ScreenContainer::iterator ScreenIterator
Iterator type for Screen instances stored by this class.
Definition: uimanager.h:126
Boole IsKeyboardEvent() const
Does this MetaCode Represent a state of a keyboard Event.
Definition: metacode.cpp:334
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
This class is responsible for the registration and handling of hotkeys in the UI system.
Definition: hotkeyhandler.h:58
virtual void _OnFocusGained()
Self logic to be executed when focus is given to this widget.
Definition: widget.cpp:485
This is the base class for all widgets.
Definition: widget.h:126
Boole SwitchFocus(Widget *NewFocus)
Updates the current focus to a new target.
Definition: uimanager.cpp:252
This class implements the default set of tags used by the UI markup system.
MarkupParserContainer::const_iterator ConstMarkupParserIterator
Const Iterator type for MarkupParser instances stored by this class.
Definition: uimanager.h:122
void DestroyAtlas(TextureAtlas *ToBeDestroyed)
Destroys a loaded texture atlas.
Definition: uimanager.cpp:292
std::map< String, FontData * > FontDataContainer
Container type for storing fonts packed into this atlas.
Definition: textureatlas.h:75
virtual void DoWork(Threading::DefaultThreadSpecificStorage::Type &CurrentThreadStorage)
This does any required update of the Graphical Scene graph and REnders one frame. ...
Definition: uimanager.cpp:93
void HandlePostFocusMouseInput(const Input::MetaCode &Code)
Handles mouse processes after the update of the main focus.
Definition: uimanager.cpp:238
Entresol * TheEntresol
The actual pointer to the Entresol core class.
Definition: managerbase.h:108
The defintion of the Resource Manager.
void BindHotKey(const Input::MetaCode &HotKey, UI::Button *BoundButton)
Binds a key to a button.
virtual ~DefaultUIManagerFactory()
Class destructor.
Definition: uimanager.cpp:735
void HandlePostFocusKeyboardInput(const Input::MetaCode &Code)
Handles keyboard processes after the update of the main focus.
Definition: uimanager.cpp:233
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:206
Input::InputCode GetCode() const
This Returns the Inputcode.
Definition: metacode.cpp:244
void UnregisterAllMarkupParsers()
Removes all MarkupParsers from this manager.
Definition: uimanager.cpp:504
Whole GetNumScreens() const
Gets the number of screens created and stored in this manager.
Definition: uimanager.cpp:334
void HandlePostFocusControllerInput(const Input::MetaCode &Code)
Handles controller processes after the update of the main focus.
Definition: uimanager.cpp:246
WidgetUpdateWorkUnit * GetWidgetUpdateWork()
Gets the work unit responsible for updating the widgets in this manager.
Definition: uimanager.cpp:715
virtual void ClearDependencies()
Drop any information about what work units this one depends on.
Definition: workunit.cpp:110
DeviceUpdateWorkUnit * GetDeviceUpdateWork()
Gets the work unit responsible for updating the input device classes.
virtual void _OnMouseEnter()
Self logic to be executed when the mouse cursor enters the bounds of this widget. ...
Definition: widget.cpp:441
virtual void _SetZOrder(const UInt16 &Zorder)
Ssts the ZOrder value for this renderable.
Thrown when parameters are checked at runtime and found invalid.
Definition: exception.h:108
Input::MetaCode::ConstMetaCodeIterator ConstMetaCodeIterator
Const Iterator type for convenient MetaCode storage.
Definition: metacode.h:355
This Determines the kind of user input.
Definition: metacode.h:93
Input::MetaCode::MetaCodeContainer MetaCodeContainer
Convenience datatype for storage of MetaCodes.
Definition: metacode.h:351
Widget * HoveredWidget
A pointer to the current widget in the UI system the mouse is hovered over.
Definition: uimanager.h:165
std::pair< String, Real > FontResult
An std::pair type for returning the result of a font suggestion.
Definition: uimanager.h:140
Graphics::Viewport * GetHoveredViewport() const
Gets a pointer to the current viewport the mouse cursor is hovered over.
Definition: mouse.cpp:201
virtual void Initialize()
Configures this manager for use prior to entering the main loop.
Definition: uimanager.cpp:693
virtual void Deinitialize()
Removes this manager from any necessary configuration so it can be safely disposed of...
Definition: uimanager.cpp:705
This class is responsible for any and all user interactions with the User interface/HUD.
Definition: uimanager.h:114
virtual String GetName() const =0
Gets the name of this parser implementation.
virtual void _OnFocusLocked()
Self logic to be executed when focus is locked to this widget.
Definition: widget.cpp:507
void RemoveAutoRegisterCode(const Input::MetaCode &Code)
Removes a previously set auto-registering input code.
Definition: uimanager.cpp:454
Boole MouseIsInUISystem() const
Checks to see if the mouse is over a UI element.
Definition: uimanager.cpp:570
void DestroyAllAtlases()
Destroys all loaded texture atlases.
Definition: uimanager.cpp:295
TextureAtlasHandler * GetAtlasHandler() const
Gets this managers Atlas Handler.
Definition: uimanager.cpp:536
FontDataContainer::iterator FontDataIterator
Iterator type for fonts stored in this class.
Definition: textureatlas.h:77
MarkupParser * GetMarkupParser(const String &ParserName) const
Gets a MarkupParser by it's registered name.
Definition: uimanager.cpp:490
void DestroyScreen(Screen *Screen)
Deletes a screen and removes all trace of it from the manager.
Definition: uimanager.cpp:339
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
QuadRenderable * GetParent() const
Gets the parent of this quad.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
void UnbindHotKey(const Input::MetaCode &HotKey, Button *BoundButton)
Removes a previously set hotkey binding.
Definition: uimanager.cpp:430
Screen * GetLowestVisibleScreenOnViewport(Graphics::Viewport *WindowViewport) const
Gets the lowest ZOrder screen that is visible on a viewport.
Definition: uimanager.cpp:400
void DestroyAtlas(TextureAtlas *ToBeDestroyed)
Destroys a loaded texture atlas.
void AddAutoRegisterCode(const Input::MetaCode &Code)
Adds a key or button that will be auto-registered with every created UI button.
Definition: uimanager.cpp:444
This class is a helper class, specifically for use as a button.
Definition: button.h:66
Boole IsWidget() const
Gets whether or not this renderable is a Widget.
Definition: renderable.cpp:83
void DestroyAllMarkupParsers()
Removes and destroys all MarkupParsers from this manager.
Definition: uimanager.cpp:518
void HandlePreFocusControllerInput(const Input::MetaCode &Code)
Handles controller processes prior to the update of the main focus.
Definition: uimanager.cpp:227
Vector2 GetViewportPosition() const
Gets the position of the mouse cursor relative to the origin of the viewport in the window with the m...
Definition: mouse.cpp:216
void ShowScreensOnViewport(Graphics::Viewport *WindowViewport, Screen *Exclude=NULL)
Shows all screens bound to a specific viewport.
Definition: uimanager.cpp:360
virtual Boole GetVisible() const
Gets the visibility setting of this renderable.
Definition: widget.cpp:243
virtual Boole IsDragged() const
Gets whether or not the system mouse is being dragged over this widget.
Definition: widget.cpp:165
DefaultUIManagerFactory()
Class constructor.
Definition: uimanager.cpp:732
This is a base class for the parsing of markup texts contained in text layers.
Definition: markupparser.h:126
This handles the creation, storage and overall handling of Texture Atlases.
virtual void _OnMouseDragStart()
Self logic to be executed when the mouse cursor starts dragging across the bounds of this widget...
Definition: widget.cpp:463
FontDataContainer & GetFonts()
Gets the full listing of all the FontData instances in this TextureAtlas.
MarkupParserContainer MarkupParsers
A container storing all the registered/known markup parsers.
Definition: uimanager.h:149
virtual void _OnFocusUnlocked()
Self logic to be executed when focus is no longer locked to this widget.
Definition: widget.cpp:513
Boole MouseMoved
Stores whether or not the mouse moved since the last time the UI was updated.
Definition: uimanager.h:186
String GetManagerImplName() const
Gets the name of the manager that is created by this factory.
Definition: uimanager.cpp:738
virtual void _OnMouseExit()
Self logic to be executed when the mouse cursor leaves the bounds of thiw widget. ...
Definition: widget.cpp:452
void UnbindHotKey(const Input::MetaCode &HotKey, UI::Button *BoundButton)
Removes a previously set hotkey binding.
This class is a helper class for creating UI's. It is responsible for storing and keeping track of al...
Definition: screen.h:142
virtual void _OnMouseDragEnd()
Self logic to be executed when the mouse cursor stops dragging across the bounds of this widget...
Definition: widget.cpp:474
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
void HideScreensOnViewport(Graphics::Viewport *WindowViewport, Screen *Exclude=NULL)
Hides all screens bound to a specific viewport.
Definition: uimanager.cpp:380
Boole IsMouseMotionEvent() const
Does this MetaCode Represent movement of the mouse or mouse wheel.
Definition: metacode.cpp:340
This is a Mezzanine::Threading::iWorkUnit for the updating of widgets in the UI system.
Definition: uimanager.h:73
Boole IsMouseEvent() const
Does this MetaCode Represent a state of a mouse Event.
Definition: metacode.cpp:337
ScreenContainer::reverse_iterator ReverseScreenIterator
Reverse Iterator type for Screen instances stored by this class.
Definition: uimanager.h:130
Widget * GetWidgetFocus() const
Gets the current widget being controlled.
Definition: uimanager.cpp:533
virtual ~WidgetUpdateWorkUnit()
Class destructor.
Definition: uimanager.cpp:87
Boole IsMouseButton() const
Does this MetaCode Represent a state of a Mouse button.
Definition: metacode.cpp:325
virtual void UpdateScreens()
Updates the UI system based on the most recent inputs.
Definition: uimanager.cpp:626
virtual ~UIManager()
Class Destructor.
Definition: uimanager.cpp:149
InputContainer InjectedInputs
A container storing all of the Inputs generated/tracked during the last UI update.
Definition: uimanager.h:158
InputContainer AutoRegisterCodes
A container storing all of the Inputs buttons will be set to activate in response to...
Definition: uimanager.h:155
Boole Initialized
Simple Boole indicating whether or not this manager has been initialized.
Definition: managerbase.h:111