1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/**
* @file llbadge.h
* @brief Header for badges
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLBADGE_H
#define LL_LLBADGE_H
#include <string>
#include "lluicolor.h"
#include "lluictrl.h"
#include "llstring.h"
#include "lluiimage.h"
#include "llview.h"
#include "llfontvertexbuffer.h"
//
// Declarations
//
class LLFontGL;
class LLFontVertexBuffer;
class LLScrollContainer;
class LLUICtrlFactory;
//
// Relative Position Alignment
//
namespace LLRelPos
{
enum Location
{
CENTER = 0,
LEFT = (1 << 0),
RIGHT = (1 << 1),
TOP = (1 << 2),
BOTTOM = (1 << 3),
BOTTOM_LEFT = (BOTTOM | LEFT),
BOTTOM_RIGHT = (BOTTOM | RIGHT),
TOP_LEFT = (TOP | LEFT),
TOP_RIGHT = (TOP | RIGHT),
};
inline bool IsBottom(Location relPos) { return (relPos & BOTTOM) == BOTTOM; }
inline bool IsCenter(Location relPos) { return (relPos == CENTER); }
inline bool IsLeft(Location relPos) { return (relPos & LEFT) == LEFT; }
inline bool IsRight(Location relPos) { return (relPos & RIGHT) == RIGHT; }
inline bool IsTop(Location relPos) { return (relPos & TOP) == TOP; }
}
// NOTE: This needs to occur before Optional<LLRelPos::Location> declaration for proper compilation.
namespace LLInitParam
{
template<>
struct TypeValues<LLRelPos::Location> : public TypeValuesHelper<LLRelPos::Location>
{
static void declareValues();
};
}
//
// Classes
//
class LLBadge
: public LLUICtrl
{
public:
struct Params
: public LLInitParam::Block<Params, LLUICtrl::Params>
{
Optional< LLHandle<LLView> > owner; // Mandatory in code but not in xml
Optional< LLUIImage* > border_image;
Optional< LLUIColor > border_color;
Optional< LLUIImage* > image;
Optional< LLUIColor > image_color;
Optional< std::string > label;
Optional< LLUIColor > label_color;
Optional< S32 > label_offset_horiz;
Optional< S32 > label_offset_vert;
Optional< LLRelPos::Location > location;
Optional< S32 > location_offset_hcenter;
Optional< S32 > location_offset_vcenter;
Optional< U32 > location_percent_hcenter;
Optional< U32 > location_percent_vcenter;
Optional< F32 > padding_horiz;
Optional< F32 > padding_vert;
Params();
bool equals(const Params&) const;
};
protected:
friend class LLUICtrlFactory;
LLBadge(const Params& p);
public:
~LLBadge();
bool addToView(LLView * view);
virtual void draw();
const std::string getLabel() const { return wstring_to_utf8str(mLabel); }
void setLabel( const LLStringExplicit& label);
void setDrawAtParentTop(bool draw_at_top) { mDrawAtParentTop = draw_at_top;}
private:
LLPointer< LLUIImage > mBorderImage;
LLUIColor mBorderColor;
const LLFontGL* mGLFont;
LLFontVertexBuffer mFontBuffer;
LLPointer< LLUIImage > mImage;
LLUIColor mImageColor;
LLUIString mLabel;
LLUIColor mLabelColor;
S32 mLabelOffsetHoriz;
S32 mLabelOffsetVert;
LLRelPos::Location mLocation;
S32 mLocationOffsetHCenter;
S32 mLocationOffsetVCenter;
F32 mLocationPercentHCenter;
F32 mLocationPercentVCenter;
LLHandle< LLView > mOwner;
F32 mPaddingHoriz;
F32 mPaddingVert;
LLScrollContainer* mParentScroller;
bool mDrawAtParentTop;
};
// Build time optimization, generate once in .cpp file
#ifndef LLBADGE_CPP
extern template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, bool recurse) const;
#endif
#endif // LL_LLBADGE_H
|