diff options
Diffstat (limited to 'indra/llwindow')
-rw-r--r-- | indra/llwindow/llkeyboard.cpp | 88 | ||||
-rw-r--r-- | indra/llwindow/llkeyboard.h | 16 | ||||
-rw-r--r-- | indra/llwindow/llmousehandler.cpp | 2 | ||||
-rw-r--r-- | indra/llwindow/llmousehandler.h | 12 |
4 files changed, 62 insertions, 56 deletions
diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 5404ac50e5..f6f6c3931c 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -327,7 +327,7 @@ BOOL LLKeyboard::keyFromString(const std::string& str, KEY *key) // static -std::string LLKeyboard::stringFromKey(KEY key, bool translate) +std::string LLKeyboard::stringFromKey(KEY key) { std::string res = get_if_there(sKeysToNames, key, std::string()); if (res.empty()) @@ -338,60 +338,16 @@ std::string LLKeyboard::stringFromKey(KEY key, bool translate) res = std::string(buffer); } - if (translate) + LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; + if (trans != NULL) { - LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; - if (trans != NULL) - { - res = trans(res.c_str()); - } + res = trans(res.c_str()); } return res; } -//static -std::string LLKeyboard::stringFromAccelerator(MASK accel_mask) -{ - std::string res; - - LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; - - if (trans == NULL) - { - LL_ERRS() << "No mKeyStringTranslator" << LL_ENDL; - return res; - } - // Append any masks -#ifdef LL_DARWIN - // Standard Mac names for modifier keys in menu equivalents - // We could use the symbol characters, but they only exist in certain fonts. - if (accel_mask & MASK_CONTROL) - { - if (accel_mask & MASK_MAC_CONTROL) - { - res.append(trans("accel-mac-control")); - } - else - { - res.append(trans("accel-mac-command")); // Symbol would be "\xE2\x8C\x98" - } - } - if (accel_mask & MASK_ALT) - res.append(trans("accel-mac-option")); // Symbol would be "\xE2\x8C\xA5" - if (accel_mask & MASK_SHIFT) - res.append(trans("accel-mac-shift")); // Symbol would be "\xE2\x8C\xA7" -#else - if (accel_mask & MASK_CONTROL) - res.append(trans("accel-win-control")); - if (accel_mask & MASK_ALT) - res.append(trans("accel-win-alt")); - if (accel_mask & MASK_SHIFT) - res.append(trans("accel-win-shift")); -#endif - return res; -} //static std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key ) { @@ -403,7 +359,41 @@ std::string LLKeyboard::stringFromAccelerator( MASK accel_mask, KEY key ) return res; } - res.append(stringFromAccelerator(accel_mask)); + LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; + + if( trans == NULL ) + { + LL_ERRS() << "No mKeyStringTranslator" << LL_ENDL; + return res; + } + + // Append any masks +#ifdef LL_DARWIN + // Standard Mac names for modifier keys in menu equivalents + // We could use the symbol characters, but they only exist in certain fonts. + if( accel_mask & MASK_CONTROL ) + { + if ( accel_mask & MASK_MAC_CONTROL ) + { + res.append( trans("accel-mac-control") ); + } + else + { + res.append( trans("accel-mac-command") ); // Symbol would be "\xE2\x8C\x98" + } + } + if( accel_mask & MASK_ALT ) + res.append( trans("accel-mac-option") ); // Symbol would be "\xE2\x8C\xA5" + if( accel_mask & MASK_SHIFT ) + res.append( trans("accel-mac-shift") ); // Symbol would be "\xE2\x8C\xA7" +#else + if( accel_mask & MASK_CONTROL ) + res.append( trans("accel-win-control") ); + if( accel_mask & MASK_ALT ) + res.append( trans("accel-win-alt") ); + if( accel_mask & MASK_SHIFT ) + res.append( trans("accel-win-shift") ); +#endif std::string key_string = LLKeyboard::stringFromKey(key); if ((accel_mask & MASK_NORMALKEYS) && (key_string[0] == '-' || key_string[0] == '=' || key_string[0] == '+')) diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 36bd8bcbed..6f2dc87317 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -38,10 +38,10 @@ enum EKeystate { KEYSTATE_DOWN, KEYSTATE_LEVEL, - KEYSTATE_UP + KEYSTATE_UP }; -typedef boost::function<bool(EKeystate keystate)> LLKeyFunc; +typedef boost::function<void(EKeystate keystate)> LLKeyFunc; typedef std::string (LLKeyStringTranslatorFunc)(const char *label); enum EKeyboardInsertMode @@ -50,6 +50,15 @@ enum EKeyboardInsertMode LL_KIM_OVERWRITE }; +class LLKeyBinding +{ +public: + KEY mKey; + MASK mMask; +// const char *mName; // unused + LLKeyFunc mFunction; +}; + class LLWindowCallbacks; class LLKeyboard @@ -94,8 +103,7 @@ public: static BOOL maskFromString(const std::string& str, MASK *mask); // False on failure static BOOL keyFromString(const std::string& str, KEY *key); // False on failure - static std::string stringFromKey(KEY key, bool translate = true); - static std::string stringFromAccelerator( MASK accel_mask ); // separated for convinience, returns with "+": "Shift+" or "Shift+Alt+"... + static std::string stringFromKey(KEY key); static std::string stringFromAccelerator( MASK accel_mask, KEY key ); void setCallbacks(LLWindowCallbacks *cbs) { mCallbacks = cbs; } diff --git a/indra/llwindow/llmousehandler.cpp b/indra/llwindow/llmousehandler.cpp index e41ebd42f3..d5fa65fe4b 100644 --- a/indra/llwindow/llmousehandler.cpp +++ b/indra/llwindow/llmousehandler.cpp @@ -27,7 +27,7 @@ #include "llmousehandler.h" //virtual -BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down) +BOOL LLMouseHandler::handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down) { BOOL handled = FALSE; if (down) diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h index d221dd117c..1dcd0348d8 100644 --- a/indra/llwindow/llmousehandler.h +++ b/indra/llwindow/llmousehandler.h @@ -29,7 +29,6 @@ #include "linden_common.h" #include "llrect.h" -#include "indra_constants.h" // Mostly-abstract interface. // Intended for use via multiple inheritance. @@ -47,7 +46,16 @@ public: SHOW_ALWAYS, } EShowToolTip; - virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EMouseClickType clicktype, BOOL down); + typedef enum { + CLICK_LEFT, + CLICK_MIDDLE, + CLICK_RIGHT, + CLICK_BUTTON4, + CLICK_BUTTON5, + CLICK_DOUBLELEFT + } EClickType; + + virtual BOOL handleAnyMouseClick(S32 x, S32 y, MASK mask, EClickType clicktype, BOOL down); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask) = 0; virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask) = 0; |