diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llcontainerview.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llcontainerview.cpp')
-rw-r--r-- | linden/indra/newview/llcontainerview.cpp | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/linden/indra/newview/llcontainerview.cpp b/linden/indra/newview/llcontainerview.cpp new file mode 100644 index 0000000..058d19c --- /dev/null +++ b/linden/indra/newview/llcontainerview.cpp | |||
@@ -0,0 +1,232 @@ | |||
1 | /** | ||
2 | * @file llcontainerview.cpp | ||
3 | * @brief Container for all statistics info | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llcontainerview.h" | ||
31 | |||
32 | #include "llerror.h" | ||
33 | #include "llfontgl.h" | ||
34 | #include "llgl.h" | ||
35 | #include "llui.h" | ||
36 | #include "llresmgr.h" | ||
37 | #include "llstring.h" | ||
38 | |||
39 | LLContainerView::LLContainerView(const std::string& name, const LLRect& rect) | ||
40 | : LLView(name, rect, FALSE) | ||
41 | { | ||
42 | mCollapsible = TRUE; | ||
43 | mDisplayChildren = TRUE; | ||
44 | } | ||
45 | |||
46 | LLContainerView::~LLContainerView() | ||
47 | { | ||
48 | // Children all cleaned up by default view destructor. | ||
49 | } | ||
50 | |||
51 | EWidgetType LLContainerView::getWidgetType() const | ||
52 | { | ||
53 | return WIDGET_TYPE_CONTAINER_VIEW; | ||
54 | } | ||
55 | |||
56 | LLString LLContainerView::getWidgetTag() const | ||
57 | { | ||
58 | return LL_CONTAINER_VIEW_TAG; | ||
59 | } | ||
60 | |||
61 | BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) | ||
62 | { | ||
63 | BOOL handled = FALSE; | ||
64 | if (mDisplayChildren) | ||
65 | { | ||
66 | handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL; | ||
67 | } | ||
68 | if (!handled) | ||
69 | { | ||
70 | if( mCollapsible && (y >= mRect.getHeight() - 10) ) | ||
71 | { | ||
72 | setDisplayChildren(!mDisplayChildren); | ||
73 | reshape(mRect.getWidth(), mRect.getHeight(), FALSE); | ||
74 | } | ||
75 | } | ||
76 | return TRUE; | ||
77 | } | ||
78 | |||
79 | BOOL LLContainerView::handleMouseUp(S32 x, S32 y, MASK mask) | ||
80 | { | ||
81 | if (mDisplayChildren) | ||
82 | { | ||
83 | LLView::childrenHandleMouseUp(x, y, mask); | ||
84 | } | ||
85 | return TRUE; | ||
86 | } | ||
87 | |||
88 | void LLContainerView::draw() | ||
89 | { | ||
90 | if (!getVisible()) | ||
91 | { | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | { | ||
96 | LLGLSNoTexture gls_no_texture; | ||
97 | |||
98 | gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); | ||
99 | } | ||
100 | |||
101 | // Draw the label. | ||
102 | gResMgr->getRes( LLFONT_OCRA )->renderUTF8(mLabel, 0, 2, mRect.getHeight() - 2, LLColor4(1,1,1,1), LLFontGL::LEFT, LLFontGL::TOP); | ||
103 | |||
104 | LLView::draw(); | ||
105 | } | ||
106 | |||
107 | void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent) | ||
108 | { | ||
109 | // Determine the sizes and locations of all contained views | ||
110 | U32 total_height = 0; | ||
111 | U32 top, left, right, bottom; | ||
112 | //LLView *childp; | ||
113 | |||
114 | // These will be used for the children | ||
115 | left = 4; | ||
116 | top = mRect.getHeight() - 4; | ||
117 | right = mRect.getWidth() - 2; | ||
118 | bottom = top; | ||
119 | |||
120 | // Leave some space for the top label/grab handle | ||
121 | total_height += 20; | ||
122 | |||
123 | if (mDisplayChildren) | ||
124 | { | ||
125 | // Determine total height | ||
126 | U32 child_height = 0; | ||
127 | for (child_list_const_iter_t child_iter = getChildList()->begin(); | ||
128 | child_iter != getChildList()->end(); ++child_iter) | ||
129 | { | ||
130 | LLView *childp = *child_iter; | ||
131 | if (!childp->getVisible()) | ||
132 | { | ||
133 | llwarns << "Incorrect visibility!" << llendl; | ||
134 | } | ||
135 | LLRect child_rect = childp->getRequiredRect(); | ||
136 | child_height += child_rect.getHeight(); | ||
137 | child_height += 2; | ||
138 | } | ||
139 | total_height += child_height; | ||
140 | } | ||
141 | |||
142 | |||
143 | if (followsTop()) | ||
144 | { | ||
145 | mRect.mBottom = mRect.mTop - total_height; | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | mRect.mTop = mRect.mBottom + total_height; | ||
150 | } | ||
151 | mRect.mRight = mRect.mLeft + width; | ||
152 | |||
153 | top = total_height - 20; | ||
154 | bottom = top; | ||
155 | |||
156 | if (mDisplayChildren) | ||
157 | { | ||
158 | // Iterate through all children, and put in container from top down. | ||
159 | for (child_list_const_iter_t child_iter = getChildList()->begin(); | ||
160 | child_iter != getChildList()->end(); ++child_iter) | ||
161 | { | ||
162 | LLView *childp = *child_iter; | ||
163 | LLRect child_rect = childp->getRequiredRect(); | ||
164 | bottom -= child_rect.getHeight(); | ||
165 | LLRect r(left, bottom + child_rect.getHeight(), right, bottom); | ||
166 | childp->setRect(r); | ||
167 | childp->reshape(right - left, top - bottom); | ||
168 | top = bottom - 2; | ||
169 | bottom = top; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | if (!called_from_parent) | ||
174 | { | ||
175 | if (getParent()) | ||
176 | { | ||
177 | getParent()->reshape(getParent()->getRect().getWidth(), getParent()->getRect().getHeight(), FALSE); | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | |||
182 | LLRect LLContainerView::getRequiredRect() | ||
183 | { | ||
184 | LLRect req_rect; | ||
185 | //LLView *childp; | ||
186 | U32 total_height = 0; | ||
187 | |||
188 | // Determine the sizes and locations of all contained views | ||
189 | |||
190 | // Leave some space for the top label/grab handle | ||
191 | |||
192 | if (mDisplayChildren) | ||
193 | { | ||
194 | total_height = 20; | ||
195 | |||
196 | // Determine total height | ||
197 | U32 child_height = 0; | ||
198 | for (child_list_const_iter_t child_iter = getChildList()->begin(); | ||
199 | child_iter != getChildList()->end(); ++child_iter) | ||
200 | { | ||
201 | LLView *childp = *child_iter; | ||
202 | LLRect child_rect = childp->getRequiredRect(); | ||
203 | child_height += child_rect.getHeight(); | ||
204 | child_height += 2; | ||
205 | } | ||
206 | |||
207 | total_height += child_height; | ||
208 | } | ||
209 | else | ||
210 | { | ||
211 | total_height = 20; | ||
212 | } | ||
213 | |||
214 | req_rect.mTop = total_height; | ||
215 | return req_rect; | ||
216 | } | ||
217 | |||
218 | void LLContainerView::setLabel(const LLString& label) | ||
219 | { | ||
220 | mLabel = label; | ||
221 | } | ||
222 | |||
223 | void LLContainerView::setDisplayChildren(const BOOL displayChildren) | ||
224 | { | ||
225 | mDisplayChildren = displayChildren; | ||
226 | for (child_list_const_iter_t child_iter = getChildList()->begin(); | ||
227 | child_iter != getChildList()->end(); ++child_iter) | ||
228 | { | ||
229 | LLView *childp = *child_iter; | ||
230 | childp->setVisible(mDisplayChildren); | ||
231 | } | ||
232 | } | ||