diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/llfloater.h | 418 |
1 files changed, 418 insertions, 0 deletions
diff --git a/linden/indra/llui/llfloater.h b/linden/indra/llui/llfloater.h new file mode 100644 index 0000000..4826648 --- /dev/null +++ b/linden/indra/llui/llfloater.h | |||
@@ -0,0 +1,418 @@ | |||
1 | /** | ||
2 | * @file llfloater.h | ||
3 | * @brief LLFloater base class | ||
4 | * | ||
5 | * Copyright (c) 2002-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 | // Floating "windows" within the GL display, like the inventory floater, | ||
29 | // mini-map floater, etc. | ||
30 | |||
31 | |||
32 | #ifndef LL_FLOATER_H | ||
33 | #define LL_FLOATER_H | ||
34 | |||
35 | #include "llpanel.h" | ||
36 | #include "lluuid.h" | ||
37 | #include "lltabcontainer.h" | ||
38 | #include <set> | ||
39 | |||
40 | class LLDragHandle; | ||
41 | class LLResizeHandle; | ||
42 | class LLResizeBar; | ||
43 | class LLButton; | ||
44 | class LLMultiFloater; | ||
45 | |||
46 | const S32 LLFLOATER_VPAD = 6; | ||
47 | const S32 LLFLOATER_HPAD = 6; | ||
48 | const S32 LLFLOATER_CLOSE_BOX_SIZE = 16; | ||
49 | const S32 LLFLOATER_HEADER_SIZE = 16; | ||
50 | |||
51 | const BOOL RESIZE_YES = TRUE; | ||
52 | const BOOL RESIZE_NO = FALSE; | ||
53 | |||
54 | const S32 DEFAULT_MIN_WIDTH = 100; | ||
55 | const S32 DEFAULT_MIN_HEIGHT = 100; | ||
56 | |||
57 | const BOOL DRAG_ON_TOP = FALSE; | ||
58 | const BOOL DRAG_ON_LEFT = TRUE; | ||
59 | |||
60 | const BOOL MINIMIZE_YES = TRUE; | ||
61 | const BOOL MINIMIZE_NO = FALSE; | ||
62 | |||
63 | const BOOL CLOSE_YES = TRUE; | ||
64 | const BOOL CLOSE_NO = FALSE; | ||
65 | |||
66 | const BOOL ADJUST_VERTICAL_YES = TRUE; | ||
67 | const BOOL ADJUST_VERTICAL_NO = FALSE; | ||
68 | |||
69 | |||
70 | class LLFloater : public LLPanel | ||
71 | { | ||
72 | friend class LLFloaterView; | ||
73 | public: | ||
74 | enum EFloaterButtons | ||
75 | { | ||
76 | BUTTON_CLOSE, | ||
77 | BUTTON_RESTORE, | ||
78 | BUTTON_MINIMIZE, | ||
79 | BUTTON_TEAR_OFF, | ||
80 | BUTTON_EDIT, | ||
81 | BUTTON_COUNT | ||
82 | }; | ||
83 | |||
84 | LLFloater(); | ||
85 | LLFloater(const LLString& name); //simple constructor for data-driven initialization | ||
86 | LLFloater( const LLString& name, const LLRect& rect, const LLString& title, | ||
87 | BOOL resizable = FALSE, | ||
88 | S32 min_width = DEFAULT_MIN_WIDTH, | ||
89 | S32 min_height = DEFAULT_MIN_HEIGHT, | ||
90 | BOOL drag_on_left = FALSE, | ||
91 | BOOL minimizable = TRUE, | ||
92 | BOOL close_btn = TRUE, | ||
93 | BOOL bordered = BORDER_NO); | ||
94 | |||
95 | LLFloater( const LLString& name, const LLString& rect_control, const LLString& title, | ||
96 | BOOL resizable = FALSE, | ||
97 | S32 min_width = DEFAULT_MIN_WIDTH, | ||
98 | S32 min_height = DEFAULT_MIN_HEIGHT, | ||
99 | BOOL drag_on_left = FALSE, | ||
100 | BOOL minimizable = TRUE, | ||
101 | BOOL close_btn = TRUE, | ||
102 | BOOL bordered = BORDER_NO); | ||
103 | |||
104 | virtual ~LLFloater(); | ||
105 | |||
106 | virtual LLXMLNodePtr getXML(bool save_children = true) const; | ||
107 | static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); | ||
108 | void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE); | ||
109 | |||
110 | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = 1); | ||
111 | /*virtual*/ void translate(S32 x, S32 y); | ||
112 | /*virtual*/ BOOL canSnapTo(LLView* other_view); | ||
113 | /*virtual*/ void snappedTo(LLView* snap_view); | ||
114 | /*virtual*/ void setFocus( BOOL b ); | ||
115 | /*virtual*/ void setIsChrome(BOOL is_chrome); | ||
116 | |||
117 | // Can be called multiple times to reset floater parameters. | ||
118 | // Deletes all children of the floater. | ||
119 | virtual void init(const LLString& title, BOOL resizable, | ||
120 | S32 min_width, S32 min_height, BOOL drag_on_left, | ||
121 | BOOL minimizable, BOOL close_btn); | ||
122 | virtual EWidgetType getWidgetType() const; | ||
123 | virtual LLString getWidgetTag() const; | ||
124 | |||
125 | virtual void open(); | ||
126 | |||
127 | // If allowed, close the floater cleanly, releasing focus. | ||
128 | // app_quitting is passed to onClose() below. | ||
129 | virtual void close(bool app_quitting = false); | ||
130 | |||
131 | void setAutoFocus(BOOL focus) { mAutoFocus = focus; setFocus(focus); } | ||
132 | |||
133 | // Release keyboard and mouse focus | ||
134 | void releaseFocus(); | ||
135 | |||
136 | // moves to center of gFloaterView | ||
137 | void center(); | ||
138 | // applies rectangle stored in mRectControl, if any | ||
139 | void applyRectControl(); | ||
140 | |||
141 | |||
142 | LLMultiFloater* getHost() { return (LLMultiFloater*)LLFloater::getFloaterByHandle(mHostHandle); } | ||
143 | |||
144 | void setTitle( const LLString& title ); | ||
145 | const LLString& getTitle() const; | ||
146 | virtual void setMinimized(BOOL b); | ||
147 | void moveResizeHandleToFront(); | ||
148 | void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE); | ||
149 | void addDependentFloater(LLViewHandle dependent_handle, BOOL reposition = TRUE); | ||
150 | LLFloater* getDependee() { return (LLFloater*)LLFloater::getFloaterByHandle(mDependeeHandle); } | ||
151 | void removeDependentFloater(LLFloater* dependent); | ||
152 | BOOL isMinimized() { return mMinimized; } | ||
153 | BOOL isFrontmost(); | ||
154 | BOOL isDependent() { return !mDependeeHandle.isDead(); } | ||
155 | void setCanMinimize(BOOL can_minimize); | ||
156 | void setCanClose(BOOL can_close); | ||
157 | void setCanTearOff(BOOL can_tear_off); | ||
158 | virtual void setCanResize(BOOL can_resize); | ||
159 | void setCanDrag(BOOL can_drag); | ||
160 | void setHost(LLMultiFloater* host); | ||
161 | BOOL isResizable() const { return mResizable; } | ||
162 | void setResizeLimits( S32 min_width, S32 min_height ); | ||
163 | void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; } | ||
164 | |||
165 | |||
166 | bool isMinimizeable() const{ return mButtonsEnabled[BUTTON_MINIMIZE]; } | ||
167 | // Does this window have a close button, NOT can we close it right now. | ||
168 | bool isCloseable() const{ return (mButtonsEnabled[BUTTON_CLOSE] ? true : false); } | ||
169 | bool isDragOnLeft() const{ return mDragOnLeft; } | ||
170 | S32 getMinWidth() const{ return mMinWidth; } | ||
171 | S32 getMinHeight() const{ return mMinHeight; } | ||
172 | |||
173 | virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); | ||
174 | virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); | ||
175 | virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); | ||
176 | |||
177 | virtual void draw(); | ||
178 | |||
179 | // Call destroy() to free memory, or setVisible(FALSE) to keep it | ||
180 | // If app_quitting, you might not want to save your visibility. | ||
181 | // Defaults to destroy(). | ||
182 | virtual void onClose(bool app_quitting); | ||
183 | |||
184 | // Defaults to true. | ||
185 | virtual BOOL canClose(); | ||
186 | |||
187 | virtual void setVisible(BOOL visible); | ||
188 | void setFrontmost(BOOL take_focus = TRUE); | ||
189 | |||
190 | // Defaults to false. | ||
191 | virtual BOOL canSaveAs(); | ||
192 | |||
193 | // Defaults to no-op. | ||
194 | virtual void saveAs(); | ||
195 | |||
196 | void setSnapTarget(LLViewHandle handle) { mSnappedTo = handle; } | ||
197 | void clearSnapTarget() { mSnappedTo.markDead(); } | ||
198 | LLViewHandle getSnapTarget() { return mSnappedTo; } | ||
199 | |||
200 | /*virtual*/ LLView* getRootMostFastFrameView(); | ||
201 | |||
202 | static void closeByMenu(void *userdata); | ||
203 | static void onClickClose(void *userdata); | ||
204 | static void onClickMinimize(void *userdata); | ||
205 | static void onClickTearOff(void *userdata); | ||
206 | static void onClickEdit(void *userdata); | ||
207 | |||
208 | static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; } | ||
209 | static void setEditModeEnabled(BOOL enable); | ||
210 | static BOOL getEditModeEnabled(); | ||
211 | static LLMultiFloater* getFloaterHost() {return sHostp; } | ||
212 | |||
213 | static LLFloater* getFloaterByHandle(LLViewHandle handle); | ||
214 | |||
215 | protected: | ||
216 | // Don't call this directly. You probably want to call close(). JC | ||
217 | void destroy(); | ||
218 | virtual void bringToFront(S32 x, S32 y); | ||
219 | virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE); | ||
220 | void setForeground(BOOL b); // called only by floaterview | ||
221 | void cleanupHandles(); // remove handles to dead floaters | ||
222 | void createMinimizeButton(); | ||
223 | void updateButtons(); | ||
224 | void buildButtons(); | ||
225 | |||
226 | protected: | ||
227 | // static LLViewerImage* sBackgroundImage; | ||
228 | // static LLViewerImage* sShadowImage; | ||
229 | |||
230 | LLDragHandle* mDragHandle; | ||
231 | LLResizeBar* mResizeBar[4]; | ||
232 | LLResizeHandle* mResizeHandle[4]; | ||
233 | LLButton *mMinimizeButton; | ||
234 | BOOL mCanTearOff; | ||
235 | BOOL mMinimized; | ||
236 | LLRect mPreviousRect; | ||
237 | BOOL mForeground; | ||
238 | LLViewHandle mDependeeHandle; | ||
239 | |||
240 | BOOL mFirstLook; // TRUE if the _next_ time this floater is visible will be the first time in the session that it is visible. | ||
241 | |||
242 | BOOL mResizable; | ||
243 | S32 mMinWidth; | ||
244 | S32 mMinHeight; | ||
245 | |||
246 | BOOL mAutoFocus; | ||
247 | BOOL mEditing; | ||
248 | |||
249 | typedef std::set<LLViewHandle> handle_set_t; | ||
250 | typedef std::set<LLViewHandle>::iterator handle_set_iter_t; | ||
251 | handle_set_t mDependents; | ||
252 | bool mDragOnLeft; | ||
253 | |||
254 | BOOL mButtonsEnabled[BUTTON_COUNT]; | ||
255 | LLButton* mButtons[BUTTON_COUNT]; | ||
256 | F32 mButtonScale; | ||
257 | |||
258 | LLViewHandle mSnappedTo; | ||
259 | |||
260 | LLViewHandle mHostHandle; | ||
261 | LLViewHandle mLastHostHandle; | ||
262 | |||
263 | static BOOL sEditModeEnabled; | ||
264 | static LLMultiFloater* sHostp; | ||
265 | static LLString sButtonActiveImageNames[BUTTON_COUNT]; | ||
266 | static LLString sButtonInactiveImageNames[BUTTON_COUNT]; | ||
267 | static LLString sButtonPressedImageNames[BUTTON_COUNT]; | ||
268 | static LLString sButtonNames[BUTTON_COUNT]; | ||
269 | static LLString sButtonToolTips[BUTTON_COUNT]; | ||
270 | typedef void (*click_callback)(void *); | ||
271 | static click_callback sButtonCallbacks[BUTTON_COUNT]; | ||
272 | |||
273 | typedef std::map<LLViewHandle, LLFloater*> handle_map_t; | ||
274 | typedef std::map<LLViewHandle, LLFloater*>::iterator handle_map_iter_t; | ||
275 | static handle_map_t sFloaterMap; | ||
276 | |||
277 | std::vector<LLView*> mMinimizedHiddenChildren; | ||
278 | }; | ||
279 | |||
280 | |||
281 | ///////////////////////////////////////////////////////////// | ||
282 | // LLFloaterView | ||
283 | // Parent of all floating panels | ||
284 | |||
285 | class LLFloaterView : public LLUICtrl | ||
286 | { | ||
287 | public: | ||
288 | LLFloaterView( const LLString& name, const LLRect& rect ); | ||
289 | |||
290 | virtual EWidgetType getWidgetType() const; | ||
291 | virtual LLString getWidgetTag() const; | ||
292 | |||
293 | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); | ||
294 | void reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); | ||
295 | |||
296 | /*virtual*/ void draw(); | ||
297 | /*virtual*/ const LLRect getSnapRect() const; | ||
298 | void refresh(); | ||
299 | |||
300 | void getNewFloaterPosition( S32* left, S32* top ); | ||
301 | void resetStartingFloaterPosition(); | ||
302 | LLRect findNeighboringPosition( LLFloater* reference_floater, LLFloater* neighbor ); | ||
303 | |||
304 | // Given a child of gFloaterView, make sure this view can fit entirely onscreen. | ||
305 | void adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside); | ||
306 | |||
307 | void getMinimizePosition( S32 *left, S32 *bottom); | ||
308 | void restoreAll(); // un-minimize all floaters | ||
309 | typedef std::set<LLView*> skip_list_t; | ||
310 | void pushVisibleAll(BOOL visible, const skip_list_t& skip_list = skip_list_t()); | ||
311 | void popVisibleAll(const skip_list_t& skip_list = skip_list_t()); | ||
312 | |||
313 | void setCycleMode(BOOL mode); | ||
314 | BOOL getCycleMode(); | ||
315 | void bringToFront( LLFloater* child, BOOL give_focus = TRUE ); | ||
316 | void highlightFocusedFloater(); | ||
317 | void unhighlightFocusedFloater(); | ||
318 | void focusFrontFloater(); | ||
319 | void destroyAllChildren(); | ||
320 | // attempt to close all floaters | ||
321 | void closeAllChildren(bool app_quitting); | ||
322 | BOOL allChildrenClosed(); | ||
323 | |||
324 | LLFloater* getFrontmost(); | ||
325 | LLFloater* getBackmost(); | ||
326 | LLFloater* getParentFloater(LLView* viewp); | ||
327 | LLFloater* getFocusedFloater(); | ||
328 | void syncFloaterTabOrder(); | ||
329 | |||
330 | // Get a floater based the handle. If this returns NULL, it is up | ||
331 | // to the caller to discard the handle. | ||
332 | LLFloater* getFloaterByHandle(LLViewHandle handle); | ||
333 | |||
334 | // Returns z order of child provided. 0 is closest, larger numbers | ||
335 | // are deeper in the screen. If there is no such child, the return | ||
336 | // value is not defined. | ||
337 | S32 getZOrder(LLFloater* child); | ||
338 | |||
339 | void setSnapOffsetBottom(S32 offset) { mSnapOffsetBottom = offset; } | ||
340 | |||
341 | private: | ||
342 | S32 mColumn; | ||
343 | S32 mNextLeft; | ||
344 | S32 mNextTop; | ||
345 | BOOL mFocusCycleMode; | ||
346 | S32 mSnapOffsetBottom; | ||
347 | }; | ||
348 | |||
349 | class LLMultiFloater : public LLFloater | ||
350 | { | ||
351 | public: | ||
352 | LLMultiFloater(); | ||
353 | LLMultiFloater(LLTabContainerCommon::TabPosition tab_pos); | ||
354 | LLMultiFloater(const LLString& name); | ||
355 | LLMultiFloater(const LLString& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = FALSE); | ||
356 | LLMultiFloater(const LLString& name, const LLString& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = FALSE); | ||
357 | virtual ~LLMultiFloater(); | ||
358 | |||
359 | virtual void init(const LLString& title, BOOL resizable, | ||
360 | S32 min_width, S32 min_height, BOOL drag_on_left, | ||
361 | BOOL minimizable, BOOL close_btn); | ||
362 | |||
363 | virtual BOOL postBuild(); | ||
364 | /*virtual*/ void open(); | ||
365 | /*virtual*/ void onClose(bool app_quitting); | ||
366 | /*virtual*/ void draw(); | ||
367 | /*virtual*/ void setVisible(BOOL visible); | ||
368 | /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); | ||
369 | |||
370 | /*virtual*/ EWidgetType getWidgetType() const; | ||
371 | /*virtual*/ LLString getWidgetTag() const; | ||
372 | |||
373 | virtual void setCanResize(BOOL can_resize); | ||
374 | virtual void growToFit(LLFloater* floaterp, S32 width, S32 height); | ||
375 | virtual void addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainerCommon::eInsertionPoint insertion_point = LLTabContainerCommon::END); | ||
376 | |||
377 | virtual void showFloater(LLFloater* floaterp); | ||
378 | virtual void removeFloater(LLFloater* floaterp); | ||
379 | |||
380 | virtual void tabOpen(LLFloater* opened_floater, bool from_click); | ||
381 | virtual void tabClose(); | ||
382 | |||
383 | virtual BOOL selectFloater(LLFloater* floaterp); | ||
384 | virtual void selectNextFloater(); | ||
385 | virtual void selectPrevFloater(); | ||
386 | |||
387 | virtual LLFloater* getActiveFloater(); | ||
388 | virtual BOOL isFloaterFlashing(LLFloater* floaterp); | ||
389 | virtual S32 getFloaterCount(); | ||
390 | |||
391 | virtual void setFloaterFlashing(LLFloater* floaterp, BOOL flashing); | ||
392 | virtual BOOL closeAllFloaters(); //Returns FALSE if the floater could not be closed due to pending confirmation dialogs | ||
393 | void setTabContainer(LLTabContainerCommon* tab_container) { if (!mTabContainer) mTabContainer = tab_container; } | ||
394 | static void onTabSelected(void* userdata, bool); | ||
395 | |||
396 | protected: | ||
397 | struct LLFloaterData | ||
398 | { | ||
399 | S32 mWidth; | ||
400 | S32 mHeight; | ||
401 | BOOL mCanMinimize; | ||
402 | BOOL mCanResize; | ||
403 | }; | ||
404 | |||
405 | LLTabContainerCommon* mTabContainer; | ||
406 | |||
407 | typedef std::map<LLViewHandle, LLFloaterData> floater_data_map_t; | ||
408 | floater_data_map_t mFloaterDataMap; | ||
409 | |||
410 | LLTabContainerCommon::TabPosition mTabPos; | ||
411 | BOOL mAutoResize; | ||
412 | }; | ||
413 | |||
414 | |||
415 | extern LLFloaterView* gFloaterView; | ||
416 | |||
417 | #endif // LL_FLOATER_H | ||
418 | |||