aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lltabcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/lltabcontainer.cpp213
1 files changed, 98 insertions, 115 deletions
diff --git a/linden/indra/llui/lltabcontainer.cpp b/linden/indra/llui/lltabcontainer.cpp
index e632cf1..7f581dc 100644
--- a/linden/indra/llui/lltabcontainer.cpp
+++ b/linden/indra/llui/lltabcontainer.cpp
@@ -64,7 +64,7 @@ const S32 TABCNTRV_HEADER_HEIGHT = LLPANEL_BORDER_WIDTH + TABCNTRV_CLOSE_BTN_SIZ
64const S32 TABCNTRV_ARROW_BTN_SIZE = 16; 64const S32 TABCNTRV_ARROW_BTN_SIZE = 16;
65const S32 TABCNTRV_PAD = 0; 65const S32 TABCNTRV_PAD = 0;
66 66
67 67static LLRegisterWidget<LLTabContainer> r("tab_container");
68 68
69LLTabContainer::LLTabContainer(const LLString& name, const LLRect& rect, TabPosition pos, 69LLTabContainer::LLTabContainer(const LLString& name, const LLRect& rect, TabPosition pos,
70 BOOL bordered, BOOL is_vertical ) 70 BOOL bordered, BOOL is_vertical )
@@ -115,18 +115,6 @@ void LLTabContainer::setValue(const LLSD& value)
115} 115}
116 116
117//virtual 117//virtual
118EWidgetType LLTabContainer::getWidgetType() const
119{
120 return WIDGET_TYPE_TAB_CONTAINER;
121}
122
123//virtual
124LLString LLTabContainer::getWidgetTag() const
125{
126 return LL_TAB_CONTAINER_COMMON_TAG;
127}
128
129//virtual
130void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent) 118void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent)
131{ 119{
132 LLPanel::reshape( width, height, called_from_parent ); 120 LLPanel::reshape( width, height, called_from_parent );
@@ -134,7 +122,7 @@ void LLTabContainer::reshape(S32 width, S32 height, BOOL called_from_parent)
134} 122}
135 123
136//virtual 124//virtual
137LLView* LLTabContainer::getChildByName(const LLString& name, BOOL recurse) const 125LLView* LLTabContainer::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const
138{ 126{
139 tuple_list_t::const_iterator itor; 127 tuple_list_t::const_iterator itor;
140 for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) 128 for (itor = mTabList.begin(); itor != mTabList.end(); ++itor)
@@ -145,19 +133,20 @@ LLView* LLTabContainer::getChildByName(const LLString& name, BOOL recurse) const
145 return panel; 133 return panel;
146 } 134 }
147 } 135 }
136
148 if (recurse) 137 if (recurse)
149 { 138 {
150 for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) 139 for (itor = mTabList.begin(); itor != mTabList.end(); ++itor)
151 { 140 {
152 LLPanel *panel = (*itor)->mTabPanel; 141 LLPanel *panel = (*itor)->mTabPanel;
153 LLView *child = panel->getChild<LLView>(name, recurse); 142 LLView *child = panel->getChildView(name, recurse, FALSE);
154 if (child) 143 if (child)
155 { 144 {
156 return child; 145 return child;
157 } 146 }
158 } 147 }
159 } 148 }
160 return LLView::getChildByName(name, recurse); 149 return LLView::getChildView(name, recurse, create_if_missing);
161} 150}
162 151
163// virtual 152// virtual
@@ -185,124 +174,122 @@ void LLTabContainer::draw()
185 } 174 }
186 175
187 setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f))); 176 setScrollPosPixels((S32)lerp((F32)getScrollPosPixels(), (F32)target_pixel_scroll, LLCriticalDamp::getInterpolant(0.08f)));
188 if( getVisible() ) 177
178 BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0);
179 if (!mIsVertical)
189 { 180 {
190 BOOL has_scroll_arrows = (mMaxScrollPos > 0) || (mScrollPosPixels > 0); 181 mJumpPrevArrowBtn->setVisible( has_scroll_arrows );
191 if (!mIsVertical) 182 mJumpNextArrowBtn->setVisible( has_scroll_arrows );
192 { 183 }
193 mJumpPrevArrowBtn->setVisible( has_scroll_arrows ); 184 mPrevArrowBtn->setVisible( has_scroll_arrows );
194 mJumpNextArrowBtn->setVisible( has_scroll_arrows ); 185 mNextArrowBtn->setVisible( has_scroll_arrows );
195 }
196 mPrevArrowBtn->setVisible( has_scroll_arrows );
197 mNextArrowBtn->setVisible( has_scroll_arrows );
198 186
199 S32 left = 0, top = 0; 187 S32 left = 0, top = 0;
200 if (mIsVertical) 188 if (mIsVertical)
201 { 189 {
202 top = getRect().getHeight() - getTopBorderHeight() - LLPANEL_BORDER_WIDTH - 1 - (has_scroll_arrows ? TABCNTRV_ARROW_BTN_SIZE : 0); 190 top = getRect().getHeight() - getTopBorderHeight() - LLPANEL_BORDER_WIDTH - 1 - (has_scroll_arrows ? TABCNTRV_ARROW_BTN_SIZE : 0);
203 top += getScrollPosPixels(); 191 top += getScrollPosPixels();
204 } 192 }
205 else 193 else
206 { 194 {
207 // Set the leftmost position of the tab buttons. 195 // Set the leftmost position of the tab buttons.
208 left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD); 196 left = LLPANEL_BORDER_WIDTH + (has_scroll_arrows ? (TABCNTR_ARROW_BTN_SIZE * 2) : TABCNTR_TAB_H_PAD);
209 left -= getScrollPosPixels(); 197 left -= getScrollPosPixels();
210 } 198 }
211 199
212 // Hide all the buttons 200 // Hide all the buttons
201 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
202 {
203 LLTabTuple* tuple = *iter;
204 tuple->mButton->setVisible( FALSE );
205 }
206
207 LLPanel::draw();
208
209 // if tabs are hidden, don't draw them and leave them in the invisible state
210 if (!getTabsHidden())
211 {
212 // Show all the buttons
213 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) 213 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
214 { 214 {
215 LLTabTuple* tuple = *iter; 215 LLTabTuple* tuple = *iter;
216 tuple->mButton->setVisible( FALSE ); 216 tuple->mButton->setVisible( TRUE );
217 } 217 }
218 218
219 LLPanel::draw(); 219 // Draw some of the buttons...
220 220 LLRect clip_rect = getLocalRect();
221 // if tabs are hidden, don't draw them and leave them in the invisible state 221 if (has_scroll_arrows)
222 if (!getTabsHidden())
223 { 222 {
224 // Show all the buttons 223 // ...but clip them.
225 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) 224 if (mIsVertical)
226 { 225 {
227 LLTabTuple* tuple = *iter; 226 clip_rect.mBottom = mNextArrowBtn->getRect().mTop + 3*TABCNTRV_PAD;
228 tuple->mButton->setVisible( TRUE ); 227 clip_rect.mTop = mPrevArrowBtn->getRect().mBottom - 3*TABCNTRV_PAD;
229 } 228 }
230 229 else
231 // Draw some of the buttons...
232 LLRect clip_rect = getLocalRect();
233 if (has_scroll_arrows)
234 { 230 {
235 // ...but clip them. 231 clip_rect.mLeft = mPrevArrowBtn->getRect().mRight;
236 if (mIsVertical) 232 clip_rect.mRight = mNextArrowBtn->getRect().mLeft;
237 {
238 clip_rect.mBottom = mNextArrowBtn->getRect().mTop + 3*TABCNTRV_PAD;
239 clip_rect.mTop = mPrevArrowBtn->getRect().mBottom - 3*TABCNTRV_PAD;
240 }
241 else
242 {
243 clip_rect.mLeft = mPrevArrowBtn->getRect().mRight;
244 clip_rect.mRight = mNextArrowBtn->getRect().mLeft;
245 }
246 } 233 }
247 LLLocalClipRect clip(clip_rect); 234 }
235 LLLocalClipRect clip(clip_rect);
248 236
249 S32 max_scroll_visible = getTabCount() - getMaxScrollPos() + getScrollPos(); 237 S32 max_scroll_visible = getTabCount() - getMaxScrollPos() + getScrollPos();
250 S32 idx = 0; 238 S32 idx = 0;
251 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter) 239 for(tuple_list_t::iterator iter = mTabList.begin(); iter != mTabList.end(); ++iter)
252 { 240 {
253 LLTabTuple* tuple = *iter; 241 LLTabTuple* tuple = *iter;
254 242
255 tuple->mButton->translate( left ? left - tuple->mButton->getRect().mLeft : 0, 243 tuple->mButton->translate( left ? left - tuple->mButton->getRect().mLeft : 0,
256 top ? top - tuple->mButton->getRect().mTop : 0 ); 244 top ? top - tuple->mButton->getRect().mTop : 0 );
257 if (top) top -= BTN_HEIGHT + TABCNTRV_PAD; 245 if (top) top -= BTN_HEIGHT + TABCNTRV_PAD;
258 if (left) left += tuple->mButton->getRect().getWidth(); 246 if (left) left += tuple->mButton->getRect().getWidth();
259 247
260 if (!mIsVertical) 248 if (!mIsVertical)
249 {
250 if( idx < getScrollPos() )
261 { 251 {
262 if( idx < getScrollPos() ) 252 if( tuple->mButton->getFlashing() )
263 {
264 if( tuple->mButton->getFlashing() )
265 {
266 mPrevArrowBtn->setFlashing( TRUE );
267 }
268 }
269 else if( max_scroll_visible < idx )
270 { 253 {
271 if( tuple->mButton->getFlashing() ) 254 mPrevArrowBtn->setFlashing( TRUE );
272 {
273 mNextArrowBtn->setFlashing( TRUE );
274 }
275 } 255 }
276 } 256 }
277 LLUI::pushMatrix(); 257 else if( max_scroll_visible < idx )
278 { 258 {
279 LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f); 259 if( tuple->mButton->getFlashing() )
280 tuple->mButton->draw(); 260 {
261 mNextArrowBtn->setFlashing( TRUE );
262 }
281 } 263 }
282 LLUI::popMatrix();
283
284 idx++;
285 } 264 }
286 265 LLUI::pushMatrix();
287
288 if( mIsVertical && has_scroll_arrows )
289 { 266 {
290 // Redraw the arrows so that they appears on top. 267 LLUI::translate((F32)tuple->mButton->getRect().mLeft, (F32)tuple->mButton->getRect().mBottom, 0.f);
291 gGL.pushMatrix(); 268 tuple->mButton->draw();
292 gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
293 mPrevArrowBtn->draw();
294 gGL.popMatrix();
295
296 gGL.pushMatrix();
297 gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
298 mNextArrowBtn->draw();
299 gGL.popMatrix();
300 } 269 }
270 LLUI::popMatrix();
271
272 idx++;
301 } 273 }
302 274
303 mPrevArrowBtn->setFlashing(FALSE); 275
304 mNextArrowBtn->setFlashing(FALSE); 276 if( mIsVertical && has_scroll_arrows )
277 {
278 // Redraw the arrows so that they appears on top.
279 gGL.pushMatrix();
280 gGL.translatef((F32)mPrevArrowBtn->getRect().mLeft, (F32)mPrevArrowBtn->getRect().mBottom, 0.f);
281 mPrevArrowBtn->draw();
282 gGL.popMatrix();
283
284 gGL.pushMatrix();
285 gGL.translatef((F32)mNextArrowBtn->getRect().mLeft, (F32)mNextArrowBtn->getRect().mBottom, 0.f);
286 mNextArrowBtn->draw();
287 gGL.popMatrix();
288 }
305 } 289 }
290
291 mPrevArrowBtn->setFlashing(FALSE);
292 mNextArrowBtn->setFlashing(FALSE);
306} 293}
307 294
308 295
@@ -524,12 +511,8 @@ BOOL LLTabContainer::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_
524} 511}
525 512
526// virtual 513// virtual
527BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) 514BOOL LLTabContainer::handleKeyHere(KEY key, MASK mask)
528{ 515{
529 if (!getEnabled()) return FALSE;
530
531 if (!gFocusMgr.childHasKeyboardFocus(this)) return FALSE;
532
533 BOOL handled = FALSE; 516 BOOL handled = FALSE;
534 if (key == KEY_LEFT && mask == MASK_ALT) 517 if (key == KEY_LEFT && mask == MASK_ALT)
535 { 518 {
@@ -687,7 +670,7 @@ void LLTabContainer::addTabPanel(LLPanel* child,
687 // already a child of mine 670 // already a child of mine
688 return; 671 return;
689 } 672 }
690 const LLFontGL* font = gResMgr->getRes( mIsVertical ? LLFONT_SANSSERIF : LLFONT_SANSSERIF_SMALL ); 673 const LLFontGL* font = LLResMgr::getInstance()->getRes( mIsVertical ? LLFONT_SANSSERIF : LLFONT_SANSSERIF_SMALL );
691 674
692 // Store the original label for possible xml export. 675 // Store the original label for possible xml export.
693 child->setLabel(label); 676 child->setLabel(label);
@@ -1272,7 +1255,7 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const L
1272 1255
1273 if (!mIsVertical) 1256 if (!mIsVertical)
1274 { 1257 {
1275 const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); 1258 const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
1276 // remove current width from total tab strip width 1259 // remove current width from total tab strip width
1277 mTotalTabWidth -= tuple->mButton->getRect().getWidth(); 1260 mTotalTabWidth -= tuple->mButton->getRect().getWidth();
1278 1261
@@ -1353,7 +1336,7 @@ void LLTabContainer::setPanelTitle(S32 index, const LLString& title)
1353 { 1336 {
1354 LLTabTuple* tuple = getTab(index); 1337 LLTabTuple* tuple = getTab(index);
1355 LLButton* tab_button = tuple->mButton; 1338 LLButton* tab_button = tuple->mButton;
1356 const LLFontGL* fontp = gResMgr->getRes( LLFONT_SANSSERIF_SMALL ); 1339 const LLFontGL* fontp = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF_SMALL );
1357 mTotalTabWidth -= tab_button->getRect().getWidth(); 1340 mTotalTabWidth -= tab_button->getRect().getWidth();
1358 tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight()); 1341 tab_button->reshape(llclamp(fontp->getWidth(title) + TAB_PADDING + tuple->mPadding, mMinTabWidth, mMaxTabWidth), tab_button->getRect().getHeight());
1359 mTotalTabWidth += tab_button->getRect().getWidth(); 1342 mTotalTabWidth += tab_button->getRect().getWidth();