diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llbutton.cpp | 5 | ||||
-rw-r--r-- | indra/llui/llbutton.h | 5 | ||||
-rw-r--r-- | indra/llui/lldraghandle.cpp | 9 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 238 | ||||
-rw-r--r-- | indra/llui/llfloater.h | 12 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.cpp | 22 | ||||
-rw-r--r-- | indra/llui/llfloaterreg.h | 4 | ||||
-rw-r--r-- | indra/llui/llmenubutton.cpp | 2 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 7 | ||||
-rw-r--r-- | indra/llui/llmenugl.h | 2 | ||||
-rw-r--r-- | indra/llui/llmultifloater.cpp | 12 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 45 | ||||
-rw-r--r-- | indra/llui/llpanel.h | 30 | ||||
-rw-r--r-- | indra/llui/lltooltip.cpp | 107 | ||||
-rw-r--r-- | indra/llui/lltooltip.h | 13 |
15 files changed, 381 insertions, 132 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index fd369730d6..a7946cacf5 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -486,6 +486,11 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask) mNeedsHighlight = FALSE; } +void LLButton::setHighlight(bool b) +{ + mNeedsHighlight = b; +} + BOOL LLButton::handleHover(S32 x, S32 y, MASK mask) { if (!childrenHandleHover(x, y, mask)) diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 7fc4997133..85580a98bf 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -176,6 +176,7 @@ public: BOOL getToggleState() const; void setToggleState(BOOL b); + void setHighlight(bool b); void setFlashing( BOOL b ); BOOL getFlashing() const { return mFlashing; } @@ -241,8 +242,8 @@ public: void setForcePressedState(BOOL b) { mForcePressedState = b; } protected: - const LLPointer<LLUIImage>& getImageUnselected() const { return mImageUnselected; } - const LLPointer<LLUIImage>& getImageSelected() const { return mImageSelected; } + LLPointer<LLUIImage> getImageUnselected() const { return mImageUnselected; } + LLPointer<LLUIImage> getImageSelected() const { return mImageSelected; } LLFrameTimer mMouseDownTimer; diff --git a/indra/llui/lldraghandle.cpp b/indra/llui/lldraghandle.cpp index 8eccd709ce..d9b98b1c28 100644 --- a/indra/llui/lldraghandle.cpp +++ b/indra/llui/lldraghandle.cpp @@ -49,9 +49,9 @@ #include "lluictrlfactory.h" const S32 LEADING_PAD = 5; -const S32 TITLE_PAD = 8; +const S32 TITLE_HPAD = 8; const S32 BORDER_PAD = 1; -const S32 LEFT_PAD = BORDER_PAD + TITLE_PAD + LEADING_PAD; +const S32 LEFT_PAD = BORDER_PAD + TITLE_HPAD + LEADING_PAD; const S32 RIGHT_PAD = BORDER_PAD + 32; // HACK: space for close btn and minimize btn S32 LLDragHandle::sSnapMargin = 5; @@ -240,19 +240,20 @@ void LLDragHandleLeft::draw() void LLDragHandleTop::reshapeTitleBox() { + static LLUICachedControl<S32> title_vpad("UIFloaterTitleVPad", 0); if( ! mTitleBox) { return; } const LLFontGL* font = LLFontGL::getFontSansSerif(); - S32 title_width = font->getWidth( mTitleBox->getText() ) + TITLE_PAD; + S32 title_width = font->getWidth( mTitleBox->getText() ) + TITLE_HPAD; if (getMaxTitleWidth() > 0) title_width = llmin(title_width, getMaxTitleWidth()); S32 title_height = llround(font->getLineHeight()); LLRect title_rect; title_rect.setLeftTopAndSize( LEFT_PAD, - getRect().getHeight() - BORDER_PAD, + getRect().getHeight() - title_vpad, getRect().getWidth() - LEFT_PAD - RIGHT_PAD, title_height); diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 021e2e94ac..8c72b079ee 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -189,11 +189,14 @@ LLFloater::Params::Params() can_close("can_close", true), can_drag_on_left("can_drag_on_left", false), can_tear_off("can_tear_off", true), + save_dock_state("save_dock_state", false), save_rect("save_rect", false), save_visibility("save_visibility", false), + can_dock("can_dock", false), + header_height("header_height", 0), + legacy_header_height("legacy_header_height", 0), open_callback("open_callback"), - close_callback("close_callback"), - can_dock("can_dock", false) + close_callback("close_callback") { visible = false; } @@ -219,7 +222,7 @@ void LLFloater::initClass() static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater"); LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) -: LLPanel(), +: LLPanel(), // intentionally do not pass params here, see initFromParams mDragHandle(NULL), mTitle(p.title), mShortTitle(p.short_title), @@ -233,6 +236,8 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mResizable(p.can_resize), mMinWidth(p.min_width), mMinHeight(p.min_height), + mHeaderHeight(p.header_height), + mLegacyHeaderHeight(p.legacy_header_height), mMinimized(FALSE), mForeground(FALSE), mFirstLook(TRUE), @@ -263,11 +268,8 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) mButtonsEnabled[i] = FALSE; mButtons[i] = NULL; } - for (S32 i = 0; i < 4; i++) - { - mResizeBar[i] = NULL; - mResizeHandle[i] = NULL; - } + addDragHandle(); + addResizeCtrls(); initFromParams(p); @@ -280,10 +282,6 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p) // Note: Floaters constructed from XML call init() twice! void LLFloater::initFloater() { - addDragHandle(); - - addResizeCtrls(); - // Close button. if (mCanClose) { @@ -323,9 +321,6 @@ void LLFloater::initFloater() void LLFloater::addDragHandle() { - static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); - S32 close_box_size = mCanClose ? floater_close_box_size : 0; - if (!mDragHandle) { if (mDragOnLeft) @@ -346,6 +341,14 @@ void LLFloater::addDragHandle() } addChild(mDragHandle); } + layoutDragHandle(); +} + +void LLFloater::layoutDragHandle() +{ + static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0); + S32 close_box_size = mCanClose ? floater_close_box_size : 0; + LLRect rect; if (mDragOnLeft) { @@ -361,40 +364,17 @@ void LLFloater::addDragHandle() } void LLFloater::addResizeCtrls() -{ - for (S32 i = 0; i < 4; i++) - { - if (mResizeBar[i]) - { - removeChild(mResizeBar[i]); - delete mResizeBar[i]; - mResizeBar[i] = NULL; - } - if (mResizeHandle[i]) - { - removeChild(mResizeHandle[i]); - delete mResizeHandle[i]; - mResizeHandle[i] = NULL; - } - } - if( !mResizable ) - { - return; - } - +{ // Resize bars (sides) - const S32 RESIZE_BAR_THICKNESS = 3; LLResizeBar::Params p; p.name("resizebar_left"); p.resizing_view(this); - p.rect(LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0)); p.min_size(mMinWidth); p.side(LLResizeBar::LEFT); mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p); addChild( mResizeBar[LLResizeBar::LEFT] ); p.name("resizebar_top"); - p.rect(LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS)); p.min_size(mMinHeight); p.side(LLResizeBar::TOP); @@ -402,15 +382,12 @@ void LLFloater::addResizeCtrls() addChild( mResizeBar[LLResizeBar::TOP] ); p.name("resizebar_right"); - p.rect(LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0)); p.min_size(mMinWidth); - p.side(LLResizeBar::RIGHT); - + p.side(LLResizeBar::RIGHT); mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p); addChild( mResizeBar[LLResizeBar::RIGHT] ); p.name("resizebar_bottom"); - p.rect(LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0)); p.min_size(mMinHeight); p.side(LLResizeBar::BOTTOM); mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p); @@ -421,27 +398,69 @@ void LLFloater::addResizeCtrls() // handles must not be mouse-opaque, otherwise they block hover events // to other buttons like the close box. JC handle_p.mouse_opaque(false); - handle_p.rect(LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0)); handle_p.min_width(mMinWidth); handle_p.min_height(mMinHeight); handle_p.corner(LLResizeHandle::RIGHT_BOTTOM); mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); addChild(mResizeHandle[0]); - handle_p.rect(LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT)); handle_p.corner(LLResizeHandle::RIGHT_TOP); mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); addChild(mResizeHandle[1]); - handle_p.rect(LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 )); handle_p.corner(LLResizeHandle::LEFT_BOTTOM); mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); addChild(mResizeHandle[2]); - handle_p.rect(LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT )); handle_p.corner(LLResizeHandle::LEFT_TOP); mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p); addChild(mResizeHandle[3]); + + layoutResizeCtrls(); +} + +void LLFloater::layoutResizeCtrls() +{ + LLRect rect; + + // Resize bars (sides) + const S32 RESIZE_BAR_THICKNESS = 3; + rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0); + mResizeBar[LLResizeBar::LEFT]->setRect(rect); + + rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS); + mResizeBar[LLResizeBar::TOP]->setRect(rect); + + rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0); + mResizeBar[LLResizeBar::RIGHT]->setRect(rect); + + rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0); + mResizeBar[LLResizeBar::BOTTOM]->setRect(rect); + + // Resize handles (corners) + rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0); + mResizeHandle[0]->setRect(rect); + + rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT); + mResizeHandle[1]->setRect(rect); + + rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 ); + mResizeHandle[2]->setRect(rect); + + rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT ); + mResizeHandle[3]->setRect(rect); +} + +void LLFloater::enableResizeCtrls(bool enable) +{ + for (S32 i = 0; i < 4; ++i) + { + mResizeBar[i]->setVisible(enable); + mResizeBar[i]->setEnabled(enable); + + mResizeHandle[i]->setVisible(enable); + mResizeHandle[i]->setEnabled(enable); + } } // virtual @@ -483,6 +502,7 @@ LLFloater::~LLFloater() storeRectControl(); setVisible(false); // We're not visible if we're destroyed storeVisibilityControl(); + storeDockStateControl(); } void LLFloater::storeRectControl() @@ -501,6 +521,15 @@ void LLFloater::storeVisibilityControl() } } +void LLFloater::storeDockStateControl() +{ + if( !sQuitting && mDocStateControl.size() > 1 ) + { + LLUI::sSettingGroups["floater"]->setBOOL( mDocStateControl, isDocked() ); + } +} + + void LLFloater::setVisible( BOOL visible ) { LLPanel::setVisible(visible); // calls handleVisibilityChange() @@ -759,6 +788,16 @@ void LLFloater::applyRectControl() } } +void LLFloater::applyDockState() +{ + if (mDocStateControl.size() > 1) + { + bool dockState = LLUI::sSettingGroups["floater"]->getBOOL(mDocStateControl); + setDocked(dockState); + } + +} + void LLFloater::applyTitle() { if (!mDragHandle) @@ -909,7 +948,8 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) void LLFloater::setMinimized(BOOL minimize) { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0); if (minimize == mMinimized) return; @@ -1082,7 +1122,8 @@ void LLFloater::setFocus( BOOL b ) void LLFloater::setRect(const LLRect &rect) { LLPanel::setRect(rect); - addDragHandle(); // re-add drag handle, sized based on rect + layoutDragHandle(); + layoutResizeCtrls(); } // virtual @@ -1376,7 +1417,10 @@ void LLFloater::setDocked(bool docked, bool pop_on_undock) mButtonsEnabled[BUTTON_DOCK] = !mDocked; mButtonsEnabled[BUTTON_UNDOCK] = mDocked; updateButtons(); + + storeDockStateControl(); } + } // static @@ -1389,9 +1433,9 @@ void LLFloater::onClickMinimize(LLFloater* self) void LLFloater::onClickTearOff(LLFloater* self) { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); if (!self) return; + S32 floater_header_size = self->mHeaderHeight; LLMultiFloater* host_floater = self->getHost(); if (host_floater) //Tear off { @@ -1548,26 +1592,42 @@ void LLFloater::draw() shadow_color % alpha, llround(shadow_offset)); - // No transparent windows in simple UI + LLUIImage* image = NULL; + LLColor4 color; if (isBackgroundOpaque()) { - gl_rect_2d( left, top, right, bottom, getBackgroundColor() % alpha ); + // NOTE: image may not be set + image = getBackgroundImage(); + color = getBackgroundColor(); } else { - gl_rect_2d( left, top, right, bottom, getTransparentColor() % alpha ); + image = getTransparentImage(); + color = getTransparentColor(); } - if(hasFocus() - && !getIsChrome() - && !getCurrentTitle().empty()) + if (image) + { + // We're using images for this floater's backgrounds + image->draw(getLocalRect(), UI_VERTEX_COLOR % alpha); + } + else { - static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor"); + // We're not using images, use old-school flat colors + gl_rect_2d( left, top, right, bottom, color % alpha ); + // draw highlight on title bar to indicate focus. RDW - const LLFontGL* font = LLFontGL::getFontSansSerif(); - LLRect r = getRect(); - gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1, - titlebar_focus_color % alpha, 0, TRUE); + if(hasFocus() + && !getIsChrome() + && !getCurrentTitle().empty()) + { + static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor"); + + const LLFontGL* font = LLFontGL::getFontSansSerif(); + LLRect r = getRect(); + gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - (S32)font->getLineHeight() - 1, + titlebar_focus_color % alpha, 0, TRUE); + } } } @@ -1617,18 +1677,6 @@ void LLFloater::draw() drawChild(focused_child); } - 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 - static LLUIColor focus_border_color = LLUIColorTable::instance().getColor("FloaterFocusBorderColor"); - static LLUIColor unfocus_border_color = LLUIColorTable::instance().getColor("FloaterUnfocusBorderColor"); - LLUI::setLineWidth(1.5f); - LLColor4 outlineColor = gFocusMgr.childHasKeyboardFocus(this) ? focus_border_color : unfocus_border_color; - gl_rect_2d_offset_local(0, getRect().getHeight() + 1, getRect().getWidth() + 1, 0, outlineColor % alpha, -LLPANEL_BORDER_WIDTH, FALSE); - LLUI::setLineWidth(1.f); - } - // update tearoff button for torn off floaters // when last host goes away if (mCanTearOff && !getHost()) @@ -1677,7 +1725,7 @@ void LLFloater::setCanTearOff(BOOL can_tear_off) void LLFloater::setCanResize(BOOL can_resize) { mResizable = can_resize; - addResizeCtrls(); + enableResizeCtrls(can_resize); } void LLFloater::setCanDrag(BOOL can_drag) @@ -2113,7 +2161,8 @@ void LLFloaterView::focusFrontFloater() void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom) { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + 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(); @@ -2488,6 +2537,11 @@ void LLFloater::setInstanceName(const std::string& name) { mVisibilityControl = LLFloaterReg::declareVisibilityControl(mInstanceName); } + if(!mDocStateControl.empty()) + { + mDocStateControl = LLFloaterReg::declareDockStateControl(mInstanceName); + } + } } @@ -2528,6 +2582,9 @@ void LLFloater::setupParamsForExport(Params& p, LLView* parent) void LLFloater::initFromParams(const LLFloater::Params& p) { + // *NOTE: We have too many classes derived from LLFloater to retrofit them + // all to pass in params via constructors. So we use this method. + // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible LLPanel::initFromParams(p); @@ -2539,11 +2596,12 @@ void LLFloater::initFromParams(const LLFloater::Params& p) setCanMinimize(p.can_minimize); setCanClose(p.can_close); setCanDock(p.can_dock); + setCanResize(p.can_resize); + setResizeLimits(p.min_width, p.min_height); mDragOnLeft = p.can_drag_on_left; - mResizable = p.can_resize; - mMinWidth = p.min_width; - mMinHeight = p.min_height; + mHeaderHeight = p.header_height; + mLegacyHeaderHeight = p.legacy_header_height; mSingleInstance = p.single_instance; mAutoTile = p.auto_tile; @@ -2555,6 +2613,11 @@ void LLFloater::initFromParams(const LLFloater::Params& p) { mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set } + + if(p.save_dock_state) + { + mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set + } // open callback if (p.open_callback.isProvided()) @@ -2599,6 +2662,23 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o LLFloater::setFloaterHost(last_host); } + // HACK: When we changed the header height to 25 pixels in Viewer 2, rather + // than re-layout all the floaters we use this value in pixels to make the + // whole floater bigger and change the top-left coordinate for widgets. + // The goal is to eventually set mLegacyHeaderHeight to zero, which would + // make the top-left corner for widget layout the same as the top-left + // corner of the window's content area. James + S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight); + if (header_stretch > 0) + { + // Stretch the floater vertically, don't move widgets + LLRect rect = getRect(); + rect.mTop += header_stretch; + + // This will also update drag handle, title bar, close box, etc. + setRect(rect); + } + BOOL result; { LLFastTimer ft(POST_BUILD); @@ -2616,6 +2696,8 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o moveResizeHandlesToFront(); + applyDockState(); + return true; // *TODO: Error checking } diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 2fdaecf59a..ef0d06a58e 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -124,7 +124,10 @@ public: can_tear_off, save_rect, save_visibility, + save_dock_state, can_dock; + Optional<S32> header_height, + legacy_header_height; // HACK see initFromXML() Optional<CommitCallbackParam> open_callback, close_callback; @@ -209,6 +212,7 @@ public: bool isDragOnLeft() const{ return mDragOnLeft; } S32 getMinWidth() const{ return mMinWidth; } S32 getMinHeight() const{ return mMinHeight; } + S32 getHeaderHeight() const { return mHeaderHeight; } virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); @@ -277,8 +281,10 @@ protected: void setRectControl(const std::string& rectname) { mRectControl = rectname; }; void applyRectControl(); + void applyDockState(); void storeRectControl(); void storeVisibilityControl(); + void storeDockStateControl(); void setKey(const LLSD& key); void setInstanceName(const std::string& name); @@ -302,7 +308,10 @@ private: void buildButtons(); BOOL offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButtons index); void addResizeCtrls(); + void layoutResizeCtrls(); + void enableResizeCtrls(bool enable); void addDragHandle(); + void layoutDragHandle(); // repair layout public: // Called when floater is opened, passes mKey @@ -316,6 +325,7 @@ public: protected: std::string mRectControl; std::string mVisibilityControl; + std::string mDocStateControl; LLSD mKey; // Key used for retrieving instances; set (for now) by LLFLoaterReg LLDragHandle* mDragHandle; @@ -340,6 +350,8 @@ private: S32 mMinWidth; S32 mMinHeight; + S32 mHeaderHeight; // height in pixels of header for title, drag bar + S32 mLegacyHeaderHeight;// HACK see initFloaterXML() BOOL mMinimized; BOOL mForeground; diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index 3c5a8a6921..8bb9e0d9ff 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -127,7 +127,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) bool success = LLUICtrlFactory::getInstance()->buildFloater(res, xui_file, NULL); if (!success) { - llwarns << "Failed to buid floater type: '" << name << "'." << llendl; + llwarns << "Failed to build floater type: '" << name << "'." << llendl; return NULL; } @@ -364,6 +364,26 @@ std::string LLFloaterReg::declareVisibilityControl(const std::string& name) } //static +std::string LLFloaterReg::declareDockStateControl(const std::string& name) +{ + std::string controlname = getDockStateControlName(name); + LLUI::sSettingGroups["floater"]->declareBOOL(controlname, FALSE, + llformat("Window Docking state for %s", name.c_str()), + TRUE); + return controlname; + +} + +//static +std::string LLFloaterReg::getDockStateControlName(const std::string& name) +{ + std::string res = std::string("floater_dock_") + name; + LLStringUtil::replaceChar( res, ' ', '_' ); + return res; +} + + +//static void LLFloaterReg::registerControlVariables() { // Iterate through alll registered instance names and register rect and visibility control variables diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 451bd1dbe3..634a235926 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -121,6 +121,10 @@ public: static std::string declareRectControl(const std::string& name); static std::string getVisibilityControlName(const std::string& name); static std::string declareVisibilityControl(const std::string& name); + + static std::string declareDockStateControl(const std::string& name); + static std::string getDockStateControlName(const std::string& name); + static void registerControlVariables(); // Callback wrappers diff --git a/indra/llui/llmenubutton.cpp b/indra/llui/llmenubutton.cpp index 8dbcd6e229..a657ed039a 100644 --- a/indra/llui/llmenubutton.cpp +++ b/indra/llui/llmenubutton.cpp @@ -85,6 +85,8 @@ void LLMenuButton::toggleMenu() void LLMenuButton::hideMenu() { + if(!mMenu) + return; mMenu->setVisible(FALSE); } diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index cf013efca0..91e7e46195 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -2894,8 +2894,8 @@ void hide_top_view( LLView* view ) } -// x and y are the desired location for the popup, NOT necessarily the -// mouse location +// x and y are the desired location for the popup, in the spawning_view's +// coordinate frame, NOT necessarily the mouse location // static void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) { @@ -3435,7 +3435,7 @@ void LLMenuHolderGL::setActivatedItem(LLMenuItemGL* item) LLTearOffMenu::LLTearOffMenu(LLMenuGL* menup) : LLFloater(LLSD()) { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + S32 floater_header_size = getHeaderHeight(); setName(menup->getName()); setTitle(menup->getLabel()); @@ -3479,7 +3479,6 @@ LLTearOffMenu::~LLTearOffMenu() void LLTearOffMenu::draw() { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); mMenu->setBackgroundVisible(isBackgroundOpaque()); mMenu->needsArrange(); diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 48887ec352..09d9e407c7 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -505,7 +505,7 @@ public: void buildDrawLabels(); void createJumpKeys(); - // Show popup at a specific location. + // Show popup at a specific location, in the spawn_view's coordinate frame static void showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y); // Whether to drop shadow menu bar diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index e8ce1a8d97..78738c826d 100644 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -54,7 +54,8 @@ LLMultiFloater::LLMultiFloater(const LLSD& key, const LLFloater::Params& params) void LLMultiFloater::buildTabContainer() { - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; LLTabContainer::Params p; p.name(std::string("Preview Tabs")); @@ -131,7 +132,8 @@ BOOL LLMultiFloater::closeAllFloaters() void LLMultiFloater::growToFit(S32 content_width, S32 content_height) { static LLUICachedControl<S32> tabcntr_close_btn_size ("UITabCntrCloseBtnSize", 0); - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; S32 tabcntr_header_height = LLPANEL_BORDER_WIDTH + tabcntr_close_btn_size; S32 new_width = llmax(getRect().getWidth(), content_width + LLPANEL_BORDER_WIDTH * 2); S32 new_height = llmax(getRect().getHeight(), content_height + floater_header_size + tabcntr_header_height); @@ -432,6 +434,7 @@ void LLMultiFloater::onTabSelected() void LLMultiFloater::setCanResize(BOOL can_resize) { LLFloater::setCanResize(can_resize); + if (!mTabContainer) return; if (isResizable() && mTabContainer->getTabPosition() == LLTabContainer::BOTTOM) { mTabContainer->setRightTabBtnOffset(RESIZE_HANDLE_WIDTH); @@ -455,13 +458,16 @@ BOOL LLMultiFloater::postBuild() } mTabContainer = getChild<LLTabContainer>("Preview Tabs"); + + setCanResize(mResizable); return TRUE; } void LLMultiFloater::updateResizeLimits() { static LLUICachedControl<S32> tabcntr_close_btn_size ("UITabCntrCloseBtnSize", 0); - static LLUICachedControl<S32> floater_header_size ("UIFloaterHeaderSize", 0); + const LLFloater::Params& default_params = LLFloater::getDefaultParams(); + S32 floater_header_size = default_params.header_height; S32 tabcntr_header_height = LLPANEL_BORDER_WIDTH + tabcntr_close_btn_size; // initialize minimum size constraint to the original xml values. S32 new_min_width = mOrigMinWidth; diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 095200ddc3..0d340699c5 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -71,10 +71,12 @@ const LLPanel::Params& LLPanel::getDefaultParams() LLPanel::Params::Params() : has_border("border", false), border(""), - bg_opaque_color("bg_opaque_color"), - bg_alpha_color("bg_alpha_color"), background_visible("background_visible", false), background_opaque("background_opaque", false), + bg_opaque_color("bg_opaque_color"), + bg_alpha_color("bg_alpha_color"), + bg_opaque_image("bg_opaque_image"), + bg_alpha_image("bg_alpha_image"), min_width("min_width", 100), min_height("min_height", 100), strings("string"), @@ -92,10 +94,12 @@ LLPanel::Params::Params() LLPanel::LLPanel(const LLPanel::Params& p) : LLUICtrl(p), - mBgColorAlpha(p.bg_alpha_color()), - mBgColorOpaque(p.bg_opaque_color()), mBgVisible(p.background_visible), mBgOpaque(p.background_opaque), + mBgOpaqueColor(p.bg_opaque_color()), + mBgAlphaColor(p.bg_alpha_color()), + mBgOpaqueImage(p.bg_opaque_image()), + mBgAlphaImage(p.bg_alpha_image()), mDefaultBtn(NULL), mBorder(NULL), mLabel(p.label), @@ -103,6 +107,8 @@ LLPanel::LLPanel(const LLPanel::Params& p) mCommitCallbackRegistrar(false), mEnableCallbackRegistrar(false), mXMLFilename(p.filename) + // *NOTE: Be sure to also change LLPanel::initFromParams(). We have too + // many classes derived from LLPanel to retrofit them all to pass in params. { setIsChrome(FALSE); @@ -178,19 +184,31 @@ void LLPanel::draw() // draw background if( mBgVisible ) { - //RN: I don't see the point of this - S32 left = 0;//LLPANEL_BORDER_WIDTH; - S32 top = getRect().getHeight();// - LLPANEL_BORDER_WIDTH; - S32 right = getRect().getWidth();// - LLPANEL_BORDER_WIDTH; - S32 bottom = 0;//LLPANEL_BORDER_WIDTH; - + LLRect local_rect = getLocalRect(); if (mBgOpaque ) { - gl_rect_2d( left, top, right, bottom, mBgColorOpaque.get() % alpha); + // opaque, in-front look + if (mBgOpaqueImage.notNull()) + { + mBgOpaqueImage->draw( local_rect, UI_VERTEX_COLOR % alpha ); + } + else + { + // fallback to flat colors when there are no images + gl_rect_2d( local_rect, mBgOpaqueColor.get() % alpha); + } } else { - gl_rect_2d( left, top, right, bottom, mBgColorAlpha.get() % alpha); + // transparent, in-back look + if (mBgAlphaImage.notNull()) + { + mBgAlphaImage->draw( local_rect, UI_VERTEX_COLOR % alpha ); + } + else + { + gl_rect_2d( local_rect, mBgAlphaColor.get() % alpha ); + } } } @@ -443,7 +461,8 @@ void LLPanel::initFromParams(const LLPanel::Params& p) setBackgroundOpaque(p.background_opaque); setBackgroundColor(p.bg_opaque_color().get()); setTransparentColor(p.bg_alpha_color().get()); - + mBgOpaqueImage = p.bg_opaque_image(); + mBgAlphaImage = p.bg_alpha_image(); } static LLFastTimer::DeclareTimer FTM_PANEL_SETUP("Panel Setup"); diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index e8db68ffbb..c213809d68 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -48,6 +48,7 @@ const BOOL BORDER_YES = TRUE; const BOOL BORDER_NO = FALSE; class LLButton; +class LLUIImage; /* * General purpose concrete view base class. @@ -72,12 +73,15 @@ public: Optional<bool> has_border; Optional<LLViewBorder::Params> border; - Optional<LLUIColor> bg_opaque_color, - bg_alpha_color; - Optional<bool> background_visible, background_opaque; + Optional<LLUIColor> bg_opaque_color, + bg_alpha_color; + // opaque image is for "panel in foreground" look + Optional<LLUIImage*> bg_opaque_image, + bg_alpha_image; + Optional<S32> min_width, min_height; @@ -127,10 +131,12 @@ public: BOOL hasBorder() const { return mBorder != NULL; } void setBorderVisible( BOOL b ); - 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 setBackgroundColor( const LLColor4& color ) { mBgOpaqueColor = color; } + const LLColor4& getBackgroundColor() const { return mBgOpaqueColor; } + void setTransparentColor(const LLColor4& color) { mBgAlphaColor = color; } + const LLColor4& getTransparentColor() const { return mBgAlphaColor; } + LLPointer<LLUIImage> getBackgroundImage() const { return mBgOpaqueImage; } + LLPointer<LLUIImage> getTransparentImage() const { return mBgAlphaImage; } void setBackgroundVisible( BOOL b ) { mBgVisible = b; } BOOL isBackgroundVisible() const { return mBgVisible; } void setBackgroundOpaque(BOOL b) { mBgOpaque = b; } @@ -248,10 +254,12 @@ protected: std::string mHelpTopic; // the name of this panel's help topic to display in the Help Viewer private: - LLUIColor mBgColorAlpha; - LLUIColor mBgColorOpaque; - BOOL mBgVisible; - BOOL mBgOpaque; + BOOL mBgVisible; // any background at all? + BOOL mBgOpaque; // use opaque color or image + LLUIColor mBgOpaqueColor; + LLUIColor mBgAlphaColor; + LLPointer<LLUIImage> mBgOpaqueImage; // "panel in front" look + LLPointer<LLUIImage> mBgAlphaImage; // "panel in back" look LLViewBorder* mBorder; LLButton* mDefaultBtn; LLUIString mLabel; diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index c8094f9c7c..34501ae080 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -38,10 +38,11 @@ // Library includes #include "lltextbox.h" #include "lliconctrl.h" +#include "llbutton.h" #include "llmenugl.h" // hideMenus() #include "llui.h" // positionViewNearMouse() #include "llwindow.h" - +#include "lltrans.h" // // Constants // @@ -155,7 +156,10 @@ LLToolTip::Params::Params() visible_time_near("visible_time_near", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeNear" )), visible_time_far("visible_time_far", LLUI::sSettingGroups["config"]->getF32( "ToolTipVisibleTimeFar" )), sticky_rect("sticky_rect"), - image("image") + image("image"), + time_based_media("time_based_media", false), + web_based_media("web_based_media", false), + media_playing("media_playing", false) { name = "tooltip"; font = LLFontGL::getFontSansSerif(); @@ -167,7 +171,11 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) : LLPanel(p), mMaxWidth(p.max_width), mHasClickCallback(p.click_callback.isProvided()), - mPadding(p.padding) + mPadding(p.padding), + mTextBox(NULL), + mInfoButton(NULL), + mPlayMediaButton(NULL), + mHomePageButton(NULL) { LLTextBox::Params params; params.initial_value = "tip_text"; @@ -186,25 +194,82 @@ LLToolTip::LLToolTip(const LLToolTip::Params& p) params.allow_html = false; // disallow hyperlinks in tooltips, as they want to spawn their own explanatory tooltips mTextBox = LLUICtrlFactory::create<LLTextBox> (params); addChild(mTextBox); - + + S32 TOOLTIP_ICON_SIZE = 0; + S32 TOOLTIP_PLAYBUTTON_SIZE = 0; if (p.image.isProvided()) { - LLIconCtrl::Params icon_params; - icon_params.name = "tooltip_icon"; + LLButton::Params icon_params; + icon_params.name = "tooltip_info"; LLRect icon_rect; LLUIImage* imagep = p.image; - const S32 TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16); + TOOLTIP_ICON_SIZE = (imagep ? imagep->getWidth() : 16); icon_rect.setOriginAndSize(mPadding, mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); icon_params.rect = icon_rect; - icon_params.follows.flags = FOLLOWS_LEFT | FOLLOWS_BOTTOM; - icon_params.image = p.image; - icon_params.mouse_opaque = false; - addChild(LLUICtrlFactory::create<LLIconCtrl>(icon_params)); - + //icon_params.follows.flags = FOLLOWS_LEFT | FOLLOWS_BOTTOM; + icon_params.image_unselected(imagep); + icon_params.scale_image(true); + icon_params.flash_color(icon_params.highlight_color()); + mInfoButton = LLUICtrlFactory::create<LLButton>(icon_params); + if (p.click_callback.isProvided()) + { + mInfoButton->setCommitCallback(boost::bind(p.click_callback())); + } + addChild(mInfoButton); + // move text over to fit image in mTextBox->translate(TOOLTIP_ICON_SIZE + mPadding, 0); } - + + if (p.time_based_media.isProvided() && p.time_based_media == true) + { + LLButton::Params p_button; + p_button.name(std::string("play_media")); + TOOLTIP_PLAYBUTTON_SIZE = 16; + LLRect button_rect; + button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); + p_button.rect = button_rect; + p_button.image_selected.name("button_anim_pause.tga"); + p_button.image_unselected.name("button_anim_play.tga"); + p_button.scale_image(true); + + mPlayMediaButton = LLUICtrlFactory::create<LLButton>(p_button); + if(p.click_playmedia_callback.isProvided()) + { + mPlayMediaButton->setCommitCallback(boost::bind(p.click_playmedia_callback())); + } + if(p.media_playing.isProvided()) + { + mPlayMediaButton->setToggleState(p.media_playing); + } + addChild(mPlayMediaButton); + + // move text over to fit image in + mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0); + } + + if (p.web_based_media.isProvided() && p.web_based_media == true) + { + LLButton::Params p_w_button; + p_w_button.name(std::string("home_page")); + TOOLTIP_PLAYBUTTON_SIZE = 16; + LLRect button_rect; + button_rect.setOriginAndSize((mPadding +TOOLTIP_ICON_SIZE+ mPadding ), mPadding, TOOLTIP_ICON_SIZE, TOOLTIP_ICON_SIZE); + p_w_button.rect = button_rect; + p_w_button.image_unselected.name("map_home.tga"); + p_w_button.scale_image(true); + + mHomePageButton = LLUICtrlFactory::create<LLButton>(p_w_button); + if(p.click_homepage_callback.isProvided()) + { + mHomePageButton->setCommitCallback(boost::bind(p.click_homepage_callback())); + } + addChild(mHomePageButton); + + // move text over to fit image in + mTextBox->translate(TOOLTIP_PLAYBUTTON_SIZE + mPadding, 0); + } + if (p.click_callback.isProvided()) { setMouseUpCallback(boost::bind(p.click_callback())); @@ -255,6 +320,10 @@ void LLToolTip::setVisible(BOOL visible) BOOL LLToolTip::handleHover(S32 x, S32 y, MASK mask) { + //mInfoButton->setFlashing(true); + if(mInfoButton) + mInfoButton->setHighlight(true); + LLPanel::handleHover(x, y, mask); if (mHasClickCallback) { @@ -263,6 +332,14 @@ BOOL LLToolTip::handleHover(S32 x, S32 y, MASK mask) return TRUE; } +void LLToolTip::onMouseLeave(S32 x, S32 y, MASK mask) +{ + //mInfoButton->setFlashing(true); + if(mInfoButton) + mInfoButton->setHighlight(false); + LLUICtrl::onMouseLeave(x, y, mask); +} + void LLToolTip::draw() { F32 alpha = 1.f; @@ -393,7 +470,9 @@ void LLToolTipMgr::show(const LLToolTip::Params& params) && LLUI::getMouseIdleTime() > params.delay_time) // the mouse has been still long enough { bool tooltip_changed = mLastToolTipParams.message() != params.message() - || mLastToolTipParams.pos() != params.pos(); + || mLastToolTipParams.pos() != params.pos() + || mLastToolTipParams.time_based_media() != params.time_based_media() + || mLastToolTipParams.web_based_media() != params.web_based_media(); bool tooltip_shown = mToolTip && mToolTip->getVisible() diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h index 63e7249a12..4a5f60f93d 100644 --- a/indra/llui/lltooltip.h +++ b/indra/llui/lltooltip.h @@ -81,6 +81,13 @@ public: Optional<click_callback_t> click_callback; Optional<LLUIImage*> image; + + + Optional<bool> time_based_media; + Optional<bool> web_based_media; + Optional<bool> media_playing; + Optional<click_callback_t> click_playmedia_callback; + Optional<click_callback_t> click_homepage_callback; Optional<S32> max_width; Optional<S32> padding; Optional<bool> wrap; @@ -89,7 +96,7 @@ public: }; /*virtual*/ void draw(); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); - + /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask); /*virtual*/ void setValue(const LLSD& value); /*virtual*/ void setVisible(BOOL visible); @@ -101,6 +108,10 @@ public: private: class LLTextBox* mTextBox; + class LLButton* mInfoButton; + class LLButton* mPlayMediaButton; + class LLButton* mHomePageButton; + LLFrameTimer mFadeTimer; LLFrameTimer mVisibleTimer; S32 mMaxWidth; |