aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llfloater.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llfloater.h')
-rw-r--r--linden/indra/llui/llfloater.h172
1 files changed, 104 insertions, 68 deletions
diff --git a/linden/indra/llui/llfloater.h b/linden/indra/llui/llfloater.h
index 56b0e6e..534af16 100644
--- a/linden/indra/llui/llfloater.h
+++ b/linden/indra/llui/llfloater.h
@@ -112,8 +112,8 @@ public:
112 void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE); 112 void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE);
113 113
114 /*virtual*/ void userSetShape(const LLRect& new_rect); 114 /*virtual*/ void userSetShape(const LLRect& new_rect);
115 /*virtual*/ BOOL canSnapTo(LLView* other_view); 115 /*virtual*/ BOOL canSnapTo(const LLView* other_view);
116 /*virtual*/ void snappedTo(LLView* snap_view); 116 /*virtual*/ void snappedTo(const LLView* snap_view);
117 /*virtual*/ void setFocus( BOOL b ); 117 /*virtual*/ void setFocus( BOOL b );
118 /*virtual*/ void setIsChrome(BOOL is_chrome); 118 /*virtual*/ void setIsChrome(BOOL is_chrome);
119 119
@@ -122,16 +122,14 @@ public:
122 virtual void init(const LLString& title, BOOL resizable, 122 virtual void init(const LLString& title, BOOL resizable,
123 S32 min_width, S32 min_height, BOOL drag_on_left, 123 S32 min_width, S32 min_height, BOOL drag_on_left,
124 BOOL minimizable, BOOL close_btn); 124 BOOL minimizable, BOOL close_btn);
125 virtual EWidgetType getWidgetType() const; 125 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER; }
126 virtual LLString getWidgetTag() const; 126 virtual LLString getWidgetTag() const { return LL_FLOATER_TAG; };
127 127
128 virtual void open(); /* Flawfinder: ignore */ 128 virtual void open(); /* Flawfinder: ignore */
129 129
130 // If allowed, close the floater cleanly, releasing focus. 130 // If allowed, close the floater cleanly, releasing focus.
131 // app_quitting is passed to onClose() below. 131 // app_quitting is passed to onClose() below.
132 virtual void close(bool app_quitting = false); 132 virtual void close(bool app_quitting = false);
133
134 void setAutoFocus(BOOL focus) { mAutoFocus = focus; setFocus(focus); }
135 133
136 // Release keyboard and mouse focus 134 // Release keyboard and mouse focus
137 void releaseFocus(); 135 void releaseFocus();
@@ -142,18 +140,18 @@ public:
142 void applyRectControl(); 140 void applyRectControl();
143 141
144 142
145 LLMultiFloater* getHost() { return (LLMultiFloater*)LLFloater::getFloaterByHandle(mHostHandle); } 143 LLMultiFloater* getHost() { return (LLMultiFloater*)mHostHandle.get(); }
146 144
147 void setTitle( const LLString& title ); 145 void setTitle( const LLString& title );
148 const LLString& getTitle() const; 146 const LLString& getTitle() const;
149 void setShortTitle( const LLString& short_title ); 147 void setShortTitle( const LLString& short_title );
150 LLString getShortTitle(); 148 LLString getShortTitle();
151 virtual void setMinimized(BOOL b); 149 virtual void setMinimized(BOOL b);
152 void moveResizeHandlesToFront(); 150 void moveResizeHandlesToFront();
153 void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE); 151 void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE);
154 void addDependentFloater(LLViewHandle dependent_handle, BOOL reposition = TRUE); 152 void addDependentFloater(LLHandle<LLFloater> dependent_handle, BOOL reposition = TRUE);
155 LLFloater* getDependee() { return (LLFloater*)LLFloater::getFloaterByHandle(mDependeeHandle); } 153 LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); }
156 void removeDependentFloater(LLFloater* dependent); 154 void removeDependentFloater(LLFloater* dependent);
157 BOOL isMinimized() { return mMinimized; } 155 BOOL isMinimized() { return mMinimized; }
158 BOOL isFrontmost(); 156 BOOL isFrontmost();
159 BOOL isDependent() { return !mDependeeHandle.isDead(); } 157 BOOL isDependent() { return !mDependeeHandle.isDead(); }
@@ -167,10 +165,9 @@ public:
167 void setResizeLimits( S32 min_width, S32 min_height ); 165 void setResizeLimits( S32 min_width, S32 min_height );
168 void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; } 166 void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; }
169 167
170
171 bool isMinimizeable() const{ return mButtonsEnabled[BUTTON_MINIMIZE]; } 168 bool isMinimizeable() const{ return mButtonsEnabled[BUTTON_MINIMIZE]; }
172 // Does this window have a close button, NOT can we close it right now. 169 // Does this window have a close button, NOT can we close it right now.
173 bool isCloseable() const{ return (mButtonsEnabled[BUTTON_CLOSE] ? true : false); } 170 bool isCloseable() const{ return (mButtonsEnabled[BUTTON_CLOSE]); }
174 bool isDragOnLeft() const{ return mDragOnLeft; } 171 bool isDragOnLeft() const{ return mDragOnLeft; }
175 S32 getMinWidth() const{ return mMinWidth; } 172 S32 getMinWidth() const{ return mMinWidth; }
176 S32 getMinHeight() const{ return mMinHeight; } 173 S32 getMinHeight() const{ return mMinHeight; }
@@ -181,29 +178,28 @@ public:
181 178
182 virtual void draw(); 179 virtual void draw();
183 180
184 // does nothing by default 181 virtual void onOpen() {}
185 virtual void onOpen();
186 182
187 // Call destroy() to free memory, or setVisible(FALSE) to keep it 183 // Call destroy() to free memory, or setVisible(FALSE) to keep it
188 // If app_quitting, you might not want to save your visibility. 184 // If app_quitting, you might not want to save your visibility.
189 // Defaults to destroy(). 185 // Defaults to destroy().
190 virtual void onClose(bool app_quitting); 186 virtual void onClose(bool app_quitting) { destroy(); }
191 187
192 // Defaults to true. 188 virtual BOOL canClose() { return TRUE; }
193 virtual BOOL canClose();
194 189
195 virtual void setVisible(BOOL visible); 190 virtual void setVisible(BOOL visible);
196 void setFrontmost(BOOL take_focus = TRUE); 191 void setFrontmost(BOOL take_focus = TRUE);
197 192
198 // Defaults to false. 193 // Defaults to false.
199 virtual BOOL canSaveAs(); 194 virtual BOOL canSaveAs() const { return FALSE; }
200 195
201 // Defaults to no-op. 196 virtual void saveAs() {}
202 virtual void saveAs();
203 197
204 void setSnapTarget(LLViewHandle handle) { mSnappedTo = handle; } 198 void setSnapTarget(LLHandle<LLFloater> handle) { mSnappedTo = handle; }
205 void clearSnapTarget() { mSnappedTo.markDead(); } 199 void clearSnapTarget() { mSnappedTo.markDead(); }
206 LLViewHandle getSnapTarget() { return mSnappedTo; } 200 LLHandle<LLFloater> getSnapTarget() { return mSnappedTo; }
201
202 LLHandle<LLFloater> getHandle() { return mHandle; }
207 203
208 static void closeFocusedFloater(); 204 static void closeFocusedFloater();
209 205
@@ -214,39 +210,39 @@ public:
214 210
215 static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; } 211 static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; }
216 static void setEditModeEnabled(BOOL enable); 212 static void setEditModeEnabled(BOOL enable);
217 static BOOL getEditModeEnabled(); 213 static BOOL getEditModeEnabled() { return sEditModeEnabled; }
218 static LLMultiFloater* getFloaterHost() {return sHostp; } 214 static LLMultiFloater* getFloaterHost() {return sHostp; }
219 215
220 static void show(LLFloater* floaterp);
221 static void hide(LLFloater* floaterp);
222 static BOOL visible(LLFloater* floaterp);
223
224 static LLFloater* getFloaterByHandle(LLViewHandle handle);
225
226protected: 216protected:
227 // Don't call this directly. You probably want to call close(). JC 217
228 void destroy();
229 virtual void bringToFront(S32 x, S32 y); 218 virtual void bringToFront(S32 x, S32 y);
230 virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE); 219 virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE);
220
221 void setExpandedRect(const LLRect& rect) { mExpandedRect = rect; } // size when not minimized
222 const LLRect& getExpandedRect() const { return mExpandedRect; }
223
224 void setAutoFocus(BOOL focus) { mAutoFocus = focus; } // whether to automatically take focus when opened
225 LLDragHandle* getDragHandle() const { return mDragHandle; }
226
227 void destroy() { die(); } // Don't call this directly. You probably want to call close(). JC
228
229private:
230
231 void setForeground(BOOL b); // called only by floaterview 231 void setForeground(BOOL b); // called only by floaterview
232 void cleanupHandles(); // remove handles to dead floaters 232 void cleanupHandles(); // remove handles to dead floaters
233 void createMinimizeButton(); 233 void createMinimizeButton();
234 void updateButtons(); 234 void updateButtons();
235 void buildButtons(); 235 void buildButtons();
236 236
237protected: 237 LLRect mExpandedRect;
238// static LLViewerImage* sBackgroundImage;
239// static LLViewerImage* sShadowImage;
240
241 LLDragHandle* mDragHandle; 238 LLDragHandle* mDragHandle;
242 LLResizeBar* mResizeBar[4]; 239 LLResizeBar* mResizeBar[4];
243 LLResizeHandle* mResizeHandle[4]; 240 LLResizeHandle* mResizeHandle[4];
244 LLButton *mMinimizeButton; 241 LLButton *mMinimizeButton;
245 BOOL mCanTearOff; 242 BOOL mCanTearOff;
246 BOOL mMinimized; 243 BOOL mMinimized;
247 LLRect mPreviousRect;
248 BOOL mForeground; 244 BOOL mForeground;
249 LLViewHandle mDependeeHandle; 245 LLHandle<LLFloater> mDependeeHandle;
250 LLString mShortTitle; 246 LLString mShortTitle;
251 247
252 BOOL mFirstLook; // TRUE if the _next_ time this floater is visible will be the first time in the session that it is visible. 248 BOOL mFirstLook; // TRUE if the _next_ time this floater is visible will be the first time in the session that it is visible.
@@ -255,25 +251,24 @@ protected:
255 S32 mMinWidth; 251 S32 mMinWidth;
256 S32 mMinHeight; 252 S32 mMinHeight;
257 253
258 BOOL mAutoFocus;
259 BOOL mEditing; 254 BOOL mEditing;
260 255
261 typedef std::set<LLViewHandle> handle_set_t; 256 typedef std::set<LLHandle<LLFloater> > handle_set_t;
262 typedef std::set<LLViewHandle>::iterator handle_set_iter_t; 257 typedef std::set<LLHandle<LLFloater> >::iterator handle_set_iter_t;
263 handle_set_t mDependents; 258 handle_set_t mDependents;
264 bool mDragOnLeft; 259 bool mDragOnLeft;
265 260
266 BOOL mButtonsEnabled[BUTTON_COUNT]; 261 BOOL mButtonsEnabled[BUTTON_COUNT];
267 LLButton* mButtons[BUTTON_COUNT]; 262 LLButton* mButtons[BUTTON_COUNT];
268 F32 mButtonScale; 263 F32 mButtonScale;
269 264 BOOL mAutoFocus;
270 LLViewHandle mSnappedTo; 265 LLHandle<LLFloater> mSnappedTo;
271 266
272 LLViewHandle mHostHandle; 267 LLHandle<LLFloater> mHostHandle;
273 LLViewHandle mLastHostHandle; 268 LLHandle<LLFloater> mLastHostHandle;
274 269
275 static BOOL sEditModeEnabled;
276 static LLMultiFloater* sHostp; 270 static LLMultiFloater* sHostp;
271 static BOOL sEditModeEnabled;
277 static LLString sButtonActiveImageNames[BUTTON_COUNT]; 272 static LLString sButtonActiveImageNames[BUTTON_COUNT];
278 static LLString sButtonInactiveImageNames[BUTTON_COUNT]; 273 static LLString sButtonInactiveImageNames[BUTTON_COUNT];
279 static LLString sButtonPressedImageNames[BUTTON_COUNT]; 274 static LLString sButtonPressedImageNames[BUTTON_COUNT];
@@ -282,15 +277,18 @@ protected:
282 typedef void (*click_callback)(void *); 277 typedef void (*click_callback)(void *);
283 static click_callback sButtonCallbacks[BUTTON_COUNT]; 278 static click_callback sButtonCallbacks[BUTTON_COUNT];
284 279
285 typedef std::map<LLViewHandle, LLFloater*> handle_map_t; 280 typedef std::map<LLHandle<LLFloater>, LLFloater*> handle_map_t;
286 typedef std::map<LLViewHandle, LLFloater*>::iterator handle_map_iter_t; 281 typedef std::map<LLHandle<LLFloater>, LLFloater*>::iterator handle_map_iter_t;
287 static handle_map_t sFloaterMap; 282 static handle_map_t sFloaterMap;
288 283
289 std::vector<LLViewHandle> mMinimizedHiddenChildren; 284 std::vector<LLHandle<LLView> > mMinimizedHiddenChildren;
290 285
291 BOOL mHasBeenDraggedWhileMinimized; 286 BOOL mHasBeenDraggedWhileMinimized;
292 S32 mPreviousMinimizedBottom; 287 S32 mPreviousMinimizedBottom;
293 S32 mPreviousMinimizedLeft; 288 S32 mPreviousMinimizedLeft;
289
290private:
291 LLRootHandle<LLFloater> mHandle;
294}; 292};
295 293
296///////////////////////////////////////////////////////////// 294/////////////////////////////////////////////////////////////
@@ -302,14 +300,14 @@ class LLFloaterView : public LLUICtrl
302public: 300public:
303 LLFloaterView( const LLString& name, const LLRect& rect ); 301 LLFloaterView( const LLString& name, const LLRect& rect );
304 302
305 virtual EWidgetType getWidgetType() const; 303 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER_VIEW; }
306 virtual LLString getWidgetTag() const; 304 virtual LLString getWidgetTag() const { return LL_FLOATER_VIEW_TAG; }
307 305
308 /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); 306 /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
309 void reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); 307 void reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical);
310 308
311 /*virtual*/ void draw(); 309 /*virtual*/ void draw();
312 /*virtual*/ const LLRect getSnapRect() const; 310 /*virtual*/ LLRect getSnapRect() const;
313 void refresh(); 311 void refresh();
314 312
315 void getNewFloaterPosition( S32* left, S32* top ); 313 void getNewFloaterPosition( S32* left, S32* top );
@@ -325,8 +323,8 @@ public:
325 void pushVisibleAll(BOOL visible, const skip_list_t& skip_list = skip_list_t()); 323 void pushVisibleAll(BOOL visible, const skip_list_t& skip_list = skip_list_t());
326 void popVisibleAll(const skip_list_t& skip_list = skip_list_t()); 324 void popVisibleAll(const skip_list_t& skip_list = skip_list_t());
327 325
328 void setCycleMode(BOOL mode); 326 void setCycleMode(BOOL mode) { mFocusCycleMode = mode; }
329 BOOL getCycleMode(); 327 BOOL getCycleMode() const { return mFocusCycleMode; }
330 void bringToFront( LLFloater* child, BOOL give_focus = TRUE ); 328 void bringToFront( LLFloater* child, BOOL give_focus = TRUE );
331 void highlightFocusedFloater(); 329 void highlightFocusedFloater();
332 void unhighlightFocusedFloater(); 330 void unhighlightFocusedFloater();
@@ -342,10 +340,6 @@ public:
342 LLFloater* getFocusedFloater(); 340 LLFloater* getFocusedFloater();
343 void syncFloaterTabOrder(); 341 void syncFloaterTabOrder();
344 342
345 // Get a floater based the handle. If this returns NULL, it is up
346 // to the caller to discard the handle.
347 LLFloater* getFloaterByHandle(LLViewHandle handle);
348
349 // Returns z order of child provided. 0 is closest, larger numbers 343 // Returns z order of child provided. 0 is closest, larger numbers
350 // are deeper in the screen. If there is no such child, the return 344 // are deeper in the screen. If there is no such child, the return
351 // value is not defined. 345 // value is not defined.
@@ -361,15 +355,16 @@ private:
361 S32 mSnapOffsetBottom; 355 S32 mSnapOffsetBottom;
362}; 356};
363 357
358// https://wiki.lindenlab.com/mediawiki/index.php?title=LLMultiFloater&oldid=81376
364class LLMultiFloater : public LLFloater 359class LLMultiFloater : public LLFloater
365{ 360{
366public: 361public:
367 LLMultiFloater(); 362 LLMultiFloater();
368 LLMultiFloater(LLTabContainerCommon::TabPosition tab_pos); 363 LLMultiFloater(LLTabContainer::TabPosition tab_pos);
369 LLMultiFloater(const LLString& name); 364 LLMultiFloater(const LLString& name);
370 LLMultiFloater(const LLString& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); 365 LLMultiFloater(const LLString& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE);
371 LLMultiFloater(const LLString& name, const LLString& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); 366 LLMultiFloater(const LLString& name, const LLString& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE);
372 virtual ~LLMultiFloater(); 367 virtual ~LLMultiFloater() {};
373 368
374 virtual BOOL postBuild(); 369 virtual BOOL postBuild();
375 /*virtual*/ void open(); /* Flawfinder: ignore */ 370 /*virtual*/ void open(); /* Flawfinder: ignore */
@@ -377,12 +372,12 @@ public:
377 /*virtual*/ void draw(); 372 /*virtual*/ void draw();
378 /*virtual*/ void setVisible(BOOL visible); 373 /*virtual*/ void setVisible(BOOL visible);
379 /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); 374 /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
380 /*virtual*/ EWidgetType getWidgetType() const; 375 /*virtual*/ EWidgetType getWidgetType() const { return WIDGET_TYPE_MULTI_FLOATER; }
381 /*virtual*/ LLString getWidgetTag() const; 376 /*virtual*/ LLString getWidgetTag() const { return LL_MULTI_FLOATER_TAG; };
382 377
383 virtual void setCanResize(BOOL can_resize); 378 virtual void setCanResize(BOOL can_resize);
384 virtual void growToFit(S32 content_width, S32 content_height); 379 virtual void growToFit(S32 content_width, S32 content_height);
385 virtual void addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainerCommon::eInsertionPoint insertion_point = LLTabContainerCommon::END); 380 virtual void addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END);
386 381
387 virtual void showFloater(LLFloater* floaterp); 382 virtual void showFloater(LLFloater* floaterp);
388 virtual void removeFloater(LLFloater* floaterp); 383 virtual void removeFloater(LLFloater* floaterp);
@@ -400,7 +395,7 @@ public:
400 395
401 virtual void setFloaterFlashing(LLFloater* floaterp, BOOL flashing); 396 virtual void setFloaterFlashing(LLFloater* floaterp, BOOL flashing);
402 virtual BOOL closeAllFloaters(); //Returns FALSE if the floater could not be closed due to pending confirmation dialogs 397 virtual BOOL closeAllFloaters(); //Returns FALSE if the floater could not be closed due to pending confirmation dialogs
403 void setTabContainer(LLTabContainerCommon* tab_container) { if (!mTabContainer) mTabContainer = tab_container; } 398 void setTabContainer(LLTabContainer* tab_container) { if (!mTabContainer) mTabContainer = tab_container; }
404 static void onTabSelected(void* userdata, bool); 399 static void onTabSelected(void* userdata, bool);
405 400
406 virtual void updateResizeLimits(); 401 virtual void updateResizeLimits();
@@ -414,15 +409,56 @@ protected:
414 BOOL mCanResize; 409 BOOL mCanResize;
415 }; 410 };
416 411
417 LLTabContainerCommon* mTabContainer; 412 LLTabContainer* mTabContainer;
418 413
419 typedef std::map<LLViewHandle, LLFloaterData> floater_data_map_t; 414 typedef std::map<LLHandle<LLFloater>, LLFloaterData> floater_data_map_t;
420 floater_data_map_t mFloaterDataMap; 415 floater_data_map_t mFloaterDataMap;
421 416
422 LLTabContainerCommon::TabPosition mTabPos; 417 LLTabContainer::TabPosition mTabPos;
423 BOOL mAutoResize; 418 BOOL mAutoResize;
424}; 419};
425 420
421// visibility policy specialized for floaters
422template<>
423class VisibilityPolicy<LLFloater>
424{
425public:
426 // visibility methods
427 static bool visible(LLFloater* instance, const LLSD& key)
428 {
429 if (instance)
430 {
431 return !instance->isMinimized() && instance->isInVisibleChain();
432 }
433 return FALSE;
434 }
435
436 static void show(LLFloater* instance, const LLSD& key)
437 {
438 if (instance)
439 {
440 instance->open();
441 if (instance->getHost())
442 {
443 instance->getHost()->open();
444 }
445 }
446 }
447
448 static void hide(LLFloater* instance, const LLSD& key)
449 {
450 if (instance) instance->close();
451 }
452};
453
454
455// singleton implementation for floaters (provides visibility policy)
456// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=79410
457
458template <class T> class LLFloaterSingleton : public LLUISingleton<T, VisibilityPolicy<LLFloater> >
459{
460};
461
426 462
427extern LLFloaterView* gFloaterView; 463extern LLFloaterView* gFloaterView;
428 464