MezzanineEngine
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Mezzanine
src
UI
nineboxstrategy.h
1
//© Copyright 2010 - 2012 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 _uinineboxstrategy_h
41
#define _uinineboxstrategy_h
42
43
#include "UI/mousehoverstrategy.h"
44
#include "UI/rect.h"
45
#include <map>
46
47
namespace
Mezzanine
48
{
49
namespace
UI
50
{
51
/// @enum NineBoxPartition
52
/// @brief Enum describing the different 9-Box partitions of a screen.
53
enum
NineBoxPartition
54
{
55
NBP_TopLeft = 1,
56
NBP_TopCenter = 2,
57
NBP_TopRight = 4,
58
NBP_RightCenter = 8,
59
NBP_Center = 16,
60
NBP_LeftCenter = 32,
61
NBP_BottomLeft = 64,
62
NBP_BottomCenter = 128,
63
NBP_BottomRight = 256
64
};
//NineBoxPartition
65
66
///////////////////////////////////////////////////////////////////////////////
67
/// @class PartitionData
68
/// @headerfile nineboxstrategy.h
69
/// @brief This is a helper class for storing metadata for partitions.
70
/// @details
71
///////////////////////////////////////
72
class
MEZZ_LIB
PartitionData
73
{
74
public
:
75
/// @brief Basic container type for Widget storage by this class.
76
typedef
std::vector<Widget*>
WidgetContainer
;
77
public
:
78
/// @brief An enum value identifying which screen partition this is.
79
NineBoxPartition
PartitionID
;
80
/// @brief A Rect representing the pixel limits of this screen partition.
81
Rect
PartitionRect
;
82
/// @brief A container storing all the quads that overlap with this screen partition.
83
WidgetContainer
Widgets
;
84
85
/// @brief Class constructor.
86
/// @param PartID An enum value identifying which screen partition this is.
87
PartitionData
(
const
NineBoxPartition
& PartID) :
88
PartitionID(PartID)
89
{ }
90
/// @brief Class destructor.
91
~PartitionData
()
92
{ }
93
};
//PartitionData
94
95
///////////////////////////////////////////////////////////////////////////////
96
/// @class NineBoxStrategy
97
/// @headerfile nineboxstrategy.h
98
/// @brief This strategy partitions the screen into 9 area's that track which Quads are in them, allowing a smaller list of quads to be checked.
99
/// @details
100
///////////////////////////////////////
101
class
MEZZ_LIB
NineBoxStrategy
:
public
MouseHoverStrategy
102
{
103
public
:
104
/// @brief Basic container type for PartitionData storage by this class.
105
typedef
std::vector<PartitionData*>
PartitionVec
;
106
protected
:
107
/// @brief A container storing all the quads that overlap with this screen partition.
108
PartitionVec
Partitions
;
109
110
/// @brief Updates the partition cache with the newest quad positions
111
void
UpdateCache();
112
/// @brief Convenience method for calculating the actual size and position of a single partition.
113
/// @param PartID The enum value to calculate the pixel size and position for.
114
/// @param ScreenSize The current size of the screen the partition is on.
115
/// @param Returns a Rect storing the actual size and position of the specified partition.
116
Rect
CalculatePartitionRect(
const
NineBoxPartition
& PartID,
const
Vector2
& ScreenSize);
117
/// @brief Gets the partition that the provided position is in.
118
/// @param MousePos The screen position used to determine which partition to retrieve.
119
/// @return Returns a pointer to the PartitionData of the partition the provided mouse position is above.
120
PartitionData
* GetHoveredPartition(
const
Vector2
& MousePos);
121
public
:
122
/// @brief Class constructor.
123
NineBoxStrategy
();
124
/// @brief Class destructor.
125
virtual
~
NineBoxStrategy
();
126
127
///////////////////////////////////////////////////////////////////////////////
128
// Utility
129
130
/// @copydoc MouseHoverStrategy::FindHoveredWidget(const Vector2& MousePos)
131
Widget
* FindHoveredWidget(
const
Vector2
& MousePos);
132
};
//NineBoxStrategy
133
}
//UI
134
}
//Mezzanine
135
136
#endif
Generated on Mon Jan 6 2014 20:58:06 for MezzanineEngine by
1.8.4