diff options
233 files changed, 6692 insertions, 7623 deletions
diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index 39ee014241..504552a9d2 100644 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -58,6 +58,12 @@ #ifdef LL_WINDOWS #pragma warning (3 : 4702) // we like level 3, not 4 +// level 4 warnings that we need to disable: +#pragma warning (disable : 4100) // unreferenced formal parameter +#pragma warning (disable : 4127) // conditional expression is constant (e.g. while(1) ) +#pragma warning (disable : 4244) // possible loss of data on conversions +#pragma warning (disable : 4512) // assignment operator could not be generated +#pragma warning (disable : 4706) // assignment within conditional (even if((x = y)) ) #endif // LL_WINDOWS // Linden only libs in alpha-order other than stdtypes.h diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index b72046c104..b0a47b6820 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -243,25 +243,25 @@ protected: // Expands LLPointer to return a pointer to a special instance of class Type instead of NULL. // This is useful in instances where operations on NULL pointers are semantically safe and/or // when error checking occurs at a different granularity or in a different part of the code -// than when referencing an object via a LLHandle. +// than when referencing an object via a LLSafeHandle. // template <class Type> -class LLHandle +class LLSafeHandle { public: - LLHandle() : + LLSafeHandle() : mPointer(NULL) { } - LLHandle(Type* ptr) : + LLSafeHandle(Type* ptr) : mPointer(NULL) { assign(ptr); } - LLHandle(const LLHandle<Type>& ptr) : + LLSafeHandle(const LLSafeHandle<Type>& ptr) : mPointer(NULL) { assign(ptr.mPointer); @@ -269,13 +269,13 @@ public: // support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> - LLHandle(const LLHandle<Subclass>& ptr) : + LLSafeHandle(const LLSafeHandle<Subclass>& ptr) : mPointer(NULL) { assign(ptr.get()); } - ~LLHandle() + ~LLSafeHandle() { unref(); } @@ -300,17 +300,17 @@ public: operator const Type*() const { return mPointer; } bool operator !=(Type* ptr) const { return (mPointer != ptr); } bool operator ==(Type* ptr) const { return (mPointer == ptr); } - bool operator ==(const LLHandle<Type>& ptr) const { return (mPointer == ptr.mPointer); } - bool operator < (const LLHandle<Type>& ptr) const { return (mPointer < ptr.mPointer); } - bool operator > (const LLHandle<Type>& ptr) const { return (mPointer > ptr.mPointer); } + bool operator ==(const LLSafeHandle<Type>& ptr) const { return (mPointer == ptr.mPointer); } + bool operator < (const LLSafeHandle<Type>& ptr) const { return (mPointer < ptr.mPointer); } + bool operator > (const LLSafeHandle<Type>& ptr) const { return (mPointer > ptr.mPointer); } - LLHandle<Type>& operator =(Type* ptr) + LLSafeHandle<Type>& operator =(Type* ptr) { assign(ptr); return *this; } - LLHandle<Type>& operator =(const LLHandle<Type>& ptr) + LLSafeHandle<Type>& operator =(const LLSafeHandle<Type>& ptr) { assign(ptr.mPointer); return *this; @@ -318,7 +318,7 @@ public: // support assignment up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> - LLHandle<Type>& operator =(const LLHandle<Subclass>& ptr) + LLSafeHandle<Type>& operator =(const LLSafeHandle<Subclass>& ptr) { assign(ptr.get()); return *this; @@ -399,11 +399,25 @@ protected: //---------------------------------------------------------------------------- -// LLSingleton implements the getInstance() method part of the Singleton pattern. It can't make -// the derived class constructors protected, though, so you have to do that yourself. -// The proper way to use LLSingleton is to inherit from it while using the typename that you'd -// like to be static as the template parameter, like so: -// class FooBar: public LLSingleton<FooBar> +// LLSingleton implements the getInstance() method part of the Singleton +// pattern. It can't make the derived class constructors protected, though, so +// you have to do that yourself. +// +// There are two ways to use LLSingleton. The first way is to inherit from it +// while using the typename that you'd like to be static as the template +// parameter, like so: +// +// class Foo: public LLSingleton<Foo>{}; +// +// Foo* instance = Foo::getInstance(); +// +// The second way is to define a seperate class that exposes the singleton +// interface: +// +// class FooSingleton: public LLSingleton<Foo>{}; +// +// Foo* instance = FooSingleton::getInstance(); +// // As currently written, it is not thread-safe. template <typename T> class LLSingleton diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h index e7b15dcc58..1fa5a741d5 100644 --- a/indra/llmath/llrect.h +++ b/indra/llmath/llrect.h @@ -152,68 +152,74 @@ public: mBottom <= rect->mTop && rect->mBottom <= mTop ; } - void set(Type left, Type top, Type right, Type bottom) + LLRectBase& set(Type left, Type top, Type right, Type bottom) { mLeft = left; mTop = top; mRight = right; mBottom = bottom; + return *this; } // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect - void setOriginAndSize( Type left, Type bottom, Type width, Type height) + LLRectBase& setOriginAndSize( Type left, Type bottom, Type width, Type height) { mLeft = left; mTop = bottom + height; mRight = left + width; mBottom = bottom; + return *this; } // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect - void setLeftTopAndSize( Type left, Type top, Type width, Type height) + LLRectBase& setLeftTopAndSize( Type left, Type top, Type width, Type height) { mLeft = left; mTop = top; mRight = left + width; mBottom = top - height; + return *this; } - void setCenterAndSize(Type x, Type y, Type width, Type height) + LLRectBase& setCenterAndSize(Type x, Type y, Type width, Type height) { mLeft = x - width/2; mTop = y + height/2; mRight = x + width/2; mBottom = y - height/2; + return *this; } - void translate(Type horiz, Type vertical) + LLRectBase& translate(Type horiz, Type vertical) { mLeft += horiz; mRight += horiz; mTop += vertical; mBottom += vertical; + return *this; } - void stretch( Type dx, Type dy) + LLRectBase& stretch( Type dx, Type dy) { mLeft -= dx; mRight += dx; mTop += dy; mBottom -= dy; - makeValid(); + return makeValid(); } - void stretch( Type delta ) + LLRectBase& stretch( Type delta ) { stretch(delta, delta); - + return *this; } - void makeValid() + LLRectBase& makeValid() { mLeft = llmin(mLeft, mRight); mBottom = llmin(mBottom, mTop); + return *this; } bool isNull() const @@ -221,15 +227,16 @@ public: return mLeft == mRight || mBottom == mTop; } - void unionWith(const LLRectBase &other) + LLRectBase& unionWith(const LLRectBase &other) { mLeft = llmin(mLeft, other.mLeft); mRight = llmax(mRight, other.mRight); mBottom = llmin(mBottom, other.mBottom); mTop = llmax(mTop, other.mTop); + return *this; } - void intersectWith(const LLRectBase &other) + LLRectBase& intersectWith(const LLRectBase &other) { mLeft = llmax(mLeft, other.mLeft); mRight = llmin(mRight, other.mRight); @@ -243,6 +250,7 @@ public: { mBottom = mTop; } + return *this; } friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect) diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 3472c3eb5d..274bf5cc04 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -46,8 +46,6 @@ const char* CN_WAITING = "(waiting)"; const char* CN_NOBODY = "(nobody)"; const char* CN_NONE = "(none)"; -const char* CN_HIPPOS = "(hippos)"; -const F32 HIPPO_PROBABILITY = 0.01f; // llsd serialization constants static const std::string AGENTS("agents"); @@ -498,35 +496,26 @@ void LLCacheName::exportFile(std::ostream& ostr) } -BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) +BOOL LLCacheName::getName(const LLUUID& id, std::string& first, std::string& last) { if(id.isNull()) { - // The function signature needs to change to pass in the - // length of first and last. - strcpy(first, CN_NOBODY); /*Flawfinder: ignore*/ - last[0] = '\0'; + first = CN_NOBODY; + last.clear(); return FALSE; } LLCacheNameEntry* entry = get_ptr_in_map(impl.mCache, id ); if (entry) { - // The function signature needs to change to pass in the - // length of first and last. - strcpy(first, entry->mFirstName); /*Flawfinder: ignore*/ - strcpy(last, entry->mLastName); /*Flawfinder: ignore*/ + first = entry->mFirstName; + last = entry->mLastName; return TRUE; } else { - //The function signature needs to change to pass in the - //length of first and last. - strcpy(first,(ll_frand() < HIPPO_PROBABILITY) - ? CN_HIPPOS - : CN_WAITING); - strcpy(last, ""); /*Flawfinder: ignore*/ - + first = CN_WAITING; + last.clear(); if (!impl.isRequestPending(id)) { impl.mAskNameQueue.insert(id); @@ -536,15 +525,29 @@ BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) } +BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname) +{ + std::string first_name, last_name; + BOOL res = getName(id, first_name, last_name); + fullname = first_name + " " + last_name; + return res; +} +// *TODO: Deprecate +BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) +{ + std::string first_name, last_name; + BOOL res = getName(id, first_name, last_name); + strcpy(first, first_name.c_str()); + strcpy(last, last_name.c_str()); + return res; +} -BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) +BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) { - // The function signature needs to change to pass in the - // length of first and last. - strcpy(group, CN_NONE); /*Flawfinder: ignore*/ + group = CN_NONE; return FALSE; } @@ -560,16 +563,12 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) if (entry) { - // The function signature needs to change to pass in the length - // of group. - strcpy(group, entry->mGroupName); /*Flawfinder: ignore*/ + group = entry->mGroupName; return TRUE; } else { - // The function signature needs to change to pass in the length - // of first and last. - strcpy(group, CN_WAITING); /*Flawfinder: ignore*/ + group = CN_WAITING; if (!impl.isRequestPending(id)) { impl.mAskGroupQueue.insert(id); @@ -578,6 +577,16 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) } } +// *TODO: Deprecate +BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) +{ + std::string group_name; + BOOL res = getGroupName(id, group_name); + strcpy(group, group_name.c_str()); + return res; +} + + // TODO: Make the cache name callback take a SINGLE std::string, // not a separate first and last name. void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callback, void* user_data) diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 4eae6365bc..d9518e0f91 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -76,12 +76,15 @@ public: // If not available, copies the string "waiting". // Returns TRUE iff available. BOOL getName(const LLUUID& id, char* first, char* last); + BOOL getName(const LLUUID& id, std::string& first, std::string& last); + BOOL getFullName(const LLUUID& id, std::string& fullname); // If available, this method copies the group name into the string // provided. The caller must allocate at least // DB_GROUP_NAME_BUF_SIZE characters. If not available, this // method copies the string "waiting". Returns TRUE iff available. BOOL getGroupName(const LLUUID& id, char* group); + BOOL getGroupName(const LLUUID& id, std::string& group); // Call the callback with the group or avatar name. // If the data is currently available, may call the callback immediatly diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index ce3a4b64c7..6c27ccc037 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -189,7 +189,7 @@ void LLButton::init(void (*click_callback)(void*), void *callback_data, const LL mGLFont = ( font ? font : LLFontGL::sSansSerif); // Hack to make sure there is space for at least one character - if (mRect.getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(" ")) + if (getRect().getWidth() - (mRightHPad + mLeftHPad) < mGLFont->getWidth(" ")) { // Use old defaults mLeftHPad = LLBUTTON_ORIG_H_PAD; @@ -252,12 +252,12 @@ void LLButton::onCommit() (*mMouseUpCallback)(mCallbackUserData); } - if (mSoundFlags & MOUSE_DOWN) + if (getSoundFlags() & MOUSE_DOWN) { make_ui_sound("UISndClick"); } - if (mSoundFlags & MOUSE_UP) + if (getSoundFlags() & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } @@ -279,7 +279,7 @@ void LLButton::onCommit() BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent) { BOOL handled = FALSE; - if( getVisible() && mEnabled && !called_from_parent && ' ' == uni_char && !gKeyboard->getKeyRepeated(' ')) + if( getVisible() && getEnabled() && !called_from_parent && ' ' == uni_char && !gKeyboard->getKeyRepeated(' ')) { if (mIsToggle) { @@ -298,7 +298,7 @@ BOOL LLButton::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_parent) BOOL LLButton::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent ) { BOOL handled = FALSE; - if( getVisible() && mEnabled && !called_from_parent ) + if( getVisible() && getEnabled() && !called_from_parent ) { if( mCommitOnReturn && KEY_RETURN == key && mask == MASK_NONE && !gKeyboard->getKeyRepeated(key)) { @@ -337,7 +337,7 @@ BOOL LLButton::handleMouseDown(S32 x, S32 y, MASK mask) mMouseDownTimer.start(); mMouseDownFrame = LLFrameTimer::getFrameCount(); - if (mSoundFlags & MOUSE_DOWN) + if (getSoundFlags() & MOUSE_DOWN) { make_ui_sound("UISndClick"); } @@ -367,7 +367,7 @@ BOOL LLButton::handleMouseUp(S32 x, S32 y, MASK mask) // If mouseup in the widget, it's been clicked if (pointInView(x, y)) { - if (mSoundFlags & MOUSE_UP) + if (getSoundFlags() & MOUSE_UP) { make_ui_sound("UISndClickRelease"); } @@ -400,7 +400,7 @@ BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) if (mMouseDownTimer.getStarted() && NULL != mHeldDownCallback) { - F32 elapsed = mMouseDownTimer.getElapsedTimeF32(); + F32 elapsed = getHeldDownTime(); if( mHeldDownDelay <= elapsed && mHeldDownFrameDelay <= LLFrameTimer::getFrameCount() - mMouseDownFrame) { mHeldDownCallback( mCallbackUserData ); @@ -505,11 +505,11 @@ void LLButton::draw() // enabled and tentative // or // disabled but checked - if (!mImageDisabledSelected.isNull() && ( (mEnabled && mTentative) || (!mEnabled && pressed ) ) ) + if (!mImageDisabledSelected.isNull() && ( (getEnabled() && getTentative()) || (!getEnabled() && pressed ) ) ) { mImagep = mImageDisabledSelected; } - else if (!mImageDisabled.isNull() && !mEnabled && !pressed) + else if (!mImageDisabled.isNull() && !getEnabled() && !pressed) { mImagep = mImageDisabled; } @@ -523,7 +523,7 @@ void LLButton::draw() LLColor4 label_color; // label changes when button state changes, not when pressed - if ( mEnabled ) + if ( getEnabled() ) { if ( mToggleState ) { @@ -551,7 +551,7 @@ void LLButton::draw() if( mToggleState ) { - if( mEnabled || mDisabledSelectedLabel.empty() ) + if( getEnabled() || mDisabledSelectedLabel.empty() ) { label = mSelectedLabel; } @@ -562,7 +562,7 @@ void LLButton::draw() } else { - if( mEnabled || mDisabledLabel.empty() ) + if( getEnabled() || mDisabledLabel.empty() ) { label = mUnselectedLabel; } @@ -573,7 +573,7 @@ void LLButton::draw() } // draw default button border - if (mEnabled && mBorderEnabled && gFocusMgr.getAppHasFocus()) // because we're the default button in a panel + if (getEnabled() && mBorderEnabled && gFocusMgr.getAppHasFocus()) // because we're the default button in a panel { drawBorder(LLUI::sColorsGroup->getColor( "ButtonBorderColor" ), BORDER_SIZE); } @@ -598,7 +598,7 @@ void LLButton::draw() // Otherwise draw basic rectangular button. if( mImagep.notNull() && !mScaleImage) { - mImagep->draw(0, 0, mEnabled ? mImageColor : mDisabledImageColor ); + mImagep->draw(0, 0, getEnabled() ? mImageColor : mDisabledImageColor ); if (mCurGlowStrength > 0.01f) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -609,26 +609,26 @@ void LLButton::draw() else if ( mImagep.notNull() && mScaleImage) { - mImagep->draw(0, 0, mRect.getWidth(), mRect.getHeight(), mEnabled ? mImageColor : mDisabledImageColor ); + mImagep->draw(0, 0, getRect().getWidth(), getRect().getHeight(), getEnabled() ? mImageColor : mDisabledImageColor ); if (mCurGlowStrength > 0.01f) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); - mImagep->drawSolid(0, 0, mRect.getWidth(), mRect.getHeight(), LLColor4(1.f, 1.f, 1.f, mCurGlowStrength)); + mImagep->drawSolid(0, 0, getRect().getWidth(), getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, mCurGlowStrength)); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } else { // no image - llwarns << "No image for button " << mName << llendl; + llwarns << "No image for button " << getName() << llendl; // draw it in pink so we can find it - gl_rect_2d(0, mRect.getHeight(), mRect.getWidth(), 0, LLColor4::pink1, FALSE); + gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4::pink1, FALSE); } // let overlay image and text play well together S32 text_left = mLeftHPad; - S32 text_right = mRect.getWidth() - mRightHPad; - S32 text_width = mRect.getWidth() - mLeftHPad - mRightHPad; + S32 text_right = getRect().getWidth() - mRightHPad; + S32 text_width = getRect().getWidth() - mLeftHPad - mRightHPad; // draw overlay image if (mImageOverlay.notNull()) @@ -637,7 +637,7 @@ void LLButton::draw() S32 overlay_width = mImageOverlay->getWidth(); S32 overlay_height = mImageOverlay->getHeight(); - F32 scale_factor = llmin((F32)mRect.getWidth() / (F32)overlay_width, (F32)mRect.getHeight() / (F32)overlay_height, 1.f); + F32 scale_factor = llmin((F32)getRect().getWidth() / (F32)overlay_width, (F32)getRect().getHeight() / (F32)overlay_height, 1.f); overlay_width = llround((F32)overlay_width * scale_factor); overlay_height = llround((F32)overlay_height * scale_factor); @@ -682,7 +682,7 @@ void LLButton::draw() text_right -= overlay_width + 1; text_width -= overlay_width + 1; mImageOverlay->draw( - mRect.getWidth() - mRightHPad - overlay_width, + getRect().getWidth() - mRightHPad - overlay_width, center_y - (overlay_height / 2), overlay_width, overlay_height, @@ -706,7 +706,7 @@ void LLButton::draw() x = text_right; break; case LLFontGL::HCENTER: - x = mRect.getWidth() / 2; + x = getRect().getWidth() / 2; break; case LLFontGL::LEFT: default: @@ -714,7 +714,7 @@ void LLButton::draw() break; } - S32 y_offset = 2 + (mRect.getHeight() - 20)/2; + S32 y_offset = 2 + (getRect().getHeight() - 20)/2; if (pressed) { @@ -743,8 +743,8 @@ void LLButton::draw() void LLButton::drawBorder(const LLColor4& color, S32 size) { S32 left = -size; - S32 top = mRect.getHeight() + size; - S32 right = mRect.getWidth() + size; + S32 top = getRect().getHeight() + size; + S32 right = getRect().getWidth() + size; S32 bottom = -size; if (mImagep.isNull()) @@ -1146,7 +1146,7 @@ LLView* LLButton::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa return button; } -void LLButton::setHelpURLCallback(std::string help_url) +void LLButton::setHelpURLCallback(const LLString &help_url) { mHelpURL = help_url; setClickedCallback(clicked_help,this); diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 0e140a45a6..a181fbbf56 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -52,10 +52,14 @@ extern S32 LLBUTTON_V_PAD; extern S32 BTN_HEIGHT_SMALL; extern S32 BTN_HEIGHT; - // All button widths should be rounded up to this size extern S32 BTN_GRID; +// +// Helpful functions +// +S32 round_up(S32 grid, S32 value); + class LLUICtrlFactory; @@ -124,6 +128,7 @@ public: BOOL getFlashing() const { return mFlashing; } void setHAlign( LLFontGL::HAlign align ) { mHAlign = align; } + LLFontGL::HAlign getHAlign() const { return mHAlign; } void setLeftHPad( S32 pad ) { mLeftHPad = pad; } void setRightHPad( S32 pad ) { mRightHPad = pad; } @@ -162,6 +167,7 @@ public: void setFont(const LLFontGL *font) { mGLFont = ( font ? font : LLFontGL::sSansSerif); } void setScaleImage(BOOL scale) { mScaleImage = scale; } + BOOL getScaleImage() const { return mScaleImage; } void setDropShadowedText(BOOL b) { mDropShadowedText = b; } @@ -171,9 +177,10 @@ public: void setHoverGlowStrength(F32 strength) { mHoverGlowStrength = strength; } -public: void setImageUnselected(const LLString &image_name); + const LLString& getImageUnselectedName() const { return mImageUnselectedName; } void setImageSelected(const LLString &image_name); + const LLString& getImageSelectedName() const { return mImageSelectedName; } void setImageHoverSelected(const LLString &image_name); void setImageHoverUnselected(const LLString &image_name); void setImageDisabled(const LLString &image_name); @@ -187,14 +194,29 @@ public: void setImageDisabledSelected(LLPointer<LLUIImage> image); void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; } - BOOL getCommitOnReturn() { return mCommitOnReturn; } + BOOL getCommitOnReturn() const { return mCommitOnReturn; } + + void setHelpURLCallback(const LLString &help_url); + const LLString& getHelpURL() const { return mHelpURL; } - void setHelpURLCallback(std::string help_url); - LLString getHelpURL() { return mHelpURL; } protected: + virtual void drawBorder(const LLColor4& color, S32 size); -protected: + void setImageUnselectedID(const LLUUID &image_id); + const LLUUID& getImageUnselectedID() const { return mImageUnselectedID; } + void setImageSelectedID(const LLUUID &image_id); + const LLUUID& getImageSelectedID() const { return mImageSelectedID; } + void setImageHoverSelectedID(const LLUUID &image_id); + void setImageHoverUnselectedID(const LLUUID &image_id); + void setImageDisabledID(const LLUUID &image_id); + void setImageDisabledSelectedID(const LLUUID &image_id); + const LLPointer<LLUIImage>& getImageUnselected() const { return mImageUnselected; } + const LLPointer<LLUIImage>& getImageSelected() const { return mImageSelected; } + + LLFrameTimer mMouseDownTimer; + +private: void (*mClickedCallback)(void* data ); void (*mMouseDownCallback)(void *data); @@ -203,7 +225,6 @@ protected: const LLFontGL *mGLFont; - LLFrameTimer mMouseDownTimer; S32 mMouseDownFrame; F32 mHeldDownDelay; // seconds, after which held-down callbacks get called S32 mHeldDownFrameDelay; // frames, after which held-down callbacks get called @@ -232,7 +253,6 @@ protected: LLUIString mDisabledSelectedLabel; LLColor4 mDisabledSelectedLabelColor; - LLUUID mImageUnselectedID; LLUUID mImageSelectedID; LLUUID mImageHoverSelectedID; @@ -280,7 +300,4 @@ protected: LLFrameTimer mFlashingTimer; }; -// Helpful functions -S32 round_up(S32 grid, S32 value); - #endif // LL_LLBUTTON_H diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index b0a7e9d27f..536e9a6dc6 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -212,7 +212,7 @@ void LLCheckBoxCtrl::reshape(S32 width, S32 height, BOOL called_from_parent) void LLCheckBoxCtrl::draw() { - if (mEnabled) + if (getEnabled()) { mLabel->setColor( mTextEnabledColor ); } diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp index fc3967f5bf..b5c46cdff1 100644 --- a/indra/llui/llclipboard.cpp +++ b/indra/llui/llclipboard.cpp @@ -61,7 +61,7 @@ void LLClipboard::copyFromSubstring(const LLWString &src, S32 pos, S32 len, cons } -LLWString LLClipboard::getPasteWString( LLUUID* source_id ) +const LLWString& LLClipboard::getPasteWString( LLUUID* source_id ) { if( mSourceID.notNull() ) { @@ -88,7 +88,7 @@ LLWString LLClipboard::getPasteWString( LLUUID* source_id ) } -BOOL LLClipboard::canPasteString() +BOOL LLClipboard::canPasteString() const { return LLView::getWindow()->isClipboardTextAvailable(); } diff --git a/indra/llui/llclipboard.h b/indra/llui/llclipboard.h index 999a17acc2..31ebd04826 100644 --- a/indra/llui/llclipboard.h +++ b/indra/llui/llclipboard.h @@ -36,24 +36,20 @@ #include "llstring.h" #include "lluuid.h" -// -// Classes -// + class LLClipboard { -protected: - LLUUID mSourceID; - LLWString mString; - public: LLClipboard(); ~LLClipboard(); void copyFromSubstring(const LLWString ©_from, S32 pos, S32 len, const LLUUID& source_id = LLUUID::null ); - - - BOOL canPasteString(); - LLWString getPasteWString(LLUUID* source_id = NULL); + BOOL canPasteString() const; + const LLWString& getPasteWString(LLUUID* source_id = NULL); + +private: + LLUUID mSourceID; + LLWString mString; }; diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 28237823dd..250ca523d2 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -99,7 +99,7 @@ LLComboBox::LLComboBox( const LLString& name, const LLRect &rect, const LLString mList->setCommitOnKeyboardMovement(FALSE); addChild(mList); - LLRect border_rect(0, mRect.getHeight(), mRect.getWidth(), 0); + LLRect border_rect(0, getRect().getHeight(), getRect().getWidth(), 0); mBorder = new LLViewBorder( "combo border", border_rect ); addChild( mBorder ); mBorder->setFollowsAll(); @@ -444,7 +444,7 @@ void LLComboBox::setButtonVisible(BOOL visible) mButton->setVisible(visible); if (mTextEntry) { - LLRect text_entry_rect(0, mRect.getHeight(), mRect.getWidth(), 0); + LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); if (visible) { text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); @@ -460,7 +460,7 @@ void LLComboBox::draw() { mBorder->setKeyboardFocusHighlight(hasFocus()); - mButton->setEnabled(mEnabled /*&& !mList->isEmpty()*/); + mButton->setEnabled(getEnabled() /*&& !mList->isEmpty()*/); // Draw children normally LLUICtrl::draw(); @@ -494,13 +494,13 @@ void LLComboBox::updateLayout() if (mAllowTextEntry) { S32 shadow_size = LLUI::sConfigGroup->getS32("DropShadowButton"); - mButton->setRect(LLRect( mRect.getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size, + mButton->setRect(LLRect( getRect().getWidth() - llmax(8,mArrowImage->getWidth(0)) - 2 * shadow_size, rect.mTop, rect.mRight, rect.mBottom)); mButton->setTabStop(FALSE); if (!mTextEntry) { - LLRect text_entry_rect(0, mRect.getHeight(), mRect.getWidth(), 0); + LLRect text_entry_rect(0, getRect().getHeight(), getRect().getWidth(), 0); text_entry_rect.mRight -= llmax(8,mArrowImage->getWidth(0)) + 2 * LLUI::sConfigGroup->getS32("DropShadowButton"); // clear label on button LLString cur_label = mButton->getLabelSelected(); @@ -575,7 +575,7 @@ void LLComboBox::showList() LLRect rect = mList->getRect(); - S32 min_width = mRect.getWidth(); + S32 min_width = getRect().getWidth(); S32 max_width = llmax(min_width, MAX_COMBO_WIDTH); S32 list_width = llclamp(mList->getMaxContentWidth(), min_width, max_width); @@ -589,7 +589,7 @@ void LLComboBox::showList() else { // stack on top or bottom, depending on which has more room - if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight()) + if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight()) { // Move rect so it hangs off the bottom of this view rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); @@ -597,21 +597,21 @@ void LLComboBox::showList() else { // move rect so it stacks on top of this view (clipped to size of screen) - rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); + rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); } } } else // ABOVE { - if (rect.getHeight() <= root_view_local.mTop - mRect.getHeight()) + if (rect.getHeight() <= root_view_local.mTop - getRect().getHeight()) { // move rect so it stacks on top of this view (clipped to size of screen) - rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); + rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); } else { // stack on top or bottom, depending on which has more room - if (-root_view_local.mBottom > root_view_local.mTop - mRect.getHeight()) + if (-root_view_local.mBottom > root_view_local.mTop - getRect().getHeight()) { // Move rect so it hangs off the bottom of this view rect.setLeftTopAndSize(0, 0, list_width, llmin(-root_view_local.mBottom, rect.getHeight())); @@ -619,7 +619,7 @@ void LLComboBox::showList() else { // move rect so it stacks on top of this view (clipped to size of screen) - rect.setOriginAndSize(0, mRect.getHeight(), list_width, llmin(root_view_local.mTop - mRect.getHeight(), rect.getHeight())); + rect.setOriginAndSize(0, getRect().getHeight(), list_width, llmin(root_view_local.mTop - getRect().getHeight(), rect.getHeight())); } } @@ -752,15 +752,15 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_ { tool_tip = getShowNamesToolTip(); } - else if (!mToolTipMsg.empty()) - { - tool_tip = mToolTipMsg; - } else { - tool_tip = getValue().asString(); + tool_tip = getToolTip(); + if (tool_tip.empty()) + { + tool_tip = getValue().asString(); + } } - + if( !tool_tip.empty() ) { msg = tool_tip; @@ -770,7 +770,7 @@ BOOL LLComboBox::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_ 0, 0, &(sticky_rect_screen->mLeft), &(sticky_rect_screen->mBottom) ); localPointToScreen( - mRect.getWidth(), mRect.getHeight(), + getRect().getWidth(), getRect().getHeight(), &(sticky_rect_screen->mRight), &(sticky_rect_screen->mTop) ); } return TRUE; @@ -1037,11 +1037,11 @@ BOOL LLComboBox::setCurrentByID(const LLUUID& id) return found; } -LLUUID LLComboBox::getCurrentID() +LLUUID LLComboBox::getCurrentID() const { return mList->getStringUUIDSelectedItem(); } -BOOL LLComboBox::setSelectedByValue(LLSD value, BOOL selected) +BOOL LLComboBox::setSelectedByValue(const LLSD& value, BOOL selected) { BOOL found = mList->setSelectedByValue(value, selected); if (found) @@ -1056,7 +1056,7 @@ LLSD LLComboBox::getSelectedValue() return mList->getSelectedValue(); } -BOOL LLComboBox::isSelected(LLSD value) +BOOL LLComboBox::isSelected(const LLSD& value) const { return mList->isSelected(value); } @@ -1190,14 +1190,14 @@ void LLFlyoutButton::updateLayout() { LLComboBox::updateLayout(); - mButton->setOrigin(mRect.getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); - mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, mRect.getHeight()); + mButton->setOrigin(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, 0); + mButton->reshape(FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); mButton->setFollows(FOLLOWS_RIGHT | FOLLOWS_TOP | FOLLOWS_BOTTOM); mButton->setTabStop(FALSE); mButton->setImageOverlay(mListPosition == BELOW ? "down_arrow.tga" : "up_arrow.tga", LLFontGL::RIGHT); mActionButton->setOrigin(0, 0); - mActionButton->reshape(mRect.getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, mRect.getHeight()); + mActionButton->reshape(getRect().getWidth() - FLYOUT_BUTTON_ARROW_WIDTH, getRect().getHeight()); } //static diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 303ba83e92..13c2455d61 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -158,10 +158,10 @@ public: virtual BOOL selectNthItem( S32 index ) { return setCurrentByIndex(index); } virtual S32 getFirstSelectedIndex() const { return getCurrentIndex(); } virtual BOOL setCurrentByID( const LLUUID& id ); - virtual LLUUID getCurrentID(); // LLUUID::null if no items in menu - virtual BOOL setSelectedByValue(LLSD value, BOOL selected); + virtual LLUUID getCurrentID() const; // LLUUID::null if no items in menu + virtual BOOL setSelectedByValue(const LLSD& value, BOOL selected); virtual LLSD getSelectedValue(); - virtual BOOL isSelected(LLSD value); + virtual BOOL isSelected(const LLSD& value) const; virtual BOOL operateOnSelection(EOperation op); virtual BOOL operateOnAll(EOperation op); @@ -182,18 +182,20 @@ public: void updateSelection(); virtual void showList(); virtual void hideList(); - + protected: LLButton* mButton; LLScrollListCtrl* mList; - S32 mButtonPadding; LLViewBorder* mBorder; + EPreferredPosition mListPosition; + LLPointer<LLImageGL> mArrowImage; + +private: + S32 mButtonPadding; LLLineEditor* mTextEntry; - LLPointer<LLImageGL> mArrowImage; BOOL mAllowTextEntry; S32 mMaxChars; BOOL mTextEntryTentative; - EPreferredPosition mListPosition; void (*mPrearrangeCallback)(LLUICtrl*,void*); void (*mTextEntryCallback)(LLLineEditor*, void*); }; diff --git a/indra/llui/llctrlselectioninterface.h b/indra/llui/llctrlselectioninterface.h index 77811d049b..e43e20a4c0 100644 --- a/indra/llui/llctrlselectioninterface.h +++ b/indra/llui/llctrlselectioninterface.h @@ -63,14 +63,14 @@ public: // TomY TODO: Simply cast the UUIDs to LLSDs, using the selectByValue function virtual BOOL setCurrentByID( const LLUUID& id ) = 0; - virtual LLUUID getCurrentID() = 0; + virtual LLUUID getCurrentID() const = 0; - BOOL selectByValue(LLSD value); - BOOL deselectByValue(LLSD value); - virtual BOOL setSelectedByValue(LLSD value, BOOL selected) = 0; + BOOL selectByValue(const LLSD value); + BOOL deselectByValue(const LLSD value); + virtual BOOL setSelectedByValue(const LLSD& value, BOOL selected) = 0; virtual LLSD getSelectedValue() = 0; - virtual BOOL isSelected(LLSD value) = 0; + virtual BOOL isSelected(const LLSD& value) const = 0; virtual BOOL operateOnSelection(EOperation op) = 0; virtual BOOL operateOnAll(EOperation op) = 0; @@ -100,7 +100,7 @@ class LLCtrlScrollInterface public: virtual ~LLCtrlScrollInterface(); - virtual S32 getScrollPos() = 0; + virtual S32 getScrollPos() const = 0; virtual void setScrollPos( S32 pos ) = 0; virtual void scrollToShowSelected() = 0; }; diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index ca536ea024..a4e92e11d0 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -74,7 +74,24 @@ LLDragHandle::LLDragHandle( const LLString& name, const LLRect& rect, const LLSt void LLDragHandle::setTitleVisible(BOOL visible) { - mTitleBox->setVisible(visible); + if(mTitleBox) + { + mTitleBox->setVisible(visible); + } +} + +void LLDragHandle::setTitleBox(LLTextBox* titlebox) +{ + if( mTitleBox ) + { + removeChild(mTitleBox); + delete mTitleBox; + } + mTitleBox = titlebox; + if(mTitleBox) + { + addChild( mTitleBox ); + } } LLDragHandleTop::LLDragHandleTop(const LLString& name, const LLRect &rect, const LLString& title) @@ -113,46 +130,28 @@ LLString LLDragHandleLeft::getWidgetTag() const void LLDragHandleTop::setTitle(const LLString& title) { - if( mTitleBox ) - { - removeChild(mTitleBox); - delete mTitleBox; - } - LLString trimmed_title = title; LLString::trim(trimmed_title); const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); - mTitleBox = new LLTextBox( "Drag Handle Title", mRect, trimmed_title, font ); - mTitleBox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); - mTitleBox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); - reshapeTitleBox(); + LLTextBox* titlebox = new LLTextBox( "Drag Handle Title", getRect(), trimmed_title, font ); + titlebox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); + titlebox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); - // allow empty titles, as default behavior replaces them with title box name - if (trimmed_title.empty()) - { - mTitleBox->setText(LLString::null); - } - addChild( mTitleBox ); + setTitleBox(titlebox); + reshapeTitleBox(); } const LLString& LLDragHandleTop::getTitle() const { - return mTitleBox->getText(); + return getTitleBox() == NULL ? LLString::null : getTitleBox()->getText(); } void LLDragHandleLeft::setTitle(const LLString& ) { - if( mTitleBox ) - { - removeChild(mTitleBox); - delete mTitleBox; - } - - mTitleBox = NULL; - + setTitleBox(NULL); /* no title on left edge */ } @@ -166,14 +165,14 @@ const LLString& LLDragHandleLeft::getTitle() const void LLDragHandleTop::draw() { /* Disable lines. Can drag anywhere in most windows. JC - if( getVisible() && mEnabled && mForeground) + if( getVisible() && getEnabled() && mForeground) { const S32 BORDER_PAD = 2; const S32 HPAD = 2; const S32 VPAD = 2; S32 left = BORDER_PAD + HPAD; - S32 top = mRect.getHeight() - 2 * VPAD; - S32 right = mRect.getWidth() - HPAD; + S32 top = getRect().getHeight() - 2 * VPAD; + S32 right = getRect().getWidth() - HPAD; // S32 bottom = VPAD; // draw lines for drag areas @@ -183,7 +182,7 @@ void LLDragHandleTop::draw() LLRect title_rect = mTitleBox->getRect(); S32 title_right = title_rect.mLeft + mTitleWidth; - BOOL show_right_side = title_right < mRect.getWidth(); + BOOL show_right_side = title_right < getRect().getWidth(); for( S32 i=0; i<4; i++ ) { @@ -204,9 +203,9 @@ void LLDragHandleTop::draw() */ // Colorize the text to match the frontmost state - if (mTitleBox) + if (getTitleBox()) { - mTitleBox->setEnabled(mForeground); + getTitleBox()->setEnabled(getForeground()); } LLView::draw(); @@ -217,7 +216,7 @@ void LLDragHandleTop::draw() void LLDragHandleLeft::draw() { /* Disable lines. Can drag anywhere in most windows. JC - if( getVisible() && mEnabled && mForeground ) + if( getVisible() && getEnabled() && mForeground ) { const S32 BORDER_PAD = 2; // const S32 HPAD = 2; @@ -225,8 +224,8 @@ void LLDragHandleLeft::draw() const S32 LINE_SPACING = 3; S32 left = BORDER_PAD + LINE_SPACING; - S32 top = mRect.getHeight() - 2 * VPAD; -// S32 right = mRect.getWidth() - HPAD; + S32 top = getRect().getHeight() - 2 * VPAD; +// S32 right = getRect().getWidth() - HPAD; S32 bottom = VPAD; // draw lines for drag areas @@ -234,7 +233,7 @@ void LLDragHandleLeft::draw() // no titles yet //LLRect title_rect = mTitleBox->getRect(); //S32 title_right = title_rect.mLeft + mTitleWidth; - //BOOL show_right_side = title_right < mRect.getWidth(); + //BOOL show_right_side = title_right < getRect().getWidth(); S32 line = left; for( S32 i=0; i<4; i++ ) @@ -249,9 +248,9 @@ void LLDragHandleLeft::draw() */ // Colorize the text to match the frontmost state - if (mTitleBox) + if (getTitleBox()) { - mTitleBox->setEnabled(mForeground); + getTitleBox()->setEnabled(getForeground()); } LLView::draw(); @@ -259,19 +258,23 @@ void LLDragHandleLeft::draw() void LLDragHandleTop::reshapeTitleBox() { + if( ! getTitleBox()) + { + return; + } const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); - S32 title_width = font->getWidth( mTitleBox->getText() ) + TITLE_PAD; - if (mMaxTitleWidth > 0) - title_width = llmin(title_width, mMaxTitleWidth); + S32 title_width = font->getWidth( getTitleBox()->getText() ) + TITLE_PAD; + if (getMaxTitleWidth() > 0) + title_width = llmin(title_width, getMaxTitleWidth()); S32 title_height = llround(font->getLineHeight()); LLRect title_rect; title_rect.setLeftTopAndSize( LEFT_PAD, - mRect.getHeight() - BORDER_PAD, - mRect.getWidth() - LEFT_PAD - RIGHT_PAD, + getRect().getHeight() - BORDER_PAD, + getRect().getWidth() - LEFT_PAD - RIGHT_PAD, title_height); - mTitleBox->setRect( title_rect ); + getTitleBox()->setRect( title_rect ); } void LLDragHandleTop::reshape(S32 width, S32 height, BOOL called_from_parent) diff --git a/indra/llui/lldraghandle.h b/indra/llui/lldraghandle.h index cd3ce04718..940eb21e66 100644 --- a/indra/llui/lldraghandle.h +++ b/indra/llui/lldraghandle.h @@ -45,11 +45,14 @@ class LLDragHandle : public LLView { public: LLDragHandle(const LLString& name, const LLRect& rect, const LLString& title ); + virtual ~LLDragHandle() { setTitleBox(NULL); } virtual void setValue(const LLSD& value); void setForeground(BOOL b) { mForeground = b; } + BOOL getForeground() const { return mForeground; } void setMaxTitleWidth(S32 max_width) {mMaxTitleWidth = llmin(max_width, mMaxTitleWidth); } + S32 getMaxTitleWidth() const { return mMaxTitleWidth; } void setTitleVisible(BOOL visible); virtual void setTitle( const LLString& title ) = 0; @@ -61,6 +64,10 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); protected: + LLTextBox* getTitleBox() const { return mTitleBox; } + void setTitleBox(LLTextBox*); + +private: S32 mDragLastScreenX; S32 mDragLastScreenY; S32 mLastMouseScreenX; diff --git a/indra/llui/lleditmenuhandler.cpp b/indra/llui/lleditmenuhandler.cpp index 9fb9cbe16c..435556b56c 100644 --- a/indra/llui/lleditmenuhandler.cpp +++ b/indra/llui/lleditmenuhandler.cpp @@ -33,98 +33,6 @@ #include "lleditmenuhandler.h" -LLEditMenuHandler* gEditMenuHandler = NULL; +/* static */ +LLEditMenuHandler* LLEditMenuHandler::gEditMenuHandler = NULL; -// virtual -LLEditMenuHandler::~LLEditMenuHandler() -{ } - -// virtual -void LLEditMenuHandler::undo() -{ } - -// virtual -BOOL LLEditMenuHandler::canUndo() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::redo() -{ } - -// virtual -BOOL LLEditMenuHandler::canRedo() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::cut() -{ } - -// virtual -BOOL LLEditMenuHandler::canCut() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::copy() -{ } - -// virtual -BOOL LLEditMenuHandler::canCopy() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::paste() -{ } - -// virtual -BOOL LLEditMenuHandler::canPaste() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::doDelete() -{ } - -// virtual -BOOL LLEditMenuHandler::canDoDelete() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::selectAll() -{ } - -// virtual -BOOL LLEditMenuHandler::canSelectAll() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::deselect() -{ } - -// virtual -BOOL LLEditMenuHandler::canDeselect() -{ - return FALSE; -} - -// virtual -void LLEditMenuHandler::duplicate() -{ } - -// virtual -BOOL LLEditMenuHandler::canDuplicate() -{ - return FALSE; -} diff --git a/indra/llui/lleditmenuhandler.h b/indra/llui/lleditmenuhandler.h index b035a29fb4..22f5076c93 100644 --- a/indra/llui/lleditmenuhandler.h +++ b/indra/llui/lleditmenuhandler.h @@ -37,37 +37,43 @@ class LLEditMenuHandler { public: // this is needed even though this is just an interface class. - virtual ~LLEditMenuHandler(); + virtual ~LLEditMenuHandler() {}; - virtual void undo(); - virtual BOOL canUndo(); + virtual void undo() {}; + virtual BOOL canUndo() const { return FALSE; } - virtual void redo(); - virtual BOOL canRedo(); + virtual void redo() {}; + virtual BOOL canRedo() const { return FALSE; } - virtual void cut(); - virtual BOOL canCut(); + virtual void cut() {}; + virtual BOOL canCut() const { return FALSE; } - virtual void copy(); - virtual BOOL canCopy(); + virtual void copy() {}; + virtual BOOL canCopy() const { return FALSE; } - virtual void paste(); - virtual BOOL canPaste(); + virtual void paste() {}; + virtual BOOL canPaste() const { return FALSE; } // "delete" is a keyword - virtual void doDelete(); - virtual BOOL canDoDelete(); + virtual void doDelete() {}; + virtual BOOL canDoDelete() const { return FALSE; } - virtual void selectAll(); - virtual BOOL canSelectAll(); + virtual void selectAll() {}; + virtual BOOL canSelectAll() const { return FALSE; } - virtual void deselect(); - virtual BOOL canDeselect(); + virtual void deselect() {}; + virtual BOOL canDeselect() const { return FALSE; } - virtual void duplicate(); - virtual BOOL canDuplicate(); + virtual void duplicate() {}; + virtual BOOL canDuplicate() const { return FALSE; } + + // TODO: Instead of being a public data member, it would be better to hide it altogether + // and have a "set" method and then a bunch of static versions of the cut, copy, paste + // methods, etc that operate on the current global instance. That would drastically + // simplify the existing code that accesses this global variable by putting all the + // null checks in the one implementation of those static methods. -MG + static LLEditMenuHandler* gEditMenuHandler; }; -extern LLEditMenuHandler* gEditMenuHandler; #endif diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 0754d0eda9..5c1f8429d1 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -142,20 +142,18 @@ LLFloater::LLFloater() : mButtons[i] = NULL; } mDragHandle = NULL; + mHandle.bind(this); } LLFloater::LLFloater(const LLString& name) -: LLPanel(name) +: LLPanel(name), mAutoFocus(TRUE) // automatically take focus when opened { for (S32 i = 0; i < BUTTON_COUNT; i++) { mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } - LLString title; // null string - // automatically take focus when opened - mAutoFocus = TRUE; init(title, FALSE, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, FALSE, TRUE, TRUE); // defaults } @@ -168,15 +166,13 @@ LLFloater::LLFloater(const LLString& name, const LLRect& rect, const LLString& t BOOL minimizable, BOOL close_btn, BOOL bordered) -: LLPanel(name, rect, bordered) +: LLPanel(name, rect, bordered), mAutoFocus(TRUE) // automatically take focus when opened { for (S32 i = 0; i < BUTTON_COUNT; i++) { mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } - // automatically take focus when opened - mAutoFocus = TRUE; init( title, resizable, min_width, min_height, drag_on_left, minimizable, close_btn); } @@ -188,15 +184,13 @@ LLFloater::LLFloater(const LLString& name, const LLString& rect_control, const L BOOL minimizable, BOOL close_btn, BOOL bordered) -: LLPanel(name, rect_control, bordered) +: LLPanel(name, rect_control, bordered), mAutoFocus(TRUE) // automatically take focus when opened { for (S32 i = 0; i < BUTTON_COUNT; i++) { mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } - // automatically take focus when opened - mAutoFocus = TRUE; init( title, resizable, min_width, min_height, drag_on_left, minimizable, close_btn); } @@ -206,6 +200,8 @@ void LLFloater::init(const LLString& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn) { + mHandle.bind(this); + // Init function can be called more than once, so clear out old data. for (S32 i = 0; i < BUTTON_COUNT; i++) { @@ -219,20 +215,20 @@ void LLFloater::init(const LLString& title, } mButtonScale = 1.f; - BOOL need_border = mBorder != NULL; - + //sjb: Thia is a bit of a hack: + BOOL need_border = hasBorder(); + // remove the border since deleteAllChildren() will also delete the border (but not clear mBorder) + removeBorder(); // this will delete mBorder too deleteAllChildren(); - // make sure we don't have a pointer to an old, deleted border - mBorder = NULL; - //sjb: HACK! we had a border which was just deleted, so re-create it + // add the border back if we want it if (need_border) { - addBorder(); + addBorder(); } // chrome floaters don't take focus at all - mIsFocusRoot = !getIsChrome(); + setFocusRoot(!getIsChrome()); // Reset cached pointers mDragHandle = NULL; @@ -257,7 +253,7 @@ void LLFloater::init(const LLString& title, // Floaters start not minimized. When minimized, they save their // prior rectangle to be used on restore. mMinimized = FALSE; - mPreviousRect.set(0,0,0,0); + mExpandedRect.set(0,0,0,0); S32 close_pad; // space to the right of close box S32 close_box_size; // For layout purposes, how big is the close box? @@ -288,31 +284,20 @@ void LLFloater::init(const LLString& title, // Drag Handle // Add first so it's in the background. // const S32 drag_pad = 2; - LLRect drag_handle_rect; - if (!drag_on_left) - { - drag_handle_rect.set( 0, mRect.getHeight(), mRect.getWidth(), 0 ); - - /* - drag_handle_rect.setLeftTopAndSize( - 0, mRect.getHeight(), - mRect.getWidth() - - LLPANEL_BORDER_WIDTH - - drag_pad - - minimize_box_size - minimize_pad - - close_box_size - close_pad, - DRAG_HANDLE_HEIGHT); - */ - mDragHandle = new LLDragHandleTop( "Drag Handle", drag_handle_rect, title ); - } - else + if (drag_on_left) { + LLRect drag_handle_rect; drag_handle_rect.setOriginAndSize( 0, 0, DRAG_HANDLE_WIDTH, - mRect.getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); + getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size); mDragHandle = new LLDragHandleLeft("drag", drag_handle_rect, title ); } + else // drag on top + { + LLRect drag_handle_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); + mDragHandle = new LLDragHandleTop( "Drag Handle", drag_handle_rect, title ); + } addChild(mDragHandle); // Resize Handle @@ -327,28 +312,28 @@ void LLFloater::init(const LLString& title, mResizeBar[LLResizeBar::LEFT] = new LLResizeBar( "resizebar_left", this, - LLRect( 0, mRect.getHeight(), RESIZE_BAR_THICKNESS, 0), + LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0), min_width, S32_MAX, LLResizeBar::LEFT ); addChild( mResizeBar[0] ); mResizeBar[LLResizeBar::TOP] = new LLResizeBar( "resizebar_top", this, - LLRect( 0, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_BAR_THICKNESS), + LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS), min_height, S32_MAX, LLResizeBar::TOP ); addChild( mResizeBar[1] ); mResizeBar[LLResizeBar::RIGHT] = new LLResizeBar( "resizebar_right", this, - LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), + LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0), min_width, S32_MAX, LLResizeBar::RIGHT ); addChild( mResizeBar[2] ); mResizeBar[LLResizeBar::BOTTOM] = new LLResizeBar( "resizebar_bottom", this, - LLRect( 0, RESIZE_BAR_THICKNESS, mRect.getWidth(), 0), + LLRect( 0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0), min_height, S32_MAX, LLResizeBar::BOTTOM ); addChild( mResizeBar[3] ); @@ -356,14 +341,14 @@ void LLFloater::init(const LLString& title, // Resize handles (corners) mResizeHandle[0] = new LLResizeHandle( "Resize Handle", - LLRect( mRect.getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, mRect.getWidth(), 0), + LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0), min_width, min_height, LLResizeHandle::RIGHT_BOTTOM); addChild(mResizeHandle[0]); mResizeHandle[1] = new LLResizeHandle( "resize", - LLRect( mRect.getWidth() - RESIZE_HANDLE_WIDTH, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_HANDLE_HEIGHT), + LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT), min_width, min_height, LLResizeHandle::RIGHT_TOP ); @@ -377,7 +362,7 @@ void LLFloater::init(const LLString& title, addChild(mResizeHandle[2]); mResizeHandle[3] = new LLResizeHandle( "resize", - LLRect( 0, mRect.getHeight(), RESIZE_HANDLE_WIDTH, mRect.getHeight() - RESIZE_HANDLE_HEIGHT ), + LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ), min_width, min_height, LLResizeHandle::LEFT_TOP ); @@ -413,7 +398,7 @@ void LLFloater::init(const LLString& title, setVisible(FALSE); // add self to handle->floater map - sFloaterMap[mViewHandle] = this; + sFloaterMap[mHandle] = this; if (!getParent()) { @@ -450,7 +435,7 @@ LLFloater::~LLFloater() // correct, non-minimized positions. setMinimized( FALSE ); - sFloaterMap.erase(mViewHandle); + sFloaterMap.erase(mHandle); delete mDragHandle; for (S32 i = 0; i < 4; i++) @@ -460,22 +445,6 @@ LLFloater::~LLFloater() } } -// virtual -EWidgetType LLFloater::getWidgetType() const -{ - return WIDGET_TYPE_FLOATER; -} - -// virtual -LLString LLFloater::getWidgetTag() const -{ - return LL_FLOATER_TAG; -} - -void LLFloater::destroy() -{ - die(); -} void LLFloater::setVisible( BOOL visible ) { @@ -501,7 +470,7 @@ void LLFloater::setVisible( BOOL visible ) for(handle_set_iter_t dependent_it = mDependents.begin(); dependent_it != mDependents.end(); ) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); if (floaterp) { @@ -513,10 +482,10 @@ void LLFloater::setVisible( BOOL visible ) void LLFloater::open() /* Flawfinder: ignore */ { - if (mSoundFlags != SILENT + if (getSoundFlags() != SILENT // don't play open sound for hosted (tabbed) windows && !getHost() - && !sHostp + && !getFloaterHost() && (!getVisible() || isMinimized())) { make_ui_sound("UISndWindowOpen"); @@ -524,17 +493,16 @@ void LLFloater::open() /* Flawfinder: ignore */ //RN: for now, we don't allow rehosting from one multifloater to another // just need to fix the bugs - LLMultiFloater* hostp = getHost(); - if (sHostp != NULL && hostp == NULL) + if (getFloaterHost() != NULL && getHost() == NULL) { // needs a host // only select tabs if window they are hosted in is visible - sHostp->addFloater(this, sHostp->getVisible()); + getFloaterHost()->addFloater(this, getFloaterHost()->getVisible()); } - else if (hostp != NULL) + else if (getHost() != NULL) { // already hosted - hostp->showFloater(this); + getHost()->showFloater(this); } else { @@ -558,7 +526,7 @@ void LLFloater::close(bool app_quitting) ((LLMultiFloater*)getHost())->removeFloater(this); } - if (mSoundFlags != SILENT + if (getSoundFlags() != SILENT && getVisible() && !getHost() && !app_quitting) @@ -571,7 +539,7 @@ void LLFloater::close(bool app_quitting) dependent_it != mDependents.end(); ) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); if (floaterp) { ++dependent_it; @@ -595,7 +563,7 @@ void LLFloater::close(bool app_quitting) // give focus to dependee floater if it exists, and we had focus first if (isDependent()) { - LLFloater* dependee = LLFloater::getFloaterByHandle(mDependeeHandle); + LLFloater* dependee = mDependeeHandle.get(); if (dependee && !dependee->isDead()) { dependee->setFocus(TRUE); @@ -661,20 +629,15 @@ void LLFloater::center() // hosted floaters can't move return; } - const LLRect &window = gFloaterView->getRect(); - - S32 left = window.mLeft + (window.getWidth() - mRect.getWidth()) / 2; - S32 bottom = window.mBottom + (window.getHeight() - mRect.getHeight()) / 2; - - translate( left - mRect.mLeft, bottom - mRect.mBottom ); + centerWithin(gFloaterView->getRect()); } void LLFloater::applyRectControl() { - if (!mRectControl.empty()) + if (!getRectControl().empty()) { - const LLRect& rect = LLUI::sConfigGroup->getRect(mRectControl); - translate( rect.mLeft - mRect.mLeft, rect.mBottom - mRect.mBottom); + const LLRect& rect = LLUI::sConfigGroup->getRect(getRectControl()); + translate( rect.mLeft - getRect().mLeft, rect.mBottom - getRect().mBottom); if (mResizable) { reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight())); @@ -715,7 +678,7 @@ LLString LLFloater::getShortTitle() -BOOL LLFloater::canSnapTo(LLView* other_view) +BOOL LLFloater::canSnapTo(const LLView* other_view) { if (NULL == other_view) { @@ -727,7 +690,7 @@ BOOL LLFloater::canSnapTo(LLView* other_view) { LLFloater* other_floaterp = (LLFloater*)other_view; - if (other_floaterp->getSnapTarget() == mViewHandle && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) + if (other_floaterp->getSnapTarget() == getHandle() && mDependents.find(other_floaterp->getHandle()) != mDependents.end()) { // this is a dependent that is already snapped to us, so don't snap back to it return FALSE; @@ -737,7 +700,7 @@ BOOL LLFloater::canSnapTo(LLView* other_view) return LLPanel::canSnapTo(other_view); } -void LLFloater::snappedTo(LLView* snap_view) +void LLFloater::snappedTo(const LLView* snap_view) { if (!snap_view || snap_view == getParent()) { @@ -754,7 +717,7 @@ void LLFloater::snappedTo(LLView* snap_view) void LLFloater::userSetShape(const LLRect& new_rect) { - LLRect old_rect = mRect; + const LLRect& old_rect = getRect(); LLView::userSetShape(new_rect); // if not minimized, adjust all snapped dependents to new shape @@ -764,22 +727,22 @@ void LLFloater::userSetShape(const LLRect& new_rect) for(handle_set_iter_t dependent_it = mDependents.begin(); dependent_it != mDependents.end(); ++dependent_it) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); // is a dependent snapped to us? - if (floaterp && floaterp->getSnapTarget() == mViewHandle) + if (floaterp && floaterp->getSnapTarget() == getHandle()) { S32 delta_x = 0; S32 delta_y = 0; // check to see if it snapped to right or top, and move if dependee floater is resizing LLRect dependent_rect = floaterp->getRect(); - if (dependent_rect.mLeft - mRect.mLeft >= old_rect.getWidth() || // dependent on my right? - dependent_rect.mRight == mRect.mLeft + old_rect.getWidth()) // dependent aligned with my right + if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? + dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right { // was snapped directly onto right side or aligned with it delta_x += new_rect.getWidth() - old_rect.getWidth(); } - if (dependent_rect.mBottom - mRect.mBottom >= old_rect.getHeight() || - dependent_rect.mTop == mRect.mBottom + old_rect.getHeight()) + if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || + dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) { // was snapped directly onto top side or aligned with it delta_y += new_rect.getHeight() - old_rect.getHeight(); @@ -812,7 +775,7 @@ void LLFloater::setMinimized(BOOL minimize) if (minimize) { - mPreviousRect = mRect; + mExpandedRect = getRect(); reshape( MINIMIZED_WIDTH, LLFLOATER_HEADER_SIZE, TRUE); @@ -843,7 +806,7 @@ void LLFloater::setMinimized(BOOL minimize) LLView* viewp = *child_it; if (!viewp->getVisible()) { - mMinimizedHiddenChildren.push_back(viewp->mViewHandle); + mMinimizedHiddenChildren.push_back(viewp->getHandle()); } viewp->setVisible(FALSE); } @@ -860,7 +823,7 @@ void LLFloater::setMinimized(BOOL minimize) dependent_it != mDependents.end(); ++dependent_it) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); if (floaterp) { if (floaterp->isMinimizeable()) @@ -890,8 +853,8 @@ void LLFloater::setMinimized(BOOL minimize) mPreviousMinimizedBottom = currentRect.mBottom; } - reshape( mPreviousRect.getWidth(), mPreviousRect.getHeight(), TRUE ); - setOrigin( mPreviousRect.mLeft, mPreviousRect.mBottom ); + reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE ); + setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom ); if (mButtonsEnabled[BUTTON_RESTORE]) { @@ -906,10 +869,10 @@ void LLFloater::setMinimized(BOOL minimize) viewp->setVisible(TRUE); } - std::vector<LLViewHandle>::iterator itor = mMinimizedHiddenChildren.begin(); + std::vector<LLHandle<LLView> >::iterator itor = mMinimizedHiddenChildren.begin(); for ( ; itor != mMinimizedHiddenChildren.end(); ++itor) { - LLView* viewp = LLView::getViewByHandle(*itor); + LLView* viewp = itor->get(); if(viewp) { viewp->setVisible(FALSE); @@ -922,7 +885,7 @@ void LLFloater::setMinimized(BOOL minimize) dependent_it != mDependents.end(); ++dependent_it) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); if (floaterp) { floaterp->setMinimized(FALSE); @@ -979,7 +942,7 @@ void LLFloater::setIsChrome(BOOL is_chrome) // remove focus if we're changing to chrome setFocus(FALSE); // can't Ctrl-Tab to "chrome" floaters - mIsFocusRoot = FALSE; + setFocusRoot(FALSE); } // no titles displayed on "chrome" floaters @@ -1011,7 +974,7 @@ void LLFloater::cleanupHandles() for(handle_set_iter_t dependent_it = mDependents.begin(); dependent_it != mDependents.end(); ) { - LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* floaterp = dependent_it->get(); if (!floaterp) { mDependents.erase(dependent_it++); @@ -1085,7 +1048,7 @@ void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition) if (reposition) { floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp)); - floaterp->setSnapTarget(mViewHandle); + floaterp->setSnapTarget(getHandle()); } gFloaterView->adjustToFitScreen(floaterp, FALSE); if (floaterp->isFrontmost()) @@ -1095,9 +1058,9 @@ void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition) } } -void LLFloater::addDependentFloater(LLViewHandle dependent, BOOL reposition) +void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition) { - LLFloater* dependent_floaterp = LLFloater::getFloaterByHandle(dependent); + LLFloater* dependent_floaterp = dependent.get(); if(dependent_floaterp) { addDependentFloater(dependent_floaterp, reposition); @@ -1107,7 +1070,7 @@ void LLFloater::addDependentFloater(LLViewHandle dependent, BOOL reposition) void LLFloater::removeDependentFloater(LLFloater* floaterp) { mDependents.erase(floaterp->getHandle()); - floaterp->mDependeeHandle = LLViewHandle::sDeadHandle; + floaterp->mDependeeHandle = LLHandle<LLFloater>(); } // virtual @@ -1215,32 +1178,13 @@ void LLFloater::setFrontmost(BOOL take_focus) } } -// static -LLFloater* LLFloater::getFloaterByHandle(LLViewHandle handle) -{ - LLFloater* floater = NULL; - if (sFloaterMap.count(handle)) - { - floater = sFloaterMap[handle]; - } - if (floater && !floater->isDead()) - { - return floater; - } - else - { - return NULL; - } -} - //static void LLFloater::setEditModeEnabled(BOOL enable) { if (enable != sEditModeEnabled) { S32 count = 0; - std::map<LLViewHandle, LLFloater*>::iterator iter; - for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) + for(handle_map_iter_t iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) { LLFloater* floater = iter->second; if (!floater->isDead()) @@ -1255,41 +1199,6 @@ void LLFloater::setEditModeEnabled(BOOL enable) sEditModeEnabled = enable; } -//static -BOOL LLFloater::getEditModeEnabled() -{ - return sEditModeEnabled; -} - -//static -void LLFloater::show(LLFloater* floaterp) -{ - if (floaterp) - { - gFocusMgr.triggerFocusFlash(); - floaterp->open(); - if (floaterp->getHost()) - { - floaterp->getHost()->open(); - } - } -} - -//static -void LLFloater::hide(LLFloater* floaterp) -{ - if (floaterp) floaterp->close(); -} - -//static -BOOL LLFloater::visible(LLFloater* floaterp) -{ - if (floaterp) - { - return !floaterp->isMinimized() && floaterp->isInVisibleChain(); - } - return FALSE; -} // static void LLFloater::onClickMinimize(void *userdata) @@ -1316,9 +1225,9 @@ void LLFloater::onClickTearOff(void *userdata) self->open(); /* Flawfinder: ignore */ // only force position for floaters that don't have that data saved - if (self->mRectControl.empty()) + if (self->getRectControl().empty()) { - new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - LLFLOATER_HEADER_SIZE - 5, self->mRect.getWidth(), self->mRect.getHeight()); + new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - LLFLOATER_HEADER_SIZE - 5, self->getRect().getWidth(), self->getRect().getHeight()); self->setRect(new_rect); } gFloaterView->adjustToFitScreen(self, FALSE); @@ -1327,7 +1236,7 @@ void LLFloater::onClickTearOff(void *userdata) } else //Attach to parent. { - LLMultiFloater* new_host = (LLMultiFloater*)LLFloater::getFloaterByHandle(self->mLastHostHandle); + LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get(); if (new_host) { new_host->showFloater(self); @@ -1351,7 +1260,7 @@ void LLFloater::closeFocusedFloater() { LLFloater* focused_floater = NULL; - std::map<LLViewHandle, LLFloater*>::iterator iter; + handle_map_iter_t iter; for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) { focused_floater = iter->second; @@ -1396,16 +1305,16 @@ void LLFloater::draw() if( getVisible() ) { // draw background - if( mBgVisible ) + if( isBackgroundVisible() ) { S32 left = LLPANEL_BORDER_WIDTH; - S32 top = mRect.getHeight() - LLPANEL_BORDER_WIDTH; - S32 right = mRect.getWidth() - LLPANEL_BORDER_WIDTH; + S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH; + S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH; S32 bottom = LLPANEL_BORDER_WIDTH; LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow"); F32 shadow_offset = (F32)LLUI::sConfigGroup->getS32("DropShadowFloater"); - if (!mBgOpaque) + if (!isBackgroundOpaque()) { shadow_offset *= 0.2f; shadow_color.mV[VALPHA] *= 0.5f; @@ -1415,13 +1324,13 @@ void LLFloater::draw() llround(shadow_offset)); // No transparent windows in simple UI - if (mBgOpaque) + if (isBackgroundOpaque()) { - gl_rect_2d( left, top, right, bottom, mBgColorOpaque ); + gl_rect_2d( left, top, right, bottom, getBackgroundColor() ); } else { - gl_rect_2d( left, top, right, bottom, mBgColorAlpha ); + gl_rect_2d( left, top, right, bottom, getTransparentColor() ); } if(gFocusMgr.childHasKeyboardFocus(this) && !getIsChrome() && !getTitle().empty()) @@ -1434,19 +1343,19 @@ void LLFloater::draw() } } - if( mDefaultBtn) + if( getDefaultButton() ) { - if (gFocusMgr.childHasKeyboardFocus( this ) && mDefaultBtn->getEnabled()) + if (gFocusMgr.childHasKeyboardFocus( this ) && getDefaultButton()->getEnabled()) { LLUICtrl* focus_ctrl = gFocusMgr.getKeyboardFocus(); // is this button a direct descendent and not a nested widget (e.g. checkbox)? BOOL focus_is_child_button = focus_ctrl->getWidgetType() == WIDGET_TYPE_BUTTON && focus_ctrl->getParent() == this; // only enable default button when current focus is not a button - mDefaultBtn->setBorderEnabled(!focus_is_child_button); + getDefaultButton()->setBorderEnabled(!focus_is_child_button); } else { - mDefaultBtn->setBorderEnabled(FALSE); + getDefaultButton()->setBorderEnabled(FALSE); } } @@ -1461,13 +1370,13 @@ void LLFloater::draw() LLView::draw(); - if( mBgVisible ) + if( isBackgroundVisible() ) { // add in a border to improve spacialized visual aclarity ;) // use lines instead of gl_rect_2d so we can round the edges as per james' recommendation LLUI::setLineWidth(1.5f); LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? LLUI::sColorsGroup->getColor("FloaterFocusBorderColor") : LLUI::sColorsGroup->getColor("FloaterUnfocusBorderColor"); - gl_rect_2d_offset_local(0, mRect.getHeight() + 1, mRect.getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE); + gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor, -LLPANEL_BORDER_WIDTH, FALSE); LLUI::setLineWidth(1.f); } @@ -1481,7 +1390,7 @@ void LLFloater::draw() // when last host goes away if (mCanTearOff && !getHost()) { - LLFloater* old_host = gFloaterView->getFloaterByHandle(mLastHostHandle); + LLFloater* old_host = mLastHostHandle.get(); if (!old_host) { setCanTearOff(FALSE); @@ -1490,33 +1399,6 @@ void LLFloater::draw() } } -// virtual -void LLFloater::onOpen() -{ -} - -// virtual -void LLFloater::onClose(bool app_quitting) -{ - destroy(); -} - -// virtual -BOOL LLFloater::canClose() -{ - return TRUE; -} - -// virtual -BOOL LLFloater::canSaveAs() -{ - return FALSE; -} - -// virtual -void LLFloater::saveAs() -{ -} void LLFloater::setCanMinimize(BOOL can_minimize) { @@ -1585,28 +1467,28 @@ void LLFloater::setCanResize(BOOL can_resize) mResizeBar[0] = new LLResizeBar( "resizebar_left", this, - LLRect( 0, mRect.getHeight(), RESIZE_BAR_THICKNESS, 0), + LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0), mMinWidth, S32_MAX, LLResizeBar::LEFT ); addChild( mResizeBar[0] ); mResizeBar[1] = new LLResizeBar( "resizebar_top", this, - LLRect( 0, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_BAR_THICKNESS), + LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS), mMinHeight, S32_MAX, LLResizeBar::TOP ); addChild( mResizeBar[1] ); mResizeBar[2] = new LLResizeBar( "resizebar_right", this, - LLRect( mRect.getWidth() - RESIZE_BAR_THICKNESS, mRect.getHeight(), mRect.getWidth(), 0), + LLRect( getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0), mMinWidth, S32_MAX, LLResizeBar::RIGHT ); addChild( mResizeBar[2] ); mResizeBar[3] = new LLResizeBar( "resizebar_bottom", this, - LLRect( 0, RESIZE_BAR_THICKNESS, mRect.getWidth(), 0), + LLRect( 0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0), mMinHeight, S32_MAX, LLResizeBar::BOTTOM ); addChild( mResizeBar[3] ); @@ -1614,14 +1496,14 @@ void LLFloater::setCanResize(BOOL can_resize) // Resize handles (corners) mResizeHandle[0] = new LLResizeHandle( "Resize Handle", - LLRect( mRect.getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, mRect.getWidth(), 0), + LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0), mMinWidth, mMinHeight, LLResizeHandle::RIGHT_BOTTOM); addChild(mResizeHandle[0]); mResizeHandle[1] = new LLResizeHandle( "resize", - LLRect( mRect.getWidth() - RESIZE_HANDLE_WIDTH, mRect.getHeight(), mRect.getWidth(), mRect.getHeight() - RESIZE_HANDLE_HEIGHT), + LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT), mMinWidth, mMinHeight, LLResizeHandle::RIGHT_TOP ); @@ -1635,7 +1517,7 @@ void LLFloater::setCanResize(BOOL can_resize) addChild(mResizeHandle[2]); mResizeHandle[3] = new LLResizeHandle( "resize", - LLRect( 0, mRect.getHeight(), RESIZE_HANDLE_WIDTH, mRect.getHeight() - RESIZE_HANDLE_HEIGHT ), + LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ), mMinWidth, mMinHeight, LLResizeHandle::LEFT_TOP ); @@ -1672,15 +1554,15 @@ void LLFloater::updateButtons() { btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH, - mRect.getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, + getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } else { btn_rect.setLeftTopAndSize( - mRect.getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, - mRect.getHeight() - CLOSE_BOX_FROM_TOP, + getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * button_count, + getRect().getHeight() - CLOSE_BOX_FROM_TOP, llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), llround((F32)LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } @@ -1698,7 +1580,7 @@ void LLFloater::updateButtons() } } - mDragHandle->setMaxTitleWidth(mRect.getWidth() - (button_count * (LLFLOATER_CLOSE_BOX_SIZE + 1))); + mDragHandle->setMaxTitleWidth(getRect().getWidth() - (button_count * (LLFLOATER_CLOSE_BOX_SIZE + 1))); } void LLFloater::buildButtons() @@ -1710,15 +1592,15 @@ void LLFloater::buildButtons() { btn_rect.setLeftTopAndSize( LLPANEL_BORDER_WIDTH, - mRect.getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), + getRect().getHeight() - CLOSE_BOX_FROM_TOP - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } else { btn_rect.setLeftTopAndSize( - mRect.getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), - mRect.getHeight() - CLOSE_BOX_FROM_TOP, + getRect().getWidth() - LLPANEL_BORDER_WIDTH - (LLFLOATER_CLOSE_BOX_SIZE + 1) * (i + 1), + getRect().getHeight() - CLOSE_BOX_FROM_TOP, llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale), llround(LLFLOATER_CLOSE_BOX_SIZE * mButtonScale)); } @@ -1761,16 +1643,6 @@ LLFloaterView::LLFloaterView( const LLString& name, const LLRect& rect ) resetStartingFloaterPosition(); } -EWidgetType LLFloaterView::getWidgetType() const -{ - return WIDGET_TYPE_FLOATER_VIEW; -} - -LLString LLFloaterView::getWidgetTag() const -{ - return LL_FLOATER_VIEW_TAG; -} - // By default, adjust vertical. void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) { @@ -1780,8 +1652,8 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent) // When reshaping this view, make the floaters follow their closest edge. void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical) { - S32 old_width = mRect.getWidth(); - S32 old_height = mRect.getHeight(); + S32 old_width = getRect().getWidth(); + S32 old_height = getRect().getHeight(); for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { @@ -1835,7 +1707,7 @@ void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent, BOOL for(LLFloater::handle_set_iter_t dependent_it = floaterp->mDependents.begin(); dependent_it != floaterp->mDependents.end(); ++dependent_it) { - LLFloater* dependent_floaterp = getFloaterByHandle(*dependent_it); + LLFloater* dependent_floaterp = dependent_it->get(); if (dependent_floaterp) { dependent_floaterp->setFollows(follow_flags); @@ -1937,7 +1809,7 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin(); dependent_it != reference_floater->mDependents.end(); ++dependent_it) { - LLFloater* sibling = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* sibling = dependent_it->get(); // check for dependents within 10 pixels of base floater if (sibling && sibling != neighbor && @@ -1949,8 +1821,8 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF } S32 left_margin = llmax(0, base_rect.mLeft); - S32 right_margin = llmax(0, mRect.getWidth() - base_rect.mRight); - S32 top_margin = llmax(0, mRect.getHeight() - base_rect.mTop); + S32 right_margin = llmax(0, getRect().getWidth() - base_rect.mRight); + S32 top_margin = llmax(0, getRect().getHeight() - base_rect.mTop); S32 bottom_margin = llmax(0, base_rect.mBottom); // find position for floater in following order @@ -1959,22 +1831,22 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF { if (right_margin > width) { - new_rect.translate(base_rect.mRight - neighbor->mRect.mLeft, base_rect.mTop - neighbor->mRect.mTop); + new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop); return new_rect; } else if (left_margin > width) { - new_rect.translate(base_rect.mLeft - neighbor->mRect.mRight, base_rect.mTop - neighbor->mRect.mTop); + new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop); return new_rect; } else if (bottom_margin > height) { - new_rect.translate(base_rect.mLeft - neighbor->mRect.mLeft, base_rect.mBottom - neighbor->mRect.mTop); + new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop); return new_rect; } else if (top_margin > height) { - new_rect.translate(base_rect.mLeft - neighbor->mRect.mLeft, base_rect.mTop - neighbor->mRect.mBottom); + new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom); return new_rect; } @@ -1989,15 +1861,6 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF return new_rect; } -void LLFloaterView::setCycleMode(BOOL mode) -{ - mFocusCycleMode = mode; -} - -BOOL LLFloaterView::getCycleMode() -{ - return mFocusCycleMode; -} void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus) { @@ -2027,7 +1890,7 @@ void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus) for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); dependent_it != floater->mDependents.end(); ) { - LLFloater* sibling = LLFloater::getFloaterByHandle(*dependent_it); + LLFloater* sibling = dependent_it->get(); if (sibling) { floaters_to_move.push_back(sibling); @@ -2058,7 +1921,7 @@ void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus) for(LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin(); dependent_it != child->mDependents.end(); ) { - LLFloater* dependent = getFloaterByHandle(*dependent_it); + LLFloater* dependent = dependent_it->get(); if (dependent) { sendChildToFront(dependent); @@ -2099,7 +1962,7 @@ void LLFloaterView::highlightFocusedFloater() dependent_it != floater->mDependents.end(); ++dependent_it) { - LLFloater* dependent_floaterp = getFloaterByHandle(*dependent_it); + LLFloater* dependent_floaterp = dependent_it->get(); if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp)) { floater_or_dependent_has_focus = TRUE; @@ -2112,7 +1975,7 @@ void LLFloaterView::highlightFocusedFloater() for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin(); dependent_it != floater->mDependents.end(); ) { - LLFloater* dependent_floaterp = getFloaterByHandle(*dependent_it); + LLFloater* dependent_floaterp = dependent_it->get(); if (dependent_floaterp) { dependent_floaterp->setForeground(floater_or_dependent_has_focus); @@ -2341,9 +2204,9 @@ void LLFloaterView::draw() } } -const LLRect LLFloaterView::getSnapRect() const +LLRect LLFloaterView::getSnapRect() const { - LLRect snap_rect = mRect; + LLRect snap_rect = getRect(); snap_rect.mBottom += mSnapOffsetBottom; return snap_rect; @@ -2410,23 +2273,6 @@ void LLFloaterView::syncFloaterTabOrder() } } -LLFloater* LLFloaterView::getFloaterByHandle(LLViewHandle handle) -{ - if (handle == LLViewHandle::sDeadHandle) - { - return NULL; - } - for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) - { - LLView* viewp = *child_it; - if (((LLFloater*)viewp)->getHandle() == handle) - { - return (LLFloater*)viewp; - } - } - return NULL; -} - LLFloater* LLFloaterView::getParentFloater(LLView* viewp) { LLView* parentp = viewp->getParent(); @@ -2492,13 +2338,13 @@ void LLFloaterView::popVisibleAll(const skip_list_t& skip_list) LLMultiFloater::LLMultiFloater() : mTabContainer(NULL), - mTabPos(LLTabContainerCommon::TOP), + mTabPos(LLTabContainer::TOP), mAutoResize(TRUE) { } -LLMultiFloater::LLMultiFloater(LLTabContainerCommon::TabPosition tab_pos) : +LLMultiFloater::LLMultiFloater(LLTabContainer::TabPosition tab_pos) : mTabContainer(NULL), mTabPos(tab_pos), mAutoResize(TRUE) @@ -2509,7 +2355,7 @@ LLMultiFloater::LLMultiFloater(LLTabContainerCommon::TabPosition tab_pos) : LLMultiFloater::LLMultiFloater(const LLString &name) : LLFloater(name), mTabContainer(NULL), - mTabPos(LLTabContainerCommon::TOP), + mTabPos(LLTabContainer::TOP), mAutoResize(FALSE) { } @@ -2521,16 +2367,16 @@ LLMultiFloater::LLMultiFloater( BOOL auto_resize) : LLFloater(name, rect, name), mTabContainer(NULL), - mTabPos(LLTabContainerCommon::TOP), + mTabPos(LLTabContainer::TOP), mAutoResize(auto_resize) { mTabContainer = new LLTabContainer("Preview Tabs", - LLRect(LLPANEL_BORDER_WIDTH, mRect.getHeight() - LLFLOATER_HEADER_SIZE, mRect.getWidth() - LLPANEL_BORDER_WIDTH, 0), + LLRect(LLPANEL_BORDER_WIDTH, getRect().getHeight() - LLFLOATER_HEADER_SIZE, getRect().getWidth() - LLPANEL_BORDER_WIDTH, 0), mTabPos, - NULL, - NULL); + FALSE, + FALSE); mTabContainer->setFollowsAll(); - if (mResizable) + if (isResizable()) { mTabContainer->setRightTabBtnOffset(RESIZE_HANDLE_WIDTH); } @@ -2549,12 +2395,12 @@ LLMultiFloater::LLMultiFloater( mAutoResize(auto_resize) { mTabContainer = new LLTabContainer("Preview Tabs", - LLRect(LLPANEL_BORDER_WIDTH, mRect.getHeight() - LLFLOATER_HEADER_SIZE, mRect.getWidth() - LLPANEL_BORDER_WIDTH, 0), - mTabPos, - NULL, - NULL); + LLRect(LLPANEL_BORDER_WIDTH, getRect().getHeight() - LLFLOATER_HEADER_SIZE, getRect().getWidth() - LLPANEL_BORDER_WIDTH, 0), + mTabPos, + FALSE, + FALSE); mTabContainer->setFollowsAll(); - if (mResizable && mTabPos == LLTabContainerCommon::BOTTOM) + if (isResizable() && mTabPos == LLTabContainer::BOTTOM) { mTabContainer->setRightTabBtnOffset(RESIZE_HANDLE_WIDTH); } @@ -2563,21 +2409,6 @@ LLMultiFloater::LLMultiFloater( } -LLMultiFloater::~LLMultiFloater() -{ -} - -// virtual -EWidgetType LLMultiFloater::getWidgetType() const -{ - return WIDGET_TYPE_MULTI_FLOATER; -} - -// virtual -LLString LLMultiFloater::getWidgetTag() const -{ - return LL_MULTI_FLOATER_TAG; -} void LLMultiFloater::open() /* Flawfinder: ignore */ { @@ -2597,7 +2428,7 @@ void LLMultiFloater::onClose(bool app_quitting) { if(closeAllFloaters() == TRUE) { - LLFloater::onClose(app_quitting ? true : false); + LLFloater::onClose(app_quitting); }//else not all tabs could be closed... } @@ -2648,16 +2479,18 @@ BOOL LLMultiFloater::closeAllFloaters() void LLMultiFloater::growToFit(S32 content_width, S32 content_height) { - S32 new_width = llmax(mRect.getWidth(), content_width + LLPANEL_BORDER_WIDTH * 2); - S32 new_height = llmax(mRect.getHeight(), content_height + LLFLOATER_HEADER_SIZE + TABCNTR_HEADER_HEIGHT); + S32 new_width = llmax(getRect().getWidth(), content_width + LLPANEL_BORDER_WIDTH * 2); + S32 new_height = llmax(getRect().getHeight(), content_height + LLFLOATER_HEADER_SIZE + TABCNTR_HEADER_HEIGHT); - if (isMinimized()) - { - mPreviousRect.setLeftTopAndSize(mPreviousRect.mLeft, mPreviousRect.mTop, new_width, new_height); - } + if (isMinimized()) + { + LLRect newrect; + newrect.setLeftTopAndSize(getExpandedRect().mLeft, getExpandedRect().mTop, new_width, new_height); + setExpandedRect(newrect); + } else { - S32 old_height = mRect.getHeight(); + S32 old_height = getRect().getHeight(); reshape(new_width, new_height); // keep top left corner in same position translate(0, old_height - new_height); @@ -2737,7 +2570,7 @@ void LLMultiFloater::addFloater(LLFloater* floaterp, BOOL select_added_floater, } floaterp->setHost(this); - if (mMinimized) + if (isMinimized()) { floaterp->setVisible(FALSE); } @@ -2920,7 +2753,7 @@ void LLMultiFloater::onTabSelected(void* userdata, bool from_click) void LLMultiFloater::setCanResize(BOOL can_resize) { LLFloater::setCanResize(can_resize); - if (mResizable && mTabContainer->getTabPosition() == LLTabContainer::BOTTOM) + if (isResizable() && mTabContainer->getTabPosition() == LLTabContainer::BOTTOM) { mTabContainer->setRightTabBtnOffset(RESIZE_HANDLE_WIDTH); } @@ -2963,20 +2796,23 @@ void LLMultiFloater::updateResizeLimits() } setResizeLimits(new_min_width, new_min_height); - S32 cur_height = mRect.getHeight(); - S32 new_width = llmax(mRect.getWidth(), new_min_width); - S32 new_height = llmax(mRect.getHeight(), new_min_height); + S32 cur_height = getRect().getHeight(); + S32 new_width = llmax(getRect().getWidth(), new_min_width); + S32 new_height = llmax(getRect().getHeight(), new_min_height); if (isMinimized()) { - mPreviousRect.setLeftTopAndSize(mPreviousRect.mLeft, mPreviousRect.mTop, llmax(mPreviousRect.getWidth(), new_width), llmax(mPreviousRect.getHeight(), new_height)); + const LLRect& expanded = getExpandedRect(); + LLRect newrect; + newrect.setLeftTopAndSize(expanded.mLeft, expanded.mTop, llmax(expanded.getWidth(), new_width), llmax(expanded.getHeight(), new_height)); + setExpandedRect(newrect); } else { reshape(new_width, new_height); // make sure upper left corner doesn't move - translate(0, cur_height - mRect.getHeight()); + translate(0, cur_height - getRect().getHeight()); // make sure this window is visible on screen when it has been modified // (tab added, etc) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 1d88501b01..5eb55e0420 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -112,8 +112,8 @@ public: void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE); /*virtual*/ void userSetShape(const LLRect& new_rect); - /*virtual*/ BOOL canSnapTo(LLView* other_view); - /*virtual*/ void snappedTo(LLView* snap_view); + /*virtual*/ BOOL canSnapTo(const LLView* other_view); + /*virtual*/ void snappedTo(const LLView* snap_view); /*virtual*/ void setFocus( BOOL b ); /*virtual*/ void setIsChrome(BOOL is_chrome); @@ -122,16 +122,14 @@ public: virtual void init(const LLString& title, BOOL resizable, S32 min_width, S32 min_height, BOOL drag_on_left, BOOL minimizable, BOOL close_btn); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER; } + virtual LLString getWidgetTag() const { return LL_FLOATER_TAG; }; virtual void open(); /* Flawfinder: ignore */ // If allowed, close the floater cleanly, releasing focus. // app_quitting is passed to onClose() below. virtual void close(bool app_quitting = false); - - void setAutoFocus(BOOL focus) { mAutoFocus = focus; setFocus(focus); } // Release keyboard and mouse focus void releaseFocus(); @@ -142,18 +140,18 @@ public: void applyRectControl(); - LLMultiFloater* getHost() { return (LLMultiFloater*)LLFloater::getFloaterByHandle(mHostHandle); } + LLMultiFloater* getHost() { return (LLMultiFloater*)mHostHandle.get(); } void setTitle( const LLString& title ); - const LLString& getTitle() const; + const LLString& getTitle() const; void setShortTitle( const LLString& short_title ); LLString getShortTitle(); virtual void setMinimized(BOOL b); void moveResizeHandlesToFront(); void addDependentFloater(LLFloater* dependent, BOOL reposition = TRUE); - void addDependentFloater(LLViewHandle dependent_handle, BOOL reposition = TRUE); - LLFloater* getDependee() { return (LLFloater*)LLFloater::getFloaterByHandle(mDependeeHandle); } - void removeDependentFloater(LLFloater* dependent); + void addDependentFloater(LLHandle<LLFloater> dependent_handle, BOOL reposition = TRUE); + LLFloater* getDependee() { return (LLFloater*)mDependeeHandle.get(); } + void removeDependentFloater(LLFloater* dependent); BOOL isMinimized() { return mMinimized; } BOOL isFrontmost(); BOOL isDependent() { return !mDependeeHandle.isDead(); } @@ -167,10 +165,9 @@ public: void setResizeLimits( S32 min_width, S32 min_height ); void getResizeLimits( S32* min_width, S32* min_height ) { *min_width = mMinWidth; *min_height = mMinHeight; } - bool isMinimizeable() const{ return mButtonsEnabled[BUTTON_MINIMIZE]; } // Does this window have a close button, NOT can we close it right now. - bool isCloseable() const{ return (mButtonsEnabled[BUTTON_CLOSE] ? true : false); } + bool isCloseable() const{ return (mButtonsEnabled[BUTTON_CLOSE]); } bool isDragOnLeft() const{ return mDragOnLeft; } S32 getMinWidth() const{ return mMinWidth; } S32 getMinHeight() const{ return mMinHeight; } @@ -181,29 +178,28 @@ public: virtual void draw(); - // does nothing by default - virtual void onOpen(); + virtual void onOpen() {} // Call destroy() to free memory, or setVisible(FALSE) to keep it // If app_quitting, you might not want to save your visibility. // Defaults to destroy(). - virtual void onClose(bool app_quitting); + virtual void onClose(bool app_quitting) { destroy(); } - // Defaults to true. - virtual BOOL canClose(); + virtual BOOL canClose() const { return TRUE; } virtual void setVisible(BOOL visible); void setFrontmost(BOOL take_focus = TRUE); // Defaults to false. - virtual BOOL canSaveAs(); + virtual BOOL canSaveAs() const { return FALSE; } - // Defaults to no-op. - virtual void saveAs(); + virtual void saveAs() {} - void setSnapTarget(LLViewHandle handle) { mSnappedTo = handle; } + void setSnapTarget(LLHandle<LLFloater> handle) { mSnappedTo = handle; } void clearSnapTarget() { mSnappedTo.markDead(); } - LLViewHandle getSnapTarget() { return mSnappedTo; } + LLHandle<LLFloater> getSnapTarget() { return mSnappedTo; } + + LLHandle<LLFloater> getHandle() { return mHandle; } static void closeFocusedFloater(); @@ -214,39 +210,39 @@ public: static void setFloaterHost(LLMultiFloater* hostp) {sHostp = hostp; } static void setEditModeEnabled(BOOL enable); - static BOOL getEditModeEnabled(); + static BOOL getEditModeEnabled() { return sEditModeEnabled; } static LLMultiFloater* getFloaterHost() {return sHostp; } - static void show(LLFloater* floaterp); - static void hide(LLFloater* floaterp); - static BOOL visible(LLFloater* floaterp); - - static LLFloater* getFloaterByHandle(LLViewHandle handle); - protected: - // Don't call this directly. You probably want to call close(). JC - void destroy(); + virtual void bringToFront(S32 x, S32 y); - virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE); + virtual void setVisibleAndFrontmost(BOOL take_focus=TRUE); + + void setExpandedRect(const LLRect& rect) { mExpandedRect = rect; } // size when not minimized + const LLRect& getExpandedRect() const { return mExpandedRect; } + + void setAutoFocus(BOOL focus) { mAutoFocus = focus; } // whether to automatically take focus when opened + LLDragHandle* getDragHandle() const { return mDragHandle; } + + void destroy() { die(); } // Don't call this directly. You probably want to call close(). JC + +private: + void setForeground(BOOL b); // called only by floaterview void cleanupHandles(); // remove handles to dead floaters void createMinimizeButton(); void updateButtons(); void buildButtons(); -protected: -// static LLViewerImage* sBackgroundImage; -// static LLViewerImage* sShadowImage; - + LLRect mExpandedRect; LLDragHandle* mDragHandle; LLResizeBar* mResizeBar[4]; LLResizeHandle* mResizeHandle[4]; LLButton *mMinimizeButton; BOOL mCanTearOff; BOOL mMinimized; - LLRect mPreviousRect; BOOL mForeground; - LLViewHandle mDependeeHandle; + LLHandle<LLFloater> mDependeeHandle; LLString mShortTitle; 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: S32 mMinWidth; S32 mMinHeight; - BOOL mAutoFocus; BOOL mEditing; - typedef std::set<LLViewHandle> handle_set_t; - typedef std::set<LLViewHandle>::iterator handle_set_iter_t; + typedef std::set<LLHandle<LLFloater> > handle_set_t; + typedef std::set<LLHandle<LLFloater> >::iterator handle_set_iter_t; handle_set_t mDependents; bool mDragOnLeft; BOOL mButtonsEnabled[BUTTON_COUNT]; LLButton* mButtons[BUTTON_COUNT]; F32 mButtonScale; - - LLViewHandle mSnappedTo; + BOOL mAutoFocus; + LLHandle<LLFloater> mSnappedTo; - LLViewHandle mHostHandle; - LLViewHandle mLastHostHandle; + LLHandle<LLFloater> mHostHandle; + LLHandle<LLFloater> mLastHostHandle; - static BOOL sEditModeEnabled; static LLMultiFloater* sHostp; + static BOOL sEditModeEnabled; static LLString sButtonActiveImageNames[BUTTON_COUNT]; static LLString sButtonInactiveImageNames[BUTTON_COUNT]; static LLString sButtonPressedImageNames[BUTTON_COUNT]; @@ -282,15 +277,18 @@ protected: typedef void (*click_callback)(void *); static click_callback sButtonCallbacks[BUTTON_COUNT]; - typedef std::map<LLViewHandle, LLFloater*> handle_map_t; - typedef std::map<LLViewHandle, LLFloater*>::iterator handle_map_iter_t; + typedef std::map<LLHandle<LLFloater>, LLFloater*> handle_map_t; + typedef std::map<LLHandle<LLFloater>, LLFloater*>::iterator handle_map_iter_t; static handle_map_t sFloaterMap; - std::vector<LLViewHandle> mMinimizedHiddenChildren; + std::vector<LLHandle<LLView> > mMinimizedHiddenChildren; BOOL mHasBeenDraggedWhileMinimized; S32 mPreviousMinimizedBottom; S32 mPreviousMinimizedLeft; + +private: + LLRootHandle<LLFloater> mHandle; }; ///////////////////////////////////////////////////////////// @@ -302,14 +300,14 @@ class LLFloaterView : public LLUICtrl public: LLFloaterView( const LLString& name, const LLRect& rect ); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_FLOATER_VIEW; } + virtual LLString getWidgetTag() const { return LL_FLOATER_VIEW_TAG; } /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); void reshape(S32 width, S32 height, BOOL called_from_parent, BOOL adjust_vertical); /*virtual*/ void draw(); - /*virtual*/ const LLRect getSnapRect() const; + /*virtual*/ LLRect getSnapRect() const; void refresh(); void getNewFloaterPosition( S32* left, S32* top ); @@ -325,8 +323,8 @@ public: void pushVisibleAll(BOOL visible, const skip_list_t& skip_list = skip_list_t()); void popVisibleAll(const skip_list_t& skip_list = skip_list_t()); - void setCycleMode(BOOL mode); - BOOL getCycleMode(); + void setCycleMode(BOOL mode) { mFocusCycleMode = mode; } + BOOL getCycleMode() const { return mFocusCycleMode; } void bringToFront( LLFloater* child, BOOL give_focus = TRUE ); void highlightFocusedFloater(); void unhighlightFocusedFloater(); @@ -342,10 +340,6 @@ public: LLFloater* getFocusedFloater(); void syncFloaterTabOrder(); - // Get a floater based the handle. If this returns NULL, it is up - // to the caller to discard the handle. - LLFloater* getFloaterByHandle(LLViewHandle handle); - // Returns z order of child provided. 0 is closest, larger numbers // are deeper in the screen. If there is no such child, the return // value is not defined. @@ -361,15 +355,16 @@ private: S32 mSnapOffsetBottom; }; +// https://wiki.lindenlab.com/mediawiki/index.php?title=LLMultiFloater&oldid=81376 class LLMultiFloater : public LLFloater { public: LLMultiFloater(); - LLMultiFloater(LLTabContainerCommon::TabPosition tab_pos); + LLMultiFloater(LLTabContainer::TabPosition tab_pos); LLMultiFloater(const LLString& name); LLMultiFloater(const LLString& name, const LLRect& rect, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); LLMultiFloater(const LLString& name, const LLString& rect_control, LLTabContainer::TabPosition tab_pos = LLTabContainer::TOP, BOOL auto_resize = TRUE); - virtual ~LLMultiFloater(); + virtual ~LLMultiFloater() {}; virtual BOOL postBuild(); /*virtual*/ void open(); /* Flawfinder: ignore */ @@ -377,12 +372,12 @@ public: /*virtual*/ void draw(); /*virtual*/ void setVisible(BOOL visible); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); - /*virtual*/ EWidgetType getWidgetType() const; - /*virtual*/ LLString getWidgetTag() const; + /*virtual*/ EWidgetType getWidgetType() const { return WIDGET_TYPE_MULTI_FLOATER; } + /*virtual*/ LLString getWidgetTag() const { return LL_MULTI_FLOATER_TAG; }; virtual void setCanResize(BOOL can_resize); virtual void growToFit(S32 content_width, S32 content_height); - virtual void addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainerCommon::eInsertionPoint insertion_point = LLTabContainerCommon::END); + virtual void addFloater(LLFloater* floaterp, BOOL select_added_floater, LLTabContainer::eInsertionPoint insertion_point = LLTabContainer::END); virtual void showFloater(LLFloater* floaterp); virtual void removeFloater(LLFloater* floaterp); @@ -400,7 +395,7 @@ public: virtual void setFloaterFlashing(LLFloater* floaterp, BOOL flashing); virtual BOOL closeAllFloaters(); //Returns FALSE if the floater could not be closed due to pending confirmation dialogs - void setTabContainer(LLTabContainerCommon* tab_container) { if (!mTabContainer) mTabContainer = tab_container; } + void setTabContainer(LLTabContainer* tab_container) { if (!mTabContainer) mTabContainer = tab_container; } static void onTabSelected(void* userdata, bool); virtual void updateResizeLimits(); @@ -414,15 +409,56 @@ protected: BOOL mCanResize; }; - LLTabContainerCommon* mTabContainer; + LLTabContainer* mTabContainer; - typedef std::map<LLViewHandle, LLFloaterData> floater_data_map_t; + typedef std::map<LLHandle<LLFloater>, LLFloaterData> floater_data_map_t; floater_data_map_t mFloaterDataMap; - LLTabContainerCommon::TabPosition mTabPos; + LLTabContainer::TabPosition mTabPos; BOOL mAutoResize; }; +// visibility policy specialized for floaters +template<> +class VisibilityPolicy<LLFloater> +{ +public: + // visibility methods + static bool visible(LLFloater* instance, const LLSD& key) + { + if (instance) + { + return !instance->isMinimized() && instance->isInVisibleChain(); + } + return FALSE; + } + + static void show(LLFloater* instance, const LLSD& key) + { + if (instance) + { + instance->open(); + if (instance->getHost()) + { + instance->getHost()->open(); + } + } + } + + static void hide(LLFloater* instance, const LLSD& key) + { + if (instance) instance->close(); + } +}; + + +// singleton implementation for floaters (provides visibility policy) +// https://wiki.lindenlab.com/mediawiki/index.php?title=LLFloaterSingleton&oldid=79410 + +template <class T> class LLFloaterSingleton : public LLUISingleton<T, VisibilityPolicy<LLFloater> > +{ +}; + extern LLFloaterView* gFloaterView; diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index e3337eb588..29c6aa3c30 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -57,12 +57,8 @@ LLFocusMgr::LLFocusMgr() { } -LLFocusMgr::~LLFocusMgr() -{ - mFocusHistory.clear(); -} -void LLFocusMgr::releaseFocusIfNeeded( LLView* view ) +void LLFocusMgr::releaseFocusIfNeeded( const LLView* view ) { if( childHasMouseCapture( view ) ) { @@ -146,7 +142,7 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock) if (focus_subtree) { - mFocusHistory[focus_subtree->mViewHandle] = mKeyboardFocus ? mKeyboardFocus->mViewHandle : LLViewHandle::sDeadHandle; + mFocusHistory[focus_subtree->getHandle()] = mKeyboardFocus ? mKeyboardFocus->getHandle() : LLHandle<LLView>(); } } @@ -156,10 +152,6 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock) } } -void LLFocusMgr::setDefaultKeyboardFocus(LLUICtrl* default_focus) -{ - mDefaultKeyboardFocus = default_focus; -} // Returns TRUE is parent or any descedent of parent has keyboard focus. BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const @@ -177,7 +169,7 @@ BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const } // Returns TRUE is parent or any descedent of parent is the mouse captor. -BOOL LLFocusMgr::childHasMouseCapture( LLView* parent ) +BOOL LLFocusMgr::childHasMouseCapture( const LLView* parent ) const { if( mMouseCaptor && mMouseCaptor->isView() ) { @@ -194,7 +186,7 @@ BOOL LLFocusMgr::childHasMouseCapture( LLView* parent ) return FALSE; } -void LLFocusMgr::removeKeyboardFocusWithoutCallback( LLView* focus ) +void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLView* focus ) { // should be ok to unlock here, as you have to know the locked view // in order to unlock it @@ -253,7 +245,7 @@ void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) } } -void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) +void LLFocusMgr::removeMouseCaptureWithoutCallback( const LLMouseHandler* captor ) { //if (mFocusLocked) //{ @@ -269,7 +261,7 @@ void LLFocusMgr::removeMouseCaptureWithoutCallback( LLMouseHandler* captor ) } -BOOL LLFocusMgr::childIsTopCtrl( LLView* parent ) +BOOL LLFocusMgr::childIsTopCtrl( const LLView* parent ) const { LLView* top_view = (LLView*)mTopCtrl; while( top_view ) @@ -304,7 +296,7 @@ void LLFocusMgr::setTopCtrl( LLUICtrl* new_top ) } } -void LLFocusMgr::removeTopCtrlWithoutCallback( LLUICtrl* top_view ) +void LLFocusMgr::removeTopCtrlWithoutCallback( const LLUICtrl* top_view ) { if( mTopCtrl == top_view ) { @@ -325,12 +317,12 @@ void LLFocusMgr::unlockFocus() mLockedView = NULL; } -F32 LLFocusMgr::getFocusFlashAmt() +F32 LLFocusMgr::getFocusFlashAmt() const { return clamp_rescale(getFocusTime(), 0.f, FOCUS_FADE_TIME, mFocusWeight, 0.f); } -LLColor4 LLFocusMgr::getFocusColor() +LLColor4 LLFocusMgr::getFocusColor() const { LLColor4 focus_color = lerp(LLUI::sColorsGroup->getColor( "FocusColor" ), LLColor4::white, getFocusFlashAmt()); // de-emphasize keyboard focus when app has lost focus (to avoid typing into wrong window problem) @@ -362,15 +354,15 @@ void LLFocusMgr::setAppHasFocus(BOOL focus) mAppHasFocus = focus; } -LLUICtrl* LLFocusMgr::getLastFocusForGroup(LLView* subtree_root) +LLUICtrl* LLFocusMgr::getLastFocusForGroup(LLView* subtree_root) const { if (subtree_root) { - focus_history_map_t::iterator found_it = mFocusHistory.find(subtree_root->mViewHandle); + focus_history_map_t::const_iterator found_it = mFocusHistory.find(subtree_root->getHandle()); if (found_it != mFocusHistory.end()) { // found last focus for this subtree - return static_cast<LLUICtrl*>(LLView::getViewByHandle(found_it->second)); + return static_cast<LLUICtrl*>(found_it->second.get()); } } return NULL; @@ -380,6 +372,6 @@ void LLFocusMgr::clearLastFocusForGroup(LLView* subtree_root) { if (subtree_root) { - mFocusHistory.erase(subtree_root->mViewHandle); + mFocusHistory.erase(subtree_root->getHandle()); } } diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 20dc21fc3a..a3ca8bee26 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -45,48 +45,48 @@ class LLFocusMgr { public: LLFocusMgr(); - ~LLFocusMgr(); + ~LLFocusMgr() { mFocusHistory.clear(); } // Mouse Captor void setMouseCapture(LLMouseHandler* new_captor); // new_captor = NULL to release the mouse. - LLMouseHandler* getMouseCapture() { return mMouseCaptor; } - void removeMouseCaptureWithoutCallback( LLMouseHandler* captor ); - BOOL childHasMouseCapture( LLView* parent ); + LLMouseHandler* getMouseCapture() const { return mMouseCaptor; } + void removeMouseCaptureWithoutCallback( const LLMouseHandler* captor ); + BOOL childHasMouseCapture( const LLView* parent ) const; // Keyboard Focus void setKeyboardFocus(LLUICtrl* new_focus, BOOL lock = FALSE); // new_focus = NULL to release the focus. LLUICtrl* getKeyboardFocus() const { return mKeyboardFocus; } LLUICtrl* getLastKeyboardFocus() const { return mLastKeyboardFocus; } BOOL childHasKeyboardFocus( const LLView* parent ) const; - void removeKeyboardFocusWithoutCallback( LLView* focus ); + void removeKeyboardFocusWithoutCallback( const LLView* focus ); F32 getFocusTime() const { return mFocusTimer.getElapsedTimeF32(); } - F32 getFocusFlashAmt(); - LLColor4 getFocusColor(); + F32 getFocusFlashAmt() const; + LLColor4 getFocusColor() const; void triggerFocusFlash(); - BOOL getAppHasFocus() { return mAppHasFocus; } + BOOL getAppHasFocus() const { return mAppHasFocus; } void setAppHasFocus(BOOL focus); - LLUICtrl* getLastFocusForGroup(LLView* subtree_root); + LLUICtrl* getLastFocusForGroup(LLView* subtree_root) const; void clearLastFocusForGroup(LLView* subtree_root); // If setKeyboardFocus(NULL) is called, and there is a non-NULL default // keyboard focus view, focus goes there. JC - void setDefaultKeyboardFocus(LLUICtrl* default_focus); + void setDefaultKeyboardFocus(LLUICtrl* default_focus) { mDefaultKeyboardFocus = default_focus; } LLUICtrl* getDefaultKeyboardFocus() const { return mDefaultKeyboardFocus; } // Top View void setTopCtrl(LLUICtrl* new_top); LLUICtrl* getTopCtrl() const { return mTopCtrl; } - void removeTopCtrlWithoutCallback( LLUICtrl* top_view ); - BOOL childIsTopCtrl( LLView* parent ); + void removeTopCtrlWithoutCallback( const LLUICtrl* top_view ); + BOOL childIsTopCtrl( const LLView* parent ) const; // All Three - void releaseFocusIfNeeded( LLView* top_view ); + void releaseFocusIfNeeded( const LLView* top_view ); void lockFocus(); void unlockFocus(); - BOOL focusLocked() { return mLockedView != NULL; } + BOOL focusLocked() const { return mLockedView != NULL; } -protected: +private: LLUICtrl* mLockedView; // Mouse Captor @@ -105,7 +105,7 @@ protected: BOOL mAppHasFocus; - typedef std::map<LLViewHandle, LLViewHandle> focus_history_map_t; + typedef std::map<LLHandle<LLView>, LLHandle<LLView> > focus_history_map_t; focus_history_map_t mFocusHistory; #ifdef _DEBUG @@ -119,3 +119,4 @@ extern LLFocusMgr gFocusMgr; #endif // LL_LLFOCUSMGR_H + diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp index a063ebcd25..f47f166c45 100644 --- a/indra/llui/lliconctrl.cpp +++ b/indra/llui/lliconctrl.cpp @@ -91,8 +91,8 @@ void LLIconCtrl::draw() if( mImagep.notNull() ) { mImagep->draw(0, 0, - mRect.getWidth(), mRect.getHeight(), - mColor ); + getRect().getWidth(), getRect().getHeight(), + mColor ); } LLUICtrl::draw(); diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h index 1e474d0935..6535c0bb0b 100644 --- a/indra/llui/lliconctrl.h +++ b/indra/llui/lliconctrl.h @@ -69,7 +69,7 @@ public: virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); -protected: +private: LLColor4 mColor; LLString mImageName; LLUUID mImageID; diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 85d8f4b5c2..a81e26f880 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -41,7 +41,7 @@ const U32 KEYWORD_FILE_CURRENT_VERSION = 2; -inline BOOL LLKeywordToken::isHead(const llwchar* s) +inline BOOL LLKeywordToken::isHead(const llwchar* s) const { // strncmp is much faster than string compare BOOL res = TRUE; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index d279d2e627..fe36d7cbf6 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -56,11 +56,12 @@ public: { } - S32 getLength() { return mToken.size(); } - BOOL isHead(const llwchar* s); - const LLColor3& getColor() { return mColor; } - TOKEN_TYPE getType() { return mType; } - const LLWString& getToolTip() { return mToolTip; } + S32 getLength() const { return mToken.size(); } + BOOL isHead(const llwchar* s) const; + const LLWString& getToken() const { return mToken; } + const LLColor3& getColor() const { return mColor; } + TOKEN_TYPE getType() const { return mType; } + const LLWString& getToolTip() const { return mToolTip; } #ifdef _DEBUG void dump(); @@ -68,10 +69,8 @@ public: private: TOKEN_TYPE mType; -public: LLWString mToken; LLColor3 mColor; -private: LLWString mToolTip; }; @@ -82,30 +81,31 @@ public: ~LLKeywords(); BOOL loadFromFile(const LLString& filename); - BOOL isLoaded() { return mLoaded; } + BOOL isLoaded() const { return mLoaded; } void findSegments(std::vector<LLTextSegment *> *seg_list, const LLWString& text, const LLColor4 &defaultColor ); -#ifdef _DEBUG - void dump(); -#endif - // Add the token as described void addToken(LLKeywordToken::TOKEN_TYPE type, const LLString& key, const LLColor3& color, const LLString& tool_tip = LLString::null); + typedef std::map<LLWString, LLKeywordToken*> word_token_map_t; + typedef word_token_map_t::const_iterator keyword_iterator_t; + keyword_iterator_t begin() const { return mWordTokenMap.begin(); } + keyword_iterator_t end() const { return mWordTokenMap.end(); } + +#ifdef _DEBUG + void dump(); +#endif + private: LLColor3 readColor(const LLString& s); void insertSegment(std::vector<LLTextSegment *> *seg_list, LLTextSegment* new_segment, S32 text_len, const LLColor4 &defaultColor); -private: - BOOL mLoaded; -public: - typedef std::map<LLWString, LLKeywordToken*> word_token_map_t; + BOOL mLoaded; word_token_map_t mWordTokenMap; -private: typedef std::deque<LLKeywordToken*> token_list_t; token_list_t mLineTokenList; token_list_t mDelimiterTokenList; diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 4297f5fef8..391b28a21f 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -81,44 +81,6 @@ const S32 PREEDIT_STANDOUT_GAP = 1; const S32 PREEDIT_STANDOUT_POSITION = 2; const S32 PREEDIT_STANDOUT_THICKNESS = 2; -// This is a friend class of and is only used by LLLineEditor -class LLLineEditorRollback -{ -public: - LLLineEditorRollback( LLLineEditor* ed ) - : - mCursorPos( ed->mCursorPos ), - mScrollHPos( ed->mScrollHPos ), - mIsSelecting( ed->mIsSelecting ), - mSelectionStart( ed->mSelectionStart ), - mSelectionEnd( ed->mSelectionEnd ) - { - mText = ed->getText(); - } - - void doRollback( LLLineEditor* ed ) - { - ed->mCursorPos = mCursorPos; - ed->mScrollHPos = mScrollHPos; - ed->mIsSelecting = mIsSelecting; - ed->mSelectionStart = mSelectionStart; - ed->mSelectionEnd = mSelectionEnd; - ed->mText = mText; - ed->mPrevText = mText; - } - - LLString getText() { return mText; } - -private: - LLString mText; - S32 mCursorPos; - S32 mScrollHPos; - BOOL mIsSelecting; - S32 mSelectionStart; - S32 mSelectionEnd; -}; - - // // Member functions // @@ -190,7 +152,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, setFocusLostCallback(focus_lost_callback); mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft; - mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; + mMaxHPixels = getRect().getWidth() - mMinHPixels - mBorderThickness - mBorderRight; mScrollTimer.reset(); @@ -200,7 +162,7 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, // Scalable UI somehow made these rectangles off-by-one. // I don't know why. JC - LLRect border_rect(0, mRect.getHeight()-1, mRect.getWidth()-1, 0); + LLRect border_rect(0, getRect().getHeight()-1, getRect().getWidth()-1, 0); mBorder = new LLViewBorder( "line ed border", border_rect, border_bevel, border_style, mBorderThickness ); addChild( mBorder ); mBorder->setFollows(FOLLOWS_LEFT|FOLLOWS_RIGHT|FOLLOWS_TOP|FOLLOWS_BOTTOM); @@ -219,17 +181,6 @@ LLLineEditor::~LLLineEditor() } } -//virtual -EWidgetType LLLineEditor::getWidgetType() const -{ - return WIDGET_TYPE_LINE_EDITOR; -} - -//virtual -LLString LLLineEditor::getWidgetTag() const -{ - return LL_LINE_EDITOR_TAG; -} void LLLineEditor::onFocusReceived() { @@ -269,18 +220,6 @@ void LLLineEditor::onCommit() selectAll(); } -// virtual -BOOL LLLineEditor::isDirty() const -{ - return ( mText.getString() != mPrevText ); -} - -// virtual -void LLLineEditor::resetDirty() -{ - mPrevText = mText.getString(); -} - // line history support void LLLineEditor::updateHistory() @@ -306,12 +245,7 @@ void LLLineEditor::reshape(S32 width, S32 height, BOOL called_from_parent) { LLUICtrl::reshape(width, height, called_from_parent ); - mMaxHPixels = mRect.getWidth() - 2 * (mBorderThickness + UI_LINEEDITOR_H_PAD) + 1 - mBorderRight; -} - -void LLLineEditor::setEnableLineHistory( BOOL enabled ) -{ - mHaveHistory = enabled; + mMaxHPixels = getRect().getWidth() - 2 * (mBorderThickness + UI_LINEEDITOR_H_PAD) + 1 - mBorderRight; } void LLLineEditor::setEnabled(BOOL enabled) @@ -330,16 +264,12 @@ void LLLineEditor::setMaxTextLength(S32 max_text_length) void LLLineEditor::setBorderWidth(S32 left, S32 right) { - mBorderLeft = llclamp(left, 0, mRect.getWidth()); - mBorderRight = llclamp(right, 0, mRect.getWidth()); + mBorderLeft = llclamp(left, 0, getRect().getWidth()); + mBorderRight = llclamp(right, 0, getRect().getWidth()); mMinHPixels = mBorderThickness + UI_LINEEDITOR_H_PAD + mBorderLeft; - mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; + mMaxHPixels = getRect().getWidth() - mMinHPixels - mBorderThickness - mBorderRight; } -void LLLineEditor::setLabel(const LLStringExplicit &new_label) -{ - mLabel = new_label; -} void LLLineEditor::setText(const LLStringExplicit &new_text) { @@ -451,12 +381,11 @@ void LLLineEditor::setCursorToEnd() deselect(); } -BOOL LLLineEditor::canDeselect() +BOOL LLLineEditor::canDeselect() const { return hasSelection(); } - void LLLineEditor::deselect() { mSelectionStart = 0; @@ -481,7 +410,7 @@ void LLLineEditor::endSelection() } } -BOOL LLLineEditor::canSelectAll() +BOOL LLLineEditor::canSelectAll() const { return TRUE; } @@ -554,7 +483,7 @@ BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask) BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) { - if (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight)) + if (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight)) { return LLUICtrl::handleMouseDown(x, y, mask); } @@ -634,7 +563,7 @@ BOOL LLLineEditor::handleMouseDown(S32 x, S32 y, MASK mask) BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; - if (!hasMouseCapture() && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) + if (!hasMouseCapture() && (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight))) { return LLUICtrl::handleHover(x, y, mask); } @@ -705,7 +634,7 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) handled = TRUE; } - if (!handled && (x < mBorderLeft || x > (mRect.getWidth() - mBorderRight))) + if (!handled && (x < mBorderLeft || x > (getRect().getWidth() - mBorderRight))) { return LLUICtrl::handleMouseUp(x, y, mask); } @@ -856,11 +785,6 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) switch( key ) { case KEY_LEFT: - if (mIgnoreArrowKeys) - { - handled = FALSE; - break; - } if( 0 < getCursor() ) { S32 cursorPos = getCursor() - 1; @@ -877,11 +801,6 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) break; case KEY_RIGHT: - if (mIgnoreArrowKeys) - { - handled = FALSE; - break; - } if( getCursor() < mText.length()) { S32 cursorPos = getCursor() + 1; @@ -899,22 +818,12 @@ BOOL LLLineEditor::handleSelectionKey(KEY key, MASK mask) case KEY_PAGE_UP: case KEY_HOME: - if (mIgnoreArrowKeys) - { - handled = FALSE; - break; - } extendSelection( 0 ); break; case KEY_PAGE_DOWN: case KEY_END: { - if (mIgnoreArrowKeys) - { - handled = FALSE; - break; - } S32 len = mText.length(); if( len ) { @@ -962,7 +871,7 @@ void LLLineEditor::deleteSelection() } } -BOOL LLLineEditor::canCut() +BOOL LLLineEditor::canCut() const { return !mReadOnly && !mDrawAsterixes && hasSelection(); } @@ -996,7 +905,7 @@ void LLLineEditor::cut() } } -BOOL LLLineEditor::canCopy() +BOOL LLLineEditor::canCopy() const { return !mDrawAsterixes && hasSelection(); } @@ -1013,7 +922,7 @@ void LLLineEditor::copy() } } -BOOL LLLineEditor::canPaste() +BOOL LLLineEditor::canPaste() const { return !mReadOnly && gClipboard.canPasteString(); } @@ -1148,8 +1057,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) break; case KEY_LEFT: - if (!mIgnoreArrowKeys - && mask != MASK_ALT) + if (mIgnoreArrowKeys && mask == MASK_NONE) + break; + if ((mask & MASK_ALT) == 0) { if( hasSelection() ) { @@ -1174,8 +1084,9 @@ BOOL LLLineEditor::handleSpecialKey(KEY key, MASK mask) break; case KEY_RIGHT: - if (!mIgnoreArrowKeys - && mask != MASK_ALT) + if (mIgnoreArrowKeys && mask == MASK_NONE) + break; + if ((mask & MASK_ALT) == 0) { if (hasSelection()) { @@ -1428,7 +1339,7 @@ BOOL LLLineEditor::handleUnicodeCharHere(llwchar uni_char, BOOL called_from_pare } -BOOL LLLineEditor::canDoDelete() +BOOL LLLineEditor::canDoDelete() const { return ( !mReadOnly && (!mPassDelete || (hasSelection() || (getCursor() < mText.length()))) ); } @@ -1490,7 +1401,7 @@ void LLLineEditor::draw() } // draw rectangle for the background - LLRect background( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + LLRect background( 0, getRect().getHeight(), getRect().getWidth(), 0 ); background.stretch( -mBorderThickness ); LLColor4 bg_color = mReadOnlyBgColor; @@ -1521,7 +1432,7 @@ void LLLineEditor::draw() LLColor4 text_color; if (!mReadOnly) { - if (!mTentative) + if (!getTentative()) { text_color = mFgColor; } @@ -1846,7 +1757,7 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str) if( 0 < len ) { // May be a comma or period, depending on the locale - char decimal_point = gResMgr->getDecimalPoint(); + llwchar decimal_point = (llwchar)gResMgr->getDecimalPoint(); S32 i = 0; @@ -1895,7 +1806,7 @@ BOOL LLLineEditor::postvalidateFloat(const LLString &str) } // May be a comma or period, depending on the locale - char decimal_point = gResMgr->getDecimalPoint(); + llwchar decimal_point = (llwchar)gResMgr->getDecimalPoint(); for( ; i < len; i++ ) { @@ -2366,18 +2277,6 @@ void LLLineEditor::setColorParameters(LLXMLNodePtr node) } } -void LLLineEditor::setValue(const LLSD& value ) -{ - setText(value.asString()); -} - -LLSD LLLineEditor::getValue() const -{ - LLString str = getText(); - LLSD ret(str); - return ret; -} - BOOL LLLineEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) { mText.setArg(key, text); @@ -2504,7 +2403,7 @@ BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect if (control) { LLRect control_rect_screen; - localRectToScreen(mRect, &control_rect_screen); + localRectToScreen(getRect(), &control_rect_screen); LLUI::screenRectToGL(control_rect_screen, control); } @@ -2534,21 +2433,21 @@ BOOL LLLineEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect { S32 query_local = findPixelNearestPos(query - getCursor()); S32 query_screen_x, query_screen_y; - localPointToScreen(query_local, mRect.getHeight() / 2, &query_screen_x, &query_screen_y); + localPointToScreen(query_local, getRect().getHeight() / 2, &query_screen_x, &query_screen_y); LLUI::screenPointToGL(query_screen_x, query_screen_y, &coord->mX, &coord->mY); } if (bounds) { S32 preedit_left_local = findPixelNearestPos(llmax(preedit_left_column, mScrollHPos) - getCursor()); - S32 preedit_right_local = llmin(findPixelNearestPos(preedit_right_column - getCursor()), mRect.getWidth() - mBorderThickness); + S32 preedit_right_local = llmin(findPixelNearestPos(preedit_right_column - getCursor()), getRect().getWidth() - mBorderThickness); if (preedit_left_local > preedit_right_local) { // Is this condition possible? preedit_right_local = preedit_left_local; } - LLRect preedit_rect_local(preedit_left_local, mRect.getHeight(), preedit_right_local, 0); + LLRect preedit_rect_local(preedit_left_local, getRect().getHeight(), preedit_right_local, 0); LLRect preedit_rect_screen; localRectToScreen(preedit_rect_local, &preedit_rect_screen); LLUI::screenRectToGL(preedit_rect_screen, bounds); @@ -2632,7 +2531,7 @@ LLSearchEditor::LLSearchEditor(const LLString& name, LLUICtrl(name, rect, TRUE, NULL, userdata), mSearchCallback(search_callback) { - LLRect search_edit_rect(0, mRect.getHeight(), mRect.getWidth(), 0); + LLRect search_edit_rect(0, getRect().getHeight(), getRect().getWidth(), 0); mSearchEdit = new LLLineEditor("search edit", search_edit_rect, LLString::null, @@ -2668,55 +2567,6 @@ LLSearchEditor::LLSearchEditor(const LLString& name, mSearchEdit->setBorderWidth(0, btn_width); } -LLSearchEditor::~LLSearchEditor() -{ -} - -//virtual -EWidgetType LLSearchEditor::getWidgetType() const -{ - return WIDGET_TYPE_SEARCH_EDITOR; -} - -//virtual -LLString LLSearchEditor::getWidgetTag() const -{ - return LL_SEARCH_EDITOR_TAG; -} - -//virtual -void LLSearchEditor::setValue(const LLSD& value ) -{ - mSearchEdit->setValue(value); -} - -//virtual -LLSD LLSearchEditor::getValue() const -{ - return mSearchEdit->getValue(); -} - -//virtual -BOOL LLSearchEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) -{ - return mSearchEdit->setTextArg(key, text); -} - -//virtual -BOOL LLSearchEditor::setLabelArg( const LLString& key, const LLStringExplicit& text ) -{ - return mSearchEdit->setLabelArg(key, text); -} - -//virtual -void LLSearchEditor::clear() -{ - if (mSearchEdit) - { - mSearchEdit->clear(); - } -} - void LLSearchEditor::draw() { @@ -2725,10 +2575,6 @@ void LLSearchEditor::draw() LLUICtrl::draw(); } -void LLSearchEditor::setText(const LLStringExplicit &new_text) -{ - mSearchEdit->setText(new_text); -} //static void LLSearchEditor::onSearchEdit(LLLineEditor* caller, void* user_data ) diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 0739315c4d..6210c37ef3 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -1,6 +1,15 @@ /** * @file lllineeditor.h - * @brief LLLineEditor base class + * @brief Text editor widget to let users enter/edit a single line. + * + * Features: + * Text entry of a single line (text, delete, left and right arrow, insert, return). + * Callbacks either on every keystroke or just on the return key. + * Focus (allow multiple text entry widgets) + * Clipboard (cut, copy, and paste) + * Horizontal scrolling to allow strings longer than widget size allows + * Pre-validation (limit which keys can be used) + * Optional line history so previous entries can be recalled by CTRL UP/DOWN * * $LicenseInfo:firstyear=2001&license=viewergpl$ * @@ -29,19 +38,6 @@ * $/LicenseInfo$ */ -// Text editor widget to let users enter/edit a single line. -// -// -// Features: -// Text entry of a single line (text, delete, left and right arrow, insert, return). -// Callbacks either on every keystroke or just on the return key. -// Focus (allow multiple text entry widgets) -// Clipboard (cut, copy, and paste) -// Horizontal scrolling to allow strings longer than widget size allows -// Pre-validation (limit which keys can be used) -// Optional line history so previous entries can be recalled by CTRL UP/DOWN - - #ifndef LL_LLLINEEDITOR_H #define LL_LLLINEEDITOR_H @@ -61,13 +57,10 @@ class LLButton; typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr); -// -// Classes -// + class LLLineEditor : public LLUICtrl, public LLEditMenuHandler, protected LLPreeditor { - friend class LLLineEditorRollback; public: LLLineEditor(const LLString& name, @@ -85,8 +78,8 @@ public: S32 border_thickness = 1); virtual ~LLLineEditor(); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LINE_EDITOR; } + virtual LLString getWidgetTag() const { return LL_LINE_EDITOR_TAG; }; virtual LLXMLNodePtr getXML(bool save_children = true) const; void setColorParameters(LLXMLNodePtr node); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -102,22 +95,22 @@ public: // LLEditMenuHandler overrides virtual void cut(); - virtual BOOL canCut(); + virtual BOOL canCut() const; virtual void copy(); - virtual BOOL canCopy(); + virtual BOOL canCopy() const; virtual void paste(); - virtual BOOL canPaste(); + virtual BOOL canPaste() const; virtual void doDelete(); - virtual BOOL canDoDelete(); + virtual BOOL canDoDelete() const; virtual void selectAll(); - virtual BOOL canSelectAll(); + virtual BOOL canSelectAll() const; virtual void deselect(); - virtual BOOL canDeselect(); + virtual BOOL canDeselect() const; // view overrides virtual void draw(); @@ -133,16 +126,16 @@ public: virtual void setRect(const LLRect& rect); virtual BOOL acceptsTextInput() const; virtual void onCommit(); - virtual BOOL isDirty() const; // Returns TRUE if the user has changed value at all - virtual void resetDirty(); // Clear dirty state + virtual BOOL isDirty() const { return mText.getString() != mPrevText; } // Returns TRUE if user changed value at all + virtual void resetDirty() { mPrevText = mText.getString(); } // Clear dirty state // assumes UTF8 text - virtual void setValue(const LLSD& value ); - virtual LLSD getValue() const; + virtual void setValue(const LLSD& value ) { setText(value.asString()); } + virtual LLSD getValue() const { return LLSD(getText()); } virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); - void setLabel(const LLStringExplicit &new_label); + void setLabel(const LLStringExplicit &new_label) { mLabel = new_label; } void setText(const LLStringExplicit &new_text); const LLString& getText() const { return mText.getString(); } @@ -179,7 +172,6 @@ public: void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; } void setIgnoreTab(BOOL b) { mIgnoreTab = b; } void setPassDelete(BOOL b) { mPassDelete = b; } - void setDrawAsterixes(BOOL b); // get the cursor position of the beginning/end of the prev/next word in the text @@ -216,23 +208,24 @@ public: static BOOL postvalidateFloat(const LLString &str); // line history support: - void setEnableLineHistory( BOOL enabled ); // switches line history on or off + void setEnableLineHistory( BOOL enabled ) { mHaveHistory = enabled; } // switches line history on or off void updateHistory(); // stores current line in history -protected: +private: + // private helper classes void removeChar(); void addChar(const llwchar c); void setCursorAtLocalPos(S32 local_mouse_x); - S32 findPixelNearestPos(S32 cursor_offset = 0) const; void reportBadKeystroke(); - BOOL handleSpecialKey(KEY key, MASK mask); BOOL handleSelectionKey(KEY key, MASK mask); BOOL handleControlKey(KEY key, MASK mask); S32 handleCommitKey(KEY key, MASK mask); -protected: + // + // private data members + // void updateAllowingLanguageInput(); BOOL hasPreeditString() const; // Implementation (overrides) of LLPreeditor @@ -308,13 +301,53 @@ protected: LLWString mPreeditOverwrittenWString; std::vector<S32> mPreeditPositions; LLPreeditor::standouts_t mPreeditStandouts; -}; - + // private helper class + class LLLineEditorRollback + { + public: + LLLineEditorRollback( LLLineEditor* ed ) + : + mCursorPos( ed->mCursorPos ), + mScrollHPos( ed->mScrollHPos ), + mIsSelecting( ed->mIsSelecting ), + mSelectionStart( ed->mSelectionStart ), + mSelectionEnd( ed->mSelectionEnd ) + { + mText = ed->getText(); + } + + void doRollback( LLLineEditor* ed ) + { + ed->mCursorPos = mCursorPos; + ed->mScrollHPos = mScrollHPos; + ed->mIsSelecting = mIsSelecting; + ed->mSelectionStart = mSelectionStart; + ed->mSelectionEnd = mSelectionEnd; + ed->mText = mText; + ed->mPrevText = mText; + } + + LLString getText() { return mText; } + + private: + LLString mText; + S32 mCursorPos; + S32 mScrollHPos; + BOOL mIsSelecting; + S32 mSelectionStart; + S32 mSelectionEnd; + }; // end class LLLineEditorRollback + +}; // end class LLLineEditor + + + +/* + * @brief A line editor with a button to clear it and a callback to call on every edit event. + */ class LLSearchEditor : public LLUICtrl { -friend class LLLineEditorRollback; - public: LLSearchEditor(const LLString& name, const LLRect& rect, @@ -322,34 +355,34 @@ public: void (*search_callback)(const LLString& search_string, void* user_data), void* userdata); - virtual ~LLSearchEditor(); + virtual ~LLSearchEditor() {} /*virtual*/ void draw(); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SEARCH_EDITOR; } + virtual LLString getWidgetTag() const { return LL_SEARCH_EDITOR_TAG; } static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - void setText(const LLStringExplicit &new_text); + void setText(const LLStringExplicit &new_text) { mSearchEdit->setText(new_text); } void setSearchCallback(void (*search_callback)(const LLString& search_string, void* user_data), void* data) { mSearchCallback = search_callback; mCallbackUserData = data; } // LLUICtrl interface - virtual void setValue(const LLSD& value ); - virtual LLSD getValue() const; - virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ); - virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); - virtual void clear(); + virtual void setValue(const LLSD& value ) { mSearchEdit->setValue(value); } + virtual LLSD getValue() const { return mSearchEdit->getValue(); } + virtual BOOL setTextArg( const LLString& key, const LLStringExplicit& text ) { return mSearchEdit->setTextArg( key, text); } + virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ) { return mSearchEdit->setLabelArg(key, text); } + virtual void clear() { if (mSearchEdit) mSearchEdit->clear(); } -protected: - LLLineEditor* mSearchEdit; - LLButton* mClearSearchButton; +private: + static void onSearchEdit(LLLineEditor* caller, void* user_data ); + static void onClearSearch(void* user_data); + LLLineEditor* mSearchEdit; + class LLButton* mClearSearchButton; void (*mSearchCallback)(const LLString& search_string, void* user_data); - static void onSearchEdit(LLLineEditor* caller, void* user_data ); - static void onClearSearch(void* user_data); }; #endif // LL_LINEEDITOR_ diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index 19a5085a25..4e94aff7a5 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -112,12 +112,11 @@ LLColor4 LLMenuItemGL::sEnabledColor( 0.0f, 0.0f, 0.0f, 1.0f ); LLColor4 LLMenuItemGL::sDisabledColor( 0.5f, 0.5f, 0.5f, 1.0f ); LLColor4 LLMenuItemGL::sHighlightBackground( 0.0f, 0.0f, 0.7f, 1.0f ); LLColor4 LLMenuItemGL::sHighlightForeground( 1.0f, 1.0f, 1.0f, 1.0f ); -BOOL LLMenuItemGL::sDropShadowText = TRUE; LLColor4 LLMenuGL::sDefaultBackgroundColor( 0.25f, 0.25f, 0.25f, 0.75f ); BOOL LLMenuGL::sKeyboardMode = FALSE; -LLViewHandle LLMenuHolderGL::sItemLastSelectedHandle; +LLHandle<LLView> LLMenuHolderGL::sItemLastSelectedHandle; LLFrameTimer LLMenuHolderGL::sItemActivationTimer; //LLColor4 LLMenuGL::sBackgroundColor( 0.8f, 0.8f, 0.0f, 1.0f ); @@ -199,7 +198,7 @@ BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent) if( called_from_parent ) { // Downward traversal - if (mEnabled) + if (getEnabled()) { handled = childrenHandleKey( key, mask ) != NULL; } @@ -215,7 +214,7 @@ BOOL LLMenuItemGL::handleKey(KEY key, MASK mask, BOOL called_from_parent) BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) { - if( mEnabled && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) + if( getEnabled() && (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) { doIt(); return TRUE; @@ -225,15 +224,10 @@ BOOL LLMenuItemGL::handleAcceleratorKey(KEY key, MASK mask) BOOL LLMenuItemGL::handleHover(S32 x, S32 y, MASK mask) { - mGotHover = TRUE; + setHover(TRUE); getWindow()->setCursor(UI_CURSOR_ARROW); return TRUE; } - -void LLMenuItemGL::setBriefItem(BOOL b) -{ - mBriefItem = b; -} // This function checks to see if the accelerator key is already in use; // if not, it will be added to the list @@ -282,7 +276,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) // This function appends the character string representation of // the current accelerator key and mask to the provided string. -void LLMenuItemGL::appendAcceleratorString( LLString& st ) +void LLMenuItemGL::appendAcceleratorString( LLString& st ) const { // break early if this is a silly thing to do. if( KEY_NONE == mAcceleratorKey ) @@ -332,52 +326,14 @@ void LLMenuItemGL::setJumpKey(KEY key) mJumpKey = LLStringOps::toUpper((char)key); } -KEY LLMenuItemGL::getJumpKey() -{ - return mJumpKey; -} - - -// set the font used by all of the menu objects -void LLMenuItemGL::setFont(LLFontGL* font) -{ - mFont = font; -} - -// returns the height in pixels for the current font. -U32 LLMenuItemGL::getNominalHeight( void ) -{ - return llround(mFont->getLineHeight()) + MENU_ITEM_PADDING; -} - -// functions to control the color scheme -void LLMenuItemGL::setEnabledColor( const LLColor4& color ) -{ - sEnabledColor = color; -} - -void LLMenuItemGL::setDisabledColor( const LLColor4& color ) -{ - sDisabledColor = color; -} - -void LLMenuItemGL::setHighlightBGColor( const LLColor4& color ) -{ - sHighlightBackground = color; -} -void LLMenuItemGL::setHighlightFGColor( const LLColor4& color ) -{ - sHighlightForeground = color; +// virtual +U32 LLMenuItemGL::getNominalHeight( void ) const +{ + return llround(mFont->getLineHeight()) + MENU_ITEM_PADDING; } -// change the label -void LLMenuItemGL::setLabel( const LLStringExplicit& label ) -{ - mLabel = label; -} - // Get the parent menu for this item LLMenuGL* LLMenuItemGL::getMenu() { @@ -388,7 +344,7 @@ LLMenuGL* LLMenuItemGL::getMenu() // getNominalWidth() - returns the normal width of this control in // pixels - this is used for calculating the widest item, as well as // for horizontal arrangement. -U32 LLMenuItemGL::getNominalWidth( void ) +U32 LLMenuItemGL::getNominalWidth( void ) const { U32 width; @@ -442,17 +398,6 @@ void LLMenuItemGL::doIt( void ) mHighlight = highlight; } -// determine if this object represents an active sub-menu -BOOL LLMenuItemGL::isActive( void ) const -{ - return FALSE; -} - -// determine if this object represents an open sub-menu -BOOL LLMenuItemGL::isOpen( void ) const -{ - return FALSE; -} BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) { @@ -490,7 +435,7 @@ BOOL LLMenuItemGL::handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ) BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK ) { - if (mEnabled) + if (getEnabled()) { // switch to mouse navigation mode LLMenuGL::setKeyboardMode(FALSE); @@ -504,7 +449,7 @@ BOOL LLMenuItemGL::handleMouseUp( S32 x, S32 y, MASK ) BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK ) { - if (mEnabled) + if (getEnabled()) { // switch to mouse navigation mode LLMenuGL::setKeyboardMode(FALSE); @@ -512,10 +457,7 @@ BOOL LLMenuItemGL::handleMouseDown( S32 x, S32 y, MASK ) setHighlight(TRUE); return TRUE; } - else - { - return FALSE; - } + return FALSE; } @@ -529,13 +471,13 @@ void LLMenuItemGL::draw( void ) if( getEnabled() && getHighlight() && !mBriefItem) { glColor4fv( sHighlightBackground.mV ); - gl_rect_2d( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0 ); } LLColor4 color; U8 font_style = mStyle; - if (LLMenuItemGL::sDropShadowText && getEnabled() && !mDrawTextDisabled ) + if (getEnabled() && !mDrawTextDisabled ) { font_style |= LLFontGL::DROP_SHADOW_SOFT; } @@ -570,12 +512,12 @@ void LLMenuItemGL::draw( void ) LLFontGL::LEFT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE ); if( !mDrawAccelLabel.empty() ) { - mFont->render( mDrawAccelLabel.getWString(), 0, (F32)mRect.mRight - (F32)RIGHT_PLAIN_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color, + mFont->render( mDrawAccelLabel.getWString(), 0, (F32)getRect().mRight - (F32)RIGHT_PLAIN_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color, LLFontGL::RIGHT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE ); } if( !mDrawBranchLabel.empty() ) { - mFont->render( mDrawBranchLabel.getWString(), 0, (F32)mRect.mRight - (F32)RIGHT_PAD_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color, + mFont->render( mDrawBranchLabel.getWString(), 0, (F32)getRect().mRight - (F32)RIGHT_PAD_PIXELS, ((F32)MENU_ITEM_PADDING / 2.f) + 1.f, color, LLFontGL::RIGHT, LLFontGL::BOTTOM, font_style, S32_MAX, S32_MAX, NULL, FALSE ); } } @@ -595,7 +537,7 @@ void LLMenuItemGL::draw( void ) } // clear got hover every frame - mGotHover = FALSE; + setHover(FALSE); } BOOL LLMenuItemGL::setLabelArg( const LLString& key, const LLStringExplicit& text ) @@ -628,7 +570,7 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleHover(S32 x, S32 y, MASK mask); - virtual U32 getNominalHeight( void ) { return SEPARATOR_HEIGHT_PIXELS; } + virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } }; LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const LLString &name ) : @@ -638,42 +580,42 @@ LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const LLString &name ) : void LLMenuItemSeparatorGL::draw( void ) { - glColor4fv( sDisabledColor.mV ); - const S32 y = mRect.getHeight() / 2; + glColor4fv( getDisabledColor().mV ); + const S32 y = getRect().getHeight() / 2; const S32 PAD = 6; - gl_line_2d( PAD, y, mRect.getWidth() - PAD, y ); + gl_line_2d( PAD, y, getRect().getWidth() - PAD, y ); } BOOL LLMenuItemSeparatorGL::handleMouseDown(S32 x, S32 y, MASK mask) { LLMenuGL* parent_menu = getMenu(); - if (y > mRect.getHeight() / 2) + if (y > getRect().getHeight() / 2) { - return parent_menu->handleMouseDown(x + mRect.mLeft, mRect.mTop + 1, mask); + return parent_menu->handleMouseDown(x + getRect().mLeft, getRect().mTop + 1, mask); } else { - return parent_menu->handleMouseDown(x + mRect.mLeft, mRect.mBottom - 1, mask); + return parent_menu->handleMouseDown(x + getRect().mLeft, getRect().mBottom - 1, mask); } } BOOL LLMenuItemSeparatorGL::handleMouseUp(S32 x, S32 y, MASK mask) { LLMenuGL* parent_menu = getMenu(); - if (y > mRect.getHeight() / 2) + if (y > getRect().getHeight() / 2) { - return parent_menu->handleMouseUp(x + mRect.mLeft, mRect.mTop + 1, mask); + return parent_menu->handleMouseUp(x + getRect().mLeft, getRect().mTop + 1, mask); } else { - return parent_menu->handleMouseUp(x + mRect.mLeft, mRect.mBottom - 1, mask); + return parent_menu->handleMouseUp(x + getRect().mLeft, getRect().mBottom - 1, mask); } } BOOL LLMenuItemSeparatorGL::handleHover(S32 x, S32 y, MASK mask) { LLMenuGL* parent_menu = getMenu(); - if (y > mRect.getHeight() / 2) + if (y > getRect().getHeight() / 2) { parent_menu->highlightPrevItem(this, FALSE); return FALSE; @@ -711,24 +653,13 @@ LLMenuItemVerticalSeparatorGL::LLMenuItemVerticalSeparatorGL( void ) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemTearOffGL -// -// This class represents a separator. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LLMenuItemTearOffGL::LLMenuItemTearOffGL(LLViewHandle parent_floater_handle) : +LLMenuItemTearOffGL::LLMenuItemTearOffGL(LLHandle<LLFloater> parent_floater_handle) : LLMenuItemGL("tear off", TEAROFF_SEPARATOR_LABEL), mParentHandle(parent_floater_handle) { } -EWidgetType LLMenuItemTearOffGL::getWidgetType() const -{ - return WIDGET_TYPE_TEAROFF_MENU; -} - -LLString LLMenuItemTearOffGL::getWidgetTag() const -{ - return LL_MENU_ITEM_TEAR_OFF_GL_TAG; -} void LLMenuItemTearOffGL::doIt() { @@ -747,7 +678,7 @@ void LLMenuItemTearOffGL::doIt() getMenu()->arrange(); - LLFloater* parent_floater = LLFloater::getFloaterByHandle(mParentHandle); + LLFloater* parent_floater = mParentHandle.get(); LLFloater* tear_off_menu = LLTearOffMenu::create(getMenu()); if (tear_off_menu) @@ -768,27 +699,31 @@ void LLMenuItemTearOffGL::doIt() void LLMenuItemTearOffGL::draw() { // disabled items can be highlighted, but shouldn't render as such - if( getEnabled() && getHighlight() && !mBriefItem) + if( getEnabled() && getHighlight() && !isBriefItem()) { - glColor4fv( sHighlightBackground.mV ); - gl_rect_2d( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + glColor4fv( getHighlightBGColor().mV ); + gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0 ); } - if (mEnabled) + if (getEnabled()) { - glColor4fv( sEnabledColor.mV ); + glColor4fv( getEnabledColor().mV ); } else { - glColor4fv( sDisabledColor.mV ); + glColor4fv( getDisabledColor().mV ); } - const S32 y = mRect.getHeight() / 3; + const S32 y = getRect().getHeight() / 3; const S32 PAD = 6; - gl_line_2d( PAD, y, mRect.getWidth() - PAD, y ); - gl_line_2d( PAD, y * 2, mRect.getWidth() - PAD, y * 2 ); + gl_line_2d( PAD, y, getRect().getWidth() - PAD, y ); + gl_line_2d( PAD, y * 2, getRect().getWidth() - PAD, y * 2 ); +} + +U32 LLMenuItemTearOffGL::getNominalHeight( void ) const +{ + return TEAROFF_SEPARATOR_HEIGHT_PIXELS; } -U32 LLMenuItemTearOffGL::getNominalHeight( void ) { return TEAROFF_SEPARATOR_HEIGHT_PIXELS; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemBlankGL @@ -799,22 +734,16 @@ U32 LLMenuItemTearOffGL::getNominalHeight( void ) { return TEAROFF_SEPARATOR_HEI class LLMenuItemBlankGL : public LLMenuItemGL { public: - LLMenuItemBlankGL( void ); - + LLMenuItemBlankGL( void ) : LLMenuItemGL( "", "" ) + { + setEnabled(FALSE); + } virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BLANK; } virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BLANK_GL_TAG; } - - // doIt() - do the primary funcationality of the menu item. virtual void doIt( void ) {} - virtual void draw( void ) {} }; -LLMenuItemBlankGL::LLMenuItemBlankGL( void ) -: LLMenuItemGL( "", "" ) -{ - mEnabled = FALSE; -} ///============================================================================ /// Class LLMenuItemCallGL @@ -905,7 +834,7 @@ void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *conte } else { - context->addBoolControl(enabled_control, mEnabled); + context->addBoolControl(enabled_control, getEnabled()); control = context->findControl(enabled_control); control->registerListener(this, "ENABLED"); } @@ -925,7 +854,7 @@ void LLMenuItemCallGL::setVisibleControl(LLString enabled_control, LLView *conte } else { - context->addBoolControl(enabled_control, mEnabled); + context->addBoolControl(enabled_control, getEnabled()); control = context->findControl(enabled_control); control->registerListener(this, "VISIBLE"); } @@ -989,16 +918,6 @@ void LLMenuItemCallGL::doIt( void ) LLMenuItemGL::doIt(); } -EWidgetType LLMenuItemCallGL::getWidgetType() const -{ - return WIDGET_TYPE_MENU_ITEM_CALL; -} - -LLString LLMenuItemCallGL::getWidgetTag() const -{ - return LL_MENU_ITEM_CALL_GL_TAG; -} - void LLMenuItemCallGL::buildDrawLabel( void ) { LLPointer<LLEvent> fired_event = new LLEvent(this); @@ -1018,7 +937,7 @@ void LLMenuItemCallGL::buildDrawLabel( void ) BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) { - if( (!gKeyboard->getKeyRepeated(key) || mAllowKeyRepeat) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) + if( (!gKeyboard->getKeyRepeated(key) || getAllowKeyRepeat()) && (key == mAcceleratorKey) && (mask == (mAcceleratorMask & MASK_NORMALKEYS)) ) { LLPointer<LLEvent> fired_event = new LLEvent(this); fireEvent(fired_event, "on_build"); @@ -1026,7 +945,7 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) { setEnabled( mEnabledCallback( mUserData ) ); } - if( !mEnabled ) + if( !getEnabled() ) { if( mOnDisabledCallback ) { @@ -1127,20 +1046,10 @@ LLXMLNodePtr LLMenuItemCheckGL::getXML(bool save_children) const return node; } -EWidgetType LLMenuItemCheckGL::getWidgetType() const -{ - return WIDGET_TYPE_MENU_ITEM_CHECK; -} - -LLString LLMenuItemCheckGL::getWidgetTag() const -{ - return LL_MENU_ITEM_CHECK_GL_TAG; -} - // called to rebuild the draw label void LLMenuItemCheckGL::buildDrawLabel( void ) { - if(mChecked || (mCheckCallback && mCheckCallback( mUserData ) ) ) + if(mChecked || (mCheckCallback && mCheckCallback( getUserData() ) ) ) { mDrawBoolLabel = BOOLEAN_TRUE_PREFIX; } @@ -1216,23 +1125,13 @@ LLView* LLMenuItemBranchGL::getChildByName(const LLString& name, BOOL recurse) c return mBranch; } // Always recurse on branches - return mBranch->getChildByName(name, recurse); -} - -EWidgetType LLMenuItemBranchGL::getWidgetType() const -{ - return WIDGET_TYPE_MENU_ITEM_BRANCH; -} - -LLString LLMenuItemBranchGL::getWidgetTag() const -{ - return LL_MENU_ITEM_BRANCH_GL_TAG; + return mBranch->getChild<LLView>(name, recurse); } // virtual BOOL LLMenuItemBranchGL::handleMouseUp(S32 x, S32 y, MASK mask) { - if (mEnabled) + if (getEnabled()) { // switch to mouse navigation mode LLMenuGL::setKeyboardMode(FALSE); @@ -1335,18 +1234,11 @@ BOOL LLMenuItemBranchGL::handleUnicodeChar(llwchar uni_char, BOOL called_from_pa } -// set the hover status (called by it's menu) void LLMenuItemBranchGL::setHighlight( BOOL highlight ) { if (highlight == getHighlight()) return; - // make sure only yourself is highlighted - if (highlight) - { - getMenu()->clearHoverItem(); - } - - BOOL auto_open = mEnabled && (!mBranch->getVisible() || mBranch->getTornOff()); + BOOL auto_open = getEnabled() && (!mBranch->getVisible() || mBranch->getTornOff()); // torn off menus don't open sub menus on hover unless they have focus if (getMenu()->getTornOff() && !((LLFloater*)getMenu()->getParent())->hasFocus()) { @@ -1357,8 +1249,7 @@ void LLMenuItemBranchGL::setHighlight( BOOL highlight ) { auto_open = FALSE; } - - mHighlight = highlight; + LLMenuItemGL::setHighlight(highlight); if( highlight ) { if(auto_open) @@ -1380,11 +1271,6 @@ void LLMenuItemBranchGL::setHighlight( BOOL highlight ) } } -void LLMenuItemBranchGL::setEnabledSubMenus(BOOL enabled) -{ - mBranch->setEnabledSubMenus(enabled); -} - void LLMenuItemBranchGL::draw() { LLMenuItemGL::draw(); @@ -1394,18 +1280,6 @@ void LLMenuItemBranchGL::draw() } } -// determine if this object is active -// which, for branching menus, means the branch is open and has "focus" -BOOL LLMenuItemBranchGL::isActive( void ) const -{ - return isOpen() && mBranch->getHighlightedItem(); -} - -BOOL LLMenuItemBranchGL::isOpen( void ) const -{ - return mBranch->isOpen(); -} - void LLMenuItemBranchGL::updateBranchParent(LLView* parentp) { if (mBranch->getParent() == NULL) @@ -1478,8 +1352,8 @@ void LLMenuItemBranchGL::openMenu() LLRect rect = mBranch->getRect(); // calculate root-view relative position for branch menu - S32 left = mRect.mRight; - S32 top = mRect.mTop - mRect.mBottom; + S32 left = getRect().mRight; + S32 top = getRect().mTop - getRect().mBottom; localPointToOtherView(left, top, &left, &top, mBranch->getParent()); @@ -1505,7 +1379,7 @@ void LLMenuItemBranchGL::openMenu() if( x - menu_region_rect.mLeft > menu_region_width - rect.getWidth() ) { // move sub-menu over to left side - delta_x = llmax(-x, (-1 * (rect.getWidth() + mRect.getWidth()))); + delta_x = llmax(-x, (-1 * (rect.getWidth() + getRect().getWidth()))); } mBranch->translate( delta_x, delta_y ); mBranch->setVisible( TRUE ); @@ -1536,7 +1410,7 @@ public: // returns the normal width of this control in pixels - this is // used for calculating the widest item, as well as for horizontal // arrangement. - virtual U32 getNominalWidth( void ); + virtual U32 getNominalWidth( void ) const; // called to rebuild the draw label virtual void buildDrawLabel( void ); @@ -1570,10 +1444,10 @@ LLMenuItemBranchDownGL::LLMenuItemBranchDownGL( const LLString& name, // returns the normal width of this control in pixels - this is used // for calculating the widest item, as well as for horizontal // arrangement. -U32 LLMenuItemBranchDownGL::getNominalWidth( void ) +U32 LLMenuItemBranchDownGL::getNominalWidth( void ) const { U32 width = LEFT_PAD_PIXELS + LEFT_WIDTH_PIXELS + RIGHT_PAD_PIXELS; - width += mFont->getWidth( mLabel.getWString().c_str() ); + width += getFont()->getWidth( mLabel.getWString().c_str() ); return width; } @@ -1588,32 +1462,33 @@ void LLMenuItemBranchDownGL::buildDrawLabel( void ) void LLMenuItemBranchDownGL::openMenu( void ) { - if( mBranch->getVisible() && !mBranch->getTornOff() ) + LLMenuGL* branch = getBranch(); + if( branch->getVisible() && !branch->getTornOff() ) { - mBranch->setVisible( FALSE ); + branch->setVisible( FALSE ); } else { - if (mBranch->getTornOff()) + if (branch->getTornOff()) { - gFloaterView->bringToFront((LLFloater*)mBranch->getParent()); + gFloaterView->bringToFront((LLFloater*)branch->getParent()); } else { // We're showing the drop-down menu, so patch up its labels/rects - mBranch->arrange(); + branch->arrange(); - LLRect rect = mBranch->getRect(); + LLRect rect = branch->getRect(); S32 left = 0; - S32 top = mRect.mBottom; - localPointToOtherView(left, top, &left, &top, mBranch->getParent()); + S32 top = getRect().mBottom; + localPointToOtherView(left, top, &left, &top, branch->getParent()); rect.setLeftTopAndSize( left, top, rect.getWidth(), rect.getHeight() ); - mBranch->setRect( rect ); + branch->setRect( rect ); S32 x = 0; S32 y = 0; - mBranch->localPointToScreen( 0, 0, &x, &y ); + branch->localPointToScreen( 0, 0, &x, &y ); S32 delta_x = 0; LLCoordScreen window_size; @@ -1625,13 +1500,11 @@ void LLMenuItemBranchDownGL::openMenu( void ) { delta_x = (window_width - rect.getWidth()) - x; } - mBranch->translate( delta_x, 0 ); + branch->translate( delta_x, 0 ); setHighlight(TRUE); - mBranch->setVisible( TRUE ); + branch->setVisible( TRUE ); } - - } } @@ -1640,21 +1513,18 @@ void LLMenuItemBranchDownGL::setHighlight( BOOL highlight ) { if (highlight == getHighlight()) return; - if (highlight) - { - getMenu()->clearHoverItem(); - } - mHighlight = highlight; + //NOTE: Purposely calling all the way to the base to bypass auto-open. + LLMenuItemGL::setHighlight(highlight); if( !highlight) { - if (mBranch->getTornOff()) + if (getBranch()->getTornOff()) { - ((LLFloater*)mBranch->getParent())->setFocus(FALSE); - mBranch->clearHoverItem(); + ((LLFloater*)getBranch()->getParent())->setFocus(FALSE); + getBranch()->clearHoverItem(); } else { - mBranch->setVisible( FALSE ); + getBranch()->setVisible( FALSE ); } } } @@ -1684,8 +1554,8 @@ BOOL LLMenuItemBranchDownGL::handleMouseUp( S32 x, S32 y, MASK mask ) BOOL LLMenuItemBranchDownGL::handleAcceleratorKey(KEY key, MASK mask) { - BOOL branch_visible = mBranch->getVisible(); - BOOL handled = mBranch->handleAcceleratorKey(key, mask); + BOOL branch_visible = getBranch()->getVisible(); + BOOL handled = getBranch()->handleAcceleratorKey(key, mask); if (handled && !branch_visible && getVisible()) { // flash this menu entry because we triggered an invisible menu item @@ -1697,7 +1567,7 @@ BOOL LLMenuItemBranchDownGL::handleAcceleratorKey(KEY key, MASK mask) BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) { - BOOL menu_open = mBranch->getVisible(); + BOOL menu_open = getBranch()->getVisible(); // don't do keyboard navigation of top-level menus unless in keyboard mode, or menu expanded if (getHighlight() && getMenu()->getVisible() && (isActive() || LLMenuGL::getKeyboardMode())) { @@ -1738,7 +1608,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_ { doIt(); } - mBranch->highlightNextItem(NULL); + getBranch()->highlightNextItem(NULL); return TRUE; } else if (key == KEY_UP) @@ -1750,7 +1620,7 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_ { doIt(); } - mBranch->highlightPrevItem(NULL); + getBranch()->highlightPrevItem(NULL); return TRUE; } } @@ -1761,19 +1631,19 @@ BOOL LLMenuItemBranchDownGL::handleKeyHere(KEY key, MASK mask, BOOL called_from_ void LLMenuItemBranchDownGL::draw( void ) { //FIXME: try removing this - if (mBranch->getVisible() && !mBranch->getTornOff()) + if (getBranch()->getVisible() && !getBranch()->getTornOff()) { setHighlight(TRUE); } if( getHighlight() ) { - glColor4fv( sHighlightBackground.mV ); - gl_rect_2d( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + glColor4fv( getHighlightBGColor().mV ); + gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0 ); } - U8 font_style = mStyle; - if (LLMenuItemGL::sDropShadowText && getEnabled() && !mDrawTextDisabled ) + U8 font_style = getFontStyle(); + if (getEnabled() && !getDrawTextDisabled() ) { font_style |= LLFontGL::DROP_SHADOW_SOFT; } @@ -1781,17 +1651,17 @@ void LLMenuItemBranchDownGL::draw( void ) LLColor4 color; if (getHighlight()) { - color = sHighlightForeground; + color = getHighlightFGColor(); } - else if( mEnabled ) + else if( getEnabled() ) { - color = sEnabledColor; + color = getEnabledColor(); } else { - color = sDisabledColor; + color = getDisabledColor(); } - mFont->render( mLabel.getWString(), 0, (F32)mRect.getWidth() / 2.f, (F32)LABEL_BOTTOM_PAD_PIXELS, color, + getFont()->render( mLabel.getWString(), 0, (F32)getRect().getWidth() / 2.f, (F32)LABEL_BOTTOM_PAD_PIXELS, color, LLFontGL::HCENTER, LLFontGL::BOTTOM, font_style ); @@ -1800,19 +1670,19 @@ void LLMenuItemBranchDownGL::draw( void ) { LLString upper_case_label = mLabel.getString(); LLString::toUpper(upper_case_label); - std::string::size_type offset = upper_case_label.find(mJumpKey); + std::string::size_type offset = upper_case_label.find(getJumpKey()); if (offset != std::string::npos) { - S32 x_offset = llround((F32)mRect.getWidth() / 2.f - mFont->getWidthF32(mLabel.getString(), 0, S32_MAX) / 2.f); - S32 x_begin = x_offset + mFont->getWidth(mLabel, 0, offset); - S32 x_end = x_offset + mFont->getWidth(mLabel, 0, offset + 1); + S32 x_offset = llround((F32)getRect().getWidth() / 2.f - getFont()->getWidthF32(mLabel.getString(), 0, S32_MAX) / 2.f); + S32 x_begin = x_offset + getFont()->getWidth(mLabel, 0, offset); + S32 x_end = x_offset + getFont()->getWidth(mLabel, 0, offset + 1); gl_line_2d(x_begin, LABEL_BOTTOM_PAD_PIXELS, x_end, LABEL_BOTTOM_PAD_PIXELS); } } // reset every frame so that we only show highlight // when we get hover events on that frame - mGotHover = FALSE; + setHover(FALSE); } ///============================================================================ @@ -1820,7 +1690,7 @@ void LLMenuItemBranchDownGL::draw( void ) ///============================================================================ // Default constructor -LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLViewHandle parent_floater_handle ) +LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle ) : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), mBackgroundColor( sDefaultBackgroundColor ), mBgVisible( TRUE ), @@ -1845,7 +1715,7 @@ LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLViewHandle pa setTabStop(FALSE); } -LLMenuGL::LLMenuGL( const LLString& label, LLViewHandle parent_floater_handle ) +LLMenuGL::LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater_handle ) : LLUICtrl( label, LLRect(), FALSE, NULL, NULL ), mBackgroundColor( sDefaultBackgroundColor ), mBgVisible( TRUE ), @@ -1879,7 +1749,7 @@ LLMenuGL::~LLMenuGL( void ) mJumpKeys.clear(); } -void LLMenuGL::setCanTearOff(BOOL tear_off, LLViewHandle parent_floater_handle ) +void LLMenuGL::setCanTearOff(BOOL tear_off, LLHandle<LLFloater> parent_floater_handle ) { if (tear_off && mTearOffItem == NULL) { @@ -2317,29 +2187,13 @@ LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *fa return menu; } -// control the color scheme -void LLMenuGL::setDefaultBackgroundColor( const LLColor4& color ) -{ - sDefaultBackgroundColor = color; -} - -void LLMenuGL::setBackgroundColor( const LLColor4& color ) -{ - mBackgroundColor = color; -} - -LLColor4 LLMenuGL::getBackgroundColor() -{ - return mBackgroundColor; -} - // rearrange the child rects so they fit the shape of the menu. void LLMenuGL::arrange( void ) { // calculate the height & width, and set our rect based on that // information. - LLRect initial_rect = mRect; + const LLRect& initial_rect = getRect(); U32 width = 0, height = MENU_ITEM_PADDING; @@ -2349,8 +2203,9 @@ void LLMenuGL::arrange( void ) { const LLRect menu_region_rect = LLMenuGL::sMenuContainer ? LLMenuGL::sMenuContainer->getMenuRect() : LLRect(0, S32_MAX, S32_MAX, 0); - U32 max_width = menu_region_rect.getWidth(); - U32 max_height = menu_region_rect.getHeight(); + // torn off menus are not constrained to the size of the screen + U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); + U32 max_height = getTornOff() ? U32_MAX : menu_region_rect.getHeight(); // *FIX: create the item first and then ask for its dimensions? S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( "More" ); S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING; @@ -2429,8 +2284,7 @@ void LLMenuGL::arrange( void ) } } - mRect.mRight = mRect.mLeft + width; - mRect.mTop = mRect.mBottom + height; + setRect(LLRect(getRect().mLeft, getRect().mBottom + height, getRect().mLeft + width, getRect().mBottom)); S32 cur_height = (S32)llmin(max_height, height); S32 cur_width = 0; @@ -2622,8 +2476,7 @@ void LLMenuGL::empty( void ) // Adjust rectangle of the menu void LLMenuGL::setLeftAndBottom(S32 left, S32 bottom) { - mRect.mLeft = left; - mRect.mBottom = bottom; + setRect(LLRect(left, getRect().mTop, getRect().mRight, bottom)); arrange(); } @@ -2953,7 +2806,7 @@ BOOL LLMenuGL::handleKey( KEY key, MASK mask, BOOL called_from_parent ) BOOL handled = FALSE; // Pass down even if not visible - if( mEnabled && called_from_parent ) + if( getEnabled() && called_from_parent ) { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) { @@ -2981,7 +2834,7 @@ BOOL LLMenuGL::handleKey( KEY key, MASK mask, BOOL called_from_parent ) BOOL LLMenuGL::handleAcceleratorKey(KEY key, MASK mask) { // don't handle if not enabled - if(!mEnabled) + if(!getEnabled()) { return FALSE; } @@ -3080,7 +2933,7 @@ void LLMenuGL::draw( void ) { if (mDropShadowed && !mTornOff) { - gl_drop_shadow(0, mRect.getHeight(), mRect.getWidth(), 0, + gl_drop_shadow(0, getRect().getHeight(), getRect().getWidth(), 0, LLUI::sColorsGroup->getColor("ColorDropShadow"), LLUI::sConfigGroup->getS32("DropShadowFloater") ); } @@ -3089,7 +2942,7 @@ void LLMenuGL::draw( void ) if( mBgVisible ) { - gl_rect_2d( 0, mRect.getHeight(), mRect.getWidth(), 0, mBackgroundColor ); + gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); } LLView::draw(); } @@ -3139,7 +2992,7 @@ LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const return (LLMenuGL*)view; } } - llwarns << "Child Menu " << name << " not found in menu " << mName << llendl; + llwarns << "Child Menu " << name << " not found in menu " << getName() << llendl; return NULL; } @@ -3254,7 +3107,7 @@ void LLPieMenuBranch::buildDrawLabel( void ) if(mEnabledCallback) { setEnabled(mEnabledCallback(mUserData)); - mDrawTextDisabled = FALSE; + setDrawTextDisabled(FALSE); } else { @@ -3273,7 +3126,7 @@ void LLPieMenuBranch::buildDrawLabel( void ) break; } } - mDrawTextDisabled = !any_enabled; + setDrawTextDisabled(!any_enabled); setEnabled(TRUE); } @@ -3334,20 +3187,6 @@ LLPieMenu::LLPieMenu(const LLString& name) setCanTearOff(FALSE); } -// virtual -LLPieMenu::~LLPieMenu() -{ } - - -EWidgetType LLPieMenu::getWidgetType() const -{ - return WIDGET_TYPE_PIE_MENU; -} - -LLString LLPieMenu::getWidgetTag() const -{ - return LL_PIE_MENU_TAG; -} void LLPieMenu::initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *factory) { @@ -3621,8 +3460,8 @@ void LLPieMenu::draw() mHoverItem = NULL; } - F32 width = (F32) mRect.getWidth(); - F32 height = (F32) mRect.getHeight(); + F32 width = (F32) getRect().getWidth(); + F32 height = (F32) getRect().getHeight(); mCurRadius = PIE_SCALE_FACTOR * llmax( width/2, height/2 ); mOuterRingAlpha = mUseInfiniteRadius ? 0.f : 1.f; @@ -3696,8 +3535,8 @@ void LLPieMenu::draw() void LLPieMenu::drawBackground(LLMenuItemGL* itemp, LLColor4& color) { - F32 width = (F32) mRect.getWidth(); - F32 height = (F32) mRect.getHeight(); + F32 width = (F32) getRect().getWidth(); + F32 height = (F32) getRect().getHeight(); F32 center_x = width/2; F32 center_y = height/2; S32 steps = 100; @@ -3790,7 +3629,8 @@ void LLPieMenu::arrange() // TODO: Compute actual bounding rect for menu - mRect.setOriginAndSize(mRect.mLeft, mRect.mBottom, rect_width, rect_height ); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).setOriginAndSize(getRect().mLeft, getRect().mBottom, rect_width, rect_height ); // place items around a circle, with item 0 at positive X, // rotating counter-clockwise @@ -3827,8 +3667,8 @@ LLMenuItemGL *LLPieMenu::pieItemFromXY(S32 x, S32 y) // An arc of the pie menu is 45 degrees const F32 ARC_DEG = 45.f; - S32 delta_x = x - mRect.getWidth() / 2; - S32 delta_y = y - mRect.getHeight() / 2; + S32 delta_x = x - getRect().getWidth() / 2; + S32 delta_y = y - getRect().getHeight() / 2; // circle safe zone in the center S32 dist_squared = delta_x*delta_x + delta_y*delta_y; @@ -3838,7 +3678,7 @@ LLMenuItemGL *LLPieMenu::pieItemFromXY(S32 x, S32 y) } // infinite radius is only used with right clicks - S32 radius = llmax( mRect.getWidth()/2, mRect.getHeight()/2 ); + S32 radius = llmax( getRect().getWidth()/2, getRect().getHeight()/2 ); if (!(mUseInfiniteRadius && mRightMouseDown) && dist_squared > radius * radius) { return NULL; @@ -3876,8 +3716,8 @@ S32 LLPieMenu::pieItemIndexFromXY(S32 x, S32 y) // An arc of the pie menu is 45 degrees const F32 ARC_DEG = 45.f; // correct for non-square pixels - S32 delta_x = x - mRect.getWidth() / 2; - S32 delta_y = y - mRect.getHeight() / 2; + S32 delta_x = x - getRect().getWidth() / 2; + S32 delta_y = y - getRect().getHeight() / 2; // circle safe zone in the center if (delta_x*delta_x + delta_y*delta_y < PIE_CENTER_SIZE*PIE_CENTER_SIZE) @@ -3900,8 +3740,8 @@ S32 LLPieMenu::pieItemIndexFromXY(S32 x, S32 y) void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down) { - S32 width = mRect.getWidth(); - S32 height = mRect.getHeight(); + S32 width = getRect().getWidth(); + S32 height = getRect().getHeight(); const LLRect menu_region_rect = LLMenuGL::sMenuContainer->getMenuRect(); @@ -3911,40 +3751,45 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down) S32 local_x, local_y; parent_view->screenPointToLocal(x, y, &local_x, &local_y); - mRect.setCenterAndSize(local_x, local_y, width, height); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).setCenterAndSize(local_x, local_y, width, height); arrange(); // Adjust the pie rectangle to keep it on screen - if (mRect.mLeft < menu_region_rect.mLeft) + if (getRect().mLeft < menu_region_rect.mLeft) { - //mShiftHoriz = menu_region_rect.mLeft - mRect.mLeft; - //mRect.translate( mShiftHoriz, 0 ); - mRect.translate( menu_region_rect.mLeft - mRect.mLeft, 0 ); + //mShiftHoriz = menu_region_rect.mLeft - getRect().mLeft; + //getRect().translate( mShiftHoriz, 0 ); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).translate( menu_region_rect.mLeft - getRect().mLeft, 0 ); moved = TRUE; } - if (mRect.mRight > menu_region_rect.mRight) + if (getRect().mRight > menu_region_rect.mRight) { - //mShiftHoriz = menu_region_rect.mRight - mRect.mRight; - //mRect.translate( mShiftHoriz, 0); - mRect.translate( menu_region_rect.mRight - mRect.mRight, 0 ); + //mShiftHoriz = menu_region_rect.mRight - getRect().mRight; + //getRect().translate( mShiftHoriz, 0); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).translate( menu_region_rect.mRight - getRect().mRight, 0 ); moved = TRUE; } - if (mRect.mBottom < menu_region_rect.mBottom) + if (getRect().mBottom < menu_region_rect.mBottom) { - //mShiftVert = menu_region_rect.mBottom - mRect.mBottom; - //mRect.translate( 0, mShiftVert ); - mRect.translate( 0, menu_region_rect.mBottom - mRect.mBottom ); + //mShiftVert = menu_region_rect.mBottom - getRect().mBottom; + //getRect().translate( 0, mShiftVert ); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).translate( 0, menu_region_rect.mBottom - getRect().mBottom ); moved = TRUE; } - if (mRect.mTop > menu_region_rect.mTop) + if (getRect().mTop > menu_region_rect.mTop) { - //mShiftVert = menu_region_rect.mTop - mRect.mTop; - //mRect.translate( 0, mShiftVert ); - mRect.translate( 0, menu_region_rect.mTop - mRect.mTop ); + //mShiftVert = menu_region_rect.mTop - getRect().mTop; + //getRect().translate( 0, mShiftVert ); + // HACK: casting away const. Should use setRect or some helper function instead. + const_cast<LLRect&>(getRect()).translate( 0, menu_region_rect.mTop - getRect().mTop ); moved = TRUE; } @@ -3953,8 +3798,8 @@ void LLPieMenu::show(S32 x, S32 y, BOOL mouse_down) if (moved) { LLCoordGL center; - center.mX = (mRect.mLeft + mRect.mRight) / 2; - center.mY = (mRect.mTop + mRect.mBottom) / 2; + center.mX = (getRect().mLeft + getRect().mRight) / 2; + center.mY = (getRect().mTop + getRect().mBottom) / 2; LLUI::setCursorPositionLocal(getParent(), center.mX, center.mY); } @@ -4066,7 +3911,7 @@ LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory LLMenuBarGL *menubar = new LLMenuBarGL(name); - LLViewHandle parent_handle = LLViewHandle::sDeadHandle; + LLHandle<LLFloater> parent_handle; if (parent->getWidgetType() == WIDGET_TYPE_FLOATER) { parent_handle = ((LLFloater*)parent)->getHandle(); @@ -4246,7 +4091,7 @@ BOOL LLMenuBarGL::jumpKeysActive() void LLMenuBarGL::arrange( void ) { U32 pos = 0; - LLRect rect( 0, mRect.getHeight(), 0, 0 ); + LLRect rect( 0, getRect().getHeight(), 0, 0 ); item_list_t::const_iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) { @@ -4398,25 +4243,12 @@ LLMenuHolderGL::LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mo mCanHide = TRUE; } -LLMenuHolderGL::~LLMenuHolderGL() -{ -} - -EWidgetType LLMenuHolderGL::getWidgetType() const -{ - return WIDGET_TYPE_MENU_HOLDER; -} - -LLString LLMenuHolderGL::getWidgetTag() const -{ - return LL_MENU_HOLDER_GL_TAG; -} void LLMenuHolderGL::draw() { LLView::draw(); // now draw last selected item as overlay - LLMenuItemGL* selecteditem = (LLMenuItemGL*)LLView::getViewByHandle(sItemLastSelectedHandle); + LLMenuItemGL* selecteditem = (LLMenuItemGL*)sItemLastSelectedHandle.get(); if (selecteditem && sItemActivationTimer.getStarted() && sItemActivationTimer.getElapsedTimeF32() < ACTIVATE_HIGHLIGHT_TIME) { // make sure toggle items, for example, show the proper state when fading out @@ -4426,10 +4258,10 @@ void LLMenuHolderGL::draw() selecteditem->localRectToOtherView(selecteditem->getLocalRect(), &item_rect, this); F32 interpolant = sItemActivationTimer.getElapsedTimeF32() / ACTIVATE_HIGHLIGHT_TIME; - F32 alpha = lerp(LLMenuItemGL::sHighlightBackground.mV[VALPHA], 0.f, interpolant); - LLColor4 bg_color(LLMenuItemGL::sHighlightBackground.mV[VRED], - LLMenuItemGL::sHighlightBackground.mV[VGREEN], - LLMenuItemGL::sHighlightBackground.mV[VBLUE], + F32 alpha = lerp(LLMenuItemGL::getHighlightBGColor().mV[VALPHA], 0.f, interpolant); + LLColor4 bg_color(LLMenuItemGL::getHighlightBGColor().mV[VRED], + LLMenuItemGL::getHighlightBGColor().mV[VGREEN], + LLMenuItemGL::getHighlightBGColor().mV[VBLUE], alpha); LLUI::pushMatrix(); @@ -4466,7 +4298,7 @@ BOOL LLMenuHolderGL::handleRightMouseDown( S32 x, S32 y, MASK mask ) void LLMenuHolderGL::reshape(S32 width, S32 height, BOOL called_from_parent) { - if (width != mRect.getWidth() || height != mRect.getHeight()) + if (width != getRect().getWidth() || height != getRect().getHeight()) { hideMenus(); } @@ -4486,10 +4318,6 @@ BOOL LLMenuHolderGL::hasVisibleMenu() const return FALSE; } -const LLRect LLMenuHolderGL::getMenuRect() const -{ - return getLocalRect(); -} BOOL LLMenuHolderGL::hideMenus() { @@ -4522,7 +4350,7 @@ BOOL LLMenuHolderGL::hideMenus() void LLMenuHolderGL::setActivatedItem(LLMenuItemGL* item) { - sItemLastSelectedHandle = item->mViewHandle; + sItemLastSelectedHandle = item->getHandle(); sItemActivationTimer.start(); } @@ -4532,20 +4360,24 @@ void LLMenuHolderGL::setActivatedItem(LLMenuItemGL* item) LLTearOffMenu::LLTearOffMenu(LLMenuGL* menup) : LLFloater(menup->getName(), LLRect(0, 100, 100, 0), menup->getLabel(), FALSE, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT, FALSE, FALSE) { + // flag menu as being torn off + menup->setTornOff(TRUE); + // update menu layout as torn off menu (no spillover menus) + menup->arrange(); + LLRect rect; menup->localRectToOtherView(LLRect(-1, menup->getRect().getHeight(), menup->getRect().getWidth() + 3, 0), &rect, gFloaterView); + // make sure this floater is big enough for menu mTargetHeight = (F32)(rect.getHeight() + LLFLOATER_HEADER_SIZE + 5); reshape(rect.getWidth(), rect.getHeight()); setRect(rect); - mOldParent = menup->getParent(); - mOldParent->removeChild(menup); + // attach menu to floater menup->setFollowsAll(); + mOldParent = menup->getParent(); addChild(menup); menup->setVisible(TRUE); menup->translate(-menup->getRect().mLeft + 1, -menup->getRect().mBottom + 1); - - menup->setTornOff(TRUE); menup->setDropShadowed(FALSE); mMenu = menup; @@ -4554,19 +4386,16 @@ LLTearOffMenu::LLTearOffMenu(LLMenuGL* menup) : mMenu->highlightNextItem(NULL); } -LLTearOffMenu::~LLTearOffMenu() -{ -} void LLTearOffMenu::draw() { - mMenu->setBackgroundVisible(mBgOpaque); + mMenu->setBackgroundVisible(isBackgroundOpaque()); mMenu->arrange(); - if (mRect.getHeight() != mTargetHeight) + if (getRect().getHeight() != mTargetHeight) { // animate towards target height - reshape(mRect.getWidth(), llceil(lerp((F32)mRect.getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); + reshape(getRect().getWidth(), llceil(lerp((F32)getRect().getHeight(), mTargetHeight, LLCriticalDamp::getInterpolant(0.05f)))); } else { @@ -4667,23 +4496,3 @@ void LLTearOffMenu::onClose(bool app_quitting) destroy(); } -///============================================================================ -/// Class LLEditMenuHandlerMgr -///============================================================================ -LLEditMenuHandlerMgr& LLEditMenuHandlerMgr::getInstance() -{ - static LLEditMenuHandlerMgr instance; - return instance; -} - -LLEditMenuHandlerMgr::LLEditMenuHandlerMgr() -{ -} - -LLEditMenuHandlerMgr::~LLEditMenuHandlerMgr() -{ -} - -///============================================================================ -/// Local function definitions -///============================================================================ diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index ce33f8a379..e9b80e562b 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -44,8 +44,6 @@ #include "lluistring.h" #include "llview.h" -class LLMenuItemGL; -class LLMenuHolderGL; extern S32 MENU_BAR_HEIGHT; extern S32 MENU_BAR_WIDTH; @@ -77,13 +75,19 @@ typedef void (*label_callback)(LLString&,void*); // The LLMenuItemGL represents a single menu item in a menu. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLFontGL; -class LLMenuGL; - - 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; } + static void setDisabledColor( const LLColor4& color ) { sDisabledColor = color; } + static const LLColor4& getDisabledColor() { return sDisabledColor; } + static void setHighlightBGColor( const LLColor4& color ) { sHighlightBackground = color; } + static const LLColor4& getHighlightBGColor() { return sHighlightBackground; } + static void setHighlightFGColor( const LLColor4& color ) { sHighlightForeground = color; } + static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } + LLMenuItemGL( const LLString& name, const LLString& label, KEY key = KEY_NONE, MASK = MASK_NONE ); virtual void setValue(const LLSD& value) { setLabel(value.asString()); } @@ -99,44 +103,38 @@ public: virtual BOOL handleAcceleratorKey(KEY key, MASK mask); - BOOL getHighlight() const { return mHighlight; } - void setJumpKey(KEY key); - KEY getJumpKey(); + KEY getJumpKey() const { return mJumpKey; } // set the font used by this item. - void setFont(LLFontGL* font); + void setFont(const LLFontGL* font) { mFont = font; } + const LLFontGL* getFont() const { return mFont; } void setFontStyle(U8 style) { mStyle = style; } + U8 getFontStyle() const { return mStyle; } // returns the height in pixels for the current font. - virtual U32 getNominalHeight( void ); - - // functions to control the color scheme - static void setEnabledColor( const LLColor4& color ); - static void setDisabledColor( const LLColor4& color ); - static void setHighlightBGColor( const LLColor4& color ); - static void setHighlightFGColor( const LLColor4& color ); + virtual U32 getNominalHeight( void ) const; // Marks item as not needing space for check marks or accelerator keys - virtual void setBriefItem(BOOL brief); + virtual void setBriefItem(BOOL brief) { mBriefItem = brief; } + virtual BOOL isBriefItem() const { return mBriefItem; } virtual BOOL addToAcceleratorList(std::list<LLKeyBinding*> *listp); void setAllowKeyRepeat(BOOL allow) { mAllowKeyRepeat = allow; } - - // return the name label - LLString getLabel( void ) const { return mLabel.getString(); } + BOOL getAllowKeyRepeat() const { return mAllowKeyRepeat; } // change the label - void setLabel( const LLStringExplicit& label ); + void setLabel( const LLStringExplicit& label ) { mLabel = label; } + LLString getLabel( void ) const { return mLabel.getString(); } virtual BOOL setLabelArg( const LLString& key, const LLStringExplicit& text ); // Get the parent menu for this item - virtual LLMenuGL* getMenu(); + virtual class LLMenuGL* getMenu(); // returns the normal width of this control in pixels - this is // used for calculating the widest item, as well as for horizontal // arrangement. - virtual U32 getNominalWidth( void ); + virtual U32 getNominalWidth( void ) const; // buildDrawLabel() - constructs the string used during the draw() // function. This reduces the overall string manipulation, but can @@ -155,14 +153,14 @@ public: // doIt() - do the primary funcationality of the menu item. virtual void doIt( void ); - // set the hover status (called by it's menu) virtual void setHighlight( BOOL highlight ); + virtual BOOL getHighlight() const { return mHighlight; } // determine if this represents an active sub-menu - virtual BOOL isActive( void ) const; + virtual BOOL isActive( void ) const { return FALSE; } // determine if this represents an open sub-menu - virtual BOOL isOpen( void ) const; + virtual BOOL isOpen( void ) const { return FALSE; } virtual void setEnabledSubMenus(BOOL enable){}; @@ -172,24 +170,20 @@ public: virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask ); virtual void draw( void ); - BOOL getHover() { return mGotHover; } + BOOL getHover() const { return mGotHover; } + void setDrawTextDisabled(BOOL disabled) { mDrawTextDisabled = disabled; } BOOL getDrawTextDisabled() const { return mDrawTextDisabled; } protected: + void setHover(BOOL hover) { mGotHover = hover; } + // This function appends the character string representation of // the current accelerator key and mask to the provided string. - void appendAcceleratorString( LLString& st ); - -public: - static LLColor4 sEnabledColor; - static LLColor4 sDisabledColor; - static LLColor4 sHighlightBackground; - static LLColor4 sHighlightForeground; - -protected: - static BOOL sDropShadowText; + void appendAcceleratorString( LLString& st ) const; + KEY mAcceleratorKey; + MASK mAcceleratorMask; // mLabel contains the actual label specified by the user. LLUIString mLabel; @@ -200,12 +194,15 @@ protected: LLUIString mDrawAccelLabel; LLUIString mDrawBranchLabel; + BOOL mHighlight; +private: + static LLColor4 sEnabledColor; + static LLColor4 sDisabledColor; + static LLColor4 sHighlightBackground; + static LLColor4 sHighlightForeground; + // Keyboard and mouse variables - KEY mJumpKey; - KEY mAcceleratorKey; - MASK mAcceleratorMask; BOOL mAllowKeyRepeat; - BOOL mHighlight; BOOL mGotHover; // If true, suppress normal space for check marks on the left and accelerator @@ -213,10 +210,11 @@ protected: BOOL mBriefItem; // Font for this item - LLFontGL* mFont; - + const LLFontGL* mFont; U8 mStyle; BOOL mDrawTextDisabled; + + KEY mJumpKey; }; @@ -229,14 +227,6 @@ protected: class LLMenuItemCallGL : public LLMenuItemGL { -protected: - menu_callback mCallback; - // mEnabledCallback should return TRUE if the item should be enabled - enabled_callback mEnabledCallback; - label_callback mLabelCallback; - void* mUserData; - on_disabled_callback mOnDisabledCallback; - public: // normal constructor LLMenuItemCallGL( const LLString& name, @@ -277,8 +267,8 @@ public: virtual LLString getType() const { return "call"; } - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_CALL; } + virtual LLString getWidgetTag() const { return LL_MENU_ITEM_CALL_GL_TAG; } void setEnabledControl(LLString enabled_control, LLView *context); void setVisibleControl(LLString enabled_control, LLView *context); @@ -302,6 +292,14 @@ public: //virtual void draw(); virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); + +private: + menu_callback mCallback; + // mEnabledCallback should return TRUE if the item should be enabled + enabled_callback mEnabledCallback; + label_callback mLabelCallback; + void* mUserData; + on_disabled_callback mOnDisabledCallback; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -310,17 +308,13 @@ public: // The LLMenuItemCheckGL is an extension of the LLMenuItemCallGL // 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 check callback provided - it needs to be VERY +// careful that the provided callback is fast - it needs to be VERY // FUCKING EFFICIENT, because it may need to be checked a lot. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLMenuItemCheckGL : public LLMenuItemCallGL { -protected: - check_callback mCheckCallback; - BOOL mChecked; - public: LLMenuItemCheckGL( const LLString& name, const LLString& label, @@ -348,8 +342,8 @@ public: void setCheckedControl(LLString checked_control, LLView *context); virtual void setValue(const LLSD& value) { mChecked = value.asBoolean(); } - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_CHECK; } + virtual LLString getWidgetTag() const { return LL_MENU_ITEM_CHECK_GL_TAG; } virtual LLString getType() const { return "check"; } @@ -358,8 +352,9 @@ public: virtual bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata); - // LLView Functionality - //virtual void draw( void ); +private: + check_callback mCheckCallback; + BOOL mChecked; }; @@ -372,9 +367,6 @@ public: class LLMenuItemToggleGL : public LLMenuItemGL { -protected: - BOOL* mToggle; - public: LLMenuItemToggleGL( const LLString& name, const LLString& label, BOOL* toggle, @@ -394,6 +386,9 @@ public: // LLView Functionality //virtual void draw( void ); + +private: + BOOL* mToggle; }; @@ -408,16 +403,14 @@ public: // it in the appendMenu() method. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLMenuArrowGL; -class LLMenuItemBranchGL; -class LLMenuItemTearOffGL; - class LLMenuGL : public LLUICtrl +// TODO: The menu and menu item classes share a great deal of functionality and perhaps should be united. +// I think it may make the most sense to make LLMenuGL be a subclass of LLMenuItemGL. -MG { public: - LLMenuGL( const LLString& name, const LLString& label, LLViewHandle parent_floater = LLViewHandle::sDeadHandle ); - LLMenuGL( const LLString& label, LLViewHandle parent_floater = LLViewHandle::sDeadHandle ); + LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>()); + LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater = LLHandle<LLFloater>() ); virtual ~LLMenuGL( void ); virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); @@ -446,11 +439,12 @@ public: const LLString& getLabel( void ) const { return mLabel.getString(); } void setLabel(const LLStringExplicit& label) { mLabel = label; } - static void setDefaultBackgroundColor( const LLColor4& color ); - void setBackgroundColor( const LLColor4& color ); - LLColor4 getBackgroundColor(); + // background colors + static void setDefaultBackgroundColor( const LLColor4& color ) { sDefaultBackgroundColor = color; } + void setBackgroundColor( const LLColor4& color ) { mBackgroundColor = color; } + const LLColor4& getBackgroundColor() const { return mBackgroundColor; } void setBackgroundVisible( BOOL b ) { mBgVisible = b; } - void setCanTearOff(BOOL tear_off, LLViewHandle parent_floater_handle = LLViewHandle::sDeadHandle); + void setCanTearOff(BOOL tear_off, LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>()); // Add the menu item to this menu. virtual BOOL append( LLMenuItemGL* item ); @@ -524,7 +518,7 @@ public: BOOL getCanTearOff() { return mTearOffItem != NULL; } - KEY getJumpKey() { return mJumpKey; } + KEY getJumpKey() const { return mJumpKey; } void setJumpKey(KEY key) { mJumpKey = key; } static void setKeyboardMode(BOOL mode) { sKeyboardMode = mode; } @@ -532,40 +526,42 @@ public: static void onFocusLost(LLView* old_focus); - static LLMenuHolderGL* sMenuContainer; + static class LLMenuHolderGL* sMenuContainer; protected: void createSpilloverBranch(); void cleanupSpilloverBranch(); -protected: + // TODO: create accessor methods for these? + typedef std::list< LLMenuItemGL* > item_list_t; + item_list_t mItems; + typedef std::map<KEY, LLMenuItemGL*> navigation_key_map_t; + navigation_key_map_t mJumpKeys; + S32 mLastMouseX; + S32 mLastMouseY; + S32 mMouseVelX; + S32 mMouseVelY; + BOOL mHorizontalLayout; + BOOL mKeepFixedSize; + +private: static LLColor4 sDefaultBackgroundColor; static BOOL sKeyboardMode; LLColor4 mBackgroundColor; BOOL mBgVisible; - typedef std::list< LLMenuItemGL* > item_list_t; - item_list_t mItems; - typedef std::map<KEY, LLMenuItemGL*> navigation_key_map_t; - navigation_key_map_t mJumpKeys; LLMenuItemGL* mParentMenuItem; LLUIString mLabel; BOOL mDropShadowed; // Whether to drop shadow - BOOL mHorizontalLayout; - BOOL mKeepFixedSize; BOOL mHasSelection; LLFrameTimer mFadeTimer; - S32 mLastMouseX; - S32 mLastMouseY; - S32 mMouseVelX; - S32 mMouseVelY; BOOL mTornOff; - LLMenuItemTearOffGL* mTearOffItem; - LLMenuItemBranchGL* mSpilloverBranch; + class LLMenuItemTearOffGL* mTearOffItem; + class LLMenuItemBranchGL* mSpilloverBranch; LLMenuGL* mSpilloverMenu; - LLViewHandle mParentFloaterHandle; + LLHandle<LLFloater> mParentFloaterHandle; KEY mJumpKey; -}; +}; // end class LLMenuGL @@ -578,20 +574,15 @@ protected: class LLMenuItemBranchGL : public LLMenuItemGL { -protected: - LLMenuGL* mBranch; - public: LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, KEY key = KEY_NONE, MASK mask = MASK_NONE ); virtual LLXMLNodePtr getXML(bool save_children = true) const; - virtual LLView* getChildByName(const LLString& name, BOOL recurse) const; - - virtual LLString getType() const { return "menu"; } + virtual LLString getType() const { return "menu"; } - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_ITEM_BRANCH; } + virtual LLString getWidgetTag() const { return LL_MENU_ITEM_BRANCH_GL_TAG; } virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); @@ -615,9 +606,9 @@ public: virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); - virtual BOOL isActive() const; + virtual BOOL isActive() const { return isOpen() && mBranch->getHighlightedItem(); } - virtual BOOL isOpen() const; + virtual BOOL isOpen() const { return mBranch->isOpen(); } LLMenuGL *getBranch() const { return mBranch; } @@ -628,11 +619,16 @@ public: virtual void draw(); - virtual void setEnabledSubMenus(BOOL enabled); + virtual void setEnabledSubMenus(BOOL enabled) { mBranch->setEnabledSubMenus(enabled); } virtual void openMenu(); -}; +protected: + virtual LLView* getChildByName(const LLString& name, BOOL recurse) const; + +private: + LLMenuGL* mBranch; +}; // end class LLMenuItemBranchGL @@ -647,10 +643,10 @@ class LLPieMenu public: LLPieMenu(const LLString& name, const LLString& label); LLPieMenu(const LLString& name); - virtual ~LLPieMenu(); + virtual ~LLPieMenu() {} - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_PIE_MENU; } + virtual LLString getWidgetTag() const { return LL_PIE_MENU_TAG; } void initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *factory); @@ -682,11 +678,10 @@ public: void show(S32 x, S32 y, BOOL mouse_down); void hide(BOOL item_selected); -protected: +private: LLMenuItemGL *pieItemFromXY(S32 x, S32 y); S32 pieItemIndexFromXY(S32 x, S32 y); -private: // These cause menu items to be spuriously selected by right-clicks // near the window edge at low frame rates. I don't think they are // needed unless you shift the menu position in the draw() function. JC @@ -703,6 +698,7 @@ private: BOOL mRightMouseDown; }; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuBarGL // @@ -711,10 +707,6 @@ private: class LLMenuBarGL : public LLMenuGL { -protected: - std::list <LLKeyBinding*> mAccelerators; - BOOL mAltKeyTrigger; - public: LLMenuBarGL( const LLString& name ); virtual ~LLMenuBarGL(); @@ -748,9 +740,11 @@ public: void resetMenuTrigger() { mAltKeyTrigger = FALSE; } -protected: +private: void checkMenuTrigger(); + std::list <LLKeyBinding*> mAccelerators; + BOOL mAltKeyTrigger; }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -763,10 +757,10 @@ class LLMenuHolderGL : public LLPanel public: LLMenuHolderGL(); LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows = FOLLOWS_NONE); - virtual ~LLMenuHolderGL(); + virtual ~LLMenuHolderGL() {} - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_MENU_HOLDER; } + virtual LLString getWidgetTag() const { return LL_MENU_HOLDER_GL_TAG; } virtual BOOL hideMenus(); void reshape(S32 width, S32 height, BOOL called_from_parent); @@ -777,13 +771,13 @@ public: virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask ); virtual BOOL handleRightMouseDown( S32 x, S32 y, MASK mask ); - virtual const LLRect getMenuRect() const; + virtual const LLRect getMenuRect() const { return getLocalRect(); } virtual BOOL hasVisibleMenu() const; static void setActivatedItem(LLMenuItemGL* item); -protected: - static LLViewHandle sItemLastSelectedHandle; +private: + static LLHandle<LLView> sItemLastSelectedHandle; static LLFrameTimer sItemActivationTimer; BOOL mCanHide; @@ -793,12 +787,13 @@ protected: // Class LLTearOffMenu // // Floater that hosts a menu +// https://wiki.lindenlab.com/mediawiki/index.php?title=LLTearOffMenu&oldid=81344 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLTearOffMenu : public LLFloater { public: static LLTearOffMenu* create(LLMenuGL* menup); - virtual ~LLTearOffMenu(); + virtual ~LLTearOffMenu() {} virtual void onClose(bool app_quitting); virtual void draw(void); virtual void onFocusReceived(); @@ -807,10 +802,9 @@ public: virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); virtual void translate(S32 x, S32 y); -protected: +private: LLTearOffMenu(LLMenuGL* menup); -protected: LLView* mOldParent; LLMenuGL* mMenu; F32 mTargetHeight; @@ -825,19 +819,19 @@ protected: class LLMenuItemTearOffGL : public LLMenuItemGL { public: - LLMenuItemTearOffGL( LLViewHandle parent_floater_handle = (LLViewHandle)LLViewHandle::sDeadHandle ); + LLMenuItemTearOffGL( LLHandle<LLFloater> parent_floater_handle = LLHandle<LLFloater>()); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_TEAROFF_MENU; } + virtual LLString getWidgetTag() const { return LL_MENU_ITEM_TEAR_OFF_GL_TAG; } - virtual LLString getType() const { return "tearoff_menu"; } + virtual LLString getType() const { return "tearoff_menu"; } virtual void doIt(void); virtual void draw(void); - virtual U32 getNominalHeight(); + virtual U32 getNominalHeight() const; -protected: - LLViewHandle mParentHandle; +private: + LLHandle<LLFloater> mParentHandle; }; @@ -845,11 +839,13 @@ protected: class LLEditMenuHandlerMgr { public: - LLEditMenuHandlerMgr& getInstance(); - virtual ~LLEditMenuHandlerMgr(); -protected: - LLEditMenuHandlerMgr(); - + LLEditMenuHandlerMgr& getInstance() { + static LLEditMenuHandlerMgr instance; + return instance; + } + virtual ~LLEditMenuHandlerMgr() {} +private: + LLEditMenuHandlerMgr() {}; }; #endif // LL_LLMENUGL_H diff --git a/indra/llui/llmodaldialog.cpp b/indra/llui/llmodaldialog.cpp index af14ec418f..a150d295e5 100644 --- a/indra/llui/llmodaldialog.cpp +++ b/indra/llui/llmodaldialog.cpp @@ -74,10 +74,10 @@ LLModalDialog::~LLModalDialog() void LLModalDialog::open() /* Flawfinder: ignore */ { // SJB: Hack! Make sure we don't ever host a modal dialog - LLMultiFloater* thost = LLFloater::sHostp; - LLFloater::sHostp = NULL; + LLMultiFloater* thost = LLFloater::getFloaterHost(); + LLFloater::setFloaterHost(NULL); LLFloater::open(); - LLFloater::sHostp = thost; + LLFloater::setFloaterHost(thost); } void LLModalDialog::reshape(S32 width, S32 height, BOOL called_from_parent) @@ -157,14 +157,18 @@ void LLModalDialog::setVisible( BOOL visible ) BOOL LLModalDialog::handleMouseDown(S32 x, S32 y, MASK mask) { - if (!LLFloater::handleMouseDown(x, y, mask)) + if (mModal) { - if (mModal) + if (!LLFloater::handleMouseDown(x, y, mask)) { // Click was outside the panel make_ui_sound("UISndInvalidOp"); } } + else + { + LLFloater::handleMouseDown(x, y, mask); + } return TRUE; } @@ -247,7 +251,7 @@ void LLModalDialog::draw() LLColor4 shadow_color = LLUI::sColorsGroup->getColor("ColorDropShadow"); S32 shadow_lines = LLUI::sConfigGroup->getS32("DropShadowFloater"); - gl_drop_shadow( 0, mRect.getHeight(), mRect.getWidth(), 0, + gl_drop_shadow( 0, getRect().getHeight(), getRect().getWidth(), 0, shadow_color, shadow_lines); LLFloater::draw(); @@ -276,11 +280,7 @@ void LLModalDialog::draw() void LLModalDialog::centerOnScreen() { LLVector2 window_size = LLUI::getWindowSize(); - - S32 dialog_left = (llround(window_size.mV[VX]) - mRect.getWidth()) / 2; - S32 dialog_bottom = (llround(window_size.mV[VY]) - mRect.getHeight()) / 2; - - translate( dialog_left - mRect.mLeft, dialog_bottom - mRect.mBottom ); + centerWithin(LLRect(0, 0, llround(window_size.mV[VX]), llround(window_size.mV[VY]))); } @@ -319,3 +319,4 @@ void LLModalDialog::onAppFocusGained() } + diff --git a/indra/llui/llmodaldialog.h b/indra/llui/llmodaldialog.h index dcd5644f60..f13e5c37b7 100644 --- a/indra/llui/llmodaldialog.h +++ b/indra/llui/llmodaldialog.h @@ -40,7 +40,7 @@ class LLModalDialog; // By default, a ModalDialog is modal, i.e. no other window can have focus // However, for the sake of code reuse and simplicity, if mModal == false, // the dialog behaves like a normal floater - +// https://wiki.lindenlab.com/mediawiki/index.php?title=LLModalDialog&oldid=81385 class LLModalDialog : public LLFloater { public: @@ -67,6 +67,8 @@ public: /*virtual*/ void setVisible(BOOL visible); /*virtual*/ void draw(); + BOOL isModal() const { return mModal; } + static void onAppFocusLost(); static void onAppFocusGained(); @@ -75,9 +77,9 @@ public: protected: void centerOnScreen(); -protected: +private: LLFrameTimer mVisibleTime; - BOOL mModal; // do not change this after creation! + const BOOL mModal; static std::list<LLModalDialog*> sModalStack; // Top of stack is currently being displayed }; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 07ebfb7979..6554a25dcf 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -60,10 +60,10 @@ #include "llresizebar.h" #include "llcriticaldamp.h" -LLPanel::panel_map_t LLPanel::sPanelMap; LLPanel::alert_queue_t LLPanel::sAlertQueue; const S32 RESIZE_BAR_OVERLAP = 1; +const S32 RESIZE_BAR_HEIGHT = 3; void LLPanel::init() { @@ -78,8 +78,7 @@ void LLPanel::init() setIsChrome(FALSE); //is this a decorator to a live window or a form? mLastTabGroup = 0; - // add self to handle->panel map - sPanelMap[mViewHandle] = this; + mPanelHandle.bind(this); setTabStop(FALSE); } @@ -121,31 +120,11 @@ LLPanel::LLPanel(const LLString& name, const LLString& rect_control, BOOL border } } -void LLPanel::addBorder(LLViewBorder::EBevel border_bevel, - LLViewBorder::EStyle border_style, S32 border_thickness) -{ - removeBorder(); - mBorder = new LLViewBorder( "panel border", - LLRect(0, mRect.getHeight(), mRect.getWidth(), 0), - border_bevel, border_style, border_thickness ); - mBorder->setSaveToXML(false); - addChild( mBorder ); -} - -void LLPanel::removeBorder() -{ - delete mBorder; - mBorder = NULL; -} - - LLPanel::~LLPanel() { storeRectControl(); - sPanelMap.erase(mViewHandle); } - // virtual EWidgetType LLPanel::getWidgetType() const { @@ -159,7 +138,7 @@ LLString LLPanel::getWidgetTag() const } // virtual -BOOL LLPanel::isPanel() +BOOL LLPanel::isPanel() const { return TRUE; } @@ -170,6 +149,24 @@ BOOL LLPanel::postBuild() return TRUE; } +void LLPanel::addBorder(LLViewBorder::EBevel border_bevel, + LLViewBorder::EStyle border_style, S32 border_thickness) +{ + removeBorder(); + mBorder = new LLViewBorder( "panel border", + LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), + border_bevel, border_style, border_thickness ); + mBorder->setSaveToXML(false); + addChild( mBorder ); +} + +void LLPanel::removeBorder() +{ + delete mBorder; + mBorder = NULL; +} + + // virtual void LLPanel::clearCtrls() { @@ -200,8 +197,8 @@ void LLPanel::draw() { //RN: I don't see the point of this S32 left = 0;//LLPANEL_BORDER_WIDTH; - S32 top = mRect.getHeight();// - LLPANEL_BORDER_WIDTH; - S32 right = mRect.getWidth();// - LLPANEL_BORDER_WIDTH; + S32 top = getRect().getHeight();// - LLPANEL_BORDER_WIDTH; + S32 right = getRect().getWidth();// - LLPANEL_BORDER_WIDTH; S32 bottom = 0;//LLPANEL_BORDER_WIDTH; if (mBgOpaque ) @@ -272,13 +269,13 @@ BOOL LLPanel::handleKey(KEY key, MASK mask, BOOL called_from_parent) if( (mask == MASK_SHIFT) && (KEY_TAB == key)) { //SHIFT-TAB - LLView* cur_focus = gFocusMgr.getKeyboardFocus(); + LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); if (cur_focus && gFocusMgr.childHasKeyboardFocus(this)) { - LLView* focus_root = cur_focus; - while(cur_focus->getParent()) + LLUICtrl* focus_root = cur_focus; + while(cur_focus->getParentUICtrl()) { - cur_focus = cur_focus->getParent(); + cur_focus = cur_focus->getParentUICtrl(); if (cur_focus->isFocusRoot()) { // this is the root-most focus root found so far @@ -287,7 +284,7 @@ BOOL LLPanel::handleKey(KEY key, MASK mask, BOOL called_from_parent) } handled = focus_root->focusPrevItem(FALSE); } - else if (!cur_focus && mIsFocusRoot) + else if (!cur_focus && isFocusRoot()) { handled = focusLastItem(); if (!handled) @@ -301,13 +298,13 @@ BOOL LLPanel::handleKey(KEY key, MASK mask, BOOL called_from_parent) if( (mask == MASK_NONE ) && (KEY_TAB == key)) { //TAB - LLView* cur_focus = gFocusMgr.getKeyboardFocus(); + LLUICtrl* cur_focus = gFocusMgr.getKeyboardFocus(); if (cur_focus && gFocusMgr.childHasKeyboardFocus(this)) { - LLView* focus_root = cur_focus; - while(cur_focus->getParent()) + LLUICtrl* focus_root = cur_focus; + while(cur_focus->getParentUICtrl()) { - cur_focus = cur_focus->getParent(); + cur_focus = cur_focus->getParentUICtrl(); if (cur_focus->isFocusRoot()) { focus_root = cur_focus; @@ -315,7 +312,7 @@ BOOL LLPanel::handleKey(KEY key, MASK mask, BOOL called_from_parent) } handled = focus_root->focusNextItem(FALSE); } - else if (!cur_focus && mIsFocusRoot) + else if (!cur_focus && isFocusRoot()) { handled = focusFirstItem(); if (!handled) @@ -392,12 +389,12 @@ void LLPanel::requires(LLString name, EWidgetType type) mRequirements[name] = type; } -BOOL LLPanel::checkRequirements() +BOOL LLPanel::checkRequirements() const { BOOL retval = TRUE; LLString message; - for (requirements_map_t::iterator i = mRequirements.begin(); i != mRequirements.end(); ++i) + for (requirements_map_t::const_iterator i = mRequirements.begin(); i != mRequirements.end(); ++i) { if (!this->getCtrlByNameAndType(i->first, i->second)) { @@ -473,21 +470,6 @@ void LLPanel::setFocus(BOOL b) } } -void LLPanel::setBackgroundColor(const LLColor4& color) -{ - mBgColorOpaque = color; -} - -LLColor4 LLPanel::getBackgroundColor() -{ - return mBgColorOpaque; -} - -void LLPanel::setTransparentColor(const LLColor4& color) -{ - mBgColorAlpha = color; -} - void LLPanel::setBorderVisible(BOOL b) { if (mBorder) @@ -496,18 +478,18 @@ void LLPanel::setBorderVisible(BOOL b) } } -LLView* LLPanel::getCtrlByNameAndType(const LLString& name, EWidgetType type) +LLUICtrl* LLPanel::getCtrlByNameAndType(const LLString& name, EWidgetType type) const { LLView* view = getChildByName(name, TRUE); - if (view) + if (view && view->isCtrl()) { if (type == WIDGET_TYPE_DONTCARE || view->getWidgetType() == type) { - return view; + return (LLUICtrl*)view; } else { - llwarns << "Widget " << name << " has improper type in panel " << mName << "\n" + llwarns << "Widget " << name << " has improper type in panel " << getName() << "\n" << "Is: \t\t" << view->getWidgetType() << "\n" << "Should be: \t" << type << llendl; @@ -520,17 +502,6 @@ LLView* LLPanel::getCtrlByNameAndType(const LLString& name, EWidgetType type) return NULL; } -// static -LLPanel* LLPanel::getPanelByHandle(LLViewHandle handle) -{ - if (!sPanelMap.count(handle)) - { - return NULL; - } - - return sPanelMap[handle]; -} - // virtual LLXMLNodePtr LLPanel::getXML(bool save_children) const { @@ -718,7 +689,7 @@ void LLPanel::setPanelParameters(LLXMLNodePtr node, LLView* parent) setLabel(label); } -LLString LLPanel::getFormattedUIString(const LLString& name, const LLString::format_map_t& args) const +LLString LLPanel::getString(const LLString& name, const LLString::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -728,6 +699,7 @@ LLString LLPanel::getFormattedUIString(const LLString& name, const LLString::for formatted_string.setArgList(args); return formatted_string.getString(); } + llerrs << "Failed to find string " << name << " in panel " << getName() << llendl; return LLString::null; } @@ -738,13 +710,14 @@ LLUIString LLPanel::getUIString(const LLString& name) const { return found_it->second; } + llerrs << "Failed to find string " << name << " in panel " << getName() << llendl; return LLUIString(LLString::null); } void LLPanel::childSetVisible(const LLString& id, bool visible) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { child->setVisible(visible); @@ -753,7 +726,7 @@ void LLPanel::childSetVisible(const LLString& id, bool visible) bool LLPanel::childIsVisible(const LLString& id) const { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { return (bool)child->getVisible(); @@ -763,7 +736,7 @@ bool LLPanel::childIsVisible(const LLString& id) const void LLPanel::childSetEnabled(const LLString& id, bool enabled) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { child->setEnabled(enabled); @@ -772,7 +745,7 @@ void LLPanel::childSetEnabled(const LLString& id, bool enabled) void LLPanel::childSetTentative(const LLString& id, bool tentative) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { child->setTentative(tentative); @@ -781,7 +754,7 @@ void LLPanel::childSetTentative(const LLString& id, bool tentative) bool LLPanel::childIsEnabled(const LLString& id) const { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { return (bool)child->getEnabled(); @@ -792,7 +765,7 @@ bool LLPanel::childIsEnabled(const LLString& id) const void LLPanel::childSetToolTip(const LLString& id, const LLString& msg) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { child->setToolTip(msg); @@ -801,7 +774,7 @@ void LLPanel::childSetToolTip(const LLString& id, const LLString& msg) void LLPanel::childSetRect(const LLString& id, const LLRect& rect) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { child->setRect(rect); @@ -810,7 +783,7 @@ void LLPanel::childSetRect(const LLString& id, const LLRect& rect) bool LLPanel::childGetRect(const LLString& id, LLRect& rect) const { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { rect = child->getRect(); @@ -821,7 +794,7 @@ bool LLPanel::childGetRect(const LLString& id, LLRect& rect) const void LLPanel::childSetFocus(const LLString& id, BOOL focus) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setFocus(focus); @@ -830,7 +803,7 @@ void LLPanel::childSetFocus(const LLString& id, BOOL focus) BOOL LLPanel::childHasFocus(const LLString& id) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { return child->hasFocus(); @@ -845,7 +818,7 @@ BOOL LLPanel::childHasFocus(const LLString& id) void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocusableElement*, void*), void* user_data) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setFocusChangedCallback(cb, user_data); @@ -854,7 +827,7 @@ void LLPanel::childSetFocusChangedCallback(const LLString& id, void (*cb)(LLFocu void LLPanel::childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, void*), void *userdata ) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setCommitCallback(cb); @@ -864,7 +837,7 @@ void LLPanel::childSetCommitCallback(const LLString& id, void (*cb)(LLUICtrl*, v void LLPanel::childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void *userdata ) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setDoubleClickCallback(cb); @@ -877,7 +850,7 @@ void LLPanel::childSetDoubleClickCallback(const LLString& id, void (*cb)(void*), void LLPanel::childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*)) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setValidateBeforeCommit(cb); @@ -886,7 +859,7 @@ void LLPanel::childSetValidate(const LLString& id, BOOL (*cb)(LLUICtrl*, void*)) void LLPanel::childSetUserData(const LLString& id, void* userdata) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setCallbackUserData(userdata); @@ -895,16 +868,16 @@ void LLPanel::childSetUserData(const LLString& id, void* userdata) void LLPanel::childSetColor(const LLString& id, const LLColor4& color) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setColor(color); } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const LLString& id) +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const LLString& id) const { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { return child->getSelectionInterface(); @@ -912,9 +885,9 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const LLString& id return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const LLString& id) +LLCtrlListInterface* LLPanel::childGetListInterface(const LLString& id) const { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { return child->getListInterface(); @@ -922,9 +895,9 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const LLString& id) return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const LLString& id) +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const LLString& id) const { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { return child->getScrollInterface(); @@ -934,7 +907,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const LLString& id) void LLPanel::childSetValue(const LLString& id, LLSD value) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLView* child = getChild<LLView>(id, true); if (child) { child->setValue(value); @@ -943,7 +916,7 @@ void LLPanel::childSetValue(const LLString& id, LLSD value) LLSD LLPanel::childGetValue(const LLString& id) const { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLView* child = getChild<LLView>(id, true); if (child) { return child->getValue(); @@ -954,7 +927,7 @@ LLSD LLPanel::childGetValue(const LLString& id) const BOOL LLPanel::childSetTextArg(const LLString& id, const LLString& key, const LLStringExplicit& text) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { return child->setTextArg(key, text); @@ -964,7 +937,7 @@ BOOL LLPanel::childSetTextArg(const LLString& id, const LLString& key, const LLS BOOL LLPanel::childSetLabelArg(const LLString& id, const LLString& key, const LLStringExplicit& text) { - LLView* child = getChildByName(id, true); + LLView* child = getChild<LLView>(id); if (child) { return child->setLabelArg(key, text); @@ -984,7 +957,7 @@ BOOL LLPanel::childSetToolTipArg(const LLString& id, const LLString& key, const void LLPanel::childSetMinValue(const LLString& id, LLSD min_value) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setMinValue(min_value); @@ -993,7 +966,7 @@ void LLPanel::childSetMinValue(const LLString& id, LLSD min_value) void LLPanel::childSetMaxValue(const LLString& id, LLSD max_value) { - LLUICtrl* child = (LLUICtrl*)getChildByName(id, true); + LLUICtrl* child = getChild<LLUICtrl>(id, true); if (child) { child->setMaxValue(max_value); @@ -1002,16 +975,16 @@ void LLPanel::childSetMaxValue(const LLString& id, LLSD max_value) void LLPanel::childShowTab(const LLString& id, const LLString& tabname, bool visible) { - LLTabContainerCommon* child = LLUICtrlFactory::getTabContainerByName(this, id); + LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id); if (child) { child->selectTabByName(tabname); } } -LLPanel *LLPanel::childGetVisibleTab(const LLString& id) +LLPanel *LLPanel::childGetVisibleTab(const LLString& id) const { - LLTabContainerCommon* child = LLUICtrlFactory::getTabContainerByName(this, id); + LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id); if (child) { return child->getCurrentPanel(); @@ -1021,7 +994,7 @@ LLPanel *LLPanel::childGetVisibleTab(const LLString& id) void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata) { - LLTabContainerCommon* child = LLUICtrlFactory::getTabContainerByName(this, id); + LLTabContainer* child = LLUICtrlFactory::getTabContainerByName(this, id); if (child) { LLPanel *panel = child->getPanelByName(tabname); @@ -1033,11 +1006,6 @@ void LLPanel::childSetTabChangeCallback(const LLString& id, const LLString& tabn } } -void LLPanel::childSetText(const LLString& id, const LLStringExplicit& text) -{ - childSetValue(id, LLSD(text)); -} - void LLPanel::childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data) { LLLineEditor* child = LLUICtrlFactory::getLineEditorByName(this, id); @@ -1060,11 +1028,6 @@ void LLPanel::childSetPrevalidate(const LLString& id, BOOL (*func)(const LLWStri } } -LLString LLPanel::childGetText(const LLString& id) -{ - return childGetValue(id).asString(); -} - void LLPanel::childSetWrappedText(const LLString& id, const LLString& text, bool visible) { LLTextBox* child = (LLTextBox*)getCtrlByNameAndType(id, WIDGET_TYPE_TEXT_BOX); @@ -1095,7 +1058,7 @@ void LLPanel::childSetActionTextbox(const LLString& id, void(*function)(void*)) void LLPanel::childSetControlName(const LLString& id, const LLString& control_name) { - LLView* view = getChildByName(id, TRUE); + LLView* view = getChild<LLView>(id); if (view) { view->setControlName(control_name, NULL); @@ -1145,7 +1108,7 @@ void LLPanel::storeRectControl() { if( !mRectControl.empty() ) { - LLUI::sConfigGroup->setRect( mRectControl, mRect ); + LLUI::sConfigGroup->setRect( mRectControl, getRect() ); } } @@ -1215,6 +1178,19 @@ LLLayoutStack::~LLLayoutStack() std::for_each(mPanels.begin(), mPanels.end(), DeletePointer()); } +// virtual +EWidgetType LLLayoutStack::getWidgetType() const +{ + return WIDGET_TYPE_LAYOUT_STACK; +} + +// virtual +LLString LLLayoutStack::getWidgetTag() const +{ + return LL_LAYOUT_STACK_TAG; +} + + void LLLayoutStack::draw() { updateLayout(); @@ -1326,23 +1302,13 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactor return layout_stackp; } -S32 LLLayoutStack::getMinWidth() -{ - return mMinWidth; -} - -S32 LLLayoutStack::getMinHeight() -{ - return mMinHeight; -} - S32 LLLayoutStack::getDefaultHeight(S32 cur_height) { // if we are spanning our children (crude upward propagation of size) // then don't enforce our size on our children if (mOrientation == HORIZONTAL) { - cur_height = llmax(mMinHeight, mRect.getHeight()); + cur_height = llmax(mMinHeight, getRect().getHeight()); } return cur_height; @@ -1354,7 +1320,7 @@ S32 LLLayoutStack::getDefaultWidth(S32 cur_width) // then don't enforce our size on our children if (mOrientation == VERTICAL) { - cur_width = llmax(mMinWidth, mRect.getWidth()); + cur_width = llmax(mMinWidth, getRect().getWidth()); } return cur_width; @@ -1476,15 +1442,15 @@ void LLLayoutStack::updateLayout(BOOL force_resize) S32 pixels_to_distribute; if (mOrientation == HORIZONTAL) { - pixels_to_distribute = mRect.getWidth() - total_width; + pixels_to_distribute = getRect().getWidth() - total_width; } else //VERTICAL { - pixels_to_distribute = mRect.getHeight() - total_height; + pixels_to_distribute = getRect().getHeight() - total_height; } S32 cur_x = 0; - S32 cur_y = mRect.getHeight(); + S32 cur_y = getRect().getHeight(); for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { @@ -1619,18 +1585,19 @@ void LLLayoutStack::updateLayout(BOOL force_resize) // not enough room to fit existing contents if (!force_resize && ((cur_y != -mPanelSpacing) - || (cur_x != mRect.getWidth() + mPanelSpacing))) + || (cur_x != getRect().getWidth() + mPanelSpacing))) { // do another layout pass with all stacked elements contributing // even those that don't usually resize llassert_always(force_resize == FALSE); updateLayout(TRUE); } -} +} // end LLLayoutStack::updateLayout -LLLayoutStack::LLEmbeddedPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) + +LLLayoutStack::LLEmbeddedPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const { - e_panel_list_t::iterator panel_it; + e_panel_list_t::const_iterator panel_it; for (panel_it = mPanels.begin(); panel_it != mPanels.end(); ++panel_it) { if ((*panel_it)->mPanel == panelp) diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 88b4ecb76b..2fdf95df58 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -33,10 +33,11 @@ #ifndef LL_LLPANEL_H #define LL_LLPANEL_H -// Opaque view with a background and a border. Can contain LLUICtrls. #include "llcallbackmap.h" #include "lluictrl.h" +#include "llbutton.h" +#include "lllineeditor.h" #include "llviewborder.h" #include "lluistring.h" #include "v4color.h" @@ -47,39 +48,26 @@ const S32 LLPANEL_BORDER_WIDTH = 1; const BOOL BORDER_YES = TRUE; const BOOL BORDER_NO = FALSE; -class LLViewerImage; -class LLUUID; -class LLCheckBoxCtrl; -class LLComboBox; -class LLIconCtrl; -class LLLineEditor; -class LLRadioGroup; -class LLScrollListCtrl; -class LLSliderCtrl; -class LLSpinCtrl; -class LLTextBox; -class LLTextEditor; - -class LLAlertInfo + +struct LLAlertInfo { -public: LLString mLabel; LLString::format_map_t mArgs; - LLAlertInfo(LLString label, LLString::format_map_t args) - : mLabel(label), mArgs(args) { } - - LLAlertInfo() { } + LLAlertInfo(LLString label, LLString::format_map_t args) : mLabel(label), mArgs(args) { } + LLAlertInfo(){} }; -class LLPanel : public LLUICtrl + +/* + * General purpose concrete view base class. + * Transparent or opaque, + * With or without border, + * Can contain LLUICtrls. + */ +class LLPanel : public LLUICtrl { public: - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; - - // defaults to TRUE - virtual BOOL isPanel(); // minimal constructor for data-driven initialization LLPanel(); @@ -89,71 +77,74 @@ public: LLPanel(const LLString& name, const LLRect& rect, BOOL bordered = TRUE); // Position and size are saved to rect_control - LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE); + LLPanel(const LLString& name, const LLString& rect_control, BOOL bordered = TRUE); + + /*virtual*/ ~LLPanel(); + + // LLView interface + /*virtual*/ EWidgetType getWidgetType() const; + /*virtual*/ LLString getWidgetTag() const; + /*virtual*/ BOOL isPanel() const; + /*virtual*/ void draw(); + /*virtual*/ BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent ); + /*virtual*/ BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ); + /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; + // From LLFocusableElement + /*virtual*/ void setFocus( BOOL b ); + + // New virtuals + virtual void refresh(); // called in setFocus() + virtual BOOL postBuild(); + virtual void clearCtrls(); // overridden in LLPanelObject and LLPanelVolume + + // Border controls void addBorder( LLViewBorder::EBevel border_bevel = LLViewBorder::BEVEL_OUT, LLViewBorder::EStyle border_style = LLViewBorder::STYLE_LINE, S32 border_thickness = LLPANEL_BORDER_WIDTH ); - - void removeBorder(); - - virtual ~LLPanel(); - virtual void draw(); - virtual void refresh(); // called in setFocus() - virtual void setFocus( BOOL b ); - void setFocusRoot(BOOL b) { mIsFocusRoot = b; } - virtual BOOL handleKeyHere( KEY key, MASK mask, BOOL called_from_parent ); - virtual BOOL handleKey( KEY key, MASK mask, BOOL called_from_parent ); - virtual BOOL postBuild(); + void removeBorder(); + BOOL hasBorder() const { return mBorder != NULL; } + void setBorderVisible( BOOL b ); void requires(LLString name, EWidgetType type = WIDGET_TYPE_DONTCARE); - BOOL checkRequirements(); - - static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t()); - static BOOL nextAlert(LLAlertInfo &alert); + BOOL checkRequirements() const; - void setBackgroundColor( const LLColor4& color ); - LLColor4 getBackgroundColor(); - void setTransparentColor(const LLColor4& color); + void setBackgroundColor( const LLColor4& color ) { mBgColorOpaque = color; } + const LLColor4& getBackgroundColor() const { return mBgColorOpaque; } + void setTransparentColor(const LLColor4& color) { mBgColorAlpha = color; } + const LLColor4& getTransparentColor() const { return mBgColorAlpha; } void setBackgroundVisible( BOOL b ) { mBgVisible = b; } + BOOL isBackgroundVisible() const { return mBgVisible; } void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } + BOOL isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); void setDefaultBtn(const LLString& id); void setLabel(const LLStringExplicit& label) { mLabel = label; } LLString getLabel() const { return mLabel; } void setRectControl(const LLString& rect_control) { mRectControl.assign(rect_control); } + const LLString& getRectControl() const { return mRectControl; } void storeRectControl(); - - void setBorderVisible( BOOL b ); void setCtrlsEnabled(BOOL b); - virtual void clearCtrls(); - - LLViewHandle getHandle() { return mViewHandle; } - S32 getLastTabGroup() { return mLastTabGroup; } + LLHandle<LLPanel> getHandle() const { return mPanelHandle; } - LLView* getCtrlByNameAndType(const LLString& name, EWidgetType type); + S32 getLastTabGroup() const { return mLastTabGroup; } - static LLPanel* getPanelByHandle(LLViewHandle handle); + LLUICtrl* getCtrlByNameAndType(const LLString& name, EWidgetType type) const; - virtual const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } + const LLCallbackMap::map_t& getFactoryMap() const { return mFactoryMap; } - virtual LLXMLNodePtr getXML(bool save_children = true) const; - static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); BOOL initPanelXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); void initChildrenXML(LLXMLNodePtr node, LLUICtrlFactory* factory); void setPanelParameters(LLXMLNodePtr node, LLView *parentp); - LLString getFormattedUIString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const; + LLString getString(const LLString& name, const LLString::format_map_t& args = LLUIString::sNullArgs) const; LLUIString getUIString(const LLString& name) const; // ** Wrappers for setting child properties by name ** -TomY - // Override to set not found list - virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; - // LLView void childSetVisible(const LLString& name, bool visible); void childShow(const LLString& name) { childSetVisible(name, true); } @@ -182,9 +173,9 @@ public: void childSetColor(const LLString& id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id); - LLCtrlListInterface* childGetListInterface(const LLString& id); - LLCtrlScrollInterface* childGetScrollInterface(const LLString& id); + LLCtrlSelectionInterface* childGetSelectionInterface(const LLString& id) const; + LLCtrlListInterface* childGetListInterface(const LLString& id) const; + LLCtrlScrollInterface* childGetScrollInterface(const LLString& id) const; // This is the magic bullet for data-driven UI void childSetValue(const LLString& id, LLSD value); @@ -202,15 +193,15 @@ public: // LLTabContainer void childShowTab(const LLString& id, const LLString& tabname, bool visible = true); - LLPanel *childGetVisibleTab(const LLString& id); + LLPanel *childGetVisibleTab(const LLString& id) const; void childSetTabChangeCallback(const LLString& id, const LLString& tabname, void (*on_tab_clicked)(void*, bool), void *userdata); // LLTextBox void childSetWrappedText(const LLString& id, const LLString& text, bool visible = true); // LLTextBox/LLTextEditor/LLLineEditor - void childSetText(const LLString& id, const LLStringExplicit& text); - LLString childGetText(const LLString& id); + void childSetText(const LLString& id, const LLStringExplicit& text) { childSetValue(id, LLSD(text)); } + LLString childGetText(const LLString& id) const { return childGetValue(id).asString(); } // LLLineEditor void childSetKeystrokeCallback(const LLString& id, void (*keystroke_callback)(LLLineEditor* caller, void* user_data), void *user_data); @@ -225,16 +216,23 @@ public: void childNotFound(const LLString& id) const; void childDisplayNotFound(); - typedef std::queue<LLAlertInfo> alert_queue_t; - static alert_queue_t sAlertQueue; + static void alertXml(LLString label, LLString::format_map_t args = LLString::format_map_t()); + static BOOL nextAlert(LLAlertInfo &alert); + static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); + +protected: + // Override to set not found list + LLButton* getDefaultButton() { return mDefaultBtn; } + LLCallbackMap::map_t mFactoryMap; - typedef std::map<LLString, LLUIString> ui_string_map_t; + // Override to set not found list: + virtual LLView* getChildByName(const LLString& name, BOOL recurse = FALSE) const; private: - // common constructor + // common construction logic void init(); - -protected: + + // From LLView virtual void addCtrl( LLUICtrl* ctrl, S32 tab_group ); virtual void addCtrlAtEnd( LLUICtrl* ctrl, S32 tab_group); @@ -251,18 +249,20 @@ protected: BOOL mBgOpaque; LLViewBorder* mBorder; LLButton* mDefaultBtn; - LLCallbackMap::map_t mFactoryMap; LLString mLabel; S32 mLastTabGroup; + LLRootHandle<LLPanel> mPanelHandle; + typedef std::map<LLString, LLUIString> ui_string_map_t; ui_string_map_t mUIStrings; typedef std::map<LLString, EWidgetType> requirements_map_t; requirements_map_t mRequirements; - typedef std::map<LLViewHandle, LLPanel*> panel_map_t; - static panel_map_t sPanelMap; -}; + typedef std::queue<LLAlertInfo> alert_queue_t; + static alert_queue_t sAlertQueue; +}; // end class LLPanel + class LLLayoutStack : public LLView { @@ -280,37 +280,33 @@ public: /*virtual*/ LLXMLNodePtr getXML(bool save_children = true) const; /*virtual*/ void removeCtrl(LLUICtrl* ctrl); - virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_LAYOUT_STACK; } - virtual LLString getWidgetTag() const { return LL_LAYOUT_STACK_TAG; } + virtual EWidgetType getWidgetType() const; + virtual LLString getWidgetTag() const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); - S32 getMinWidth(); - S32 getMinHeight(); + S32 getMinWidth() const { return mMinWidth; } + S32 getMinHeight() const { return mMinHeight; } void addPanel(LLPanel* panel, S32 min_width, S32 min_height, BOOL auto_resize, BOOL user_resize, S32 index = S32_MAX); void removePanel(LLPanel* panel); void updateLayout(BOOL force_resize = FALSE); -protected: - struct LLEmbeddedPanel; - - LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp); +private: void calcMinExtents(); - S32 getMinStackSize(); - S32 getCurStackSize(); S32 getDefaultHeight(S32 cur_height); S32 getDefaultWidth(S32 cur_width); -protected: - eLayoutOrientation mOrientation; + const eLayoutOrientation mOrientation; + struct LLEmbeddedPanel; typedef std::vector<LLEmbeddedPanel*> e_panel_list_t; e_panel_list_t mPanels; + LLEmbeddedPanel* findEmbeddedPanel(LLPanel* panelp) const; S32 mMinWidth; S32 mMinHeight; S32 mPanelSpacing; -}; +}; // end class LLLayoutStack #endif diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp index 6fba415d35..8bda6780a2 100644 --- a/indra/llui/llradiogroup.cpp +++ b/indra/llui/llradiogroup.cpp @@ -29,9 +29,6 @@ * $/LicenseInfo$ */ -// An invisible view containing multiple mutually exclusive toggling -// buttons (usually radio buttons). Automatically handles the mutex -// condition by highlighting only one button at a time. #include "linden_common.h" @@ -45,6 +42,7 @@ #include "llui.h" #include "llfocusmgr.h" + LLRadioGroup::LLRadioGroup(const LLString& name, const LLRect& rect, const LLString& control_name, LLUICtrlCallback callback, @@ -73,7 +71,7 @@ void LLRadioGroup::init(BOOL border) if (border) { addChild( new LLViewBorder( "radio group border", - LLRect(0, mRect.getHeight(), mRect.getWidth(), 0), + LLRect(0, getRect().getHeight(), getRect().getWidth(), 0), LLViewBorder::BEVEL_NONE, LLViewBorder::STYLE_LINE, 1 ) ); @@ -146,11 +144,6 @@ void LLRadioGroup::setIndexEnabled(S32 index, BOOL enabled) } } -S32 LLRadioGroup::getSelectedIndex() const -{ - return mSelectedIndex; -} - BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event) { if (index < 0 || index >= (S32)mRadioButtons.size()) @@ -452,12 +445,12 @@ BOOL LLRadioGroup::setCurrentByID( const LLUUID& id ) return FALSE; } -LLUUID LLRadioGroup::getCurrentID() +LLUUID LLRadioGroup::getCurrentID() const { return LLUUID::null; } -BOOL LLRadioGroup::setSelectedByValue(LLSD value, BOOL selected) +BOOL LLRadioGroup::setSelectedByValue(const LLSD& value, BOOL selected) { S32 idx = 0; std::string value_string = value.asString(); @@ -480,7 +473,7 @@ LLSD LLRadioGroup::getSelectedValue() return getValue(); } -BOOL LLRadioGroup::isSelected(LLSD value) +BOOL LLRadioGroup::isSelected(const LLSD& value) const { S32 idx = 0; std::string value_string = value.asString(); @@ -510,13 +503,6 @@ BOOL LLRadioGroup::operateOnAll(EOperation op) } -LLRadioCtrl::LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label, - const LLFontGL* font, void (*commit_callback)(LLUICtrl*, void*), void* callback_userdata) : - LLCheckBoxCtrl(name, rect, label, font, commit_callback, callback_userdata, FALSE, RADIO_STYLE) -{ - setTabStop(FALSE); -} - LLRadioCtrl::~LLRadioCtrl() { } diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h index 5db1baeaec..d35bd741d7 100644 --- a/indra/llui/llradiogroup.h +++ b/indra/llui/llradiogroup.h @@ -29,10 +29,6 @@ * $/LicenseInfo$ */ -// An invisible view containing multiple mutually exclusive toggling -// buttons (usually radio buttons). Automatically handles the mutex -// condition by highlighting only one button at a time. - #ifndef LL_LLRADIOGROUP_H #define LL_LLRADIOGROUP_H @@ -40,21 +36,30 @@ #include "llcheckboxctrl.h" #include "llctrlselectioninterface.h" -class LLFontGL; -// Radio controls are checkbox controls with use_radio_style true +/* + * A checkbox control with use_radio_style == true. + */ class LLRadioCtrl : public LLCheckBoxCtrl { public: - LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label, - const LLFontGL* font = NULL, - void (*commit_callback)(LLUICtrl*, void*) = NULL, - void* callback_userdata = NULL); + LLRadioCtrl(const LLString& name, const LLRect& rect, const LLString& label, const LLFontGL* font = NULL, + void (*commit_callback)(LLUICtrl*, void*) = NULL, void* callback_userdata = NULL) : + LLCheckBoxCtrl(name, rect, label, font, commit_callback, callback_userdata, FALSE, RADIO_STYLE) + { + setTabStop(FALSE); + } /*virtual*/ ~LLRadioCtrl(); /*virtual*/ void setValue(const LLSD& value); }; + +/* + * An invisible view containing multiple mutually exclusive toggling + * buttons (usually radio buttons). Automatically handles the mutex + * condition by highlighting only one button at a time. + */ class LLRadioGroup : public LLUICtrl, public LLCtrlSelectionInterface { @@ -88,7 +93,7 @@ public: void setIndexEnabled(S32 index, BOOL enabled); // return the index value of the selected item - S32 getSelectedIndex() const; + S32 getSelectedIndex() const { return mSelectedIndex; } // set the index value programatically BOOL setSelectedIndex(S32 index, BOOL from_event = FALSE); @@ -97,8 +102,7 @@ public: virtual void setValue(const LLSD& value ); virtual LLSD getValue() const; - // Draw the group, but also fix the highlighting based on the - // control. + // Draw the group, but also fix the highlighting based on the control. void draw(); // You must use this method to add buttons to a radio group. @@ -106,8 +110,7 @@ public: // correctly. LLRadioCtrl* addRadioButton(const LLString& name, const LLString& label, const LLRect& rect, const LLFontGL* font); LLRadioCtrl* getRadioButton(const S32& index) { return mRadioButtons[index]; } - // Update the control as needed. Userdata must be a pointer to the - // button. + // Update the control as needed. Userdata must be a pointer to the button. static void onClickButton(LLUICtrl* radio, void* userdata); //======================================================================== @@ -120,14 +123,14 @@ public: /*virtual*/ BOOL selectNthItem( S32 index ) { return setSelectedIndex(index); } /*virtual*/ S32 getFirstSelectedIndex() const { return getSelectedIndex(); } /*virtual*/ BOOL setCurrentByID( const LLUUID& id ); - /*virtual*/ LLUUID getCurrentID(); // LLUUID::null if no items in menu - /*virtual*/ BOOL setSelectedByValue(LLSD value, BOOL selected); + /*virtual*/ LLUUID getCurrentID() const; // LLUUID::null if no items in menu + /*virtual*/ BOOL setSelectedByValue(const LLSD& value, BOOL selected); /*virtual*/ LLSD getSelectedValue(); - /*virtual*/ BOOL isSelected(LLSD value); + /*virtual*/ BOOL isSelected(const LLSD& value) const; /*virtual*/ BOOL operateOnSelection(EOperation op); /*virtual*/ BOOL operateOnAll(EOperation op); -protected: +private: // protected function shared by the two constructors. void init(BOOL border); diff --git a/indra/llui/llresizebar.cpp b/indra/llui/llresizebar.cpp index ac8c47c91c..40346513cf 100644 --- a/indra/llui/llresizebar.cpp +++ b/indra/llui/llresizebar.cpp @@ -33,8 +33,6 @@ #include "llresizebar.h" -//#include "llviewermenu.h" -//#include "llviewerimagelist.h" #include "llmath.h" #include "llui.h" #include "llmenugl.h" @@ -87,7 +85,7 @@ LLResizeBar::LLResizeBar( const LLString& name, LLView* resizing_view, const LLR BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask) { - if( mEnabled ) + if( getEnabled() ) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler needed for focus lost since this clas has no state that depends on it. @@ -119,15 +117,6 @@ BOOL LLResizeBar::handleMouseUp(S32 x, S32 y, MASK mask) return handled; } -EWidgetType LLResizeBar::getWidgetType() const -{ - return WIDGET_TYPE_RESIZE_BAR; -} - -LLString LLResizeBar::getWidgetTag() const -{ - return LL_RESIZE_BAR_TAG; -} BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) { @@ -267,5 +256,34 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask) } return handled; +} // end LLResizeBar::handleHover + +BOOL LLResizeBar::handleDoubleClick(S32 x, S32 y, MASK mask) +{ + LLRect orig_rect = mResizingView->getRect(); + LLRect scaled_rect = orig_rect; + + if (mSnappingEnabled) + { + switch( mSide ) + { + case LEFT: + mResizingView->findSnapEdge(scaled_rect.mLeft, LLCoordGL(0, 0), SNAP_LEFT, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + break; + case TOP: + mResizingView->findSnapEdge(scaled_rect.mTop, LLCoordGL(0, 0), SNAP_TOP, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + break; + case RIGHT: + mResizingView->findSnapEdge(scaled_rect.mRight, LLCoordGL(0, 0), SNAP_RIGHT, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + break; + case BOTTOM: + mResizingView->findSnapEdge(scaled_rect.mBottom, LLCoordGL(0, 0), SNAP_BOTTOM, SNAP_PARENT_AND_SIBLINGS, S32_MAX); + break; + } + } + + mResizingView->reshape(scaled_rect.getWidth(), scaled_rect.getHeight()); + mResizingView->setOrigin(scaled_rect.mLeft, scaled_rect.mBottom); + return TRUE; } diff --git a/indra/llui/llresizebar.h b/indra/llui/llresizebar.h index d040a8b229..a3fef1a28c 100644 --- a/indra/llui/llresizebar.h +++ b/indra/llui/llresizebar.h @@ -42,18 +42,19 @@ public: LLResizeBar(const LLString& name, LLView* resizing_view, const LLRect& rect, S32 min_size, S32 max_size, Side side ); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RESIZE_BAR; } + virtual LLString getWidgetTag() const { return LL_RESIZE_BAR_TAG; } // virtual void draw(); No appearance virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); + virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; } void setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; } -protected: +private: S32 mDragLastScreenX; S32 mDragLastScreenY; S32 mLastMouseScreenX; @@ -61,13 +62,11 @@ protected: LLCoordGL mLastMouseDir; S32 mMinSize; S32 mMaxSize; - Side mSide; + const Side mSide; BOOL mSnappingEnabled; LLView* mResizingView; }; -const S32 RESIZE_BAR_HEIGHT = 3; - #endif // LL_RESIZEBAR_H diff --git a/indra/llui/llresizehandle.cpp b/indra/llui/llresizehandle.cpp index 120323e7d1..36028a4513 100644 --- a/indra/llui/llresizehandle.cpp +++ b/indra/llui/llresizehandle.cpp @@ -75,23 +75,13 @@ LLResizeHandle::LLResizeHandle( const LLString& name, const LLRect& rect, S32 mi setSaveToXML(FALSE); } -EWidgetType LLResizeHandle::getWidgetType() const -{ - return WIDGET_TYPE_RESIZE_HANDLE; -} - -LLString LLResizeHandle::getWidgetTag() const -{ - return LL_RESIZE_HANDLE_TAG; -} - BOOL LLResizeHandle::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; if( getVisible() && pointInHandle(x, y) ) { handled = TRUE; - if( mEnabled ) + if( getEnabled() ) { // Route future Mouse messages here preemptively. (Release on mouse up.) // No handler needed for focus lost since this clas has no state that depends on it. @@ -292,10 +282,12 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) handled = TRUE; } - else - if( getVisible() && pointInHandle( x, y ) ) + else // don't have mouse capture { - handled = TRUE; + if( getVisible() && pointInHandle( x, y ) ) + { + handled = TRUE; + } } if( handled ) @@ -314,7 +306,8 @@ BOOL LLResizeHandle::handleHover(S32 x, S32 y, MASK mask) } return handled; -} +} // end handleHover + // assumes GL state is set for 2D void LLResizeHandle::draw() @@ -330,8 +323,8 @@ BOOL LLResizeHandle::pointInHandle( S32 x, S32 y ) { if( pointInView(x, y) ) { - const S32 TOP_BORDER = (mRect.getHeight() - RESIZE_BORDER_WIDTH); - const S32 RIGHT_BORDER = (mRect.getWidth() - RESIZE_BORDER_WIDTH); + const S32 TOP_BORDER = (getRect().getHeight() - RESIZE_BORDER_WIDTH); + const S32 RIGHT_BORDER = (getRect().getWidth() - RESIZE_BORDER_WIDTH); switch( mCorner ) { diff --git a/indra/llui/llresizehandle.h b/indra/llui/llresizehandle.h index 2701613192..34be319786 100644 --- a/indra/llui/llresizehandle.h +++ b/indra/llui/llresizehandle.h @@ -46,8 +46,8 @@ public: LLResizeHandle(const LLString& name, const LLRect& rect, S32 min_width, S32 min_height, ECorner corner = RIGHT_BOTTOM ); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_RESIZE_HANDLE; } + virtual LLString getWidgetTag() const { return LL_RESIZE_HANDLE_TAG; } virtual void draw(); virtual BOOL handleHover(S32 x, S32 y, MASK mask); @@ -56,10 +56,9 @@ public: void setResizeLimits( S32 min_width, S32 min_height ) { mMinWidth = min_width; mMinHeight = min_height; } -protected: +private: BOOL pointInHandle( S32 x, S32 y ); -protected: S32 mDragLastScreenX; S32 mDragLastScreenY; S32 mLastMouseScreenX; @@ -68,7 +67,7 @@ protected: LLPointer<LLImageGL> mImage; S32 mMinWidth; S32 mMinHeight; - ECorner mCorner; + const ECorner mCorner; }; const S32 RESIZE_HANDLE_HEIGHT = 16; diff --git a/indra/llui/llresmgr.h b/indra/llui/llresmgr.h index be2a35513f..1a452f7381 100644 --- a/indra/llui/llresmgr.h +++ b/indra/llui/llresmgr.h @@ -29,8 +29,6 @@ * $/LicenseInfo$ */ -// NOTE: this is a MINIMAL implementation. The interface will remain, but the implementation will -// (when the time is right) become dynamic and probably use external files. #ifndef LL_LLRESMGR_H #define LL_LLRESMGR_H @@ -157,11 +155,10 @@ public: LLLocale(const LLString& locale_string); virtual ~LLLocale(); -public: static const LLString USER_LOCALE; static const LLString SYSTEM_LOCALE; -protected: +private: LLString mPrevLocaleString; }; diff --git a/indra/llui/llscrollbar.cpp b/indra/llui/llscrollbar.cpp index b106bb570d..056a94afb8 100644 --- a/indra/llui/llscrollbar.cpp +++ b/indra/llui/llscrollbar.cpp @@ -92,7 +92,7 @@ LLScrollbar::LLScrollbar( if( LLScrollbar::VERTICAL == mOrientation ) { - line_up_rect.setLeftTopAndSize( 0, mRect.getHeight(), SCROLLBAR_SIZE, SCROLLBAR_SIZE ); + line_up_rect.setLeftTopAndSize( 0, getRect().getHeight(), SCROLLBAR_SIZE, SCROLLBAR_SIZE ); line_up_img="UIImgBtnScrollUpOutUUID"; line_up_selected_img="UIImgBtnScrollUpInUUID"; @@ -107,7 +107,7 @@ LLScrollbar::LLScrollbar( line_up_img="UIImgBtnScrollLeftOutUUID"; line_up_selected_img="UIImgBtnScrollLeftInUUID"; - line_down_rect.setOriginAndSize( mRect.getWidth() - SCROLLBAR_SIZE, 0, SCROLLBAR_SIZE, SCROLLBAR_SIZE ); + line_down_rect.setOriginAndSize( getRect().getWidth() - SCROLLBAR_SIZE, 0, SCROLLBAR_SIZE, SCROLLBAR_SIZE ); line_down_img="UIImgBtnScrollRightOutUUID"; line_down_selected_img="UIImgBtnScrollRightInUUID"; } @@ -210,7 +210,7 @@ void LLScrollbar::updateThumbRect() const S32 THUMB_MIN_LENGTH = 16; - S32 window_length = (mOrientation == LLScrollbar::HORIZONTAL) ? mRect.getWidth() : mRect.getHeight(); + S32 window_length = (mOrientation == LLScrollbar::HORIZONTAL) ? getRect().getWidth() : getRect().getHeight(); S32 thumb_bg_length = window_length - 2 * SCROLLBAR_SIZE; S32 visible_lines = llmin( mDocSize, mPageSize ); S32 thumb_length = mDocSize ? llmax( visible_lines * thumb_bg_length / mDocSize, THUMB_MIN_LENGTH ) : thumb_bg_length; @@ -300,8 +300,8 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) BOOL handled = FALSE; if( hasMouseCapture() ) { - S32 height = mRect.getHeight(); - S32 width = mRect.getWidth(); + S32 height = getRect().getHeight(); + S32 width = getRect().getWidth(); if( VERTICAL == mOrientation ) { @@ -408,13 +408,13 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask) mDocChanged = FALSE; return handled; -} +} // end handleHover BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) { BOOL handled = FALSE; - if( getVisible() && mRect.localPointInRect( x, y ) ) + if( getVisible() && getRect().localPointInRect( x, y ) ) { if( getEnabled() ) { @@ -427,7 +427,7 @@ BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) } BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, void *carge_data, EAcceptance *accept, LLString &tooltip_msg) + EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString &tooltip_msg) { // enable this to get drag and drop to control scrollbars //if (!drop) @@ -436,7 +436,7 @@ BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, // S32 variable_lines = getDocPosMax(); // S32 pos = (VERTICAL == mOrientation) ? y : x; // S32 thumb_length = (VERTICAL == mOrientation) ? mThumbRect.getHeight() : mThumbRect.getWidth(); - // S32 thumb_track_length = (VERTICAL == mOrientation) ? (mRect.getHeight() - 2 * SCROLLBAR_SIZE) : (mRect.getWidth() - 2 * SCROLLBAR_SIZE); + // S32 thumb_track_length = (VERTICAL == mOrientation) ? (getRect().getHeight() - 2 * SCROLLBAR_SIZE) : (getRect().getWidth() - 2 * SCROLLBAR_SIZE); // S32 usable_track_length = thumb_track_length - thumb_length; // F32 ratio = (VERTICAL == mOrientation) ? F32(pos - SCROLLBAR_SIZE - thumb_length) / usable_track_length // : F32(pos - SCROLLBAR_SIZE) / usable_track_length; @@ -485,7 +485,7 @@ void LLScrollbar::draw() screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y); BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this; - BOOL hovered = mEnabled && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); + BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y)); if (hovered) { mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f)); @@ -504,8 +504,8 @@ void LLScrollbar::draw() if (!rounded_rect_imagep) { gl_rect_2d(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0, - mOrientation == VERTICAL ? mRect.getHeight() - 2 * SCROLLBAR_SIZE : mRect.getHeight(), - mOrientation == HORIZONTAL ? mRect.getWidth() - 2 * SCROLLBAR_SIZE : mRect.getWidth(), + mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(), + mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(), mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, mTrackColor, TRUE); gl_rect_2d(mThumbRect, mThumbColor, TRUE); @@ -518,8 +518,8 @@ void LLScrollbar::draw() mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, 16, 16, - mOrientation == HORIZONTAL ? mRect.getWidth() - 2 * SCROLLBAR_SIZE : mRect.getWidth(), - mOrientation == VERTICAL ? mRect.getHeight() - 2 * SCROLLBAR_SIZE : mRect.getHeight(), + mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(), + mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(), rounded_rect_imagep, mTrackColor, TRUE); @@ -553,7 +553,8 @@ void LLScrollbar::draw() // Draw children LLView::draw(); } -} +} // end draw + void LLScrollbar::changeLine( S32 delta, BOOL update_thumb ) { @@ -579,21 +580,12 @@ void LLScrollbar::setValue(const LLSD& value) setDocPos((S32) value.asInteger()); } -EWidgetType LLScrollbar::getWidgetType() const -{ - return WIDGET_TYPE_SCROLLBAR; -} - -LLString LLScrollbar::getWidgetTag() const -{ - return LL_SCROLLBAR_TAG; -} BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) { BOOL handled = FALSE; - if( getVisible() && mEnabled && !called_from_parent ) + if( getVisible() && getEnabled() && !called_from_parent ) { switch( key ) { @@ -661,3 +653,4 @@ void LLScrollbar::onLineDownBtnPressed( void* userdata ) self->changeLine( self->mStepSize, TRUE ); } + diff --git a/indra/llui/llscrollbar.h b/indra/llui/llscrollbar.h index 50aa3cafe9..ac0bd37e3a 100644 --- a/indra/llui/llscrollbar.h +++ b/indra/llui/llscrollbar.h @@ -61,8 +61,9 @@ public: virtual ~LLScrollbar(); virtual void setValue(const LLSD& value); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLLBAR; } + virtual LLString getWidgetTag() const { return LL_SCROLLBAR_TAG; } // Overrides from LLView virtual BOOL handleKeyHere(KEY key, MASK mask, BOOL called_from_parent); @@ -71,32 +72,33 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, void *carge_data, EAcceptance *accept, LLString &tooltip_msg); + EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, LLString &tooltip_msg); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); virtual void draw(); - void setDocParams( S32 size, S32 pos ); - // How long the "document" is. void setDocSize( S32 size ); - S32 getDocSize() { return mDocSize; } + S32 getDocSize() const { return mDocSize; } // How many "lines" the "document" has scrolled. // 0 <= DocPos <= DocSize - DocVisibile void setDocPos( S32 pos ); - S32 getDocPos() { return mDocPos; } + S32 getDocPos() const { return mDocPos; } BOOL isAtBeginning(); BOOL isAtEnd(); + // Setting both at once. + void setDocParams( S32 size, S32 pos ); + // How many "lines" of the "document" is can appear on a page. void setPageSize( S32 page_size ); - S32 getPageSize() { return mPageSize; } + S32 getPageSize() const { return mPageSize; } // The farthest the document can be scrolled (top of the last page). - S32 getDocPosMax() { return llmax( 0, mDocSize - mPageSize); } + S32 getDocPosMax() const { return llmax( 0, mDocSize - mPageSize); } void pageUp(S32 overlap); void pageDown(S32 overlap); @@ -110,15 +112,15 @@ public: void setShadowColor( const LLColor4& color ) { mShadowColor = color; } void setOnScrollEndCallback(void (*callback)(void*), void* userdata) { mOnScrollEndCallback = callback; mOnScrollEndData = userdata;} -protected: + +private: void updateThumbRect(); void changeLine(S32 delta, BOOL update_thumb ); -protected: void (*mChangeCallback)( S32 new_pos, LLScrollbar* self, void* userdata ); void* mCallbackUserData; - ORIENTATION mOrientation; + const ORIENTATION mOrientation; S32 mDocSize; // Size of the document that the scrollbar is modeling. Units depend on the user. 0 <= mDocSize. S32 mDocPos; // Position within the doc that the scrollbar is modeling, in "lines" (user size) S32 mPageSize; // Maximum number of lines that can be seen at one time. diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 34a29cef51..b9d5141eb7 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -29,14 +29,6 @@ * $/LicenseInfo$ */ -//***************************************************************************** -// -// A view meant to encapsulate a clipped region which is -// scrollable. It automatically takes care of pixel perfect scrolling -// and cliipping, as well as turning the scrollbars on or off based on -// the width and height of the view you're scrolling. -// -//***************************************************************************** #include "linden_common.h" @@ -112,11 +104,11 @@ LLScrollableContainerView::LLScrollableContainerView( const LLString& name, cons void LLScrollableContainerView::init() { - LLRect border_rect( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); mBorder = new LLViewBorder( "scroll border", border_rect, LLViewBorder::BEVEL_IN ); addChild( mBorder ); - mInnerRect.set( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); mInnerRect.stretch( -mBorder->getBorderWidth() ); LLRect vertical_scroll_rect = mInnerRect; @@ -165,25 +157,6 @@ LLScrollableContainerView::~LLScrollableContainerView( void ) mScrolledView = NULL; } -/* -// scrollbar handlers -void LLScrollableContainerView::horizontalChange( S32 new_pos, - LLScrollbar* sb, - void* user_data ) -{ - LLScrollableContainerView* cont = reinterpret_cast<LLScrollableContainerView*>(user_data); -// cont->scrollHorizontal( new_pos ); -} - - -void LLScrollableContainerView::verticalChange( S32 new_pos, LLScrollbar* sb, - void* user_data ) -{ - LLScrollableContainerView* cont = reinterpret_cast<LLScrollableContainerView*>(user_data); -// cont->scrollVertical( new_pos ); -} -*/ - // internal scrollbar handlers // virtual void LLScrollableContainerView::scrollHorizontal( S32 new_pos ) @@ -215,7 +188,7 @@ void LLScrollableContainerView::reshape(S32 width, S32 height, { LLUICtrl::reshape( width, height, called_from_parent ); - mInnerRect.set( 0, mRect.getHeight(), mRect.getWidth(), 0 ); + mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); mInnerRect.stretch( -mBorder->getBorderWidth() ); if (mScrolledView) @@ -238,7 +211,7 @@ void LLScrollableContainerView::reshape(S32 width, S32 height, BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_parent ) { - if( getVisible() && mEnabled ) + if( getVisible() && getEnabled() ) { if( called_from_parent ) { @@ -278,7 +251,7 @@ BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_ BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) { - if( mEnabled ) + if( getEnabled() ) { for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) { @@ -295,7 +268,8 @@ BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) // Opaque return TRUE; } -BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContainerView::SCROLL_ORIENTATION axis) + +BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContainerView::SCROLL_ORIENTATION axis) const { if(mScrollbar[axis]->getVisible()) { @@ -315,6 +289,7 @@ BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContaine } return FALSE; } + BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, @@ -419,19 +394,19 @@ BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, LLString& msg, LLRec return TRUE; } -void LLScrollableContainerView::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) +void LLScrollableContainerView::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const { const LLRect& rect = mScrolledView->getRect(); calcVisibleSize(rect, visible_width, visible_height, show_h_scrollbar, show_v_scrollbar); } -void LLScrollableContainerView::calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) +void LLScrollableContainerView::calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const { S32 doc_width = doc_rect.getWidth(); S32 doc_height = doc_rect.getHeight(); - *visible_width = mRect.getWidth() - 2 * mBorder->getBorderWidth(); - *visible_height = mRect.getHeight() - 2 * mBorder->getBorderWidth(); + *visible_width = getRect().getWidth() - 2 * mBorder->getBorderWidth(); + *visible_height = getRect().getHeight() - 2 * mBorder->getBorderWidth(); *show_v_scrollbar = FALSE; if( *visible_height < doc_height ) @@ -544,7 +519,7 @@ void LLScrollableContainerView::draw() drawDebugRect(); } } -} +} // end draw void LLScrollableContainerView::updateScroll() { @@ -560,9 +535,9 @@ void LLScrollableContainerView::updateScroll() S32 border_width = mBorder->getBorderWidth(); if( show_v_scrollbar ) { - if( doc_rect.mTop < mRect.getHeight() - border_width ) + if( doc_rect.mTop < getRect().getHeight() - border_width ) { - mScrolledView->translate( 0, mRect.getHeight() - border_width - doc_rect.mTop ); + mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); } scrollVertical( mScrollbar[VERTICAL]->getDocPos() ); @@ -587,7 +562,7 @@ void LLScrollableContainerView::updateScroll() } else { - mScrolledView->translate( 0, mRect.getHeight() - border_width - doc_rect.mTop ); + mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); mScrollbar[VERTICAL]->setVisible( FALSE ); mScrollbar[VERTICAL]->setDocPos( 0 ); @@ -626,7 +601,7 @@ void LLScrollableContainerView::updateScroll() mScrollbar[VERTICAL]->setDocSize( doc_height ); mScrollbar[VERTICAL]->setPageSize( visible_height ); -} +} // end updateScroll void LLScrollableContainerView::setBorderVisible(BOOL b) { @@ -723,7 +698,7 @@ void LLScrollableContainerView::goToBottom() mScrollbar[VERTICAL]->setDocPos(mScrollbar[VERTICAL]->getDocSize()); } -S32 LLScrollableContainerView::getBorderWidth() +S32 LLScrollableContainerView::getBorderWidth() const { if (mBorder) { @@ -803,7 +778,3 @@ LLView* LLScrollableContainerView::fromXML(LLXMLNodePtr node, LLView *parent, LL return ret; } - -///---------------------------------------------------------------------------- -/// Local function definitions -///---------------------------------------------------------------------------- diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index 9f1978be97..0bffd0438f 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -40,21 +40,18 @@ #include "llcoord.h" #include "llscrollbar.h" -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLScrollableContainerView -// -// A view meant to encapsulate a clipped region which is -// scrollable. It automatically takes care of pixel perfect scrolling -// and cliipping, as well as turning the scrollbars on or off based on -// the width and height of the view you're scrolling. -// -// This class is a decorator class. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class LLViewBorder; class LLUICtrlFactory; - +/***************************************************************************** + * + * A decorator view class meant to encapsulate a clipped region which is + * scrollable. It automatically takes care of pixel perfect scrolling + * and cliipping, as well as turning the scrollbars on or off based on + * the width and height of the view you're scrolling. + * + *****************************************************************************/ class LLScrollableContainerView : public LLUICtrl { public: @@ -70,32 +67,26 @@ public: const LLColor4& bg_color = LLColor4(0,0,0,0) ); virtual ~LLScrollableContainerView( void ); - void init(); - void setScrolledView(LLView* view) { mScrolledView = view; } virtual void setValue(const LLSD& value) { mInnerRect.setValue(value); } virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLL_CONTAINER; } virtual LLString getWidgetTag() const { return LL_SCROLLABLE_CONTAINER_VIEW_TAG; } - // scrollbar handlers - static void horizontalChange( S32 new_pos, LLScrollbar* sb, void* user_data ); - static void verticalChange( S32 new_pos, LLScrollbar* sb, void* user_data ); - - void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ); - void calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ); + void calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const; + void calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const; void setBorderVisible( BOOL b ); void scrollToShowRect( const LLRect& rect, const LLCoordGL& desired_offset ); void setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; } - const LLRect& getScrolledViewRect() { return mScrolledView->getRect(); } + const LLRect& getScrolledViewRect() const { return mScrolledView->getRect(); } void pageUp(S32 overlap = 0); void pageDown(S32 overlap = 0); void goToTop(); void goToBottom(); - S32 getBorderWidth(); + S32 getBorderWidth() const; - BOOL needsToScroll(S32 x, S32 y, SCROLL_ORIENTATION axis); + BOOL needsToScroll(S32 x, S32 y, SCROLL_ORIENTATION axis) const; // LLView functionality virtual void reshape(S32 width, S32 height, BOOL called_from_parent); @@ -113,7 +104,9 @@ public: virtual LLXMLNodePtr getXML(bool save_children = true) const; static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); -protected: +private: + void init(); + // internal scrollbar handlers virtual void scrollHorizontal( S32 new_pos ); virtual void scrollVertical( S32 new_pos ); diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index 76389e17b4..70309ba6bc 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -126,20 +126,6 @@ void LLScrollingPanelList::updatePanelVisiblilty() } } -void LLScrollingPanelList::setValue(const LLSD& value) -{ - -} - -EWidgetType LLScrollingPanelList::getWidgetType() const -{ - return WIDGET_TYPE_SCROLLING_PANEL_LIST; -} - -LLString LLScrollingPanelList::getWidgetTag() const -{ - return LL_SCROLLING_PANEL_LIST_TAG; -} void LLScrollingPanelList::draw() { @@ -165,9 +151,3 @@ LLView* LLScrollingPanelList::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtr return scrolling_panel_list; } -// virtual -LLXMLNodePtr LLScrollingPanelList::getXML(bool save_children) const -{ - LLXMLNodePtr node = LLUICtrl::getXML(); - return node; -} diff --git a/indra/llui/llscrollingpanellist.h b/indra/llui/llscrollingpanellist.h index f697a99a06..cb832f4bec 100644 --- a/indra/llui/llscrollingpanellist.h +++ b/indra/llui/llscrollingpanellist.h @@ -35,30 +35,31 @@ #include "llview.h" #include "llpanel.h" -// virtual class for scrolling panels +/* + * Pure virtual class represents a scrolling panel. + */ class LLScrollingPanel : public LLPanel { public: - LLScrollingPanel(const LLString& name, const LLRect& rect) - : LLPanel(name, rect) - { - } + LLScrollingPanel(const LLString& name, const LLRect& rect) : LLPanel(name, rect) { } virtual void updatePanel(BOOL allow_modify) = 0; - }; - -// A set of panels that are displayed in a vertical sequence inside a scroll container. + + +/* + * A set of panels that are displayed in a vertical sequence inside a scroll container. + */ class LLScrollingPanelList : public LLUICtrl { public: LLScrollingPanelList(const LLString& name, const LLRect& rect) : LLUICtrl(name, rect, TRUE, NULL, NULL, FOLLOWS_LEFT | FOLLOWS_BOTTOM ) {} - virtual void setValue(const LLSD& value); - virtual EWidgetType getWidgetType() const; - virtual LLString getWidgetTag() const; + virtual void setValue(const LLSD& value) {}; + virtual EWidgetType getWidgetType() const { return WIDGET_TYPE_SCROLLING_PANEL_LIST; } + virtual LLString getWidgetTag() const { return LL_SCROLLING_PANEL_LIST_TAG; } - virtual LLXMLNodePtr getXML(bool save_children) const; + virtual LLXMLNodePtr getXML(bool save_children) const { return LLUICtrl::getXML(); } virtual void draw(); @@ -68,9 +69,8 @@ public: static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); -protected: +private: void updatePanelVisiblilty(); -protected: std::deque<LLScrollingPanel*> mPanelList; }; diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 9d38bd0dab..94053980e6 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp |
