40 #ifndef _uiuimanager_cpp
41 #define _uiuimanager_cpp
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"
54 #include "UI/defaultmarkupparser.h"
56 #include "Graphics/graphicsmanager.h"
57 #include "Graphics/viewport.h"
58 #include "Input/inputmanager.h"
59 #include "Input/mouse.h"
61 #include "eventmanager.h"
63 #include "MathTools/mathtools.h"
71 template<> UI::UIManager* Singleton<UI::UIManager>::SingletonPtr = NULL;
85 TargetManager(Target) { }
106 WidgetUpdateWork(NULL),
107 ThreadResources(NULL),
109 ButtonAutoRegister(false),
129 WidgetUpdateWork(NULL),
130 ThreadResources(NULL),
132 ButtonAutoRegister(false),
303 Screen* MezzScreen =
new Screen(ScreenName,Atlas,WindowViewport,
this);
308 if( (*ScreenIt)->GetZOrder() > ZOrder ) {
309 this->
Screens.insert(ScreenIt,MezzScreen);
313 this->
Screens.push_back(MezzScreen);
321 if ( Name == (*it)->GetName() ) {
322 Screen* MezzScreen = (*it);
343 if( Screen == (*it) ) {
364 if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt) != Exclude ) {
374 if( (*ScreenIt) != Exclude ) {
384 if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt) != Exclude ) {
394 if( (*ScreenIt) != Exclude ) {
404 if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt)->IsVisible() ) {
415 if( (*ScreenIt)->GetViewport() == WindowViewport && (*ScreenIt)->IsVisible() ) {
458 if( (*It) == Code ) {
480 this->
MarkupParsers.insert( std::pair<String,UI::MarkupParser*>(ParserName,ToAdd) );
493 if( MarkupIt != this->
MarkupParsers.end() )
return (*MarkupIt).second;
513 delete (*MarkupIt).second;
523 {
delete (*MarkupIt).second; }
546 case Input::MOUSEHORIZONTAL:
547 case Input::MOUSEVERTICAL:
562 Widget* Result = (*ScreenIt)->FindHoveredWidget(Point);
563 if( Result != NULL ) {
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;
593 if((*it).second->GetLineHeight() > RequestedHeight)
595 Diff = (*it).second->GetLineHeight() - RequestedHeight;
596 if(Diff < LargerMatchDiff)
598 LargerMatch = (*it).first;
599 LargerHeight = (*it).second->GetLineHeight();
600 LargerMatchDiff = Diff;
604 Diff = RequestedHeight - (*it).second->GetLineHeight();
605 if(Diff < SmallerMatchDiff)
607 SmallerMatch = (*it).first;
608 SmallerHeight = (*it).second->GetLineHeight();
609 SmallerMatchDiff = Diff;
616 if(!LargerMatch.empty())
618 Scale = RequestedHeight / LargerHeight;
621 Scale = RequestedHeight / SmallerHeight;
632 (*ScIt)->CheckViewportSize();
670 }
while( PassedFocus != NULL && !PassedFocus->
GetVisible() );
761 {
delete ToBeDestroyed; }
Widget * WidgetFocus
A pointer to the widget that is currently holding the focus.
virtual void AddDependency(iWorkUnit *NewDependency)
Force this WorkUnit to Start after another has completed.
Screen * GetScreen(const String &Name) const
Gets a screen by name.
Thrown when duplicates of teh same identity string exist.
void HandlePreFocusMouseInput(const Input::MetaCode &Code)
Handles mouse processes prior to the update of the main focus.
Screen * GetHighestVisibleScreenOnViewport(Graphics::Viewport *WindowViewport) const
Gets the highest ZOrder screen that is visible on a viewport.
InputContainer::iterator InputIterator
Iterator type for Input::MetaCode instances stored by this class.
MarkupParserContainer::iterator MarkupParserIterator
Iterator type for MarkupParser instances stored by this class.
TextureAtlas * GetAtlas(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Screen * CreateScreen(const String &ScreenName, const String &Atlas, Graphics::Viewport *WindowViewport, const UInt16 ZOrder)
Creates an internal HUD screen.
void DestroyMarkupParser(const String &ParserName)
Removes and destroys a MarkupParser from this manager.
Boole IsMarkupParserRegistered(const String &ParserName) const
Checks to see if a MarkupParser has already been registsered under a specific name.
bool Boole
Generally acts a single bit, true or false.
FontResult SuggestGlyphIndex(const Whole &Height, const String &Atlas)
Suggests a glyph index based on the desired actual height.
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.
const InputContainer & GetAutoRegisteredCodes() const
Gets the list of codes that will be auto-registered with each UI button.
ManagerType
A listing of Manager Types.
Boole ButtonAutoRegisterEnabled() const
Gets whether or not the ButtonAutoRegister feature is enabled.
static const ManagerBase::ManagerType InterfaceType
A ManagerType enum value used to describe the type of interface/functionality this manager provides...
Widget * GetHoveredWidget() const
Gets the Widget the mouse is hovering over.
TextureAtlas * GetAtlasExcept(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
Widget * CheckWidgetUnderPoint(Graphics::Viewport *VP, const Vector2 &Point)
Searches all visable screens and layers to see if a Widget is under the given point.
void RemoveAllAutoRegisterCodes()
Removes all auto-registering input codes.
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.
void ShowAllScreens(Screen *Exclude=NULL)
Shows all screens owned by this manager.
virtual ManagerType GetInterfaceType() const
This returns the type of this manager.
WidgetUpdateWorkUnit * WidgetUpdateWork
The work unit that updates all of the widgets in the UI system.
UIManager()
Class Constructor.
virtual String GetImplementationTypeName() const
This Allows any manager name to be sent to a stream. Primarily used for logging.
TextureAtlasHandler * AtlasHandler
A pointer to the class responsible for Atlas tasks in the UI system.
Threading::FrameScheduler & GetScheduler()
Gets the core structure responsible for scheduling work in the Entresol main loop.
This is a collection of smaller textures packed into a larger texture, intended to increase UI perfor...
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.
static const String ImplementationName
A String containing the name of this manager implementation.
HotKeyHandler * HKHandler
A pointer to the class responsible for HotKey tasks in the UI system.
Boole ButtonAutoRegister
Stores whether or not newly created buttons will have activation codes binded to them automatically...
ManagerBase::ManagerType GetManagerType() const
Gets the type of manager that is created by this factory.
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.
std::vector< Input::MetaCode > InputContainer
Basic container type for Input::MetaCode storage by this class.
void InjectInput(const Input::MetaCode &Code)
Injects a metacode into this manager, allowing the UI system to be aware of it.
void UnregisterMarkupParser(const String &ParserName)
Removes a MarkupParser from this manager.
ScreenContainer Screens
A container storing all the Screens created in the UI system.
UI::TextureAtlas * GetAtlasExcept(const String &AtlasName)
Gets a loaded Atlas being stored in this manager.
void BindHotKey(const Input::MetaCode &HotKey, Button *BoundButton)
Binds a key to a button.
float Real
A Datatype used to represent a real floating point number.
Input::MetaCode FocusLockCode
Stores the Input that locked the current focus.
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.
void RegisterMarkupParser(const String &ParserName, MarkupParser *ToAdd)
Registers a new MarkupParser with this Manager. method will thrown a "II_DUPLICATE_IDENTITY_EXCEPTION...
ScreenContainer::const_reverse_iterator ConstReverseScreenIterator
Const Reverse Iterator type for Screen instances stored by this class.
static Boole SingletonValid()
Checks to see if the singleton pointer is valid.
uint16_t UInt16
An 16-bit unsigned integer.
static ResourceManager * GetSingletonPtr()
Fetches a pointer to the singleton.
This class is for creating and managing viewports within a game window.
void DestroyManager(EntresolManager *ToBeDestroyed)
Destroys a Manager created by this factory.
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.
Boole FocusIsLocked() const
Gets whether or not the systems current focus is locked.
void HideAllScreens(Screen *Exclude=NULL)
Hides all screens owned by this manager.
ScreenContainer::const_iterator ConstScreenIterator
Const Iterator type for Screen instances stored by this class.
void EnableButtonAutoRegister(Boole Enable)
Enables whether or not to automatically set the activation key or button for UI buttons.
A light-weight handle for manipulating nodes in DOM tree.
void HandlePreFocusInput(const Input::MetaCode &Code)
Handles UI processing prior to the update of the main focus.
void DestroyAllAtlases()
Destroys all loaded texture atlases.
ScreenContainer::iterator ScreenIterator
Iterator type for Screen instances stored by this class.
This is used to represent a point on a 2 dimentional area, such as a screen.
This class is responsible for the registration and handling of hotkeys in the UI system.
Boole SwitchFocus(Widget *NewFocus)
Updates the current focus to a new target.
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.
void DestroyAtlas(TextureAtlas *ToBeDestroyed)
Destroys a loaded texture atlas.
std::map< String, FontData * > FontDataContainer
Container type for storing fonts packed into this atlas.
void HandlePostFocusMouseInput(const Input::MetaCode &Code)
Handles mouse processes after the update of the main focus.
Entresol * TheEntresol
The actual pointer to the Entresol core class.
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.
void HandlePostFocusKeyboardInput(const Input::MetaCode &Code)
Handles keyboard processes after the update of the main focus.
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
void UnregisterAllMarkupParsers()
Removes all MarkupParsers from this manager.
Whole GetNumScreens() const
Gets the number of screens created and stored in this manager.
void HandlePostFocusControllerInput(const Input::MetaCode &Code)
Handles controller processes after the update of the main focus.
WidgetUpdateWorkUnit * GetWidgetUpdateWork()
Gets the work unit responsible for updating the widgets in this manager.
virtual void ClearDependencies()
Drop any information about what work units this one depends on.
virtual void _SetZOrder(const UInt16 &Zorder)
Ssts the ZOrder value for this renderable.
Thrown when parameters are checked at runtime and found invalid.
Input::MetaCode::ConstMetaCodeIterator ConstMetaCodeIterator
Const Iterator type for convenient MetaCode storage.
Input::MetaCode::MetaCodeContainer MetaCodeContainer
Convenience datatype for storage of MetaCodes.
Widget * HoveredWidget
A pointer to the current widget in the UI system the mouse is hovered over.
std::pair< String, Real > FontResult
An std::pair type for returning the result of a font suggestion.
virtual void Initialize()
Configures this manager for use prior to entering the main loop.
virtual void Deinitialize()
Removes this manager from any necessary configuration so it can be safely disposed of...
This class is responsible for any and all user interactions with the User interface/HUD.
virtual String GetName() const =0
Gets the name of this parser implementation.
void RemoveAutoRegisterCode(const Input::MetaCode &Code)
Removes a previously set auto-registering input code.
Boole MouseIsInUISystem() const
Checks to see if the mouse is over a UI element.
void DestroyAllAtlases()
Destroys all loaded texture atlases.
TextureAtlasHandler * GetAtlasHandler() const
Gets this managers Atlas Handler.
FontDataContainer::iterator FontDataIterator
Iterator type for fonts stored in this class.
MarkupParser * GetMarkupParser(const String &ParserName) const
Gets a MarkupParser by it's registered name.
void DestroyScreen(Screen *Screen)
Deletes a screen and removes all trace of it from the manager.
The bulk of the engine components go in this namspace.
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.
void UnbindHotKey(const Input::MetaCode &HotKey, Button *BoundButton)
Removes a previously set hotkey binding.
Screen * GetLowestVisibleScreenOnViewport(Graphics::Viewport *WindowViewport) const
Gets the lowest ZOrder screen that is visible on a viewport.
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.
Boole IsWidget() const
Gets whether or not this renderable is a Widget.
void DestroyAllMarkupParsers()
Removes and destroys all MarkupParsers from this manager.
void HandlePreFocusControllerInput(const Input::MetaCode &Code)
Handles controller processes prior to the update of the main focus.
void ShowScreensOnViewport(Graphics::Viewport *WindowViewport, Screen *Exclude=NULL)
Shows all screens bound to a specific viewport.
DefaultUIManagerFactory()
Class constructor.
This is a base class for the parsing of markup texts contained in text layers.
This handles the creation, storage and overall handling of Texture Atlases.
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.
Boole MouseMoved
Stores whether or not the mouse moved since the last time the UI was updated.
String GetManagerImplName() const
Gets the name of the manager that is created by this factory.
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...
std::string String
A datatype used to a series of characters.
void HideScreensOnViewport(Graphics::Viewport *WindowViewport, Screen *Exclude=NULL)
Hides all screens bound to a specific viewport.
ScreenContainer::reverse_iterator ReverseScreenIterator
Reverse Iterator type for Screen instances stored by this class.
Widget * GetWidgetFocus() const
Gets the current widget being controlled.
virtual void UpdateScreens()
Updates the UI system based on the most recent inputs.
virtual ~UIManager()
Class Destructor.
InputContainer InjectedInputs
A container storing all of the Inputs generated/tracked during the last UI update.
InputContainer AutoRegisterCodes
A container storing all of the Inputs buttons will be set to activate in response to...
Boole Initialized
Simple Boole indicating whether or not this manager has been initialized.