From 84ba6c134cd7f75e8f3be86b444c9e7f57660c18 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 11 Apr 2011 20:11:26 -0700 Subject: Applied customizableTranslationMenu.patch by Grandma Bates for #533: Right Click menus are transparent on the login screen and #534: Right click menus aren't translatable --- linden/indra/llui/lllineeditor.cpp | 122 ++++++++---- linden/indra/llui/lllineeditor.h | 6 +- linden/indra/llui/llmenugl.cpp | 219 +++++++++++++++++++-- linden/indra/llui/llmenugl.h | 114 ++++++++++- linden/indra/llui/lltexteditor.cpp | 111 +++++++---- linden/indra/llui/lltexteditor.h | 1 + linden/indra/newview/llpanellogin.cpp | 2 +- .../skins/default/xui/da/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/de/menu_rightclick_text.xml | 115 +++++++++++ .../default/xui/en-us/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/es/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/fr/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/hu/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/it/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/ja/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/ko/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/pl/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/pt/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/ru/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/tr/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/uk/menu_rightclick_text.xml | 115 +++++++++++ .../skins/default/xui/zh/menu_rightclick_text.xml | 115 +++++++++++ 22 files changed, 2208 insertions(+), 92 deletions(-) create mode 100644 linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml (limited to 'linden/indra') diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index a21ad5d..1d998be 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -55,17 +55,24 @@ #include "llui.h" #include "lluictrlfactory.h" #include "llclipboard.h" +#include "llmemberlistener.h" #include "../newview/lgghunspell_wrapper.h" #include "../newview/lltranslate.h" #include "../newview/llviewercontrol.h" #include "../newview/lggautocorrect.h" + // // Imported globals // // +// Globals + + + +// // Constants // @@ -90,6 +97,8 @@ static LLRegisterWidget r1("line_editor"); /* static */ LLPointer LLLineEditor::sImage; +typedef LLMemberListener text_edit_listener_t; + // // Member functions // @@ -214,46 +223,18 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, } mImage = sImage; - // make the popup menu available - //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); - LLMenuGL* menu = new LLMenuGL("wot"); - /*if (!menu) - { - menu = new LLMenuGL(LLStringUtil::null); - }*/ - - menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); - menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); - menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this)); - menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this)); - menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this)); - - menu->appendSeparator("Transep"); - LLMenuGL* translatemenu = new LLMenuGL("Translate To"); - translatemenu->setCanTearOff(FALSE); - translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); - - menu->appendMenu(translatemenu); - menu->appendSeparator("Spelsep"); - //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); - menu->setCanTearOff(FALSE); - menu->setVisible(FALSE); + + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this); + if (!menu) + { + menu = new LLMenuGL(LLStringUtil::null); + } + + defineMenuCallbacks(menu); mPopupMenuHandle = menu->getHandle(); + menu->setBorderColor(gColors.getColor("MenuItemDisabledColor")); + menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); + } @@ -556,7 +537,7 @@ void LLLineEditor::context_translate(void * data) { LLLineEditor* line = (LLLineEditor*)data; LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; - LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translation Options", TRUE) : NULL; if (!translate_menu) { return; @@ -1318,6 +1299,67 @@ BOOL LLLineEditor::canCut() const return !mReadOnly && !mDrawAsterixes && hasSelection(); } +// method to define the associated callbacks +void LLLineEditor::defineMenuCallbacks(LLMenuGL* menu) { + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Cut Text", + this, + (void*)context_enable_cut); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Cut Text", + this, + (void*)context_cut); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Copy Text", + this, + (void*)context_enable_copy); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Copy Text", + this, + (void*)context_copy); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Paste Text", + this, + (void*)context_enable_paste); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Paste Text", + this, + (void*)context_paste); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Delete Text", + this, + (void*)context_enable_delete); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Delete Text", + this, + (void*)context_delete); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Select All Text", + this, + (void*)context_enable_selectall); + menu->setCtrlResponse(1+LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Select All Text", + this, + (void*)context_selectall); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Translate Text", + this, + (void*)context_enable_translate); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + "Translate Text", + this, + (void*)context_translate); + + + +} + // cut selection to clipboard void LLLineEditor::cut() { diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index 43ce869..54c0146 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h @@ -55,6 +55,7 @@ class LLFontGL; class LLLineEditorRollback; class LLButton; +class LLMenuGL; typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr); @@ -112,7 +113,8 @@ public: virtual BOOL canTranslate() const; virtual void insert(std::string what,S32 wher); - // LLEditMenuHandler overrides + // LLEditMenuHandler overrides and menu set up methods. + void defineMenuCallbacks(LLMenuGL* menu); virtual void cut(); virtual BOOL canCut() const; @@ -468,4 +470,6 @@ private: }; + + #endif // LL_LINEEDITOR_ diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index 91bb581..d5e1186 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp @@ -149,6 +149,18 @@ LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, K setLabel( label ); } +LLMenuItemGL::~LLMenuItemGL() { + + // Delete all the entries in the mFutureCallbackRequests vector + for(std::vector::iterator iter= mFutureCallbackRequests.begin(); + iter!=mFutureCallbackRequests.end(); + ++iter) { + delete (*iter); + } + +} + + // virtual LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const { @@ -517,6 +529,18 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& return TRUE; } + +void LLMenuItemGL::addCallbackType(U8 theType, + const std::string& name, + const std::string& userdata) { + + // Add the new callback information to the list of callbacks that are being tracked. + mFutureCallbackRequests.push_back(new LLCallbackInformation(theType,name,userdata)); + +} + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemSeparatorGL // @@ -541,6 +565,12 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } + + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + }; LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : @@ -726,6 +756,11 @@ public: } virtual void doIt( void ) {} virtual void draw( void ) {} + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + }; @@ -805,6 +840,8 @@ LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, if(!enabled) setEnabled(FALSE); } + + void LLMenuItemCallGL::setEnabledControl(std::string enabled_control, LLView *context) { // Register new listener @@ -921,6 +958,53 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) return LLMenuItemGL::handleAcceleratorKey(key, mask); } + + +// Method to add a callback function for the given type and name. +BOOL LLMenuItemCallGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { + + // Loop through all of the menu items and check to see which ones + // match the name and callback type given. + BOOL result = FALSE; + std::vector::iterator item_iter; + for (item_iter = mFutureCallbackRequests.begin(); + item_iter != mFutureCallbackRequests.end(); + ++item_iter) + { + if( ((*item_iter)->getTypeOfCallback()==llMenuItemCallType) && + ((*item_iter)->getCallbackName()==name)) { + + // Found a match. Set the user data and then determine what type it is. + setUserData(user_data); + + if(llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK) + { + setMenuCallback((menu_callback)callback_fcn,user_data); + } + + else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE) + { + setEnabledCallback((enabled_callback)callback_fcn); + } + + else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE) { + setName((*item_iter)->getCallbackUserData()); + setMenuCallback((menu_callback)callback_fcn,user_data); + } + + } + } + + + return result; + +} + + + ///============================================================================ /// Class LLMenuItemCheckGL ///============================================================================ @@ -1379,6 +1463,17 @@ void LLMenuItemBranchGL::openMenu() } +BOOL LLMenuItemBranchGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { + + // Get the menu branch and set the callback functions on all its children. + return(getBranch()->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn)); + +} + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemBranchDownGL // @@ -1982,13 +2077,31 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory LLSimpleListener* callback = parent->getListenerByName(callback_name); - if (!callback) + if (callback) { - lldebugs << "Ignoring \"on_click\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; - continue; + new_item->addListener(callback, "on_click", callback_data); + } + else { + + // A callback for this item has not yet been + // specified. Add it to the list of options + // that do not yet have callbacks. + if (call_child->hasAttribute("translate")) + { + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + item_name, + callback_data); + } + + else + { + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + item_name, + callback_data); + } } - - new_item->addListener(callback, "on_click", callback_data); } if (call_child->hasName("on_enable")) { @@ -2016,13 +2129,22 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory LLSimpleListener* callback = parent->getListenerByName(callback_name); - if (!callback) + if (callback) { - lldebugs << "Ignoring \"on_enable\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; - continue; + new_item->addListener(callback, "on_build", userdata); + } else { + + // A callback for this item has not yet been + // specified. Add it to the list of options + // that do not yet have callbacks. + + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + item_name, + callback_data); } - new_item->addListener(callback, "on_build", userdata); + } else if (call_child->hasAttribute("control")) { @@ -2188,7 +2310,7 @@ LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa LLColor4 color(0,0,0,1); if (opaque && LLUICtrlFactory::getAttributeColor(node,"color", color)) { - menu->setBackgroundColor(color); + menu->setBackgroundColor(color); } BOOL create_jump_keys = FALSE; @@ -2977,7 +3099,8 @@ void LLMenuGL::draw( void ) if( mBgVisible ) { - gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); + gl_rect_2d( -1, getRect().getHeight()+2, getRect().getWidth()+2, -2, mBorderColor,FALSE); + gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); } LLView::draw(); } @@ -3033,6 +3156,41 @@ LLMenuGL* LLMenuGL::getChildMenuByName(const std::string& name, BOOL recurse) co return NULL; } + +void LLMenuGL::setBackgroundColor( const LLColor4& color ) { + + mBackgroundColor = color; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + if((*item_iter)->getType()=="menu") + { + LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); + menuBranchItem->getBranch()->setBackgroundColor(color); + } + } + + +} + + +void LLMenuGL::setBorderColor( const LLColor4& color ) { + + mBorderColor = color; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + if((*item_iter)->getType()=="menu") + { + LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); + menuBranchItem->getBranch()->setBorderColor(color); + } + } + + +} + + BOOL LLMenuGL::clearHoverItem() { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) @@ -3098,6 +3256,26 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) menu->getParent()->sendChildToFront(menu); } + +BOOL LLMenuGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) +{ + + // Go through all of the children on this menu and set the callback function. + BOOL result = FALSE; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + result |= (*item_iter)->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn); + } + + return result; +} + + + //----------------------------------------------------------------------------- // class LLPieMenuBranch // A branch to another pie menu @@ -3117,6 +3295,12 @@ public: LLPieMenu* getBranch() { return mBranch; } + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + protected: LLPieMenu* mBranch; }; @@ -4581,3 +4765,16 @@ void LLTearOffMenu::onClose(bool app_quitting) destroy(); } + +///============================================================================ +/// Class LLCallbackInformation +///============================================================================ + +LLCallbackInformation::LLCallbackInformation(U8 theType, + const std::string& theName, + const std::string& userData) + : callbackName(theName), + callbackUserData(userData) +{ + setTypeOfCallback(theType); +} diff --git a/linden/indra/llui/llmenugl.h b/linden/indra/llui/llmenugl.h index 63f9d55..9a9d1b0 100644 --- a/linden/indra/llui/llmenugl.h +++ b/linden/indra/llui/llmenugl.h @@ -70,6 +70,57 @@ typedef BOOL (*check_callback)(void*); // contents. Put the contents of the label in the provided parameter. typedef void (*label_callback)(std::string&,void*); + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLCallbackInformation +// +// The LLCallbackInformation class is used to keep track of callback +// information for menus that might be requested at a future time. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLCallbackInformation +{ + +public : + + // Constants used for keeping track of what type of callback is required. + static const U8 LL_MENU_ITEM_CALL_GL_NONE = 0; + static const U8 LL_MENU_ITEM_CALL_GL_ON_CLICK = 1; + static const U8 LL_MENU_ITEM_CALL_GL_ON_ENABLE = 2; + static const U8 LL_MENU_ITEM_CALL_GL_TRANSLATE = 3; + + + LLCallbackInformation(U8 theType=LLCallbackInformation::LL_MENU_ITEM_CALL_GL_NONE, + const std::string& theName = LLStringUtil::null, + const std::string& userData = LLStringUtil::null); + ~LLCallbackInformation() {}; + + void setTypeOfCallback(U8 theType) {typeOfCallback = theType; } + void setCallbackName(const std::string& name) {callbackName = name; } + void setCallbackUserData(const std::string& userdata) {callbackUserData = userdata; } + + U8 getTypeOfCallback() {return(typeOfCallback); } + const std::string& getCallbackName() {return(callbackName); } + const std::string& getCallbackUserData() {return(callbackUserData); } + + BOOL isTypeMatch(U8 type) { return(type == typeOfCallback);} + BOOL isNameMatch(const std::string& name) { return(name == callbackName);} + +protected: + +private: + + U8 typeOfCallback; + std::string callbackName; + std::string callbackUserData; + +}; + + + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemGL // @@ -79,6 +130,7 @@ typedef void (*label_callback)(std::string&,void*); class LLMenuItemGL : public LLView { public: + // static functions to control the global color scheme. static void setEnabledColor( const LLColor4& color ) { sEnabledColor = color; } static const LLColor4& getEnabledColor() { return sEnabledColor; } @@ -90,7 +142,7 @@ public: static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } LLMenuItemGL( const std::string& name, const std::string& label, KEY key = KEY_NONE, MASK = MASK_NONE ); - virtual ~LLMenuItemGL() {}; + virtual ~LLMenuItemGL(); virtual void setValue(const LLSD& value) { setLabel(value.asString()); } @@ -174,6 +226,14 @@ public: void setDrawTextDisabled(BOOL disabled) { mDrawTextDisabled = disabled; } BOOL getDrawTextDisabled() const { return mDrawTextDisabled; } + // functionality for adding callbacks after the menu is constucted + void addCallbackType(U8 theType,const std::string& name,const std::string& userdata); + + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) = 0; + protected: void setHover(BOOL hover) { mGotHover = hover; } @@ -194,6 +254,11 @@ protected: LLUIString mDrawBranchLabel; BOOL mHighlight; + + // variables used for tracking callback types that will be + // requested after the widget is in place. + std::vector mFutureCallbackRequests; + private: static LLColor4 sEnabledColor; static LLColor4 sDisabledColor; @@ -214,6 +279,7 @@ private: BOOL mDrawTextDisabled; KEY mJumpKey; + }; @@ -262,6 +328,7 @@ public: KEY key = KEY_NONE, MASK mask = MASK_NONE, BOOL enabled = TRUE, on_disabled_callback on_disabled_c = NULL); + virtual LLXMLNodePtr getXML(bool save_children = true) const; virtual std::string getType() const { return "call"; } @@ -288,6 +355,13 @@ public: //virtual void draw(); + // Functionality for tracking callback types for setting after widget is in place. + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn); + + private: menu_callback mCallback; @@ -382,6 +456,12 @@ public: // LLView Functionality //virtual void draw( void ); + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + private: BOOL* mToggle; }; @@ -434,8 +514,10 @@ public: // background colors static void setDefaultBackgroundColor( const LLColor4& color ) { sDefaultBackgroundColor = color; } - void setBackgroundColor( const LLColor4& color ) { mBackgroundColor = color; } + void setBackgroundColor( const LLColor4& color ); + void setBorderColor( const LLColor4& color ); const LLColor4& getBackgroundColor() const { return mBackgroundColor; } + const LLColor4& getBorderColor() const { return mBorderColor; } void setBackgroundVisible( BOOL b ) { mBgVisible = b; } void setCanTearOff(BOOL tear_off, LLHandle parent_floater_handle = LLHandle()); @@ -525,6 +607,8 @@ public: static BOOL getKeyboardMode() { return sKeyboardMode; } static class LLMenuHolderGL* sMenuContainer; + + BOOL setCtrlResponse(U8 llMenuItemCallType,const std::string& name,void* user_data,void *callback_fcn); protected: void createSpilloverBranch(); @@ -547,6 +631,7 @@ private: static BOOL sKeyboardMode; LLColor4 mBackgroundColor; + LLColor4 mBorderColor; BOOL mBgVisible; LLMenuItemGL* mParentMenuItem; LLUIString mLabel; @@ -623,6 +708,12 @@ public: virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn); + + private: LLHandle mBranch; }; // end class LLMenuItemBranchGL @@ -668,6 +759,12 @@ public: void show(S32 x, S32 y, BOOL mouse_down); void hide(BOOL item_selected); + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + private: LLMenuItemGL *pieItemFromXY(S32 x, S32 y); S32 pieItemIndexFromXY(S32 x, S32 y); @@ -729,6 +826,12 @@ public: void resetMenuTrigger() { mAltKeyTrigger = FALSE; } + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + private: void checkMenuTrigger(); @@ -814,6 +917,12 @@ public: virtual void draw(void); virtual U32 getNominalHeight() const; + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + private: LLHandle mParentHandle; }; @@ -832,4 +941,5 @@ private: LLEditMenuHandlerMgr() {}; }; + #endif // LL_LLMENUGL_H diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 004d063..0cafd4b 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -385,43 +385,18 @@ LLTextEditor::LLTextEditor( mHTML.clear(); // make the popup menu available - //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); - LLMenuGL* menu = new LLMenuGL("wot"); - /*if (!menu) - { - menu = new LLMenuGL(LLStringUtil::null); - }*/ - menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); - menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); - menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this)); - menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this)); - menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this)); - menu->appendSeparator("Transep"); - LLMenuGL* translatemenu = new LLMenuGL("Translate To"); - translatemenu->setCanTearOff(FALSE); - translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); - - menu->appendMenu(translatemenu); - menu->appendSeparator("Spelsep"); - //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); - menu->setCanTearOff(FALSE); - menu->setVisible(FALSE); + + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this); + if (!menu) + { + menu = new LLMenuGL(LLStringUtil::null); + } + + defineMenuCallbacks(menu); mPopupMenuHandle = menu->getHandle(); + menu->setBorderColor(gColors.getColor("MenuItemDisabledColor")); + menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); + } LLTextEditor::~LLTextEditor() @@ -476,7 +451,7 @@ void LLTextEditor::context_translate(void * data) { LLTextEditor* line = (LLTextEditor*)data; LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; - LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translation Options", TRUE) : NULL; if (!translate_menu) { return; @@ -615,6 +590,68 @@ void LLTextEditor::context_selectall(void* data) if(line)line->selectAll(); } +// method to define the associated callbacks +void LLTextEditor::defineMenuCallbacks(LLMenuGL* menu) { + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Cut Text", + this, + (void*)context_enable_cut); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Cut Text", + this, + (void*)context_cut); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Copy Text", + this, + (void*)context_enable_copy); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Copy Text", + this, + (void*)context_copy); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Paste Text", + this, + (void*)context_enable_paste); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Paste Text", + this, + (void*)context_paste); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Delete Text", + this, + (void*)context_enable_delete); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Delete Text", + this, + (void*)context_delete); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Select All Text", + this, + (void*)context_enable_selectall); + menu->setCtrlResponse(1+LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Select All Text", + this, + (void*)context_selectall); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Translate Text", + this, + (void*)context_enable_translate); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + "Translate Text", + this, + (void*)context_translate); + + + +} + + void LLTextEditor::setTrackColor( const LLColor4& color ) { mScrollbar->setTrackColor(color); diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index f2a831b..1d7a735 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h @@ -167,6 +167,7 @@ public: static void spell_add(void* data); static void spell_show(void* data); std::vector getMisspelledWordsPositions(); + void defineMenuCallbacks(LLMenuGL* menu); void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE); diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp index e67e702..3f748d4 100644 --- a/linden/indra/newview/llpanellogin.cpp +++ b/linden/indra/newview/llpanellogin.cpp @@ -200,7 +200,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, mLogoImage = LLUI::getUIImage("startup_logo.j2c"); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml"); - + #if USE_VIEWER_AUTH //leave room for the login menu bar setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); diff --git a/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml new file mode 100644 index 0000000..bc16b45 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1