diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloatertest.cpp | 389 |
1 files changed, 389 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatertest.cpp b/linden/indra/newview/llfloatertest.cpp new file mode 100644 index 0000000..9f0503b --- /dev/null +++ b/linden/indra/newview/llfloatertest.cpp | |||
@@ -0,0 +1,389 @@ | |||
1 | /** | ||
2 | * @file llfloatertest.cpp | ||
3 | * @author James Cook | ||
4 | * @brief Torture-test floater for all UI elements | ||
5 | * | ||
6 | * Copyright (c) 2006-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "llviewerprecompiledheaders.h" | ||
30 | |||
31 | #include "llfloatertest.h" | ||
32 | |||
33 | #include "llbutton.h" | ||
34 | #include "llcheckboxctrl.h" | ||
35 | #include "llcombobox.h" | ||
36 | #include "llfloater.h" | ||
37 | #include "lliconctrl.h" | ||
38 | #include "lllineeditor.h" | ||
39 | #include "llradiogroup.h" | ||
40 | #include "llscrollcontainer.h" | ||
41 | #include "llscrolllistctrl.h" | ||
42 | #include "llslider.h" | ||
43 | #include "llsliderctrl.h" | ||
44 | #include "lltabcontainer.h" | ||
45 | #include "lltextbox.h" | ||
46 | #include "lltexteditor.h" | ||
47 | #include "llview.h" | ||
48 | #include "llviewborder.h" | ||
49 | |||
50 | #include "llnamelistctrl.h" | ||
51 | #include "llvieweruictrlfactory.h" | ||
52 | #include "llviewercontrol.h" | ||
53 | |||
54 | class LLFloaterTestImpl : public LLFloater | ||
55 | { | ||
56 | public: | ||
57 | LLFloaterTestImpl(); | ||
58 | |||
59 | private: | ||
60 | static void onClickButton(void*); | ||
61 | static void onClickText(void*); | ||
62 | static void onCloseTab(void*); | ||
63 | static void onClickTab(void*, bool); | ||
64 | static void onCommitCheck(LLUICtrl*, void*); | ||
65 | static void onCommitCombo(LLUICtrl*, void*); | ||
66 | static void onCommitLine(LLUICtrl*, void*); | ||
67 | static void onKeyLine(LLLineEditor*, void*); | ||
68 | static void onFocusLostLine(LLLineEditor*, void*); | ||
69 | static void onChangeRadioGroup(LLUICtrl*, void*); | ||
70 | |||
71 | LLButton* mBtnSimple; | ||
72 | LLButton* mBtnUnicode; | ||
73 | LLButton* mBtnImages; | ||
74 | LLCheckBoxCtrl* mCheckSimple; | ||
75 | LLCheckBoxCtrl* mCheckUnicode; | ||
76 | LLComboBox* mCombo; | ||
77 | LLIconCtrl* mIcon; | ||
78 | LLLineEditor* mLineEditor; | ||
79 | LLRadioGroup* mRadioGroup; | ||
80 | LLRadioCtrl* mRadio1; | ||
81 | LLRadioCtrl* mRadio2; | ||
82 | LLScrollableContainerView* mScroll; | ||
83 | LLScrollListCtrl* mScrollList; | ||
84 | LLTabContainer* mTab; | ||
85 | LLTextEditor* mTextEditor; | ||
86 | LLView* mView; | ||
87 | LLViewBorder* mViewBorder; | ||
88 | |||
89 | LLNameListCtrl* mNameList; | ||
90 | }; | ||
91 | |||
92 | |||
93 | LLFloaterTestImpl::LLFloaterTestImpl() | ||
94 | : LLFloater("test", LLRect(0, 500, 700, 0), "Test UI") | ||
95 | { | ||
96 | const S32 HPAD = 5; | ||
97 | const S32 VPAD = 5; | ||
98 | const S32 LEFT = HPAD; | ||
99 | const S32 RIGHT = getRect().getWidth() - HPAD; | ||
100 | const S32 TOP = getRect().getHeight() - LLFLOATER_HEADER_SIZE - VPAD; | ||
101 | const S32 BOTTOM = VPAD; | ||
102 | const S32 LINE = 15; | ||
103 | |||
104 | //S32 x = LEFT; | ||
105 | S32 y = TOP; | ||
106 | |||
107 | LLTextBox* text = NULL; | ||
108 | LLButton* btn = NULL; | ||
109 | LLTabContainer* tab = NULL; | ||
110 | LLPanel* panel = NULL; | ||
111 | LLCheckBoxCtrl* check = NULL; | ||
112 | LLComboBox* combo = NULL; | ||
113 | |||
114 | btn = new LLButton("can't click", | ||
115 | LLRect(LEFT+150, y, LEFT+150+100, y-LINE), | ||
116 | NULL, // LLString converts to "" | ||
117 | onClickButton, this); | ||
118 | btn->setFollows(FOLLOWS_LEFT|FOLLOWS_TOP); | ||
119 | btn->setFont(LLFontGL::sSansSerifSmall); | ||
120 | addChild(btn); | ||
121 | |||
122 | text = new LLTextBox("simple_text", | ||
123 | "simple sans-serif text that is mouse opaque opaque opaque", | ||
124 | 50, // max_width | ||
125 | LLFontGL::sSansSerifSmall, | ||
126 | TRUE); // mouse_opaque | ||
127 | text->setClickedCallback(onClickText); | ||
128 | text->setRect(LLRect(LEFT, y, RIGHT, y-LINE)); | ||
129 | addChild(text); | ||
130 | |||
131 | y -= VPAD + LINE; | ||
132 | |||
133 | btn = new LLButton("can click", | ||
134 | LLRect(LEFT+150, y, LEFT+150+100, y-LINE), | ||
135 | NULL, // LLString converts to "" | ||
136 | onClickButton, this); | ||
137 | btn->setFollows(FOLLOWS_LEFT|FOLLOWS_TOP); | ||
138 | btn->setFont(LLFontGL::sSansSerifSmall); | ||
139 | addChild(btn); | ||
140 | |||
141 | text = new LLTextBox("simple2_text", | ||
142 | LLRect(LEFT, y, RIGHT, y-LINE), | ||
143 | "monospaced, non-opaque text with tooltip, non-opaque non-opaque", | ||
144 | LLFontGL::sMonospace, | ||
145 | FALSE); // mouse_opaque | ||
146 | text->setToolTip("I'm a tooltip"); | ||
147 | addChild(text); | ||
148 | |||
149 | y -= VPAD + LINE; | ||
150 | |||
151 | tab = new LLTabContainer("test_tab", | ||
152 | LLRect(LEFT, y, RIGHT, BOTTOM), | ||
153 | LLTabContainer::TOP, | ||
154 | onCloseTab, this, | ||
155 | "Tab Title", | ||
156 | TRUE); // bordered | ||
157 | addChild(tab); | ||
158 | mTab = tab; | ||
159 | |||
160 | //----------------------------------------------------------------------- | ||
161 | // First tab container panel | ||
162 | //----------------------------------------------------------------------- | ||
163 | panel = new LLPanel("first_tab_panel", | ||
164 | LLRect(0, 400, 400, 0), // dummy rect | ||
165 | TRUE); // bordered | ||
166 | tab->addTabPanel(panel, "First", | ||
167 | TRUE, // select | ||
168 | onClickTab, this); | ||
169 | |||
170 | y = panel->getRect().getHeight() - VPAD; | ||
171 | |||
172 | text = new LLTextBox("unicode_text", | ||
173 | LLRect(LEFT, y, RIGHT, y-LINE), | ||
174 | LLString("File"), | ||
175 | LLFontGL::sSansSerif, | ||
176 | TRUE); // mouse_opaque | ||
177 | text->setToolTip("This should be Unicode text"); | ||
178 | panel->addChild(text); | ||
179 | |||
180 | y -= VPAD + LINE; | ||
181 | |||
182 | btn = new LLButton("unicode_btn", LLRect(LEFT, y, LEFT+100, y-20)); | ||
183 | btn->setLabelUnselected("unicode"); | ||
184 | btn->setLabelSelected("unicode"); | ||
185 | panel->addChild(btn); | ||
186 | |||
187 | y -= VPAD + 20; | ||
188 | |||
189 | btn = new LLButton("image_btn", | ||
190 | LLRect(LEFT, y, LEFT+32, y-32), | ||
191 | "tool_zoom.tga", | ||
192 | "tool_zoom_active.tga", | ||
193 | "", // control_name, | ||
194 | onClickButton, this, | ||
195 | LLFontGL::sSansSerifSmall); | ||
196 | btn->setFollows(FOLLOWS_LEFT | FOLLOWS_TOP); | ||
197 | panel->addChild(btn); | ||
198 | |||
199 | y -= VPAD + 32; | ||
200 | |||
201 | check = new LLCheckBoxCtrl("simple_check", | ||
202 | LLRect(LEFT, y, LEFT+150, y-LLCHECKBOXCTRL_HEIGHT), | ||
203 | "Simple Checkbox", | ||
204 | LLFontGL::sSansSerifSmall, | ||
205 | onCommitCheck, this, | ||
206 | TRUE, // initial_value | ||
207 | FALSE, // radio_style | ||
208 | "UIFloaterTestBool"); // control_which | ||
209 | panel->addChild(check); | ||
210 | |||
211 | y -= VPAD + LLCHECKBOXCTRL_HEIGHT; | ||
212 | |||
213 | check = new LLCheckBoxCtrl("unicode_check", | ||
214 | LLRect(LEFT, y, LEFT+150, y-LLCHECKBOXCTRL_HEIGHT), | ||
215 | "TODO: Unicode Checkbox", | ||
216 | LLFontGL::sSansSerifSmall, | ||
217 | onCommitCheck, this, | ||
218 | TRUE, // initial_value | ||
219 | FALSE, // radio_style | ||
220 | ""); // control_which | ||
221 | panel->addChild(check); | ||
222 | mCheckUnicode = check; | ||
223 | |||
224 | y -= VPAD + LLCHECKBOXCTRL_HEIGHT; | ||
225 | |||
226 | combo = new LLComboBox("combo", | ||
227 | LLRect(LEFT, y, LEFT+100, y-LLCOMBOBOX_HEIGHT), | ||
228 | "Combobox Label", | ||
229 | onCommitCombo, this, | ||
230 | 150); // list_width | ||
231 | combo->add("first item"); | ||
232 | combo->add("second item"); | ||
233 | combo->add("should go to the top", ADD_TOP); | ||
234 | combo->add("disabled item", NULL, ADD_BOTTOM, FALSE); | ||
235 | panel->addChild(combo); | ||
236 | |||
237 | y -= VPAD + LLCOMBOBOX_HEIGHT; | ||
238 | |||
239 | LLIconCtrl* icon = new LLIconCtrl( | ||
240 | "test_icon", | ||
241 | LLRect(LEFT, y, LEFT+32, y-32), | ||
242 | "object_cone.tga" ); | ||
243 | panel->addChild(icon); | ||
244 | mIcon = icon; | ||
245 | |||
246 | y -= VPAD + 32; | ||
247 | |||
248 | LLLineEditor* line = new LLLineEditor( | ||
249 | "test_line", | ||
250 | LLRect(LEFT, y, LEFT+200, y-20), | ||
251 | "test some unicode text here", | ||
252 | LLFontGL::sSansSerif, | ||
253 | 200, // max_length_bytes | ||
254 | onCommitLine, | ||
255 | onKeyLine, | ||
256 | onFocusLostLine, | ||
257 | this, | ||
258 | NULL, // prevalidate func | ||
259 | LLViewBorder::BEVEL_IN, | ||
260 | LLViewBorder::STYLE_LINE, | ||
261 | 1); // border thickness | ||
262 | line->setHandleEditKeysDirectly(true); | ||
263 | panel->addChild(line); | ||
264 | |||
265 | y -= VPAD + 20; | ||
266 | |||
267 | LLRadioGroup* group = new LLRadioGroup( | ||
268 | "radio_group", | ||
269 | LLRect(LEFT, y, LEFT+200, y - 50), | ||
270 | 0, // initial_index | ||
271 | onChangeRadioGroup, this, | ||
272 | TRUE); // border | ||
273 | panel->addChild(group); | ||
274 | |||
275 | S32 yy = 100; | ||
276 | group->addRadioButton("Radio1", "Radio 1", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall); | ||
277 | yy -= LINE; | ||
278 | group->addRadioButton("Radio2", "Radio 2", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall); | ||
279 | yy -= LINE; | ||
280 | group->addRadioButton("Radio3", "Radio 3", LLRect(0, yy, 200, yy-LINE), LLFontGL::sSansSerifSmall); | ||
281 | yy -= LINE; | ||
282 | |||
283 | //----------------------------------------------------------------------- | ||
284 | // Second tab container panel | ||
285 | //----------------------------------------------------------------------- | ||
286 | panel = new LLPanel("second_tab_panel", | ||
287 | LLRect(0, 400, 400, 0), // dummy rect | ||
288 | TRUE); // bordered | ||
289 | tab->addTabPanel(panel, "Second", | ||
290 | FALSE, // select | ||
291 | onClickTab, this); | ||
292 | |||
293 | y = panel->getRect().getHeight() - VPAD; | ||
294 | |||
295 | btn = new LLButton("Simple Button", | ||
296 | LLRect(LEFT, y, LEFT+100, y - 20), | ||
297 | "", | ||
298 | onClickButton, this); | ||
299 | btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT); | ||
300 | panel->addChild(btn); | ||
301 | mBtnSimple = btn; | ||
302 | |||
303 | //----------------------------------------------------------------------- | ||
304 | // Hook us up with the floater view | ||
305 | //----------------------------------------------------------------------- | ||
306 | open(); | ||
307 | center(); | ||
308 | } | ||
309 | |||
310 | // static | ||
311 | void LLFloaterTestImpl::onClickButton(void*) | ||
312 | { | ||
313 | llinfos << "button clicked" << llendl; | ||
314 | } | ||
315 | |||
316 | // static | ||
317 | void LLFloaterTestImpl::onClickText(void*) | ||
318 | { | ||
319 | llinfos << "text clicked" << llendl; | ||
320 | } | ||
321 | |||
322 | // static | ||
323 | void LLFloaterTestImpl::onCloseTab(void*) | ||
324 | { | ||
325 | llinfos << "close tab" << llendl; | ||
326 | } | ||
327 | |||
328 | // static | ||
329 | void LLFloaterTestImpl::onClickTab(void*, bool) | ||
330 | { | ||
331 | llinfos << "click tab" << llendl; | ||
332 | } | ||
333 | |||
334 | // static | ||
335 | void LLFloaterTestImpl::onCommitCheck(LLUICtrl*, void*) | ||
336 | { | ||
337 | llinfos << "commit check" << llendl; | ||
338 | } | ||
339 | |||
340 | // static | ||
341 | void LLFloaterTestImpl::onCommitCombo(LLUICtrl* ctrl, void*) | ||
342 | { | ||
343 | LLComboBox* combo = (LLComboBox*)ctrl; | ||
344 | LLString name = combo->getSimple(); | ||
345 | LLSD value = combo->getValue(); | ||
346 | llinfos << "commit combo name " << name << " value " << value.asString() << llendl; | ||
347 | } | ||
348 | |||
349 | // static | ||
350 | void LLFloaterTestImpl::onCommitLine(LLUICtrl*, void*) | ||
351 | { | ||
352 | llinfos << "commit line editor" << llendl; | ||
353 | } | ||
354 | |||
355 | // static | ||
356 | void LLFloaterTestImpl::onKeyLine(LLLineEditor*, void*) | ||
357 | { | ||
358 | llinfos << "keystroke line editor" << llendl; | ||
359 | } | ||
360 | |||
361 | // static | ||
362 | void LLFloaterTestImpl::onFocusLostLine(LLLineEditor*, void*) | ||
363 | { | ||
364 | llinfos << "focus lost line editor" << llendl; | ||
365 | } | ||
366 | |||
367 | // static | ||
368 | void LLFloaterTestImpl::onChangeRadioGroup(LLUICtrl*, void*) | ||
369 | { | ||
370 | llinfos << "change radio group" << llendl; | ||
371 | } | ||
372 | |||
373 | //--------------------------------------------------------------------------- | ||
374 | |||
375 | // static | ||
376 | void LLFloaterTest::show(void*) | ||
377 | { | ||
378 | new LLFloaterTest(); | ||
379 | } | ||
380 | |||
381 | LLFloaterTest::LLFloaterTest() | ||
382 | : impl(* new LLFloaterTestImpl) | ||
383 | { | ||
384 | } | ||
385 | |||
386 | LLFloaterTest::~LLFloaterTest() | ||
387 | { | ||
388 | delete &impl; | ||
389 | } | ||