diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llui/llscrollcontainer.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llui/llscrollcontainer.cpp')
-rw-r--r-- | linden/indra/llui/llscrollcontainer.cpp | 68 |
1 files changed, 20 insertions, 48 deletions
diff --git a/linden/indra/llui/llscrollcontainer.cpp b/linden/indra/llui/llscrollcontainer.cpp index 8c8b40c..15b59d4 100644 --- a/linden/indra/llui/llscrollcontainer.cpp +++ b/linden/indra/llui/llscrollcontainer.cpp | |||
@@ -29,18 +29,11 @@ | |||
29 | * $/LicenseInfo$ | 29 | * $/LicenseInfo$ |
30 | */ | 30 | */ |
31 | 31 | ||
32 | //***************************************************************************** | ||
33 | // | ||
34 | // A view meant to encapsulate a clipped region which is | ||
35 | // scrollable. It automatically takes care of pixel perfect scrolling | ||
36 | // and cliipping, as well as turning the scrollbars on or off based on | ||
37 | // the width and height of the view you're scrolling. | ||
38 | // | ||
39 | //***************************************************************************** | ||
40 | 32 | ||
41 | #include "linden_common.h" | 33 | #include "linden_common.h" |
42 | 34 | ||
43 | #include "llgl.h" | 35 | #include "llgl.h" |
36 | #include "llglimmediate.h" | ||
44 | 37 | ||
45 | #include "llscrollcontainer.h" | 38 | #include "llscrollcontainer.h" |
46 | #include "llscrollbar.h" | 39 | #include "llscrollbar.h" |
@@ -112,11 +105,11 @@ LLScrollableContainerView::LLScrollableContainerView( const LLString& name, cons | |||
112 | 105 | ||
113 | void LLScrollableContainerView::init() | 106 | void LLScrollableContainerView::init() |
114 | { | 107 | { |
115 | LLRect border_rect( 0, mRect.getHeight(), mRect.getWidth(), 0 ); | 108 | LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 ); |
116 | mBorder = new LLViewBorder( "scroll border", border_rect, LLViewBorder::BEVEL_IN ); | 109 | mBorder = new LLViewBorder( "scroll border", border_rect, LLViewBorder::BEVEL_IN ); |
117 | addChild( mBorder ); | 110 | addChild( mBorder ); |
118 | 111 | ||
119 | mInnerRect.set( 0, mRect.getHeight(), mRect.getWidth(), 0 ); | 112 | mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); |
120 | mInnerRect.stretch( -mBorder->getBorderWidth() ); | 113 | mInnerRect.stretch( -mBorder->getBorderWidth() ); |
121 | 114 | ||
122 | LLRect vertical_scroll_rect = mInnerRect; | 115 | LLRect vertical_scroll_rect = mInnerRect; |
@@ -165,25 +158,6 @@ LLScrollableContainerView::~LLScrollableContainerView( void ) | |||
165 | mScrolledView = NULL; | 158 | mScrolledView = NULL; |
166 | } | 159 | } |
167 | 160 | ||
168 | /* | ||
169 | // scrollbar handlers | ||
170 | void LLScrollableContainerView::horizontalChange( S32 new_pos, | ||
171 | LLScrollbar* sb, | ||
172 | void* user_data ) | ||
173 | { | ||
174 | LLScrollableContainerView* cont = reinterpret_cast<LLScrollableContainerView*>(user_data); | ||
175 | // cont->scrollHorizontal( new_pos ); | ||
176 | } | ||
177 | |||
178 | |||
179 | void LLScrollableContainerView::verticalChange( S32 new_pos, LLScrollbar* sb, | ||
180 | void* user_data ) | ||
181 | { | ||
182 | LLScrollableContainerView* cont = reinterpret_cast<LLScrollableContainerView*>(user_data); | ||
183 | // cont->scrollVertical( new_pos ); | ||
184 | } | ||
185 | */ | ||
186 | |||
187 | // internal scrollbar handlers | 161 | // internal scrollbar handlers |
188 | // virtual | 162 | // virtual |
189 | void LLScrollableContainerView::scrollHorizontal( S32 new_pos ) | 163 | void LLScrollableContainerView::scrollHorizontal( S32 new_pos ) |
@@ -215,7 +189,7 @@ void LLScrollableContainerView::reshape(S32 width, S32 height, | |||
215 | { | 189 | { |
216 | LLUICtrl::reshape( width, height, called_from_parent ); | 190 | LLUICtrl::reshape( width, height, called_from_parent ); |
217 | 191 | ||
218 | mInnerRect.set( 0, mRect.getHeight(), mRect.getWidth(), 0 ); | 192 | mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 ); |
219 | mInnerRect.stretch( -mBorder->getBorderWidth() ); | 193 | mInnerRect.stretch( -mBorder->getBorderWidth() ); |
220 | 194 | ||
221 | if (mScrolledView) | 195 | if (mScrolledView) |
@@ -238,7 +212,7 @@ void LLScrollableContainerView::reshape(S32 width, S32 height, | |||
238 | 212 | ||
239 | BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_parent ) | 213 | BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_parent ) |
240 | { | 214 | { |
241 | if( getVisible() && mEnabled ) | 215 | if( getVisible() && getEnabled() ) |
242 | { | 216 | { |
243 | if( called_from_parent ) | 217 | if( called_from_parent ) |
244 | { | 218 | { |
@@ -278,7 +252,7 @@ BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_ | |||
278 | 252 | ||
279 | BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) | 253 | BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) |
280 | { | 254 | { |
281 | if( mEnabled ) | 255 | if( getEnabled() ) |
282 | { | 256 | { |
283 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) | 257 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) |
284 | { | 258 | { |
@@ -295,7 +269,8 @@ BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) | |||
295 | // Opaque | 269 | // Opaque |
296 | return TRUE; | 270 | return TRUE; |
297 | } | 271 | } |
298 | BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContainerView::SCROLL_ORIENTATION axis) | 272 | |
273 | BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContainerView::SCROLL_ORIENTATION axis) const | ||
299 | { | 274 | { |
300 | if(mScrollbar[axis]->getVisible()) | 275 | if(mScrollbar[axis]->getVisible()) |
301 | { | 276 | { |
@@ -315,6 +290,7 @@ BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContaine | |||
315 | } | 290 | } |
316 | return FALSE; | 291 | return FALSE; |
317 | } | 292 | } |
293 | |||
318 | BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask, | 294 | BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask, |
319 | BOOL drop, | 295 | BOOL drop, |
320 | EDragAndDropType cargo_type, | 296 | EDragAndDropType cargo_type, |
@@ -419,19 +395,19 @@ BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, LLString& msg, LLRec | |||
419 | return TRUE; | 395 | return TRUE; |
420 | } | 396 | } |
421 | 397 | ||
422 | void LLScrollableContainerView::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) | 398 | void LLScrollableContainerView::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const |
423 | { | 399 | { |
424 | const LLRect& rect = mScrolledView->getRect(); | 400 | const LLRect& rect = mScrolledView->getRect(); |
425 | calcVisibleSize(rect, visible_width, visible_height, show_h_scrollbar, show_v_scrollbar); | 401 | calcVisibleSize(rect, visible_width, visible_height, show_h_scrollbar, show_v_scrollbar); |
426 | } | 402 | } |
427 | 403 | ||
428 | void LLScrollableContainerView::calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) | 404 | void LLScrollableContainerView::calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const |
429 | { | 405 | { |
430 | S32 doc_width = doc_rect.getWidth(); | 406 | S32 doc_width = doc_rect.getWidth(); |
431 | S32 doc_height = doc_rect.getHeight(); | 407 | S32 doc_height = doc_rect.getHeight(); |
432 | 408 | ||
433 | *visible_width = mRect.getWidth() - 2 * mBorder->getBorderWidth(); | 409 | *visible_width = getRect().getWidth() - 2 * mBorder->getBorderWidth(); |
434 | *visible_height = mRect.getHeight() - 2 * mBorder->getBorderWidth(); | 410 | *visible_height = getRect().getHeight() - 2 * mBorder->getBorderWidth(); |
435 | 411 | ||
436 | *show_v_scrollbar = FALSE; | 412 | *show_v_scrollbar = FALSE; |
437 | if( *visible_height < doc_height ) | 413 | if( *visible_height < doc_height ) |
@@ -484,7 +460,7 @@ void LLScrollableContainerView::draw() | |||
484 | if( mIsOpaque ) | 460 | if( mIsOpaque ) |
485 | { | 461 | { |
486 | LLGLSNoTexture no_texture; | 462 | LLGLSNoTexture no_texture; |
487 | glColor4fv( mBackgroundColor.mV ); | 463 | gGL.color4fv( mBackgroundColor.mV ); |
488 | gl_rect_2d( mInnerRect ); | 464 | gl_rect_2d( mInnerRect ); |
489 | } | 465 | } |
490 | 466 | ||
@@ -544,7 +520,7 @@ void LLScrollableContainerView::draw() | |||
544 | drawDebugRect(); | 520 | drawDebugRect(); |
545 | } | 521 | } |
546 | } | 522 | } |
547 | } | 523 | } // end draw |
548 | 524 | ||
549 | void LLScrollableContainerView::updateScroll() | 525 | void LLScrollableContainerView::updateScroll() |
550 | { | 526 | { |
@@ -560,9 +536,9 @@ void LLScrollableContainerView::updateScroll() | |||
560 | S32 border_width = mBorder->getBorderWidth(); | 536 | S32 border_width = mBorder->getBorderWidth(); |
561 | if( show_v_scrollbar ) | 537 | if( show_v_scrollbar ) |
562 | { | 538 | { |
563 | if( doc_rect.mTop < mRect.getHeight() - border_width ) | 539 | if( doc_rect.mTop < getRect().getHeight() - border_width ) |
564 | { | 540 | { |
565 | mScrolledView->translate( 0, mRect.getHeight() - border_width - doc_rect.mTop ); | 541 | mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); |
566 | } | 542 | } |
567 | 543 | ||
568 | scrollVertical( mScrollbar[VERTICAL]->getDocPos() ); | 544 | scrollVertical( mScrollbar[VERTICAL]->getDocPos() ); |
@@ -587,7 +563,7 @@ void LLScrollableContainerView::updateScroll() | |||
587 | } | 563 | } |
588 | else | 564 | else |
589 | { | 565 | { |
590 | mScrolledView->translate( 0, mRect.getHeight() - border_width - doc_rect.mTop ); | 566 | mScrolledView->translate( 0, getRect().getHeight() - border_width - doc_rect.mTop ); |
591 | 567 | ||
592 | mScrollbar[VERTICAL]->setVisible( FALSE ); | 568 | mScrollbar[VERTICAL]->setVisible( FALSE ); |
593 | mScrollbar[VERTICAL]->setDocPos( 0 ); | 569 | mScrollbar[VERTICAL]->setDocPos( 0 ); |
@@ -626,7 +602,7 @@ void LLScrollableContainerView::updateScroll() | |||
626 | 602 | ||
627 | mScrollbar[VERTICAL]->setDocSize( doc_height ); | 603 | mScrollbar[VERTICAL]->setDocSize( doc_height ); |
628 | mScrollbar[VERTICAL]->setPageSize( visible_height ); | 604 | mScrollbar[VERTICAL]->setPageSize( visible_height ); |
629 | } | 605 | } // end updateScroll |
630 | 606 | ||
631 | void LLScrollableContainerView::setBorderVisible(BOOL b) | 607 | void LLScrollableContainerView::setBorderVisible(BOOL b) |
632 | { | 608 | { |
@@ -723,7 +699,7 @@ void LLScrollableContainerView::goToBottom() | |||
723 | mScrollbar[VERTICAL]->setDocPos(mScrollbar[VERTICAL]->getDocSize()); | 699 | mScrollbar[VERTICAL]->setDocPos(mScrollbar[VERTICAL]->getDocSize()); |
724 | } | 700 | } |
725 | 701 | ||
726 | S32 LLScrollableContainerView::getBorderWidth() | 702 | S32 LLScrollableContainerView::getBorderWidth() const |
727 | { | 703 | { |
728 | if (mBorder) | 704 | if (mBorder) |
729 | { | 705 | { |
@@ -803,7 +779,3 @@ LLView* LLScrollableContainerView::fromXML(LLXMLNodePtr node, LLView *parent, LL | |||
803 | 779 | ||
804 | return ret; | 780 | return ret; |
805 | } | 781 | } |
806 | |||
807 | ///---------------------------------------------------------------------------- | ||
808 | /// Local function definitions | ||
809 | ///---------------------------------------------------------------------------- | ||