40 #ifndef _uinineboxstrategy_cpp
41 #define _uinineboxstrategy_cpp
43 #include "UI/nineboxstrategy.h"
44 #include "UI/screen.h"
45 #include "UI/widget.h"
69 Partitions(StratPartitions)
80 for( NineBoxStrategy::PartitionVec::iterator It = Partitions->begin() ; It != Partitions->end() ; ++It )
82 if( (*It)->PartitionRect.CheckOverlap(Wid->
GetRect()) )
83 (*It)->Widgets.push_back(Wid);
107 for( PartitionVec::iterator It = this->
Partitions.begin() ; It != this->
Partitions.end() ; ++It )
119 for( PartitionVec::iterator It = this->
Partitions.begin() ; It != this->
Partitions.end() ; ++It )
122 (*It)->Widgets.clear();
134 Vector2 ThirdSize(ScreenSize.
X / 3,ScreenSize.
Y / 3);
137 case NBP_TopLeft:
return Rect(
Vector2(0,0),ThirdSize);
break;
138 case NBP_TopCenter:
return Rect(
Vector2(ThirdSize.
X * 1,0),ThirdSize);
break;
139 case NBP_TopRight:
return Rect(
Vector2(ThirdSize.
X * 2,0),ThirdSize);
break;
140 case NBP_LeftCenter:
return Rect(
Vector2(0,ThirdSize.
Y * 1),ThirdSize);
break;
141 case NBP_Center:
return Rect(
Vector2(ThirdSize.
X * 1,ThirdSize.
Y * 1),ThirdSize);
break;
142 case NBP_RightCenter:
return Rect(
Vector2(ThirdSize.
X * 2,ThirdSize.
Y * 1),ThirdSize);
break;
143 case NBP_BottomLeft:
return Rect(
Vector2(0,ThirdSize.
Y * 2),ThirdSize);
break;
144 case NBP_BottomCenter:
return Rect(
Vector2(ThirdSize.
X * 1,ThirdSize.
Y * 2),ThirdSize);
break;
145 case NBP_BottomRight:
return Rect(
Vector2(ThirdSize.
X * 2,ThirdSize.
Y * 2),ThirdSize);
break;
153 for( PartitionVec::iterator It = this->
Partitions.begin() ; It != this->
Partitions.end() ; ++It )
155 if( (*It)->PartitionRect.IsInside(MousePos) )
165 if( HoveredPartition == NULL )
168 for( PartitionData::WidgetContainer::reverse_iterator WidIt = HoveredPartition->
Widgets.rbegin() ; WidIt != HoveredPartition->
Widgets.rend() ; ++WidIt )
171 if( (*WidIt)->GetVisible() && (*WidIt)->GetNumVisibleRenderLayers() ) {
173 if( (*WidIt)->IsInside(MousePos) ) {
175 if( !(*WidIt)->GetMousePassthrough() ) {
NineBoxCheck(NineBoxStrategy::PartitionVec *StratPartitions)
Functor constructor.
virtual Rect GetRect() const
Gets this QuadRenderables' Rect.
Rect CalculatePartitionRect(const NineBoxPartition &PartID, const Vector2 &ScreenSize)
Convenience method for calculating the actual size and position of a single partition.
Simple functor for finding which renderable the mouse is hovered over.
bool Boole
Generally acts a single bit, true or false.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Boole operator()(Widget *Wid)
Interface needed for processing child widgets of screens and widgets.
This class represents a box shaped area on the screen.
Boole _ProcessAllChildren(Callback *CB)
Processes all children of this screen by their zorder.
Widget * FindHoveredWidget(const Vector2 &MousePos)
Finds the hovered quad for the parent screen.
NineBoxStrategy()
Class constructor.
Real Y
Coordinate on the Y vector.
Real X
Coordinate on the X vector.
This is used to represent a point on a 2 dimentional area, such as a screen.
This is a helper class for storing metadata for partitions.
~NineBoxCheck()
Class destructor.
virtual Vector2 GetActualSize() const
Gets the pixel size of this widget.
NineBoxStrategy::PartitionVec * Partitions
A pointer to the Vector of 9 partitions on the screen to use for spacial checks.
NineBoxPartition
Enum describing the different 9-Box partitions of a screen.
PartitionData * GetHoveredPartition(const Vector2 &MousePos)
Gets the partition that the provided position is in.
Thrown when parameters are checked at runtime and found invalid.
bool ScreenDirty
Stores whether or not the parent screen has been updated since the last time this strategys cache was...
The bulk of the engine components go in this namspace.
virtual ~NineBoxStrategy()
Class destructor.
std::vector< PartitionData * > PartitionVec
Basic container type for PartitionData storage by this class.
Screen * ParentScreen
A pointer to the screen this strategy is being used by.
WidgetContainer Widgets
A container storing all the quads that overlap with this screen partition.
void UpdateCache()
Updates the partition cache with the newest quad positions.
PartitionVec Partitions
A container storing all the quads that overlap with this screen partition.