diff options
author | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-11-16 12:33:52 +0200 |
---|---|---|
committer | Dmitry Zaporozhan <dzaporozhan@productengine.com> | 2009-11-16 12:33:52 +0200 |
commit | 471897cfabbfec8d4dbee65c837d5884310ea61a (patch) | |
tree | d9ef29f52786b380bd3d496c1f5a258aefeeb772 /indra/llui | |
parent | d149b28173c2b255bd1bf1db902368dfbdf3064a (diff) | |
parent | e7519e8a977138627b429ca43a10184c82efc66e (diff) |
Merge
--HG--
branch : product-engine
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lldockablefloater.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 77 | ||||
-rw-r--r-- | indra/llui/llslider.cpp | 134 | ||||
-rw-r--r-- | indra/llui/llslider.h | 21 | ||||
-rw-r--r-- | indra/llui/lltoggleablemenu.cpp | 9 | ||||
-rw-r--r-- | indra/llui/lltoggleablemenu.h | 3 |
6 files changed, 175 insertions, 73 deletions
diff --git a/indra/llui/lldockablefloater.cpp b/indra/llui/lldockablefloater.cpp index f56cb2eee7..c3dd4ae647 100644 --- a/indra/llui/lldockablefloater.cpp +++ b/indra/llui/lldockablefloater.cpp @@ -127,6 +127,10 @@ void LLDockableFloater::setVisible(BOOL visible) mDockControl.get()->repositionDockable(); } + if (visible) + { + LLFloater::setFrontmost(TRUE); + } LLFloater::setVisible(visible); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index f2cdad8854..2a0dcaf333 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1888,41 +1888,50 @@ void LLFloaterView::reshapeFloater(S32 width, S32 height, BOOL called_from_paren // dependents use same follow flags as their "dependee" continue; } - LLRect r = floaterp->getRect(); - - // Compute absolute distance from each edge of screen - S32 left_offset = llabs(r.mLeft - 0); - S32 right_offset = llabs(old_width - r.mRight); - - S32 top_offset = llabs(old_height - r.mTop); - S32 bottom_offset = llabs(r.mBottom - 0); // Make if follow the edge it is closest to U32 follow_flags = 0x0; - if (left_offset < right_offset) + if (floaterp->isMinimized()) { - follow_flags |= FOLLOWS_LEFT; + follow_flags |= (FOLLOWS_LEFT | FOLLOWS_TOP); } else { - follow_flags |= FOLLOWS_RIGHT; - } + LLRect r = floaterp->getRect(); - // "No vertical adjustment" usually means that the bottom of the view - // has been pushed up or down. Hence we want the floaters to follow - // the top. - if (!adjust_vertical) - { - follow_flags |= FOLLOWS_TOP; - } - else if (top_offset < bottom_offset) - { - follow_flags |= FOLLOWS_TOP; - } - else - { - follow_flags |= FOLLOWS_BOTTOM; + // Compute absolute distance from each edge of screen + S32 left_offset = llabs(r.mLeft - 0); + S32 right_offset = llabs(old_width - r.mRight); + + S32 top_offset = llabs(old_height - r.mTop); + S32 bottom_offset = llabs(r.mBottom - 0); + + + if (left_offset < right_offset) + { + follow_flags |= FOLLOWS_LEFT; + } + else + { + follow_flags |= FOLLOWS_RIGHT; + } + + // "No vertical adjustment" usually means that the bottom of the view + // has been pushed up or down. Hence we want the floaters to follow + // the top. + if (!adjust_vertical) + { + follow_flags |= FOLLOWS_TOP; + } + else if (top_offset < bottom_offset) + { + follow_flags |= FOLLOWS_TOP; + } + else + { + follow_flags |= FOLLOWS_BOTTOM; + } } floaterp->setFollows(follow_flags); @@ -2172,16 +2181,16 @@ void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) const LLFloater::Params& default_params = LLFloater::getDefaultParams(); S32 floater_header_size = default_params.header_height; static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); - S32 col = 0; LLRect snap_rect_local = getLocalSnapRect(); - for(S32 row = snap_rect_local.mBottom; - row < snap_rect_local.getHeight() - floater_header_size; - row += floater_header_size ) //loop rows - { - for(col = snap_rect_local.mLeft; - col < snap_rect_local.getWidth() - minimized_width; - col += minimized_width) + for(S32 col = snap_rect_local.mLeft; + col < snap_rect_local.getWidth() - minimized_width; + col += minimized_width) + { + for(S32 row = snap_rect_local.mTop - floater_header_size; + row > floater_header_size; + row -= floater_header_size ) //loop rows { + bool foundGap = TRUE; for(child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); diff --git a/indra/llui/llslider.cpp b/indra/llui/llslider.cpp index f86776384a..da2fc7c68b 100644 --- a/indra/llui/llslider.cpp +++ b/indra/llui/llslider.cpp @@ -47,14 +47,17 @@ static LLDefaultChildRegistry::Register<LLSlider> r1("slider_bar"); // have ambigious template lookup problem LLSlider::Params::Params() -: track_color("track_color"), +: orientation ("orientation", std::string ("horizontal")), + track_color("track_color"), thumb_outline_color("thumb_outline_color"), thumb_center_color("thumb_center_color"), thumb_image("thumb_image"), thumb_image_pressed("thumb_image_pressed"), thumb_image_disabled("thumb_image_disabled"), - track_image("track_image"), - track_highlight_image("track_highlight_image"), + track_image_horizontal("track_image_horizontal"), + track_image_vertical("track_image_vertical"), + track_highlight_horizontal_image("track_highlight_horizontal_image"), + track_highlight_vertical_image("track_highlight_vertical_image"), mouse_down_callback("mouse_down_callback"), mouse_up_callback("mouse_up_callback") { @@ -64,14 +67,17 @@ LLSlider::Params::Params() LLSlider::LLSlider(const LLSlider::Params& p) : LLF32UICtrl(p), mMouseOffset( 0 ), + mOrientation ((p.orientation() == "horizontal") ? HORIZONTAL : VERTICAL), mTrackColor(p.track_color()), mThumbOutlineColor(p.thumb_outline_color()), mThumbCenterColor(p.thumb_center_color()), mThumbImage(p.thumb_image), mThumbImagePressed(p.thumb_image_pressed), mThumbImageDisabled(p.thumb_image_disabled), - mTrackImage(p.track_image), - mTrackHighlightImage(p.track_highlight_image) + mTrackImageHorizontal(p.track_image_horizontal), + mTrackImageVertical(p.track_image_vertical), + mTrackHighlightHorizontalImage(p.track_highlight_horizontal_image), + mTrackHighlightVerticalImage(p.track_highlight_vertical_image) { mViewModel->setValue(p.initial_value); updateThumbRect(); @@ -111,14 +117,29 @@ void LLSlider::updateThumbRect() S32 thumb_width = mThumbImage ? mThumbImage->getWidth() : DEFAULT_THUMB_SIZE; S32 thumb_height = mThumbImage ? mThumbImage->getHeight() : DEFAULT_THUMB_SIZE; - S32 left_edge = (thumb_width / 2); - S32 right_edge = getRect().getWidth() - (thumb_width / 2); - - S32 x = left_edge + S32( t * (right_edge - left_edge) ); - mThumbRect.mLeft = x - (thumb_width / 2); - mThumbRect.mRight = mThumbRect.mLeft + thumb_width; - mThumbRect.mBottom = getLocalRect().getCenterY() - (thumb_height / 2); - mThumbRect.mTop = mThumbRect.mBottom + thumb_height; + + if ( mOrientation == HORIZONTAL ) + { + S32 left_edge = (thumb_width / 2); + S32 right_edge = getRect().getWidth() - (thumb_width / 2); + + S32 x = left_edge + S32( t * (right_edge - left_edge) ); + mThumbRect.mLeft = x - (thumb_width / 2); + mThumbRect.mRight = mThumbRect.mLeft + thumb_width; + mThumbRect.mBottom = getLocalRect().getCenterY() - (thumb_height / 2); + mThumbRect.mTop = mThumbRect.mBottom + thumb_height; + } + else + { + S32 top_edge = (thumb_height / 2); + S32 bottom_edge = getRect().getHeight() - (thumb_height / 2); + + S32 y = top_edge + S32( t * (bottom_edge - top_edge) ); + mThumbRect.mLeft = getLocalRect().getCenterX() - (thumb_width / 2); + mThumbRect.mRight = mThumbRect.mLeft + thumb_width; + mThumbRect.mBottom = y - (thumb_height / 2); + mThumbRect.mTop = mThumbRect.mBottom + thumb_height; + } } @@ -138,18 +159,32 @@ BOOL LLSlider::handleHover(S32 x, S32 y, MASK mask) { if( hasMouseCapture() ) { - S32 thumb_half_width = mThumbImage->getWidth()/2; - S32 left_edge = thumb_half_width; - S32 right_edge = getRect().getWidth() - (thumb_half_width); + if ( mOrientation == HORIZONTAL ) + { + S32 thumb_half_width = mThumbImage->getWidth()/2; + S32 left_edge = thumb_half_width; + S32 right_edge = getRect().getWidth() - (thumb_half_width); - x += mMouseOffset; - x = llclamp( x, left_edge, right_edge ); + x += mMouseOffset; + x = llclamp( x, left_edge, right_edge ); - F32 t = F32(x - left_edge) / (right_edge - left_edge); - setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); + F32 t = F32(x - left_edge) / (right_edge - left_edge); + setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); + } + else // mOrientation == VERTICAL + { + S32 thumb_half_height = mThumbImage->getHeight()/2; + S32 top_edge = thumb_half_height; + S32 bottom_edge = getRect().getHeight() - (thumb_half_height); + + y += mMouseOffset; + y = llclamp(y, top_edge, bottom_edge); + F32 t = F32(y - top_edge) / (bottom_edge - top_edge); + setValueAndCommit(t * (mMaxValue - mMinValue) + mMinValue ); + } getWindow()->setCursor(UI_CURSOR_ARROW); - lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; + lldebugst(LLERR_USER_INPUT) << "hover handled by " << getName() << " (active)" << llendl; } else { @@ -198,7 +233,9 @@ BOOL LLSlider::handleMouseDown(S32 x, S32 y, MASK mask) // Find the offset of the actual mouse location from the center of the thumb. if (mThumbRect.pointInRect(x,y)) { - mMouseOffset = (mThumbRect.mLeft + mThumbImage->getWidth()/2) - x; + mMouseOffset = (mOrientation == HORIZONTAL) + ? (mThumbRect.mLeft + mThumbImage->getWidth()/2) - x + : (mThumbRect.mBottom + mThumbImage->getHeight()/2) - y; } else { @@ -220,15 +257,12 @@ BOOL LLSlider::handleKeyHere(KEY key, MASK mask) BOOL handled = FALSE; switch(key) { - case KEY_UP: case KEY_DOWN: - // eat up and down keys to be consistent - handled = TRUE; - break; case KEY_LEFT: setValueAndCommit(getValueF32() - getIncrement()); handled = TRUE; break; + case KEY_UP: case KEY_RIGHT: setValueAndCommit(getValueF32() + getIncrement()); handled = TRUE; @@ -239,6 +273,17 @@ BOOL LLSlider::handleKeyHere(KEY key, MASK mask) return handled; } +BOOL LLSlider::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if ( mOrientation == VERTICAL ) + { + F32 new_val = getValueF32() - clicks * getIncrement(); + setValueAndCommit(new_val); + return TRUE; + } + return LLF32UICtrl::handleScrollWheel(x,y,clicks); +} + void LLSlider::draw() { F32 alpha = getDrawContext().mAlpha; @@ -252,13 +297,36 @@ void LLSlider::draw() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // Track - LLRect track_rect(mThumbImage->getWidth() / 2, - getLocalRect().getCenterY() + (mTrackImage->getHeight() / 2), - getRect().getWidth() - mThumbImage->getWidth() / 2, - getLocalRect().getCenterY() - (mTrackImage->getHeight() / 2) ); - LLRect highlight_rect(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom); - mTrackImage->draw(track_rect, LLColor4::white % alpha); - mTrackHighlightImage->draw(highlight_rect, LLColor4::white % alpha); + LLPointer<LLUIImage>& trackImage = ( mOrientation == HORIZONTAL ) + ? mTrackImageHorizontal + : mTrackImageVertical; + + LLPointer<LLUIImage>& trackHighlightImage = ( mOrientation == HORIZONTAL ) + ? mTrackHighlightHorizontalImage + : mTrackHighlightVerticalImage; + + LLRect track_rect; + LLRect highlight_rect; + + if ( mOrientation == HORIZONTAL ) + { + track_rect.set(mThumbImage->getWidth() / 2, + getLocalRect().getCenterY() + (trackImage->getHeight() / 2), + getRect().getWidth() - mThumbImage->getWidth() / 2, + getLocalRect().getCenterY() - (trackImage->getHeight() / 2) ); + highlight_rect.set(track_rect.mLeft, track_rect.mTop, mThumbRect.getCenterX(), track_rect.mBottom); + } + else + { + track_rect.set(getLocalRect().getCenterX() - (trackImage->getWidth() / 2), + getRect().getHeight(), + getLocalRect().getCenterX() + (trackImage->getWidth() / 2), + 0); + highlight_rect.set(track_rect.mLeft, track_rect.mTop, track_rect.mRight, track_rect.mBottom); + } + + trackImage->draw(track_rect, LLColor4::white % alpha); + trackHighlightImage->draw(highlight_rect, LLColor4::white % alpha); // Thumb if (hasFocus()) diff --git a/indra/llui/llslider.h b/indra/llui/llslider.h index e2a94e4d8c..6ab0ed7922 100644 --- a/indra/llui/llslider.h +++ b/indra/llui/llslider.h @@ -39,8 +39,12 @@ class LLSlider : public LLF32UICtrl { public: + enum ORIENTATION { HORIZONTAL, VERTICAL }; + struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params> { + Optional<std::string> orientation; + Optional<LLUIColor> track_color, thumb_outline_color, thumb_center_color; @@ -48,8 +52,10 @@ public: Optional<LLUIImage*> thumb_image, thumb_image_pressed, thumb_image_disabled, - track_image, - track_highlight_image; + track_image_horizontal, + track_image_vertical, + track_highlight_horizontal_image, + track_highlight_vertical_image; Optional<CommitCallbackParam> mouse_down_callback, mouse_up_callback; @@ -77,6 +83,7 @@ public: virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleKeyHere(KEY key, MASK mask); + virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); virtual void draw(); private: @@ -90,10 +97,14 @@ private: LLPointer<LLUIImage> mThumbImage; LLPointer<LLUIImage> mThumbImagePressed; LLPointer<LLUIImage> mThumbImageDisabled; - LLPointer<LLUIImage> mTrackImage; - LLPointer<LLUIImage> mTrackHighlightImage; + LLPointer<LLUIImage> mTrackImageHorizontal; + LLPointer<LLUIImage> mTrackImageVertical; + LLPointer<LLUIImage> mTrackHighlightHorizontalImage; + LLPointer<LLUIImage> mTrackHighlightVerticalImage; + + const ORIENTATION mOrientation; - LLRect mThumbRect; + LLRect mThumbRect; LLUIColor mTrackColor; LLUIColor mThumbOutlineColor; LLUIColor mThumbCenterColor; diff --git a/indra/llui/lltoggleablemenu.cpp b/indra/llui/lltoggleablemenu.cpp index 717e135412..5df1d35383 100644 --- a/indra/llui/lltoggleablemenu.cpp +++ b/indra/llui/lltoggleablemenu.cpp @@ -40,6 +40,7 @@ static LLDefaultChildRegistry::Register<LLToggleableMenu> r("toggleable_menu"); LLToggleableMenu::LLToggleableMenu(const LLToggleableMenu::Params& p) : LLMenuGL(p), + mButtonRect(), mClosedByButtonClick(false) { } @@ -56,13 +57,19 @@ void LLToggleableMenu::handleVisibilityChange (BOOL curVisibilityIn) } } -void LLToggleableMenu::setButtonRect(const LLRect& rect, LLView* current_view) +void LLToggleableMenu::setButtonRect(const LLRect& rect, LLView* current_view) { LLRect screen; current_view->localRectToScreen(rect, &screen); mButtonRect = screen; } +void LLToggleableMenu::setButtonRect(LLView* current_view) +{ + LLRect rect = current_view->getLocalRect(); + setButtonRect(rect, current_view); +} + bool LLToggleableMenu::toggleVisibility() { if (mClosedByButtonClick) diff --git a/indra/llui/lltoggleablemenu.h b/indra/llui/lltoggleablemenu.h index 3cd66e04a8..9d8c5261b9 100644 --- a/indra/llui/lltoggleablemenu.h +++ b/indra/llui/lltoggleablemenu.h @@ -49,8 +49,11 @@ protected: public: virtual void handleVisibilityChange (BOOL curVisibilityIn); + const LLRect& getButtonRect() const { return mButtonRect; } + // Converts the given local button rect to a screen rect void setButtonRect(const LLRect& rect, LLView* current_view); + void setButtonRect(LLView* current_view); // Returns "true" if menu was not closed by button click // and is not still visible. If menu is visible toggles |