aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llmenugl.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/llmenugl.h
parentREADME.txt (diff)
downloadmeta-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/llui/llmenugl.h')
-rw-r--r--linden/indra/llui/llmenugl.h774
1 files changed, 774 insertions, 0 deletions
diff --git a/linden/indra/llui/llmenugl.h b/linden/indra/llui/llmenugl.h
new file mode 100644
index 0000000..77e2b31
--- /dev/null
+++ b/linden/indra/llui/llmenugl.h
@@ -0,0 +1,774 @@
1/**
2 * @file llmenugl.h
3 * @brief Declaration of the opengl based menu system.
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#ifndef LL_LLMENUGL_H
29#define LL_LLMENUGL_H
30
31#include <list>
32
33#include "llstring.h"
34#include "v4color.h"
35#include "llframetimer.h"
36#include "llevent.h"
37
38#include "llkeyboard.h"
39#include "llfloater.h"
40#include "lluistring.h"
41#include "llview.h"
42
43class LLMenuItemGL;
44
45extern S32 MENU_BAR_HEIGHT;
46extern S32 MENU_BAR_WIDTH;
47
48// These callbacks are used by the LLMenuItemCallGL and LLMenuItemCheckGL
49// classes during their work.
50typedef void (*menu_callback)(void*);
51
52// These callbacks are used by the LLMenuItemCallGL
53// classes during their work.
54typedef void (*on_disabled_callback)(void*);
55
56// This callback is used by the LLMenuItemCallGL and LLMenuItemCheckGL
57// to determine if the current menu is enabled.
58typedef BOOL (*enabled_callback)(void*);
59
60// This callback is used by LLMenuItemCheckGL to determine it's
61// 'checked' state.
62typedef BOOL (*check_callback)(void*);
63
64// This callback is potentially used by LLMenuItemCallGL. If provided,
65// this function is called whenever it's time to determine the label's
66// contents. Put the contents of the label in the provided parameter.
67typedef void (*label_callback)(LLString&,void*);
68
69//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70// Class LLMenuItemGL
71//
72// The LLMenuItemGL represents a single menu item in a menu.
73//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
75class LLFontGL;
76class LLMenuGL;
77
78
79class LLMenuItemGL : public LLView
80{
81public:
82 LLMenuItemGL( const LLString& name, const LLString& label, KEY key = KEY_NONE, MASK = MASK_NONE );
83
84 virtual void setValue(const LLSD& value) { setLabel(value.asString()); }
85 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM; }
86 virtual LLString getWidgetTag() const { return LL_MENU_ITEM_TAG; }
87
88 virtual LLXMLNodePtr getXML(bool save_children = true) const;
89
90 virtual LLString getType() const { return "item"; }
91
92 virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
93 virtual BOOL handleHover(S32 x, S32 y, MASK mask);
94
95 virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
96
97 BOOL getHighlight() const { return mHighlight; }
98
99 void setJumpKey(KEY key);
100 KEY getJumpKey();
101
102 // set the font used by this item.
103 void setFont(LLFontGL* font);
104 void setFontStyle(U8 style) { mStyle = style; }
105
106 // returns the height in pixels for the current font.
107 virtual U32 getNominalHeight( void );
108
109 // functions to control the color scheme
110 static void setEnabledColor( const LLColor4& color );
111 static void setDisabledColor( const LLColor4& color );
112 static void setHighlightBGColor( const LLColor4& color );
113 static void setHighlightFGColor( const LLColor4& color );
114
115 // Marks item as not needing space for check marks or accelerator keys
116 virtual void setBriefItem(BOOL brief);
117
118 virtual BOOL addToAcceleratorList(std::list<LLKeyBinding*> *listp);
119 void setAllowKeyRepeat(BOOL allow) { mAllowKeyRepeat = allow; }
120
121 // return the name label
122 LLString getLabel( void ) const { return mLabel.getString(); }
123
124 // change the label
125 void setLabel( const LLString& label );
126 virtual BOOL setLabelArg( const LLString& key, const LLString& text );
127
128 // Get the parent menu for this item
129 virtual LLMenuGL* getMenu();
130
131 // returns the normal width of this control in pixels - this is
132 // used for calculating the widest item, as well as for horizontal
133 // arrangement.
134 virtual U32 getNominalWidth( void );
135
136 // buildDrawLabel() - constructs the string used during the draw()
137 // function. This reduces the overall string manipulation, but can
138 // lead to visual errors if the state of the object changes
139 // without the knowledge of the menu item. For example, if a
140 // boolean being watched is changed outside of the menu item's
141 // doIt() function, the draw buffer will not be updated and will
142 // reflect the wrong value. If this ever becomes an issue, there
143 // are ways to fix this.
144 // Returns the enabled state of the item.
145 virtual void buildDrawLabel( void );
146
147 // for branching menu items, bring sub menus up to root level of menu hierarchy
148 virtual void updateBranchParent( LLView* parentp ){};
149
150 // doIt() - do the primary funcationality of the menu item.
151 virtual void doIt( void );
152
153 // set the hover status (called by it's menu)
154 virtual void setHighlight( BOOL highlight );
155
156 // determine if this represents an active sub-menu
157 virtual BOOL isActive( void ) const;
158
159 // determine if this represents an open sub-menu
160 virtual BOOL isOpen( void ) const;
161
162 virtual void setEnabledSubMenus(BOOL enable){};
163
164 // LLView Functionality
165 virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
166 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
167 virtual void draw( void );
168
169 BOOL getHover() { return mGotHover; }
170
171 BOOL getDrawTextDisabled() const { return mDrawTextDisabled; }
172
173protected:
174 // This function appends the character string representation of
175 // the current accelerator key and mask to the provided string.
176 void appendAcceleratorString( LLString& st );
177
178public:
179 static LLColor4 sEnabledColor;
180 static LLColor4 sDisabledColor;
181 static LLColor4 sHighlightBackground;
182 static LLColor4 sHighlightForeground;
183
184protected:
185 static BOOL sDropShadowText;
186
187 // mLabel contains the actual label specified by the user.
188 LLUIString mLabel;
189
190 // The draw labels contain some of the labels that we draw during
191 // the draw() routine. This optimizes away some of the string
192 // manipulation.
193 LLUIString mDrawBoolLabel;
194 LLUIString mDrawAccelLabel;
195 LLUIString mDrawBranchLabel;
196
197 // Keyboard and mouse variables
198 KEY mJumpKey;
199 KEY mAcceleratorKey;
200 MASK mAcceleratorMask;
201 BOOL mAllowKeyRepeat;
202 BOOL mHighlight;
203 BOOL mGotHover;
204
205 // If true, suppress normal space for check marks on the left and accelerator
206 // keys on the right.
207 BOOL mBriefItem;
208
209 // Font for this item
210 LLFontGL* mFont;
211
212 U8 mStyle;
213 BOOL mDrawTextDisabled;
214};
215
216
217//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218// Class LLMenuItemCallGL
219//
220// The LLMenuItemCallerGL represents a single menu item in a menu that
221// calls a user defined callback.
222//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223
224class LLMenuItemCallGL : public LLMenuItemGL
225{
226protected:
227 menu_callback mCallback;
228 // mEnabledCallback should return TRUE if the item should be enabled
229 enabled_callback mEnabledCallback;
230 label_callback mLabelCallback;
231 void* mUserData;
232 on_disabled_callback mOnDisabledCallback;
233
234public:
235
236
237 void setMenuCallback(menu_callback callback, void* data) { mCallback = callback; mUserData = data; };
238 void setEnabledCallback(enabled_callback callback) { mEnabledCallback = callback; };
239
240 // normal constructor
241 LLMenuItemCallGL( const LLString& name,
242 menu_callback clicked_cb,
243 enabled_callback enabled_cb = NULL,
244 void* user_data = NULL,
245 KEY key = KEY_NONE, MASK mask = MASK_NONE,
246 BOOL enabled = TRUE,
247 on_disabled_callback on_disabled_cb = NULL);
248 LLMenuItemCallGL( const LLString& name,
249 const LLString& label,
250 menu_callback clicked_cb,
251 enabled_callback enabled_cb = NULL,
252 void* user_data = NULL,
253 KEY key = KEY_NONE, MASK mask = MASK_NONE,
254 BOOL enabled = TRUE,
255 on_disabled_callback on_disabled_cb = NULL);
256
257 // constructor for when you want to trap the arrange method.
258 LLMenuItemCallGL( const LLString& name,
259 const LLString& label,
260 menu_callback clicked_cb,
261 enabled_callback enabled_cb,
262 label_callback label_cb,
263 void* user_data,
264 KEY key = KEY_NONE, MASK mask = MASK_NONE,
265 BOOL enabled = TRUE,
266 on_disabled_callback on_disabled_c = NULL);
267 LLMenuItemCallGL( const LLString& name,
268 menu_callback clicked_cb,
269 enabled_callback enabled_cb,
270 label_callback label_cb,
271 void* user_data,
272 KEY key = KEY_NONE, MASK mask = MASK_NONE,
273 BOOL enabled = TRUE,
274 on_disabled_callback on_disabled_c = NULL);
275 virtual LLXMLNodePtr getXML(bool save_children = true) const;
276
277 virtual LLString getType() const { return "call"; }
278
279 virtual EWidgetType getWidgetType() const;
280 virtual LLString getWidgetTag() const;
281
282 void setEnabledControl(LLString enabled_control, LLView *context);
283 void setVisibleControl(LLString enabled_control, LLView *context);
284
285 virtual void setUserData(void *userdata) { mUserData = userdata; }
286
287 // called to rebuild the draw label
288 virtual void buildDrawLabel( void );
289
290 // doIt() - do the primary funcationality of the menu item.
291 virtual void doIt( void );
292
293 virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
294
295 //virtual void draw();
296
297 virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
298};
299
300//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301// Class LLMenuItemCheckGL
302//
303// The LLMenuItemCheckGL is an extension of the LLMenuItemCallGL
304// class, by allowing another method to be specified which determines
305// if the menu item should consider itself checked as true or not. Be
306// careful that the check callback provided - it needs to be VERY
307// FUCKING EFFICIENT, because it may need to be checked a lot.
308//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
309
310class LLMenuItemCheckGL
311: public LLMenuItemCallGL
312{
313protected:
314 check_callback mCheckCallback;
315 BOOL mChecked;
316
317public:
318 LLMenuItemCheckGL( const LLString& name,
319 const LLString& label,
320 menu_callback callback,
321 enabled_callback enabled_cb,
322 check_callback check,
323 void* user_data,
324 KEY key = KEY_NONE, MASK mask = MASK_NONE );
325 LLMenuItemCheckGL( const LLString& name,
326 menu_callback callback,
327 enabled_callback enabled_cb,
328 check_callback check,
329 void* user_data,
330 KEY key = KEY_NONE, MASK mask = MASK_NONE );
331 LLMenuItemCheckGL( const LLString& name,
332 const LLString& label,
333 menu_callback callback,
334 enabled_callback enabled_cb,
335 LLString control_name,
336 LLView *context,
337 void* user_data,
338 KEY key = KEY_NONE, MASK mask = MASK_NONE );
339 virtual LLXMLNodePtr getXML(bool save_children = true) const;
340
341 void setCheckedControl(LLString checked_control, LLView *context);
342
343 virtual void setValue(const LLSD& value) { mChecked = value.asBoolean(); }
344 virtual EWidgetType getWidgetType() const;
345 virtual LLString getWidgetTag() const;
346
347 virtual LLString getType() const { return "check"; }
348
349 // called to rebuild the draw label
350 virtual void buildDrawLabel( void );
351
352 virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata);
353
354 // LLView Functionality
355 //virtual void draw( void );
356};
357
358
359//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360// Class LLMenuItemToggleGL
361//
362// The LLMenuItemToggleGL is a menu item that wraps around a user
363// specified and controlled boolean.
364//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365
366class LLMenuItemToggleGL : public LLMenuItemGL
367{
368protected:
369 BOOL* mToggle;
370
371public:
372 LLMenuItemToggleGL( const LLString& name, const LLString& label,
373 BOOL* toggle,
374 KEY key = KEY_NONE, MASK mask = MASK_NONE );
375
376 LLMenuItemToggleGL( const LLString& name,
377 BOOL* toggle,
378 KEY key = KEY_NONE, MASK mask = MASK_NONE );
379
380 virtual LLString getType() const { return "toggle"; }
381
382 // called to rebuild the draw label
383 virtual void buildDrawLabel( void );
384
385 // doIt() - do the primary funcationality of the menu item.
386 virtual void doIt( void );
387
388 // LLView Functionality
389 //virtual void draw( void );
390};
391
392
393//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394// Class LLMenuGL
395//
396// The Menu class represents a normal rectangular menu somewhere on
397// screen. A Menu can have menu items (described above) or sub-menus
398// attached to it. Sub-menus are implemented via a specialized
399// menu-item type known as a branch. Since it's easy to do wrong, I've
400// taken the branch functionality out of public view, and encapsulate
401// it in the appendMenu() method.
402//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403
404class LLMenuArrowGL;
405class LLMenuItemBranchGL;
406class LLMenuItemTearOffGL;
407
408class LLMenuGL
409: public LLUICtrl
410{
411public:
412 LLMenuGL( const LLString& name, const LLString& label, LLViewHandle parent_floater = LLViewHandle::sDeadHandle );
413 LLMenuGL( const LLString& label, LLViewHandle parent_floater = LLViewHandle::sDeadHandle );
414 virtual ~LLMenuGL( void );
415 virtual LLXMLNodePtr getXML(bool save_children = true) const;
416 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
417
418 void parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory *factory);
419
420 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU; }
421 virtual LLString getWidgetTag() const { return LL_MENU_GL_TAG; }
422
423 // LLView Functionality
424 virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
425 //virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent );
426 virtual BOOL handleUnicodeCharHere( llwchar uni_char, BOOL called_from_parent );
427 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
428 virtual void draw( void );
429 virtual void drawBackground(LLMenuItemGL* itemp, LLColor4& color);
430 virtual void setVisible(BOOL visible);
431
432 virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
433
434 LLMenuGL* getChildMenuByName(const LLString& name, BOOL recurse) const;
435
436 BOOL clearHoverItem();
437
438 // return the name label
439 const LLString& getLabel( void ) const { return mLabel.getString(); }
440 void setLabel(const LLString& label) { mLabel = label; }
441
442 static void setDefaultBackgroundColor( const LLColor4& color );
443 void setBackgroundColor( const LLColor4& color );
444 void setBackgroundVisible( BOOL b ) { mBgVisible = b; }
445 void setCanTearOff(BOOL tear_off, LLViewHandle parent_floater_handle = LLViewHandle::sDeadHandle);
446
447 // Add the menu item to this menu.
448 virtual BOOL append( LLMenuItemGL* item );
449
450 // add a separator to this menu
451 virtual BOOL appendSeparator( const LLString &separator_name = "separator" );
452
453 // add a menu - this will create a cascading menu
454 virtual BOOL appendMenu( LLMenuGL* menu );
455
456 // for branching menu items, bring sub menus up to root level of menu hierarchy
457 virtual void updateParent( LLView* parentp );
458
459 // setItemEnabled() - pass the name and the enable flag for a
460 // menu item. TRUE will make sure it's enabled, FALSE will disable
461 // it.
462 void setItemEnabled( const LLString& name, BOOL enable );
463
464 // propagate message to submenus
465 void setEnabledSubMenus(BOOL enable);
466
467 void setItemVisible( const LLString& name, BOOL visible);
468
469 // sets the left,bottom corner of menu, useful for popups
470 void setLeftAndBottom(S32 left, S32 bottom);
471
472 virtual BOOL handleJumpKey(KEY key);
473
474 virtual BOOL jumpKeysActive();
475
476 virtual BOOL isOpen();
477
478 // Shape this menu to fit the current state of the children, and
479 // adjust the child rects to fit. This is called automatically
480 // when you add items. *FIX: We may need to deal with visibility
481 // arrangement.
482 virtual void arrange( void );
483
484 // remove all items on the menu
485 void empty( void );
486
487 // Rearrange the components, and do the right thing if the menu doesn't
488 // fit in the bounds.
489 // virtual void arrangeWithBounds(LLRect bounds);
490
491 void setItemLastSelected(LLMenuItemGL* item); // must be in menu
492 U32 getItemCount(); // number of menu items
493 LLMenuItemGL* getItem(S32 number); // 0 = first item
494 LLMenuItemGL* getHighlightedItem();
495
496 LLMenuItemGL* highlightNextItem(LLMenuItemGL* cur_item, BOOL skip_disabled = TRUE);
497 LLMenuItemGL* highlightPrevItem(LLMenuItemGL* cur_item, BOOL skip_disabled = TRUE);
498
499 void buildDrawLabels();
500 void createJumpKeys();
501
502 // Show popup in global screen space based on last mouse location.
503 static void showPopup(LLMenuGL* menu);
504
505 // Show popup at a specific location.
506 static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y);
507
508 // Whether to drop shadow menu bar
509 void setDropShadowed( const BOOL shadowed );
510
511 void setParentMenuItem( LLMenuItemGL* parent_menu_item ) { mParentMenuItem = parent_menu_item; }
512 LLMenuItemGL* getParentMenuItem() { return mParentMenuItem; }
513
514 void setTornOff(BOOL torn_off);
515 BOOL getTornOff() { return mTornOff; }
516
517 BOOL getCanTearOff() { return mTearOffItem != NULL; }
518
519 KEY getJumpKey() { return mJumpKey; }
520 void setJumpKey(KEY key) { mJumpKey = key; }
521
522 static void setKeyboardMode(BOOL mode) { sKeyboardMode = mode; }
523 static BOOL getKeyboardMode() { return sKeyboardMode; }
524
525 static void onFocusLost(LLView* old_focus);
526 static LLView *sDefaultMenuContainer;
527
528protected:
529 void createSpilloverBranch();
530 void cleanupSpilloverBranch();
531
532protected:
533 static LLColor4 sDefaultBackgroundColor;
534 static BOOL sKeyboardMode;
535
536 LLColor4 mBackgroundColor;
537 BOOL mBgVisible;
538 typedef std::list< LLMenuItemGL* > item_list_t;
539 item_list_t mItems;
540 typedef std::map<KEY, LLMenuItemGL*> navigation_key_map_t;
541 navigation_key_map_t mJumpKeys;
542 LLMenuItemGL* mParentMenuItem;
543 LLUIString mLabel;
544 BOOL mDropShadowed; // Whether to drop shadow
545 BOOL mHorizontalLayout;
546 BOOL mKeepFixedSize;
547 BOOL mHasSelection;
548 LLFrameTimer mFadeTimer;
549 S32 mLastMouseX;
550 S32 mLastMouseY;
551 S32 mMouseVelX;
552 S32 mMouseVelY;
553 BOOL mTornOff;
554 LLMenuItemTearOffGL* mTearOffItem;
555 LLMenuItemBranchGL* mSpilloverBranch;
556 LLMenuGL* mSpilloverMenu;
557 LLViewHandle mParentFloaterHandle;
558 KEY mJumpKey;
559};
560
561//-----------------------------------------------------------------------------
562// class LLPieMenu
563// A circular menu of items, icons, etc.
564//-----------------------------------------------------------------------------
565
566class LLPieMenu
567: public LLMenuGL
568{
569public:
570 LLPieMenu(const LLString& name, const LLString& label);
571 LLPieMenu(const LLString& name);
572 virtual ~LLPieMenu();
573
574 virtual EWidgetType getWidgetType() const;
575 virtual LLString getWidgetTag() const;
576
577 void initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *factory);
578
579 // LLView Functionality
580 // can't set visibility directly, must call show or hide
581 virtual void setVisible(BOOL visible);
582
583 //virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent );
584 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
585 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
586 virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
587 virtual BOOL handleRightMouseUp( S32 x, S32 y, MASK mask );
588 virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
589 virtual void draw();
590 virtual void drawBackground(LLMenuItemGL* itemp, LLColor4& color);
591
592 virtual BOOL append(LLMenuItemGL* item);
593 virtual BOOL appendSeparator( const LLString &separator_name = "separator" );
594
595 // the enabled callback is meant for the submenu. The api works
596 // this way because the menu branch item responsible for the pie
597 // submenu is constructed here.
598 virtual BOOL appendMenu(LLPieMenu *menu,
599 enabled_callback enabled_cb = NULL,
600 void* user_data = NULL );
601 virtual void arrange( void );
602
603 // Display the menu centered on this point on the screen.
604 void show(S32 x, S32 y, BOOL mouse_down);
605 void hide(BOOL item_selected);
606
607protected:
608 LLMenuItemGL *pieItemFromXY(S32 x, S32 y);
609 S32 pieItemIndexFromXY(S32 x, S32 y);
610
611private:
612 // These cause menu items to be spuriously selected by right-clicks
613 // near the window edge at low frame rates. I don't think they are
614 // needed unless you shift the menu position in the draw() function. JC
615 //S32 mShiftHoriz; // non-zero if menu had to shift this frame
616 //S32 mShiftVert; // non-zero if menu had to shift this frame
617 BOOL mFirstMouseDown; // true from show until mouse up
618 BOOL mUseInfiniteRadius; // allow picking pie menu items anywhere outside of center circle
619 LLMenuItemGL* mHoverItem;
620 BOOL mHoverThisFrame;
621 LLFrameTimer mShrinkBorderTimer;
622 F32 mOuterRingAlpha; // for rendering pie menus as both bounded and unbounded
623 F32 mCurRadius;
624 BOOL mRightMouseDown;
625};
626
627//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
628// Class LLMenuBarGL
629//
630// A menu bar displays menus horizontally.
631//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
632
633class LLMenuBarGL : public LLMenuGL
634{
635protected:
636 std::list <LLKeyBinding*> mAccelerators;
637 BOOL mAltKeyTrigger;
638
639public:
640 LLMenuBarGL( const LLString& name );
641 virtual ~LLMenuBarGL();
642 virtual LLXMLNodePtr getXML(bool save_children = true) const;
643 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
644
645 virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_BAR; }
646 virtual LLString getWidgetTag() const { return LL_MENU_BAR_GL_TAG; }
647
648 virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
649 virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent);
650 virtual BOOL handleJumpKey(KEY key);
651
652 // rearrange the child rects so they fit the shape of the menu
653 // bar.
654 virtual void arrange( void );
655 virtual void draw();
656 virtual BOOL jumpKeysActive();
657
658 // add a vertical separator to this menu
659 virtual BOOL appendSeparator( const LLString &separator_name = "separator" );
660
661 // add a menu - this will create a drop down menu.
662 virtual BOOL appendMenu( LLMenuGL* menu );
663
664 // LLView Functionality
665 virtual BOOL handleHover( S32 x, S32 y, MASK mask );
666
667 // Returns x position of rightmost child, usually Help menu
668 S32 getRightmostMenuEdge();
669
670 void resetMenuTrigger() { mAltKeyTrigger = FALSE; }
671
672protected:
673 void checkMenuTrigger();
674
675};
676
677//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
678// Class LLMenuHolderGL
679//
680// High level view that serves as parent for all menus
681//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
682class LLMenuHolderGL : public LLPanel
683{
684public:
685 LLMenuHolderGL();
686 LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows = FOLLOWS_NONE);
687 virtual ~LLMenuHolderGL();
688
689 virtual EWidgetType getWidgetType() const;
690 virtual LLString getWidgetTag() const;
691
692 virtual BOOL hideMenus();
693 void reshape(S32 width, S32 height, BOOL called_from_parent);
694 void setCanHide(BOOL can_hide) { mCanHide = can_hide; }
695
696 // LLView functionality
697 virtual void draw();
698 virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
699 virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
700
701 static void setActivatedItem(LLMenuItemGL* item);
702 BOOL hasVisibleMenu();
703
704protected:
705 static LLViewHandle sItemLastSelectedHandle;
706 static LLFrameTimer sItemActivationTimer;
707
708 BOOL mCanHide;
709};
710
711//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
712// Class LLTearOffMenu
713//
714// Floater that hosts a menu
715//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
716class LLTearOffMenu : public LLFloater
717{
718public:
719 static LLTearOffMenu* create(LLMenuGL* menup);
720 virtual ~LLTearOffMenu();
721 virtual void onClose(bool app_quitting);
722 virtual void draw(void);
723 virtual void onFocusReceived();
724 virtual void onFocusLost();
725 virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent);
726 virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
727 virtual void translate(S32 x, S32 y);
728
729protected:
730 LLTearOffMenu(LLMenuGL* menup);
731
732protected:
733 LLView* mOldParent;
734 LLMenuGL* mMenu;
735 F32 mTargetHeight;
736};
737
738//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
739// Class LLMenuItemTearOffGL
740//
741// This class represents a separator.
742//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
743
744class LLMenuItemTearOffGL : public LLMenuItemGL
745{
746public:
747 LLMenuItemTearOffGL( LLViewHandle parent_floater_handle = (LLViewHandle)LLViewHandle::sDeadHandle );
748
749 virtual EWidgetType getWidgetType() const;
750 virtual LLString getWidgetTag() const;
751
752 virtual LLString getType() const { return "tearoff_menu"; }
753
754 virtual void doIt(void);
755 virtual void draw(void);
756 virtual U32 getNominalHeight();
757
758protected:
759 LLViewHandle mParentHandle;
760};
761
762
763// *TODO: this is currently working, so finish implementation
764class LLEditMenuHandlerMgr
765{
766public:
767 LLEditMenuHandlerMgr& getInstance();
768 virtual ~LLEditMenuHandlerMgr();
769protected:
770 LLEditMenuHandlerMgr();
771
772};
773
774#endif // LL_LLMENUGL_H