diff options
-rw-r--r-- | indra/llui/lltabcontainer.cpp | 145 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.h | 18 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.cpp | 48 | ||||
-rw-r--r-- | indra/newview/llimfloatercontainer.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_im_container.xml | 5 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/widgets/tab_container.xml | 1 |
6 files changed, 170 insertions, 48 deletions
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 6be76605fd..d959d3099c 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -35,7 +35,6 @@ #include "lltabcontainer.h" #include "llfocusmgr.h" -#include "llbutton.h" #include "lllocalcliprect.h" #include "llrect.h" #include "llresizehandle.h" @@ -96,6 +95,88 @@ public: //---------------------------------------------------------------------------- +//============================================================================ +/* + * @file lltabcontainer.cpp + * @brief class implements LLButton with LLIconCtrl on it + */ +class LLCustomButtonIconCtrl : public LLButton +{ +public: + struct Params + : public LLInitParam::Block<Params, LLButton::Params> + { + // LEFT, RIGHT, TOP, BOTTOM paddings of LLIconCtrl in this class has same value + Optional<S32> icon_ctrl_pad; + + Params(): + icon_ctrl_pad("icon_ctrl_pad", 1) + {} + }; + +protected: + friend class LLUICtrlFactory; + LLCustomButtonIconCtrl(const Params& p): + LLButton(p), + mIcon(NULL), + mIconCtrlPad(p.icon_ctrl_pad) + {} + +public: + + void updateLayout() + { + LLRect button_rect = getRect(); + LLRect icon_rect = mIcon->getRect(); + + S32 icon_size = button_rect.getHeight() - 2*mIconCtrlPad; + + switch(mIconAlignment) + { + case LLFontGL::LEFT: + icon_rect.setLeftTopAndSize(button_rect.mLeft + mIconCtrlPad, button_rect.mTop - mIconCtrlPad, + icon_size, icon_size); + setLeftHPad(icon_size + mIconCtrlPad * 2); + break; + case LLFontGL::HCENTER: + //*TODO implement for HCENTER icon alignment + break; + case LLFontGL::RIGHT: + icon_rect.setLeftTopAndSize(button_rect.mRight - mIconCtrlPad - icon_size, button_rect.mTop - mIconCtrlPad, + icon_size, icon_size); + setRightHPad(icon_size + mIconCtrlPad * 2); + break; + default: + break; + } + mIcon->setRect(icon_rect); + } + + void setIcon(LLIconCtrl* icon, LLFontGL::HAlign alignment = LLFontGL::LEFT) + { + if(icon) + { + if(mIcon) + { + removeChild(mIcon); + mIcon->die(); + } + mIcon = icon; + mIconAlignment = alignment; + + addChild(mIcon); + updateLayout(); + } + } + + +private: + LLIconCtrl* mIcon; + LLFontGL::HAlign mIconAlignment; + S32 mIconCtrlPad; +}; +//============================================================================ + struct LLPlaceHolderPanel : public LLPanel { // create dummy param block to register with "placeholder" nane @@ -127,7 +208,9 @@ LLTabContainer::Params::Params() tab_padding_right("tab_padding_right"), first_tab("first_tab"), middle_tab("middle_tab"), - last_tab("last_tab") + last_tab("last_tab"), + use_custom_icon_ctrl("use_custom_icon_ctrl", false), + tab_icon_ctrl_pad("tab_icon_ctrl_pad", 0) { name(std::string("tab_container")); mouse_opaque = false; @@ -162,7 +245,9 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p) mFont(p.font), mFirstTabParams(p.first_tab), mMiddleTabParams(p.middle_tab), - mLastTabParams(p.last_tab) + mLastTabParams(p.last_tab), + mCustomIconCtrlUsed(p.use_custom_icon_ctrl), + mTabIconCtrlPad(p.tab_icon_ctrl_pad) { static LLUICachedControl<S32> tabcntr_vert_tab_min_width ("UITabCntrVertTabMinWidth", 0); @@ -905,6 +990,11 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) LLTextBox* textbox = NULL; LLButton* btn = NULL; + LLCustomButtonIconCtrl::Params custom_btn_params; + { + custom_btn_params.icon_ctrl_pad(mTabIconCtrlPad); + } + LLButton::Params normal_btn_params; if (placeholder) { @@ -924,7 +1014,9 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) { if (mIsVertical) { - LLButton::Params p; + LLButton::Params& p = (mCustomIconCtrlUsed)? + custom_btn_params:normal_btn_params; + p.name(std::string("vert tab button")); p.rect(btn_rect); p.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT); @@ -942,11 +1034,22 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) { p.pad_left(indent); } - btn = LLUICtrlFactory::create<LLButton>(p); + + + if(mCustomIconCtrlUsed) + { + btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params); + + } + else + { + btn = LLUICtrlFactory::create<LLButton>(p); + } } else { - LLButton::Params p; + LLButton::Params& p = (mCustomIconCtrlUsed)? + custom_btn_params:normal_btn_params; p.name(std::string(child->getName()) + " tab"); p.rect(btn_rect); p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child)); @@ -980,7 +1083,14 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) p.follows.flags = p.follows.flags() | FOLLOWS_BOTTOM; } -++ btn = LLUICtrlFactory::create<LLButton>(p); + if(mCustomIconCtrlUsed) + { + btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params); + } + else + { + btn = LLUICtrlFactory::create<LLButton>(p); + } } } @@ -1484,7 +1594,7 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const L if( tuple ) { tuple->mButton->setImageOverlay(image_name, LLFontGL::LEFT, color); - reshape_tuple(tuple); + reshapeTuple(tuple); } } @@ -1494,11 +1604,26 @@ void LLTabContainer::setTabImage(LLPanel* child, const LLUUID& image_id, const L if( tuple ) { tuple->mButton->setImageOverlay(image_id, LLFontGL::LEFT, color); - reshape_tuple(tuple); + reshapeTuple(tuple); + } +} + +void LLTabContainer::setTabImage(LLPanel* child, LLIconCtrl* icon) +{ + LLTabTuple* tuple = getTabByPanel(child); + LLCustomButtonIconCtrl* button; + + if(tuple) + { + button = dynamic_cast<LLCustomButtonIconCtrl*>(tuple->mButton); + if(button) + { + button->setIcon(icon); + } } } -void LLTabContainer::reshape_tuple(LLTabTuple* tuple) +void LLTabContainer::reshapeTuple(LLTabTuple* tuple) { static LLUICachedControl<S32> tab_padding ("UITabPadding", 0); static LLUICachedControl<S32> image_left_padding ("UIButtonImageLeftPadding", 4); diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index 2a55877d3c..4b5d45fb73 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -36,6 +36,8 @@ #include "llpanel.h" #include "lltextbox.h" #include "llframetimer.h" +#include "lliconctrl.h" +#include "llbutton.h" class LLTabTuple; @@ -90,6 +92,16 @@ public: middle_tab, last_tab; + /** + * Use LLCustomButtonIconCtrl or LLButton in LLTabTuple + */ + Optional<bool> use_custom_icon_ctrl; + + /** + * Paddings for LLIconCtrl in case of LLCustomButtonIconCtrl usage(use_custom_icon_ctrl = true) + */ + Optional<S32> tab_icon_ctrl_pad; + Params(); }; @@ -173,6 +185,7 @@ public: void setTabPanelFlashing(LLPanel* child, BOOL state); void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white); void setTabImage(LLPanel* child, const LLUUID& img_id, const LLColor4& color = LLColor4::white); + void setTabImage(LLPanel* child, LLIconCtrl* icon); void setTitle( const std::string& title ); const std::string getPanelTitle(S32 index); @@ -228,7 +241,7 @@ private: // updates tab button images given the tuple, tab position and the corresponding params void update_images(LLTabTuple* tuple, TabParams params, LLTabContainer::TabPosition pos); - void reshape_tuple(LLTabTuple* tuple); + void reshapeTuple(LLTabTuple* tuple); // Variables @@ -278,6 +291,9 @@ private: TabParams mFirstTabParams; TabParams mMiddleTabParams; TabParams mLastTabParams; + + bool mCustomIconCtrlUsed; + S32 mTabIconCtrlPad; }; #endif // LL_TABCONTAINER_H diff --git a/indra/newview/llimfloatercontainer.cpp b/indra/newview/llimfloatercontainer.cpp index 22eb9a51d2..9539553121 100644 --- a/indra/newview/llimfloatercontainer.cpp +++ b/indra/newview/llimfloatercontainer.cpp @@ -37,6 +37,7 @@ #include "llfloaterreg.h" #include "llimview.h" #include "llavatariconctrl.h" +#include "llgroupiconctrl.h" #include "llagent.h" // @@ -90,43 +91,27 @@ void LLIMFloaterContainer::addFloater(LLFloater* floaterp, LLUUID session_id = floaterp->getKey(); + LLIconCtrl* icon = 0; + if(gAgent.isInGroup(session_id)) { - mSessions[session_id] = floaterp; - LLGroupMgrGroupData* group_data = LLGroupMgr::getInstance()->getGroupData(session_id); - LLGroupMgr* gm = LLGroupMgr::getInstance(); - gm->addObserver(session_id, this); - floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, session_id)); + LLGroupIconCtrl::Params icon_params = LLUICtrlFactory::instance().getDefaultParams<LLGroupIconCtrl>(); + icon_params.group_id = session_id; + icon = LLUICtrlFactory::instance().createWidget<LLGroupIconCtrl>(icon_params); - if (group_data && group_data->mInsigniaID.notNull()) - { - mTabContainer->setTabImage(get_ptr_in_map(mSessions, session_id), group_data->mInsigniaID); - } - else - { - mTabContainer->setTabImage(floaterp, "Generic_Group"); - gm->sendGroupPropertiesRequest(session_id); - } + mSessions[session_id] = floaterp; } else { LLUUID avatar_id = LLIMModel::getInstance()->getOtherParticipantID(session_id); - LLAvatarPropertiesProcessor& app = LLAvatarPropertiesProcessor::instance(); - app.addObserver(avatar_id, this); - floaterp->mCloseSignal.connect(boost::bind(&LLIMFloaterContainer::onCloseFloater, this, avatar_id)); - mSessions[avatar_id] = floaterp; - LLUUID* icon_id_ptr = LLAvatarIconIDCache::getInstance()->get(avatar_id); - if(icon_id_ptr && icon_id_ptr->notNull()) - { - mTabContainer->setTabImage(floaterp, *icon_id_ptr); - } - else - { - mTabContainer->setTabImage(floaterp, "Generic_Person"); - app.sendAvatarPropertiesRequest(avatar_id); - } + LLAvatarIconCtrl::Params icon_params = LLUICtrlFactory::instance().getDefaultParams<LLAvatarIconCtrl>(); + icon_params.avatar_id = avatar_id; + icon = LLUICtrlFactory::instance().createWidget<LLAvatarIconCtrl>(icon_params); + + mSessions[avatar_id] = floaterp; } + mTabContainer->setTabImage(floaterp, icon); } void LLIMFloaterContainer::processProperties(void* data, enum EAvatarProcessorType type) @@ -159,13 +144,6 @@ void LLIMFloaterContainer::changed(const LLUUID& group_id, LLGroupChange gc) } } -void LLIMFloaterContainer::onCloseFloater(LLUUID id) -{ - LLAvatarPropertiesProcessor::instance().removeObserver(id, this); - LLGroupMgr::instance().removeObserver(id, this); - -} - void LLIMFloaterContainer::onNewMessageReceived(const LLSD& data) { LLUUID session_id = data["from_id"].asUUID(); diff --git a/indra/newview/llimfloatercontainer.h b/indra/newview/llimfloatercontainer.h index bc06f0cbd3..daf367da11 100644 --- a/indra/newview/llimfloatercontainer.h +++ b/indra/newview/llimfloatercontainer.h @@ -69,7 +69,6 @@ private: typedef std::map<LLUUID,LLFloater*> avatarID_panel_map_t; avatarID_panel_map_t mSessions; - void onCloseFloater(LLUUID avatar_id); void onNewMessageReceived(const LLSD& data); }; diff --git a/indra/newview/skins/default/xui/en/floater_im_container.xml b/indra/newview/skins/default/xui/en/floater_im_container.xml index bd25288a9e..978b40da77 100644 --- a/indra/newview/skins/default/xui/en/floater_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_im_container.xml @@ -19,8 +19,11 @@ left="1" name="im_box_tab_container" tab_position="bottom" - tab_width="80" + tab_width="64" + tab_max_width = "134" tab_height="16" + use_custom_icon_ctrl="true" + tab_icon_ctrl_pad="2" top="0" width="390" /> <icon diff --git a/indra/newview/skins/default/xui/en/widgets/tab_container.xml b/indra/newview/skins/default/xui/en/widgets/tab_container.xml index 597c4e83b6..4a163fc1e3 100644 --- a/indra/newview/skins/default/xui/en/widgets/tab_container.xml +++ b/indra/newview/skins/default/xui/en/widgets/tab_container.xml @@ -5,6 +5,7 @@ label_pad_left - padding to the left of tab button labels --> <tab_container tab_min_width="60" tab_max_width="150" + use_custom_icon_ctrl="false" halign="center" font="SansSerifSmall" tab_height="21" |