summaryrefslogtreecommitdiff
path: root/indra/llui/llmenugl.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llmenugl.h')
-rw-r--r--indra/llui/llmenugl.h196
1 files changed, 105 insertions, 91 deletions
diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h
index 7d889c291c..19b738312e 100644
--- a/indra/llui/llmenugl.h
+++ b/indra/llui/llmenugl.h
@@ -2,31 +2,25 @@
* @file llmenugl.h
* @brief Declaration of the opengl based menu system.
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -61,9 +55,10 @@ public:
{
Optional<std::string> shortcut;
Optional<KEY> jump_key;
- Optional<bool> use_mac_ctrl;
+ Optional<bool> use_mac_ctrl,
+ allow_key_repeat;
- Deprecated rect,
+ Ignored rect,
left,
top,
right,
@@ -79,36 +74,23 @@ public:
highlight_fg_color;
- Params()
- : shortcut("shortcut"),
- jump_key("", KEY_NONE),
- use_mac_ctrl("use_mac_ctrl", false),
- rect("rect"),
- left("left"),
- top("top"),
- right("right"),
- bottom("bottom"),
- width("width"),
- height("height"),
- bottom_delta("bottom_delta"),
- left_delta("left_delta"),
- enabled_color("enabled_color"),
- disabled_color("disabled_color"),
- highlight_bg_color("highlight_bg_color"),
- highlight_fg_color("highlight_fg_color")
- {
- mouse_opaque = true;
- }
+ Params();
};
protected:
LLMenuItemGL(const Params&);
friend class LLUICtrlFactory;
public:
- virtual void setValue(const LLSD& value) { setLabel(value.asString()); }
- /*virtual*/ void onVisibilityChange(BOOL new_visibility);
+ // LLView overrides
+ /*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+ /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
+ /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+ /*virtual*/ BOOL handleRightMouseUp(S32 x, S32 y, MASK mask);
+
+ // LLUICtrl overrides
+ /*virtual*/ void setValue(const LLSD& value);
+ /*virtual*/ LLSD getValue() const;
- virtual BOOL handleHover(S32 x, S32 y, MASK mask);
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
LLColor4 getHighlightBgColor() { return mHighlightBackground.get(); }
@@ -124,8 +106,8 @@ public:
virtual U32 getNominalHeight( void ) const;
// Marks item as not needing space for check marks or accelerator keys
- virtual void setBriefItem(BOOL brief) { mBriefItem = brief; }
- virtual BOOL isBriefItem() const { return mBriefItem; }
+ virtual void setBriefItem(BOOL brief);
+ virtual BOOL isBriefItem() const;
virtual BOOL addToAcceleratorList(std::list<LLKeyBinding*> *listp);
void setAllowKeyRepeat(BOOL allow) { mAllowKeyRepeat = allow; }
@@ -137,7 +119,7 @@ public:
virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
// Get the parent menu for this item
- virtual class LLMenuGL* getMenu();
+ virtual class LLMenuGL* getMenu() const;
// returns the normal width of this control in pixels - this is
// used for calculating the widest item, as well as for horizontal
@@ -189,9 +171,7 @@ protected:
// This function appends the character string representation of
// the current accelerator key and mask to the provided string.
void appendAcceleratorString( std::string& st ) const;
-
- void initMenuEnableCallback(const EnableCallbackParam& cb, enable_signal_t& sig);
-
+
protected:
KEY mAcceleratorKey;
MASK mAcceleratorMask;
@@ -263,15 +243,18 @@ public:
{
Optional<EnableCallbackParam > on_enable;
Optional<CommitCallbackParam > on_click;
+ Optional<EnableCallbackParam > on_visible;
Params()
: on_enable("on_enable"),
- on_click("on_click")
+ on_click("on_click"),
+ on_visible("on_visible")
{}
};
protected:
LLMenuItemCallGL(const Params&);
friend class LLUICtrlFactory;
void updateEnabled( void );
+ void updateVisible( void );
public:
void initFromParams(const Params& p);
@@ -286,18 +269,19 @@ public:
//virtual void draw();
- boost::signals::connection setClickCallback( const commit_signal_t::slot_type& cb )
+ boost::signals2::connection setClickCallback( const commit_signal_t::slot_type& cb )
{
return setCommitCallback(cb);
}
- boost::signals::connection setEnableCallback( const enable_signal_t::slot_type& cb )
+ boost::signals2::connection setEnableCallback( const enable_signal_t::slot_type& cb )
{
return mEnableSignal.connect(cb);
}
-
+
private:
enable_signal_t mEnableSignal;
+ enable_signal_t mVisibleSignal;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -307,7 +291,7 @@ private:
// class, by allowing another method to be specified which determines
// if the menu item should consider itself checked as true or not. Be
// careful that the provided callback is fast - it needs to be VERY
-// FUCKING EFFICIENT, because it may need to be checked a lot.
+// EFFICIENT because it may need to be checked a lot.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class LLMenuItemCheckGL
@@ -332,11 +316,12 @@ public:
virtual void onCommit( void );
virtual void setValue(const LLSD& value);
+ virtual LLSD getValue() const;
// called to rebuild the draw label
virtual void buildDrawLabel( void );
- boost::signals::connection setCheckCallback( const enable_signal_t::slot_type& cb )
+ boost::signals2::connection setCheckCallback( const enable_signal_t::slot_type& cb )
{
return mCheckSignal.connect(cb);
}
@@ -356,13 +341,17 @@ private:
// it in the appendMenu() method.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// child widget registry
+struct MenuRegistry : public LLChildRegistry<MenuRegistry>
+{};
+
+
class LLMenuGL
: public LLUICtrl
{
public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
- Optional<LLHandle<LLFloater> > parent_floater;
Optional<KEY> jump_key;
Optional<bool> horizontal_layout,
can_tear_off,
@@ -371,16 +360,24 @@ public:
create_jump_keys,
keep_fixed_size,
scrollable;
+ Optional<U32> max_scrollable_items;
+ Optional<U32> preferred_width;
Optional<LLUIColor> bg_color;
+ Optional<S32> shortcut_pad;
Params()
- : jump_key("", KEY_NONE),
+ : jump_key("jump_key", KEY_NONE),
+ horizontal_layout("horizontal_layout"),
can_tear_off("tear_off", false),
drop_shadow("drop_shadow", true),
bg_visible("bg_visible", true),
create_jump_keys("create_jump_keys", false),
- bg_color("bg_color", LLUI::getCachedColorFunctor( "MenuDefaultBgColor" )),
- scrollable("scrollable", false)
+ bg_color("bg_color", LLUIColorTable::instance().getColor( "MenuDefaultBgColor" )),
+ scrollable("scrollable", false),
+ max_scrollable_items("max_scrollable_items", U32_MAX),
+ preferred_width("preferred_width", U32_MAX),
+ shortcut_pad("shortcut_pad")
+
{
addSynonym(bg_visible, "opaque");
addSynonym(bg_color, "color");
@@ -388,8 +385,18 @@ public:
name = "menu";
}
};
+
+ // my valid children are contained in MenuRegistry
+ typedef MenuRegistry child_registry_t;
+
void initFromParams(const Params&);
+ // textual artwork which menugl-imitators may want to match
+ static const std::string BOOLEAN_TRUE_PREFIX;
+ static const std::string BRANCH_SUFFIX;
+ static const std::string ARROW_UP;
+ static const std::string ARROW_DOWN;
+
protected:
LLMenuGL(const LLMenuGL::Params& p);
friend class LLUICtrlFactory;
@@ -410,11 +417,10 @@ public:
/*virtual*/ bool addChild(LLView* view, S32 tab_group = 0);
/*virtual*/ void removeChild( LLView* ctrl);
/*virtual*/ BOOL postBuild();
- /*virtual*/ const widget_registry_t& getChildRegistry() const;
virtual BOOL handleAcceleratorKey(KEY key, MASK mask);
- LLMenuGL* getChildMenuByName(const std::string& name, BOOL recurse) const;
+ LLMenuGL* findChildMenuByName(const std::string& name, BOOL recurse) const;
BOOL clearHoverItem();
@@ -426,7 +432,7 @@ public:
void setBackgroundColor( const LLUIColor& color ) { mBackgroundColor = color; }
const LLUIColor& getBackgroundColor() const { return mBackgroundColor; }
void setBackgroundVisible( BOOL b ) { mBgVisible = b; }
- void setCanTearOff(BOOL tear_off, LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>());
+ void setCanTearOff(BOOL tear_off);
// add a separator to this menu
virtual BOOL addSeparator();
@@ -475,10 +481,7 @@ public:
void buildDrawLabels();
void createJumpKeys();
- // Show popup in global screen space based on last mouse location.
- static void showPopup(LLMenuGL* menu);
-
- // Show popup at a specific location.
+ // Show popup at a specific location, in the spawn_view's coordinate frame
static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y);
// Whether to drop shadow menu bar
@@ -498,6 +501,8 @@ public:
static void setKeyboardMode(BOOL mode) { sKeyboardMode = mode; }
static BOOL getKeyboardMode() { return sKeyboardMode; }
+ S32 getShortcutPad() { return mShortcutPad; }
+
void scrollItemsUp();
void scrollItemsDown();
BOOL isScrollable() const { return mScrollable; }
@@ -525,6 +530,8 @@ protected:
S32 mLastMouseY;
S32 mMouseVelX;
S32 mMouseVelY;
+ U32 mMaxScrollableItems;
+ U32 mPreferredWidth;
BOOL mHorizontalLayout;
BOOL mScrollable;
BOOL mKeepFixedSize;
@@ -541,16 +548,16 @@ private:
LLHandle<LLView> mParentMenuItem;
LLUIString mLabel;
BOOL mDropShadowed; // Whether to drop shadow
- BOOL mHasSelection;
+ bool mHasSelection;
LLFrameTimer mFadeTimer;
LLTimer mScrollItemsTimer;
BOOL mTornOff;
class LLMenuItemTearOffGL* mTearOffItem;
class LLMenuItemBranchGL* mSpilloverBranch;
LLMenuGL* mSpilloverMenu;
- LLHandle<LLFloater> mParentFloaterHandle;
KEY mJumpKey;
BOOL mCreateJumpKeys;
+ S32 mShortcutPad;
}; // end class LLMenuGL
@@ -597,16 +604,16 @@ public:
virtual BOOL handleKeyHere(KEY key, MASK mask);
- virtual BOOL isActive() const { return isOpen() && getBranch() && getBranch()->getHighlightedItem(); }
+ virtual BOOL isActive() const;
- virtual BOOL isOpen() const { return getBranch() && getBranch()->isOpen(); }
+ virtual BOOL isOpen() const;
LLMenuGL* getBranch() const { return (LLMenuGL*)mBranchHandle.get(); }
virtual void updateBranchParent( LLView* parentp );
// LLView Functionality
- virtual void onVisibilityChange( BOOL curVisibilityIn );
+ virtual void handleVisibilityChange( BOOL curVisibilityIn );
virtual void draw();
@@ -614,7 +621,8 @@ public:
virtual void openMenu();
- virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const;
+ virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE) const;
+ virtual LLView* findChildView(const std::string& name, BOOL recurse = TRUE) const;
private:
LLHandle<LLView> mBranchHandle;
@@ -651,16 +659,12 @@ public:
virtual void draw ();
- virtual void show (S32 x, S32 y, BOOL adjustCursor = TRUE);
+ virtual void show (S32 x, S32 y);
virtual void hide ();
-
-
virtual BOOL handleHover ( S32 x, S32 y, MASK mask );
- virtual BOOL handleMouseDown ( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseUp ( S32 x, S32 y, MASK mask );
- virtual BOOL handleMouseUp ( S32 x, S32 y, MASK mask );
virtual bool addChild (LLView* view, S32 tab_group = 0);
@@ -700,7 +704,6 @@ public:
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
/*virtual*/ BOOL handleJumpKey(KEY key);
/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
- /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ void draw();
/*virtual*/ BOOL jumpKeysActive();
@@ -737,7 +740,9 @@ private:
class LLMenuHolderGL : public LLPanel
{
public:
- LLMenuHolderGL();
+ struct Params : public LLInitParam::Block<Params, LLPanel::Params>
+ {};
+ LLMenuHolderGL(const Params& p);
virtual ~LLMenuHolderGL() {}
virtual BOOL hideMenus();
@@ -749,11 +754,20 @@ public:
virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask );
+ // Close context menus on right mouse up not handled by menus.
+ /*virtual*/ BOOL handleRightMouseUp( S32 x, S32 y, MASK mask );
+
+ virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent);
virtual const LLRect getMenuRect() const { return getLocalRect(); }
- virtual BOOL hasVisibleMenu() const;
+ LLView*const getVisibleMenu() const;
+ virtual BOOL hasVisibleMenu() const {return getVisibleMenu() != NULL;}
static void setActivatedItem(LLMenuItemGL* item);
+ // Need to detect if mouse-up after context menu spawn has moved.
+ // If not, need to keep the menu up.
+ static LLCoordGL sContextMenuSpawnPos;
+
private:
static LLHandle<LLView> sItemLastSelectedHandle;
static LLFrameTimer sItemActivationTimer;
@@ -771,8 +785,8 @@ class LLTearOffMenu : public LLFloater
{
public:
static LLTearOffMenu* create(LLMenuGL* menup);
- virtual ~LLTearOffMenu() {}
- virtual void onClose(bool app_quitting);
+ virtual ~LLTearOffMenu();
+
virtual void draw(void);
virtual void onFocusReceived();
virtual void onFocusLost();
@@ -782,7 +796,9 @@ public:
private:
LLTearOffMenu(LLMenuGL* menup);
-
+
+ void closeTearOff();
+
LLView* mOldParent;
LLMenuGL* mMenu;
F32 mTargetHeight;
@@ -799,7 +815,6 @@ class LLMenuItemTearOffGL : public LLMenuItemGL
public:
struct Params : public LLInitParam::Block<Params, LLMenuItemGL::Params>
{
- Optional<LLHandle<LLFloater> > parent_floater_handle;
Params()
{
name = "tear off";
@@ -808,13 +823,12 @@ public:
};
LLMenuItemTearOffGL( const Params& );
-
+
virtual void onCommit(void);
virtual void draw(void);
virtual U32 getNominalHeight() const;
-private:
- LLHandle<LLFloater> mParentHandle;
+ LLFloater* getParentFloater();
};
@@ -834,7 +848,7 @@ private:
// *TODO: Eliminate
// For backwards compatability only; generally just use boost::bind
-class view_listener_t : public boost::signals::trackable
+class view_listener_t : public boost::signals2::trackable
{
public:
virtual bool handleEvent(const LLSD& userdata) = 0;