aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llview.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/llview.cpp1042
1 files changed, 418 insertions, 624 deletions
diff --git a/linden/indra/llui/llview.cpp b/linden/indra/llui/llview.cpp
index 39398b0..fbcb69e 100644
--- a/linden/indra/llui/llview.cpp
+++ b/linden/indra/llui/llview.cpp
@@ -37,6 +37,7 @@
37#include <cassert> 37#include <cassert>
38#include <boost/tokenizer.hpp> 38#include <boost/tokenizer.hpp>
39 39
40#include "llglimmediate.h"
40#include "llevent.h" 41#include "llevent.h"
41#include "llfontgl.h" 42#include "llfontgl.h"
42#include "llfocusmgr.h" 43#include "llfocusmgr.h"
@@ -61,48 +62,11 @@ BOOL LLView::sForceReshape = FALSE;
61LLView* LLView::sEditingUIView = NULL; 62LLView* LLView::sEditingUIView = NULL;
62S32 LLView::sLastLeftXML = S32_MIN; 63S32 LLView::sLastLeftXML = S32_MIN;
63S32 LLView::sLastBottomXML = S32_MIN; 64S32 LLView::sLastBottomXML = S32_MIN;
64std::map<LLViewHandle,LLView*> LLView::sViewHandleMap;
65
66S32 LLViewHandle::sNextID = 0;
67LLViewHandle LLViewHandle::sDeadHandle;
68 65
69#if LL_DEBUG 66#if LL_DEBUG
70BOOL LLView::sIsDrawing = FALSE; 67BOOL LLView::sIsDrawing = FALSE;
71#endif 68#endif
72 69
73//static
74LLView* LLView::getViewByHandle(LLViewHandle handle)
75{
76 if (handle == LLViewHandle::sDeadHandle)
77 {
78 return NULL;
79 }
80 std::map<LLViewHandle,LLView*>::iterator iter = sViewHandleMap.find(handle);
81 if (iter != sViewHandleMap.end())
82 {
83 return iter->second;
84 }
85 else
86 {
87 return NULL;
88 }
89}
90
91//static
92BOOL LLView::deleteViewByHandle(LLViewHandle handle)
93{
94 std::map<LLViewHandle,LLView*>::iterator iter = sViewHandleMap.find(handle);
95 if (iter != sViewHandleMap.end())
96 {
97 delete iter->second; // will remove from map
98 return TRUE;
99 }
100 else
101 {
102 return FALSE;
103 }
104}
105
106LLView::LLView() : 70LLView::LLView() :
107 mParentView(NULL), 71 mParentView(NULL),
108 mReshapeFlags(FOLLOWS_NONE), 72 mReshapeFlags(FOLLOWS_NONE),
@@ -115,11 +79,8 @@ LLView::LLView() :
115 mLastVisible(TRUE), 79 mLastVisible(TRUE),
116 mUseBoundingRect(FALSE), 80 mUseBoundingRect(FALSE),
117 mVisible(TRUE), 81 mVisible(TRUE),
118 mHidden(FALSE),
119 mNextInsertionOrdinal(0) 82 mNextInsertionOrdinal(0)
120{ 83{
121 mViewHandle.init();
122 sViewHandleMap[mViewHandle] = this;
123} 84}
124 85
125LLView::LLView(const LLString& name, BOOL mouse_opaque) : 86LLView::LLView(const LLString& name, BOOL mouse_opaque) :
@@ -135,11 +96,8 @@ LLView::LLView(const LLString& name, BOOL mouse_opaque) :
135 mLastVisible(TRUE), 96 mLastVisible(TRUE),
136 mUseBoundingRect(FALSE), 97 mUseBoundingRect(FALSE),
137 mVisible(TRUE), 98 mVisible(TRUE),
138 mHidden(FALSE),
139 mNextInsertionOrdinal(0) 99 mNextInsertionOrdinal(0)
140{ 100{
141 mViewHandle.init();
142 sViewHandleMap[mViewHandle] = this;
143} 101}
144 102
145 103
@@ -159,11 +117,8 @@ LLView::LLView(
159 mLastVisible(TRUE), 117 mLastVisible(TRUE),
160 mUseBoundingRect(FALSE), 118 mUseBoundingRect(FALSE),
161 mVisible(TRUE), 119 mVisible(TRUE),
162 mHidden(FALSE),
163 mNextInsertionOrdinal(0) 120 mNextInsertionOrdinal(0)
164{ 121{
165 mViewHandle.init();
166 sViewHandleMap[mViewHandle] = this;
167} 122}
168 123
169 124
@@ -183,8 +138,6 @@ LLView::~LLView()
183 gFocusMgr.removeMouseCaptureWithoutCallback( this ); 138 gFocusMgr.removeMouseCaptureWithoutCallback( this );
184 } 139 }
185 140
186 sViewHandleMap.erase(mViewHandle);
187
188 deleteAllChildren(); 141 deleteAllChildren();
189 142
190 if (mParentView != NULL) 143 if (mParentView != NULL)
@@ -203,7 +156,7 @@ LLView::~LLView()
203} 156}
204 157
205// virtual 158// virtual
206BOOL LLView::isView() 159BOOL LLView::isView() const
207{ 160{
208 return TRUE; 161 return TRUE;
209} 162}
@@ -215,16 +168,12 @@ BOOL LLView::isCtrl() const
215} 168}
216 169
217// virtual 170// virtual
218BOOL LLView::isPanel() 171BOOL LLView::isPanel() const
219{ 172{
220 return FALSE; 173 return FALSE;
221} 174}
222 175
223void LLView::setMouseOpaque(BOOL b) 176// virtual
224{
225 mMouseOpaque = b;
226}
227
228void LLView::setToolTip(const LLStringExplicit& msg) 177void LLView::setToolTip(const LLStringExplicit& msg)
229{ 178{
230 mToolTipMsg = msg; 179 mToolTipMsg = msg;
@@ -248,52 +197,6 @@ void LLView::setRect(const LLRect& rect)
248 updateBoundingRect(); 197 updateBoundingRect();
249} 198}
250 199
251
252void LLView::setFollows(U32 flags)
253{
254 mReshapeFlags = flags;
255}
256
257void LLView::setFollowsNone()
258{
259 mReshapeFlags = FOLLOWS_NONE;
260}
261
262void LLView::setFollowsLeft()
263{
264 mReshapeFlags |= FOLLOWS_LEFT;
265}
266
267void LLView::setFollowsTop()
268{
269 mReshapeFlags |= FOLLOWS_TOP;
270}
271
272void LLView::setFollowsRight()
273{
274 mReshapeFlags |= FOLLOWS_RIGHT;
275}
276
277void LLView::setFollowsBottom()
278{
279 mReshapeFlags |= FOLLOWS_BOTTOM;
280}
281
282void LLView::setFollowsAll()
283{
284 mReshapeFlags |= FOLLOWS_ALL;
285}
286
287void LLView::setSoundFlags(U8 flags)
288{
289 mSoundFlags = flags;
290}
291
292void LLView::setName(LLString name)
293{
294 mName = name;
295}
296
297void LLView::setUseBoundingRect( BOOL use_bounding_rect ) 200void LLView::setUseBoundingRect( BOOL use_bounding_rect )
298{ 201{
299 if (mUseBoundingRect != use_bounding_rect) 202 if (mUseBoundingRect != use_bounding_rect)
@@ -308,11 +211,6 @@ BOOL LLView::getUseBoundingRect()
308 return mUseBoundingRect; 211 return mUseBoundingRect;
309} 212}
310 213
311const LLString& LLView::getToolTip()
312{
313 return mToolTipMsg.getString();
314}
315
316// virtual 214// virtual
317const LLString& LLView::getName() const 215const LLString& LLView::getName() const
318{ 216{
@@ -452,8 +350,6 @@ void LLView::removeCtrl(LLUICtrl* ctrl)
452 } 350 }
453} 351}
454 352
455S32 LLView::getDefaultTabGroup() const { return mDefaultTabGroup; }
456
457LLView::ctrl_list_t LLView::getCtrlList() const 353LLView::ctrl_list_t LLView::getCtrlList() const
458{ 354{
459 ctrl_list_t controls; 355 ctrl_list_t controls;
@@ -476,12 +372,6 @@ LLView::ctrl_list_t LLView::getCtrlListSorted() const
476 return controls; 372 return controls;
477} 373}
478 374
479LLCompareByTabOrder::LLCompareByTabOrder(LLView::child_tab_order_t order): mTabOrder(order) {}
480
481bool LLCompareByTabOrder::compareTabOrders(const LLView::tab_order_t & a, const LLView::tab_order_t & b) const
482{
483 return a < b;
484}
485 375
486// This method compares two LLViews by the tab order specified in the comparator object. The 376// This method compares two LLViews by the tab order specified in the comparator object. The
487// code for this is a little convoluted because each argument can have four states: 377// code for this is a little convoluted because each argument can have four states:
@@ -537,68 +427,69 @@ BOOL LLView::isInEnabledChain() const
537 return TRUE; 427 return TRUE;
538} 428}
539 429
540BOOL LLView::isFocusRoot() const 430// virtual
431BOOL LLView::canFocusChildren() const
541{ 432{
542 return mIsFocusRoot; 433 return TRUE;
543} 434}
544 435
545LLView* LLView::findRootMostFocusRoot() 436//virtual
437void LLView::setTentative(BOOL b)
546{ 438{
547 LLView* focus_root = NULL;
548 LLView* next_view = this;
549 while(next_view)
550 {
551 if (next_view->isFocusRoot())
552 {
553 focus_root = next_view;
554 }
555 next_view = next_view->getParent();
556 }
557 return focus_root;
558} 439}
559 440
560BOOL LLView::canFocusChildren() const 441//virtual
442BOOL LLView::getTentative() const
561{ 443{
562 return TRUE; 444 return FALSE;
563} 445}
564 446
565BOOL LLView::focusNextRoot() 447//virtual
448void LLView::setEnabled(BOOL enabled)
566{ 449{
567 LLView::child_list_t result = LLView::getFocusRootsQuery().run(this); 450 mEnabled = enabled;
568 return LLView::focusNext(result);
569} 451}
570 452
571BOOL LLView::focusPrevRoot() 453//virtual
454BOOL LLView::setLabelArg( const LLString& key, const LLStringExplicit& text )
572{ 455{
573 LLView::child_list_t result = LLView::getFocusRootsQuery().run(this); 456 return FALSE;
574 return LLView::focusPrev(result);
575} 457}
576 458
577BOOL LLView::focusNextItem(BOOL text_fields_only) 459//virtual
460LLRect LLView::getSnapRect() const
578{ 461{
579 // this assumes that this method is called on the focus root. 462 return mRect;
580 LLCtrlQuery query = LLView::getTabOrderQuery(); 463}
581 if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly")) 464
582 { 465//virtual
583 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance()); 466LLRect LLView::getRequiredRect()
584 } 467{
585 LLView::child_list_t result = query(this); 468 return mRect;
469}
470
471//virtual
472void LLView::onFocusLost()
473{
474}
475
476//virtual
477void LLView::onFocusReceived()
478{
479}
480
481BOOL LLView::focusNextRoot()
482{
483 LLView::child_list_t result = LLView::getFocusRootsQuery().run(this);
586 return LLView::focusNext(result); 484 return LLView::focusNext(result);
587} 485}
588 486
589BOOL LLView::focusPrevItem(BOOL text_fields_only) 487BOOL LLView::focusPrevRoot()
590{ 488{
591 // this assumes that this method is called on the focus root. 489 LLView::child_list_t result = LLView::getFocusRootsQuery().run(this);
592 LLCtrlQuery query = LLView::getTabOrderQuery();
593 if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
594 {
595 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
596 }
597 LLView::child_list_t result = query(this);
598 return LLView::focusPrev(result); 490 return LLView::focusPrev(result);
599} 491}
600 492
601
602// static 493// static
603BOOL LLView::focusNext(LLView::child_list_t & result) 494BOOL LLView::focusNext(LLView::child_list_t & result)
604{ 495{
@@ -674,80 +565,6 @@ BOOL LLView::focusPrev(LLView::child_list_t & result)
674 return FALSE; 565 return FALSE;
675} 566}
676 567
677BOOL LLView::focusFirstItem(BOOL prefer_text_fields)
678{
679 // search for text field first
680 if(prefer_text_fields)
681 {
682 LLCtrlQuery query = LLView::getTabOrderQuery();
683 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
684 LLView::child_list_t result = query(this);
685 if(result.size() > 0)
686 {
687 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front());
688 if(!ctrl->hasFocus())
689 {
690 ctrl->setFocus(TRUE);
691 ctrl->onTabInto();
692 gFocusMgr.triggerFocusFlash();
693 }
694 return TRUE;
695 }
696 }
697 // no text field found, or we don't care about text fields
698 LLView::child_list_t result = LLView::getTabOrderQuery().run(this);
699 if(result.size() > 0)
700 {
701 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.front());
702 if(!ctrl->hasFocus())
703 {
704 ctrl->setFocus(TRUE);
705 ctrl->onTabInto();
706 gFocusMgr.triggerFocusFlash();
707 }
708 return TRUE;
709 }
710 return FALSE;
711}
712
713BOOL LLView::focusLastItem(BOOL prefer_text_fields)
714{
715 // search for text field first
716 if(prefer_text_fields)
717 {
718 LLCtrlQuery query = LLView::getTabOrderQuery();
719 query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
720 LLView::child_list_t result = query(this);
721 if(result.size() > 0)
722 {
723 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back());
724 if(!ctrl->hasFocus())
725 {
726 ctrl->setFocus(TRUE);
727 ctrl->onTabInto();
728 gFocusMgr.triggerFocusFlash();
729 }
730 return TRUE;
731 }
732 }
733 // no text field found, or we don't care about text fields
734 LLView::child_list_t result = LLView::getTabOrderQuery().run(this);
735 if(result.size() > 0)
736 {
737 LLUICtrl * ctrl = static_cast<LLUICtrl*>(result.back());
738 if(!ctrl->hasFocus())
739 {
740 ctrl->setFocus(TRUE);
741 ctrl->onTabInto();
742 gFocusMgr.triggerFocusFlash();
743 }
744 return TRUE;
745 }
746 return FALSE;
747}
748
749
750
751// delete all children. Override this function if you need to 568// delete all children. Override this function if you need to
752// perform any extra clean up such as cached pointers to selected 569// perform any extra clean up such as cached pointers to selected
753// children, etc. 570// children, etc.
@@ -773,23 +590,6 @@ void LLView::setAllChildrenEnabled(BOOL b)
773} 590}
774 591
775// virtual 592// virtual
776void LLView::setTentative(BOOL b)
777{
778}
779
780// virtual
781BOOL LLView::getTentative() const
782{
783 return FALSE;
784}
785
786// virtual
787void LLView::setEnabled(BOOL enabled)
788{
789 mEnabled = enabled;
790}
791
792// virtual
793void LLView::setVisible(BOOL visible) 593void LLView::setVisible(BOOL visible)
794{ 594{
795 if ( mVisible != visible ) 595 if ( mVisible != visible )
@@ -812,18 +612,6 @@ void LLView::setVisible(BOOL visible)
812} 612}
813 613
814// virtual 614// virtual
815void LLView::setHidden(BOOL hidden)
816{
817 mHidden = hidden;
818}
819
820// virtual
821BOOL LLView::setLabelArg(const LLString& key, const LLStringExplicit& text)
822{
823 return FALSE;
824}
825
826// virtual
827void LLView::onVisibilityChange ( BOOL new_visibility ) 615void LLView::onVisibilityChange ( BOOL new_visibility )
828{ 616{
829 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 617 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
@@ -845,9 +633,9 @@ void LLView::translate(S32 x, S32 y)
845} 633}
846 634
847// virtual 635// virtual
848BOOL LLView::canSnapTo(LLView* other_view) 636BOOL LLView::canSnapTo(const LLView* other_view) const
849{ 637{
850 return other_view->getVisible(); 638 return other_view != this && other_view->getVisible();
851} 639}
852 640
853// virtual 641// virtual
@@ -956,7 +744,7 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent)
956 if( called_from_parent ) 744 if( called_from_parent )
957 { 745 {
958 // Downward traversal 746 // Downward traversal
959 if (getVisible() && mEnabled) 747 if (getVisible() && getEnabled())
960 { 748 {
961 handled = childrenHandleKey( key, mask ) != NULL; 749 handled = childrenHandleKey( key, mask ) != NULL;
962 } 750 }
@@ -995,7 +783,7 @@ BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
995 if( called_from_parent ) 783 if( called_from_parent )
996 { 784 {
997 // Downward traversal 785 // Downward traversal
998 if (getVisible() && mEnabled) 786 if (getVisible() && getEnabled())
999 { 787 {
1000 handled = childrenHandleUnicodeChar( uni_char ) != NULL; 788 handled = childrenHandleUnicodeChar( uni_char ) != NULL;
1001 } 789 }
@@ -1058,16 +846,16 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask,
1058 LLView* handled_view = FALSE; 846 LLView* handled_view = FALSE;
1059 // CRO this is an experiment to allow drag and drop into object inventory based on the DragAndDrop tool's permissions rather than the parent 847 // CRO this is an experiment to allow drag and drop into object inventory based on the DragAndDrop tool's permissions rather than the parent
1060 if( getVisible() ) 848 if( getVisible() )
1061// if( getVisible() && mEnabled ) 849// if( getVisible() && getEnabled() )
1062 { 850 {
1063 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 851 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1064 { 852 {
1065 LLView* viewp = *child_it; 853 LLView* viewp = *child_it;
1066 S32 local_x = x - viewp->mRect.mLeft; 854 S32 local_x = x - viewp->getRect().mLeft;
1067 S32 local_y = y - viewp->mRect.mBottom; 855 S32 local_y = y - viewp->getRect().mBottom;
1068 if( viewp->pointInView(local_x, local_y) && 856 if( viewp->pointInView(local_x, local_y) &&
1069 viewp->getVisible() && 857 viewp->getVisible() &&
1070 viewp->mEnabled && 858 viewp->getEnabled() &&
1071 viewp->handleDragAndDrop(local_x, local_y, mask, drop, 859 viewp->handleDragAndDrop(local_x, local_y, mask, drop,
1072 cargo_type, 860 cargo_type,
1073 cargo_data, 861 cargo_data,
@@ -1142,7 +930,7 @@ BOOL LLView::handleDoubleClick(S32 x, S32 y, MASK mask)
1142BOOL LLView::handleScrollWheel(S32 x, S32 y, S32 clicks) 930BOOL LLView::handleScrollWheel(S32 x, S32 y, S32 clicks)
1143{ 931{
1144 BOOL handled = FALSE; 932 BOOL handled = FALSE;
1145 if( getVisible() && mEnabled ) 933 if( getVisible() && getEnabled() )
1146 { 934 {
1147 handled = childrenHandleScrollWheel( x, y, clicks ) != NULL; 935 handled = childrenHandleScrollWheel( x, y, clicks ) != NULL;
1148 if( !handled && blockMouseEvent(x, y) ) 936 if( !handled && blockMouseEvent(x, y) )
@@ -1176,13 +964,13 @@ BOOL LLView::handleRightMouseUp(S32 x, S32 y, MASK mask)
1176LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) 964LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks)
1177{ 965{
1178 LLView* handled_view = NULL; 966 LLView* handled_view = NULL;
1179 if (getVisible() && mEnabled ) 967 if (getVisible() && getEnabled() )
1180 { 968 {
1181 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 969 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1182 { 970 {
1183 LLView* viewp = *child_it; 971 LLView* viewp = *child_it;
1184 S32 local_x = x - viewp->mRect.mLeft; 972 S32 local_x = x - viewp->getRect().mLeft;
1185 S32 local_y = y - viewp->mRect.mBottom; 973 S32 local_y = y - viewp->getRect().mBottom;
1186 if (viewp->pointInView(local_x, local_y) && 974 if (viewp->pointInView(local_x, local_y) &&
1187 viewp->handleScrollWheel( local_x, local_y, clicks )) 975 viewp->handleScrollWheel( local_x, local_y, clicks ))
1188 { 976 {
@@ -1202,13 +990,13 @@ LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks)
1202LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) 990LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask)
1203{ 991{
1204 LLView* handled_view = NULL; 992 LLView* handled_view = NULL;
1205 if (getVisible() && mEnabled ) 993 if (getVisible() && getEnabled() )
1206 { 994 {
1207 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 995 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1208 { 996 {
1209 LLView* viewp = *child_it; 997 LLView* viewp = *child_it;
1210 S32 local_x = x - viewp->mRect.mLeft; 998 S32 local_x = x - viewp->getRect().mLeft;
1211 S32 local_y = y - viewp->mRect.mBottom; 999 S32 local_y = y - viewp->getRect().mBottom;
1212 if(viewp->pointInView(local_x, local_y) && 1000 if(viewp->pointInView(local_x, local_y) &&
1213 viewp->getVisible() && 1001 viewp->getVisible() &&
1214 viewp->getEnabled() && 1002 viewp->getEnabled() &&
@@ -1232,7 +1020,7 @@ LLView* LLView::childrenHandleKey(KEY key, MASK mask)
1232{ 1020{
1233 LLView* handled_view = NULL; 1021 LLView* handled_view = NULL;
1234 1022
1235 if ( getVisible() && mEnabled ) 1023 if ( getVisible() && getEnabled() )
1236 { 1024 {
1237 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1025 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1238 { 1026 {
@@ -1257,7 +1045,7 @@ LLView* LLView::childrenHandleUnicodeChar(llwchar uni_char)
1257{ 1045{
1258 LLView* handled_view = NULL; 1046 LLView* handled_view = NULL;
1259 1047
1260 if ( getVisible() && mEnabled ) 1048 if ( getVisible() && getEnabled() )
1261 { 1049 {
1262 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1050 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1263 { 1051 {
@@ -1284,12 +1072,12 @@ LLView* LLView::childrenHandleMouseDown(S32 x, S32 y, MASK mask)
1284 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1072 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1285 { 1073 {
1286 LLView* viewp = *child_it; 1074 LLView* viewp = *child_it;
1287 S32 local_x = x - viewp->mRect.mLeft; 1075 S32 local_x = x - viewp->getRect().mLeft;
1288 S32 local_y = y - viewp->mRect.mBottom; 1076 S32 local_y = y - viewp->getRect().mBottom;
1289 1077
1290 if (viewp->pointInView(local_x, local_y) && 1078 if (viewp->pointInView(local_x, local_y) &&
1291 viewp->getVisible() && 1079 viewp->getVisible() &&
1292 viewp->mEnabled && 1080 viewp->getEnabled() &&
1293 viewp->handleMouseDown( local_x, local_y, mask )) 1081 viewp->handleMouseDown( local_x, local_y, mask ))
1294 { 1082 {
1295 if (sDebugMouseHandling) 1083 if (sDebugMouseHandling)
@@ -1307,16 +1095,16 @@ LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask)
1307{ 1095{
1308 LLView* handled_view = NULL; 1096 LLView* handled_view = NULL;
1309 1097
1310 if (getVisible() && mEnabled ) 1098 if (getVisible() && getEnabled() )
1311 { 1099 {
1312 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1100 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1313 { 1101 {
1314 LLView* viewp = *child_it; 1102 LLView* viewp = *child_it;
1315 S32 local_x = x - viewp->mRect.mLeft; 1103 S32 local_x = x - viewp->getRect().mLeft;
1316 S32 local_y = y - viewp->mRect.mBottom; 1104 S32 local_y = y - viewp->getRect().mBottom;
1317 if (viewp->pointInView(local_x, local_y) && 1105 if (viewp->pointInView(local_x, local_y) &&
1318 viewp->getVisible() && 1106 viewp->getVisible() &&
1319 viewp->mEnabled && 1107 viewp->getEnabled() &&
1320 viewp->handleRightMouseDown( local_x, local_y, mask )) 1108 viewp->handleRightMouseDown( local_x, local_y, mask ))
1321 { 1109 {
1322 if (sDebugMouseHandling) 1110 if (sDebugMouseHandling)
@@ -1335,16 +1123,16 @@ LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask)
1335{ 1123{
1336 LLView* handled_view = NULL; 1124 LLView* handled_view = NULL;
1337 1125
1338 if (getVisible() && mEnabled ) 1126 if (getVisible() && getEnabled() )
1339 { 1127 {
1340 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1128 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1341 { 1129 {
1342 LLView* viewp = *child_it; 1130 LLView* viewp = *child_it;
1343 S32 local_x = x - viewp->mRect.mLeft; 1131 S32 local_x = x - viewp->getRect().mLeft;
1344 S32 local_y = y - viewp->mRect.mBottom; 1132 S32 local_y = y - viewp->getRect().mBottom;
1345 if (viewp->pointInView(local_x, local_y) && 1133 if (viewp->pointInView(local_x, local_y) &&
1346 viewp->getVisible() && 1134 viewp->getVisible() &&
1347 viewp->mEnabled && 1135 viewp->getEnabled() &&
1348 viewp->handleDoubleClick( local_x, local_y, mask )) 1136 viewp->handleDoubleClick( local_x, local_y, mask ))
1349 { 1137 {
1350 if (sDebugMouseHandling) 1138 if (sDebugMouseHandling)
@@ -1362,18 +1150,18 @@ LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask)
1362LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask) 1150LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask)
1363{ 1151{
1364 LLView* handled_view = NULL; 1152 LLView* handled_view = NULL;
1365 if( getVisible() && mEnabled ) 1153 if( getVisible() && getEnabled() )
1366 { 1154 {
1367 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1155 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1368 { 1156 {
1369 LLView* viewp = *child_it; 1157 LLView* viewp = *child_it;
1370 S32 local_x = x - viewp->mRect.mLeft; 1158 S32 local_x = x - viewp->getRect().mLeft;
1371 S32 local_y = y - viewp->mRect.mBottom; 1159 S32 local_y = y - viewp->getRect().mBottom;
1372 if (!viewp->pointInView(local_x, local_y)) 1160 if (!viewp->pointInView(local_x, local_y))
1373 continue; 1161 continue;
1374 if (!viewp->getVisible()) 1162 if (!viewp->getVisible())
1375 continue; 1163 continue;
1376 if (!viewp->mEnabled) 1164 if (!viewp->getEnabled())
1377 continue; 1165 continue;
1378 if (viewp->handleMouseUp( local_x, local_y, mask )) 1166 if (viewp->handleMouseUp( local_x, local_y, mask ))
1379 { 1167 {
@@ -1392,16 +1180,16 @@ LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask)
1392LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask) 1180LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask)
1393{ 1181{
1394 LLView* handled_view = NULL; 1182 LLView* handled_view = NULL;
1395 if( getVisible() && mEnabled ) 1183 if( getVisible() && getEnabled() )
1396 { 1184 {
1397 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1185 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
1398 { 1186 {
1399 LLView* viewp = *child_it; 1187 LLView* viewp = *child_it;
1400 S32 local_x = x - viewp->mRect.mLeft; 1188 S32 local_x = x - viewp->getRect().mLeft;
1401 S32 local_y = y - viewp->mRect.mBottom; 1189 S32 local_y = y - viewp->getRect().mBottom;
1402 if (viewp->pointInView(local_x, local_y) && 1190 if (viewp->pointInView(local_x, local_y) &&
1403 viewp->getVisible() && 1191 viewp->getVisible() &&
1404 viewp->mEnabled && 1192 viewp->getEnabled() &&
1405 viewp->handleRightMouseUp( local_x, local_y, mask )) 1193 viewp->handleRightMouseUp( local_x, local_y, mask ))
1406 { 1194 {
1407 if (sDebugMouseHandling) 1195 if (sDebugMouseHandling)
@@ -1424,8 +1212,8 @@ void LLView::draw()
1424 drawDebugRect(); 1212 drawDebugRect();
1425 1213
1426 // Check for bogus rectangle 1214 // Check for bogus rectangle
1427 if (mRect.mRight <= mRect.mLeft 1215 if (getRect().mRight <= getRect().mLeft
1428 || mRect.mTop <= mRect.mBottom) 1216 || getRect().mTop <= getRect().mBottom)
1429 { 1217 {
1430 llwarns << "Bogus rectangle for " << getName() << " with " << mRect << llendl; 1218 llwarns << "Bogus rectangle for " << getName() << " with " << mRect << llendl;
1431 } 1219 }
@@ -1503,28 +1291,28 @@ void LLView::drawDebugRect()
1503 border_color.mV[sDepth%3] = 1.f; 1291 border_color.mV[sDepth%3] = 1.f;
1504 } 1292 }
1505 1293
1506 glColor4fv( border_color.mV ); 1294 gGL.color4fv( border_color.mV );
1507 1295
1508 glBegin(GL_LINES); 1296 gGL.begin(GL_LINES);
1509 glVertex2i(0, debug_rect.getHeight() - 1); 1297 gGL.vertex2i(0, debug_rect.getHeight() - 1);
1510 glVertex2i(0, 0); 1298 gGL.vertex2i(0, 0);
1511 1299
1512 glVertex2i(0, 0); 1300 gGL.vertex2i(0, 0);
1513 glVertex2i(debug_rect.getWidth() - 1, 0); 1301 gGL.vertex2i(debug_rect.getWidth() - 1, 0);
1514 1302
1515 glVertex2i(debug_rect.getWidth() - 1, 0); 1303 gGL.vertex2i(debug_rect.getWidth() - 1, 0);
1516 glVertex2i(debug_rect.getWidth() - 1, debug_rect.getHeight() - 1); 1304 gGL.vertex2i(debug_rect.getWidth() - 1, debug_rect.getHeight() - 1);
1517 1305
1518 glVertex2i(debug_rect.getWidth() - 1, debug_rect.getHeight() - 1); 1306 gGL.vertex2i(debug_rect.getWidth() - 1, debug_rect.getHeight() - 1);
1519 glVertex2i(0, debug_rect.getHeight() - 1); 1307 gGL.vertex2i(0, debug_rect.getHeight() - 1);
1520 glEnd(); 1308 gGL.end();
1521 1309
1522 // Draw the name if it's not a leaf node 1310 // Draw the name if it's not a leaf node
1523 if (mChildList.size() && !sEditingUI) 1311 if (mChildList.size() && !sEditingUI)
1524 { 1312 {
1525 //char temp[256]; 1313 //char temp[256];
1526 S32 x, y; 1314 S32 x, y;
1527 glColor4fv( border_color.mV ); 1315 gGL.color4fv( border_color.mV );
1528 x = debug_rect.getWidth()/2; 1316 x = debug_rect.getWidth()/2;
1529 y = debug_rect.getHeight()/2; 1317 y = debug_rect.getHeight()/2;
1530 LLString debug_text = llformat("%s (%d x %d)", getName().c_str(), 1318 LLString debug_text = llformat("%s (%d x %d)", getName().c_str(),
@@ -1562,14 +1350,14 @@ void LLView::drawChild(LLView* childp, S32 x_offset, S32 y_offset, BOOL force_dr
1562void LLView::reshape(S32 width, S32 height, BOOL called_from_parent) 1350void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
1563{ 1351{
1564 // compute how much things changed and apply reshape logic to children 1352 // compute how much things changed and apply reshape logic to children
1565 S32 delta_width = width - mRect.getWidth(); 1353 S32 delta_width = width - getRect().getWidth();
1566 S32 delta_height = height - mRect.getHeight(); 1354 S32 delta_height = height - getRect().getHeight();
1567 1355
1568 if (delta_width || delta_height || sForceReshape) 1356 if (delta_width || delta_height || sForceReshape)
1569 { 1357 {
1570 // adjust our rectangle 1358 // adjust our rectangle
1571 mRect.mRight = mRect.mLeft + width; 1359 mRect.mRight = getRect().mLeft + width;
1572 mRect.mTop = mRect.mBottom + height; 1360 mRect.mTop = getRect().mBottom + height;
1573 1361
1574 // move child views according to reshape flags 1362 // move child views according to reshape flags
1575 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) 1363 for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
@@ -1615,8 +1403,8 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
1615 // for now, same as bottom 1403 // for now, same as bottom
1616 } 1404 }
1617 1405
1618 S32 delta_x = child_rect.mLeft - viewp->mRect.mLeft; 1406 S32 delta_x = child_rect.mLeft - viewp->getRect().mLeft;
1619 S32 delta_y = child_rect.mBottom - viewp->mRect.mBottom; 1407 S32 delta_y = child_rect.mBottom - viewp->getRect().mBottom;
1620 viewp->translate( delta_x, delta_y ); 1408 viewp->translate( delta_x, delta_y );
1621 viewp->reshape(child_rect.getWidth(), child_rect.getHeight()); 1409 viewp->reshape(child_rect.getWidth(), child_rect.getHeight());
1622 } 1410 }
@@ -1633,11 +1421,6 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
1633 updateBoundingRect(); 1421 updateBoundingRect();
1634} 1422}
1635 1423
1636LLRect LLView::getRequiredRect()
1637{
1638 return mRect;
1639}
1640
1641void LLView::updateBoundingRect() 1424void LLView::updateBoundingRect()
1642{ 1425{
1643 if (isDead()) return; 1426 if (isDead()) return;
@@ -1690,16 +1473,16 @@ void LLView::updateBoundingRect()
1690 } 1473 }
1691} 1474}
1692 1475
1693const LLRect LLView::getScreenRect() const 1476LLRect LLView::getScreenRect() const
1694{ 1477{
1695 // *FIX: check for one-off error 1478 // *FIX: check for one-off error
1696 LLRect screen_rect; 1479 LLRect screen_rect;
1697 localPointToScreen(0, 0, &screen_rect.mLeft, &screen_rect.mBottom); 1480 localPointToScreen(0, 0, &screen_rect.mLeft, &screen_rect.mBottom);
1698 localPointToScreen(mRect.getWidth(), mRect.getHeight(), &screen_rect.mRight, &screen_rect.mTop); 1481 localPointToScreen(getRect().getWidth(), getRect().getHeight(), &screen_rect.mRight, &screen_rect.mTop);
1699 return screen_rect; 1482 return screen_rect;
1700} 1483}
1701 1484
1702const LLRect LLView::getLocalBoundingRect() const 1485LLRect LLView::getLocalBoundingRect() const
1703{ 1486{
1704 LLRect local_bounding_rect = getBoundingRect(); 1487 LLRect local_bounding_rect = getBoundingRect();
1705 local_bounding_rect.translate(-mRect.mLeft, -mRect.mBottom); 1488 local_bounding_rect.translate(-mRect.mLeft, -mRect.mBottom);
@@ -1708,20 +1491,20 @@ const LLRect LLView::getLocalBoundingRect() const
1708} 1491}
1709 1492
1710 1493
1711const LLRect LLView::getLocalRect() const 1494LLRect LLView::getLocalRect() const
1712{ 1495{
1713 LLRect local_rect(0, mRect.getHeight(), mRect.getWidth(), 0); 1496 LLRect local_rect(0, getRect().getHeight(), getRect().getWidth(), 0);
1714 return local_rect; 1497 return local_rect;
1715} 1498}
1716 1499
1717const LLRect LLView::getLocalSnapRect() const 1500LLRect LLView::getLocalSnapRect() const
1718{ 1501{
1719 LLRect local_snap_rect = getSnapRect(); 1502 LLRect local_snap_rect = getSnapRect();
1720 local_snap_rect.translate(-mRect.mLeft, -mRect.mBottom); 1503 local_snap_rect.translate(-getRect().mLeft, -getRect().mBottom);
1721 return local_snap_rect; 1504 return local_snap_rect;
1722} 1505}
1723 1506
1724BOOL LLView::hasAncestor(const LLView* parentp) 1507BOOL LLView::hasAncestor(const LLView* parentp) const
1725{ 1508{
1726 if (!parentp) 1509 if (!parentp)
1727 { 1510 {
@@ -1760,7 +1543,7 @@ BOOL LLView::childHasKeyboardFocus( const LLString& childname ) const
1760 1543
1761BOOL LLView::hasChild(const LLString& childname, BOOL recurse) const 1544BOOL LLView::hasChild(const LLString& childname, BOOL recurse) const
1762{ 1545{
1763 return getChildByName(childname, recurse) ? TRUE : FALSE; 1546 return getChildByName(childname, recurse) != NULL;
1764} 1547}
1765 1548
1766//----------------------------------------------------------------------------- 1549//-----------------------------------------------------------------------------
@@ -1818,55 +1601,55 @@ BOOL LLView::blockMouseEvent(S32 x, S32 y) const
1818// virtual 1601// virtual
1819void LLView::screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const 1602void LLView::screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const
1820{ 1603{
1821 *local_x = screen_x - mRect.mLeft; 1604 *local_x = screen_x - getRect().mLeft;
1822 *local_y = screen_y - mRect.mBottom; 1605 *local_y = screen_y - getRect().mBottom;
1823 1606
1824 const LLView* cur = this; 1607 const LLView* cur = this;
1825 while( cur->mParentView ) 1608 while( cur->mParentView )
1826 { 1609 {
1827 cur = cur->mParentView; 1610 cur = cur->mParentView;
1828 *local_x -= cur->mRect.mLeft; 1611 *local_x -= cur->getRect().mLeft;
1829 *local_y -= cur->mRect.mBottom; 1612 *local_y -= cur->getRect().mBottom;
1830 } 1613 }
1831} 1614}
1832 1615
1833void LLView::localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const 1616void LLView::localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const
1834{ 1617{
1835 *screen_x = local_x + mRect.mLeft; 1618 *screen_x = local_x + getRect().mLeft;
1836 *screen_y = local_y + mRect.mBottom; 1619 *screen_y = local_y + getRect().mBottom;
1837 1620
1838 const LLView* cur = this; 1621 const LLView* cur = this;
1839 while( cur->mParentView ) 1622 while( cur->mParentView )
1840 { 1623 {
1841 cur = cur->mParentView; 1624 cur = cur->mParentView;
1842 *screen_x += cur->mRect.mLeft; 1625 *screen_x += cur->getRect().mLeft;
1843 *screen_y += cur->mRect.mBottom; 1626 *screen_y += cur->getRect().mBottom;
1844 } 1627 }
1845} 1628}
1846 1629
1847void LLView::screenRectToLocal(const LLRect& screen, LLRect* local) const 1630void LLView::screenRectToLocal(const LLRect& screen, LLRect* local) const
1848{ 1631{
1849 *local = screen; 1632 *local = screen;
1850 local->translate( -mRect.mLeft, -mRect.mBottom ); 1633 local->translate( -getRect().mLeft, -getRect().mBottom );
1851 1634
1852 const LLView* cur = this; 1635 const LLView* cur = this;
1853 while( cur->mParentView ) 1636 while( cur->mParentView )
1854 { 1637 {
1855 cur = cur->mParentView; 1638 cur = cur->mParentView;
1856 local->translate( -cur->mRect.mLeft, -cur->mRect.mBottom ); 1639 local->translate( -cur->getRect().mLeft, -cur->getRect().mBottom );
1857 } 1640 }
1858} 1641}
1859 1642
1860void LLView::localRectToScreen(const LLRect& local, LLRect* screen) const 1643void LLView::localRectToScreen(const LLRect& local, LLRect* screen) const
1861{ 1644{
1862 *screen = local; 1645 *screen = local;
1863 screen->translate( mRect.mLeft, mRect.mBottom ); 1646 screen->translate( getRect().mLeft, getRect().mBottom );
1864 1647
1865 const LLView* cur = this; 1648 const LLView* cur = this;
1866 while( cur->mParentView ) 1649 while( cur->mParentView )
1867 { 1650 {
1868 cur = cur->mParentView; 1651 cur = cur->mParentView;
1869 screen->translate( cur->mRect.mLeft, cur->mRect.mBottom ); 1652 screen->translate( cur->getRect().mLeft, cur->getRect().mBottom );
1870 } 1653 }
1871} 1654}
1872 1655
@@ -1880,12 +1663,15 @@ LLView* LLView::getRootView()
1880 return view; 1663 return view;
1881} 1664}
1882 1665
1883//static 1666BOOL LLView::deleteViewByHandle(LLHandle<LLView> handle)
1884LLWindow* LLView::getWindow(void)
1885{ 1667{
1886 return LLUI::sWindow; 1668 LLView* viewp = handle.get();
1669
1670 delete viewp;
1671 return viewp != NULL;
1887} 1672}
1888 1673
1674
1889// Moves the view so that it is entirely inside of constraint. 1675// Moves the view so that it is entirely inside of constraint.
1890// If the view will not fit because it's too big, aligns with the top and left. 1676// If the view will not fit because it's too big, aligns with the top and left.
1891// (Why top and left? That's where the drag bars are for floaters.) 1677// (Why top and left? That's where the drag bars are for floaters.)
@@ -1898,50 +1684,50 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
1898 { 1684 {
1899 const S32 KEEP_ONSCREEN_PIXELS = 16; 1685 const S32 KEEP_ONSCREEN_PIXELS = 16;
1900 1686
1901 if( mRect.mRight - KEEP_ONSCREEN_PIXELS < constraint.mLeft ) 1687 if( getRect().mRight - KEEP_ONSCREEN_PIXELS < constraint.mLeft )
1902 { 1688 {
1903 delta_x = constraint.mLeft - (mRect.mRight - KEEP_ONSCREEN_PIXELS); 1689 delta_x = constraint.mLeft - (getRect().mRight - KEEP_ONSCREEN_PIXELS);
1904 } 1690 }
1905 else 1691 else
1906 if( mRect.mLeft + KEEP_ONSCREEN_PIXELS > constraint.mRight ) 1692 if( getRect().mLeft + KEEP_ONSCREEN_PIXELS > constraint.mRight )
1907 { 1693 {
1908 delta_x = constraint.mRight - (mRect.mLeft + KEEP_ONSCREEN_PIXELS); 1694 delta_x = constraint.mRight - (getRect().mLeft + KEEP_ONSCREEN_PIXELS);
1909 delta_x += llmax( 0, mRect.getWidth() - constraint.getWidth() ); 1695 delta_x += llmax( 0, getRect().getWidth() - constraint.getWidth() );
1910 } 1696 }
1911 1697
1912 if( mRect.mTop > constraint.mTop ) 1698 if( getRect().mTop > constraint.mTop )
1913 { 1699 {
1914 delta_y = constraint.mTop - mRect.mTop; 1700 delta_y = constraint.mTop - getRect().mTop;
1915 } 1701 }
1916 else 1702 else
1917 if( mRect.mTop - KEEP_ONSCREEN_PIXELS < constraint.mBottom ) 1703 if( getRect().mTop - KEEP_ONSCREEN_PIXELS < constraint.mBottom )
1918 { 1704 {
1919 delta_y = constraint.mBottom - (mRect.mTop - KEEP_ONSCREEN_PIXELS); 1705 delta_y = constraint.mBottom - (getRect().mTop - KEEP_ONSCREEN_PIXELS);
1920 delta_y -= llmax( 0, mRect.getHeight() - constraint.getHeight() ); 1706 delta_y -= llmax( 0, getRect().getHeight() - constraint.getHeight() );
1921 } 1707 }
1922 } 1708 }
1923 else 1709 else
1924 { 1710 {
1925 if( mRect.mLeft < constraint.mLeft ) 1711 if( getRect().mLeft < constraint.mLeft )
1926 { 1712 {
1927 delta_x = constraint.mLeft - mRect.mLeft; 1713 delta_x = constraint.mLeft - getRect().mLeft;
1928 } 1714 }
1929 else 1715 else
1930 if( mRect.mRight > constraint.mRight ) 1716 if( getRect().mRight > constraint.mRight )
1931 { 1717 {
1932 delta_x = constraint.mRight - mRect.mRight; 1718 delta_x = constraint.mRight - getRect().mRight;
1933 delta_x += llmax( 0, mRect.getWidth() - constraint.getWidth() ); 1719 delta_x += llmax( 0, getRect().getWidth() - constraint.getWidth() );
1934 } 1720 }
1935 1721
1936 if( mRect.mTop > constraint.mTop ) 1722 if( getRect().mTop > constraint.mTop )
1937 { 1723 {
1938 delta_y = constraint.mTop - mRect.mTop; 1724 delta_y = constraint.mTop - getRect().mTop;
1939 } 1725 }
1940 else 1726 else
1941 if( mRect.mBottom < constraint.mBottom ) 1727 if( getRect().mBottom < constraint.mBottom )
1942 { 1728 {
1943 delta_y = constraint.mBottom - mRect.mBottom; 1729 delta_y = constraint.mBottom - getRect().mBottom;
1944 delta_y -= llmax( 0, mRect.getHeight() - constraint.getHeight() ); 1730 delta_y -= llmax( 0, getRect().getHeight() - constraint.getHeight() );
1945 } 1731 }
1946 } 1732 }
1947 1733
@@ -1953,10 +1739,18 @@ BOOL LLView::translateIntoRect(const LLRect& constraint, BOOL allow_partial_outs
1953 return FALSE; 1739 return FALSE;
1954} 1740}
1955 1741
1956BOOL LLView::localPointToOtherView( S32 x, S32 y, S32 *other_x, S32 *other_y, LLView* other_view) 1742void LLView::centerWithin(const LLRect& bounds)
1957{ 1743{
1958 LLView* cur_view = this; 1744 S32 left = bounds.mLeft + (bounds.getWidth() - getRect().getWidth()) / 2;
1959 LLView* root_view = NULL; 1745 S32 bottom = bounds.mBottom + (bounds.getHeight() - getRect().getHeight()) / 2;
1746
1747 translate( left - getRect().mLeft, bottom - getRect().mBottom );
1748}
1749
1750BOOL LLView::localPointToOtherView( S32 x, S32 y, S32 *other_x, S32 *other_y, LLView* other_view) const
1751{
1752 const LLView* cur_view = this;
1753 const LLView* root_view = NULL;
1960 1754
1961 while (cur_view) 1755 while (cur_view)
1962 { 1756 {
@@ -2047,8 +1841,8 @@ LLXMLNodePtr LLView::getXML(bool save_children) const
2047 node->createChild("height", TRUE)->setIntValue(getRect().getHeight()); 1841 node->createChild("height", TRUE)->setIntValue(getRect().getHeight());
2048 1842
2049 LLView* parent = getParent(); 1843 LLView* parent = getParent();
2050 S32 left = mRect.mLeft; 1844 S32 left = getRect().mLeft;
2051 S32 bottom = mRect.mBottom; 1845 S32 bottom = getRect().mBottom;
2052 if (parent) bottom -= parent->getRect().getHeight(); 1846 if (parent) bottom -= parent->getRect().getHeight();
2053 1847
2054 node->createChild("left", TRUE)->setIntValue(left); 1848 node->createChild("left", TRUE)->setIntValue(left);
@@ -2084,7 +1878,6 @@ LLXMLNodePtr LLView::getXML(bool save_children) const
2084 node->createChild("follows", TRUE)->setStringValue(buffer.str()); 1878 node->createChild("follows", TRUE)->setStringValue(buffer.str());
2085 } 1879 }
2086 // Export all widgets as enabled and visible - code must disable. 1880 // Export all widgets as enabled and visible - code must disable.
2087 node->createChild("hidden", TRUE)->setBoolValue(mHidden);
2088 node->createChild("mouse_opaque", TRUE)->setBoolValue(mMouseOpaque ); 1881 node->createChild("mouse_opaque", TRUE)->setBoolValue(mMouseOpaque );
2089 if (!mToolTipMsg.getString().empty()) 1882 if (!mToolTipMsg.getString().empty())
2090 { 1883 {
@@ -2095,7 +1888,7 @@ LLXMLNodePtr LLView::getXML(bool save_children) const
2095 node->createChild("sound_flags", TRUE)->setIntValue((S32)mSoundFlags); 1888 node->createChild("sound_flags", TRUE)->setIntValue((S32)mSoundFlags);
2096 } 1889 }
2097 1890
2098 node->createChild("enabled", TRUE)->setBoolValue(mEnabled); 1891 node->createChild("enabled", TRUE)->setBoolValue(getEnabled());
2099 1892
2100 if (!mControlName.empty()) 1893 if (!mControlName.empty())
2101 { 1894 {
@@ -2183,6 +1976,15 @@ const LLCtrlQuery & LLView::getTabOrderQuery()
2183 return query; 1976 return query;
2184} 1977}
2185 1978
1979// This class is only used internally by getFocusRootsQuery below.
1980class LLFocusRootsFilter : public LLQueryFilter, public LLSingleton<LLFocusRootsFilter>
1981{
1982 /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const
1983 {
1984 return filterResult_t(view->isCtrl() && view->isFocusRoot(), !view->isFocusRoot());
1985 }
1986};
1987
2186// static 1988// static
2187const LLCtrlQuery & LLView::getFocusRootsQuery() 1989const LLCtrlQuery & LLView::getFocusRootsQuery()
2188{ 1990{
@@ -2190,7 +1992,7 @@ const LLCtrlQuery & LLView::getFocusRootsQuery()
2190 if(query.getPreFilters().size() == 0) { 1992 if(query.getPreFilters().size() == 0) {
2191 query.addPreFilter(LLVisibleFilter::getInstance()); 1993 query.addPreFilter(LLVisibleFilter::getInstance());
2192 query.addPreFilter(LLEnabledFilter::getInstance()); 1994 query.addPreFilter(LLEnabledFilter::getInstance());
2193 query.addPreFilter(LLView::LLFocusRootsFilter::getInstance()); 1995 query.addPreFilter(LLFocusRootsFilter::getInstance());
2194 query.addPostFilter(LLRootsFilter::getInstance()); 1996 query.addPostFilter(LLRootsFilter::getInstance());
2195 } 1997 }
2196 return query; 1998 return query;
@@ -2200,167 +2002,189 @@ const LLCtrlQuery & LLView::getFocusRootsQuery()
2200void LLView::userSetShape(const LLRect& new_rect) 2002void LLView::userSetShape(const LLRect& new_rect)
2201{ 2003{
2202 reshape(new_rect.getWidth(), new_rect.getHeight()); 2004 reshape(new_rect.getWidth(), new_rect.getHeight());
2203 translate(new_rect.mLeft - mRect.mLeft, new_rect.mBottom - mRect.mBottom); 2005 translate(new_rect.mLeft - getRect().mLeft, new_rect.mBottom - getRect().mBottom);
2204} 2006}
2205 2007
2206LLView* LLView::findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir, 2008LLView* LLView::findSnapRect(LLRect& new_rect, const LLCoordGL& mouse_dir,
2207 LLView::ESnapType snap_type, S32 threshold, S32 padding) 2009 LLView::ESnapType snap_type, S32 threshold, S32 padding)
2208{ 2010{
2011 new_rect = mRect;
2209 LLView* snap_view = NULL; 2012 LLView* snap_view = NULL;
2210 2013
2211 if (!mParentView) 2014 if (!mParentView)
2212 { 2015 {
2213 new_rect = mRect; 2016 return NULL;
2214 return snap_view;
2215 } 2017 }
2216 2018
2217 // If the view is near the edge of its parent, snap it to 2019 S32 delta_x = 0;
2218 // the edge. 2020 S32 delta_y = 0;
2219 LLRect test_rect = getSnapRect(); 2021 if (mouse_dir.mX >= 0)
2220 LLRect view_rect = getSnapRect();
2221 test_rect.stretch(padding);
2222 view_rect.stretch(padding);
2223
2224 BOOL snapped_x = FALSE;
2225 BOOL snapped_y = FALSE;
2226
2227 LLRect parent_local_snap_rect = mParentView->getLocalSnapRect();
2228
2229 if (snap_type == SNAP_PARENT || snap_type == SNAP_PARENT_AND_SIBLINGS)
2230 { 2022 {
2231 if (llabs(parent_local_snap_rect.mRight - test_rect.mRight) <= threshold && (parent_local_snap_rect.mRight - test_rect.mRight) * mouse_dir.mX >= 0) 2023 S32 new_right = mRect.mRight;
2232 { 2024 LLView* view = findSnapEdge(new_right, mouse_dir, SNAP_RIGHT, snap_type, threshold, padding);
2233 view_rect.translate(parent_local_snap_rect.mRight - view_rect.mRight, 0); 2025 delta_x = new_right - mRect.mRight;
2234 snap_view = mParentView; 2026 snap_view = view ? view : snap_view;
2235 snapped_x = TRUE;
2236 }
2237
2238 if (llabs(test_rect.mLeft - parent_local_snap_rect.mLeft) <= threshold && test_rect.mLeft * mouse_dir.mX <= 0)
2239 {
2240 view_rect.translate(parent_local_snap_rect.mLeft - view_rect.mLeft, 0);
2241 snap_view = mParentView;
2242 snapped_x = TRUE;
2243 }
2244
2245 if (llabs(test_rect.mBottom - parent_local_snap_rect.mBottom) <= threshold && test_rect.mBottom * mouse_dir.mY <= 0)
2246 {
2247 view_rect.translate(0, parent_local_snap_rect.mBottom - view_rect.mBottom);
2248 snap_view = mParentView;
2249 snapped_y = TRUE;
2250 }
2251
2252 if (llabs(parent_local_snap_rect.mTop - test_rect.mTop) <= threshold && (parent_local_snap_rect.mTop - test_rect.mTop) * mouse_dir.mY >= 0)
2253 {
2254 view_rect.translate(0, parent_local_snap_rect.mTop - view_rect.mTop);
2255 snap_view = mParentView;
2256 snapped_y = TRUE;
2257 }
2258 } 2027 }
2259 if (snap_type == SNAP_SIBLINGS || snap_type == SNAP_PARENT_AND_SIBLINGS)
2260 {
2261 for ( child_list_const_iter_t child_it = mParentView->getChildList()->begin();
2262 child_it != mParentView->getChildList()->end(); ++child_it)
2263 {
2264 LLView* siblingp = *child_it;
2265 // skip self
2266 if (siblingp == this || !siblingp->getVisible() || !canSnapTo(siblingp))
2267 {
2268 continue;
2269 }
2270
2271 LLRect sibling_rect = siblingp->getSnapRect();
2272
2273 if (!snapped_x && llabs(test_rect.mRight - sibling_rect.mLeft) <= threshold && (test_rect.mRight - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2274 {
2275 view_rect.translate(sibling_rect.mLeft - view_rect.mRight, 0);
2276 if (!snapped_y)
2277 {
2278 if (llabs(test_rect.mTop - sibling_rect.mTop) <= threshold && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0)
2279 {
2280 view_rect.translate(0, sibling_rect.mTop - test_rect.mTop);
2281 snapped_y = TRUE;
2282 }
2283 else if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= threshold && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2284 {
2285 view_rect.translate(0, sibling_rect.mBottom - test_rect.mBottom);
2286 snapped_y = TRUE;
2287 }
2288 }
2289 snap_view = siblingp;
2290 snapped_x = TRUE;
2291 }
2292 2028
2293 if (!snapped_x && llabs(test_rect.mLeft - sibling_rect.mRight) <= threshold && (test_rect.mLeft - sibling_rect.mRight) * mouse_dir.mX <= 0) 2029 if (mouse_dir.mX <= 0)
2294 { 2030 {
2295 view_rect.translate(sibling_rect.mRight - view_rect.mLeft, 0); 2031 S32 new_left = mRect.mLeft;
2296 if (!snapped_y) 2032 LLView* view = findSnapEdge(new_left, mouse_dir, SNAP_LEFT, snap_type, threshold, padding);
2297 { 2033 delta_x = new_left - mRect.mLeft;
2298 if (llabs(test_rect.mTop - sibling_rect.mTop) <= threshold && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0) 2034 snap_view = view ? view : snap_view;
2299 { 2035 }
2300 view_rect.translate(0, sibling_rect.mTop - test_rect.mTop);
2301 snapped_y = TRUE;
2302 }
2303 else if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= threshold && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2304 {
2305 view_rect.translate(0, sibling_rect.mBottom - test_rect.mBottom);
2306 snapped_y = TRUE;
2307 }
2308 }
2309 snap_view = siblingp;
2310 snapped_x = TRUE;
2311 }
2312 2036
2313 if (!snapped_y && llabs(test_rect.mBottom - sibling_rect.mTop) <= threshold && (test_rect.mBottom - sibling_rect.mTop) * mouse_dir.mY <= 0) 2037 if (mouse_dir.mY >= 0)
2314 { 2038 {
2315 view_rect.translate(0, sibling_rect.mTop - view_rect.mBottom); 2039 S32 new_top = mRect.mTop;
2316 if (!snapped_x) 2040 LLView* view = findSnapEdge(new_top, mouse_dir, SNAP_TOP, snap_type, threshold, padding);
2317 { 2041 delta_y = new_top - mRect.mTop;
2318 if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= threshold && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0) 2042 snap_view = view ? view : snap_view;
2319 { 2043 }
2320 view_rect.translate(sibling_rect.mLeft - test_rect.mLeft, 0);
2321 snapped_x = TRUE;
2322 }
2323 else if (llabs(test_rect.mRight - sibling_rect.mRight) <= threshold && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2324 {
2325 view_rect.translate(sibling_rect.mRight - test_rect.mRight, 0);
2326 snapped_x = TRUE;
2327 }
2328 }
2329 snap_view = siblingp;
2330 snapped_y = TRUE;
2331 }
2332 2044
2333 if (!snapped_y && llabs(test_rect.mTop - sibling_rect.mBottom) <= threshold && (test_rect.mTop - sibling_rect.mBottom) * mouse_dir.mY <= 0) 2045 if (mouse_dir.mY <= 0)
2334 { 2046 {
2335 view_rect.translate(0, sibling_rect.mBottom - view_rect.mTop); 2047 S32 new_bottom = mRect.mBottom;
2336 if (!snapped_x) 2048 LLView* view = findSnapEdge(new_bottom, mouse_dir, SNAP_BOTTOM, snap_type, threshold, padding);
2337 { 2049 delta_y = new_bottom - mRect.mBottom;
2338 if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= threshold && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0) 2050 snap_view = view ? view : snap_view;
2339 {
2340 view_rect.translate(sibling_rect.mLeft - test_rect.mLeft, 0);
2341 snapped_x = TRUE;
2342 }
2343 else if (llabs(test_rect.mRight - sibling_rect.mRight) <= threshold && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2344 {
2345 view_rect.translate(sibling_rect.mRight - test_rect.mRight, 0);
2346 snapped_x = TRUE;
2347 }
2348 }
2349 snap_view = siblingp;
2350 snapped_y = TRUE;
2351 }
2352
2353 if (snapped_x && snapped_y)
2354 {
2355 break;
2356 }
2357 }
2358 } 2051 }
2359 2052
2360 // shrink actual view rect back down 2053 new_rect.translate(delta_x, delta_y);
2361 view_rect.stretch(-padding);
2362 new_rect = view_rect;
2363 return snap_view; 2054 return snap_view;
2055
2056 //// If the view is near the edge of its parent, snap it to
2057 //// the edge.
2058 //LLRect test_rect = getSnapRect();
2059 //LLRect view_rect = getSnapRect();
2060 //test_rect.stretch(padding);
2061 //view_rect.stretch(padding);
2062
2063 //S32 x_threshold = threshold;
2064 //S32 y_threshold = threshold;
2065
2066 //LLRect parent_local_snap_rect = mParentView->getLocalSnapRect();
2067
2068 //if (snap_type == SNAP_PARENT || snap_type == SNAP_PARENT_AND_SIBLINGS)
2069 //{
2070 // if (llabs(parent_local_snap_rect.mRight - test_rect.mRight) <= x_threshold && (parent_local_snap_rect.mRight - test_rect.mRight) * mouse_dir.mX >= 0)
2071 // {
2072 // view_rect.translate(parent_local_snap_rect.mRight - view_rect.mRight, 0);
2073 // snap_view = mParentView;
2074 // x_threshold = llabs(parent_local_snap_rect.mRight - test_rect.mRight);
2075 // }
2076
2077 // if (llabs(test_rect.mLeft - parent_local_snap_rect.mLeft) <= x_threshold && test_rect.mLeft * mouse_dir.mX <= 0)
2078 // {
2079 // view_rect.translate(parent_local_snap_rect.mLeft - view_rect.mLeft, 0);
2080 // snap_view = mParentView;
2081 // x_threshold = llabs(test_rect.mLeft - parent_local_snap_rect.mLeft);
2082 // }
2083
2084 // if (llabs(test_rect.mBottom - parent_local_snap_rect.mBottom) <= y_threshold && test_rect.mBottom * mouse_dir.mY <= 0)
2085 // {
2086 // view_rect.translate(0, parent_local_snap_rect.mBottom - view_rect.mBottom);
2087 // snap_view = mParentView;
2088 // y_threshold = llabs(test_rect.mBottom - parent_local_snap_rect.mBottom);
2089 // }
2090
2091 // if (llabs(parent_local_snap_rect.mTop - test_rect.mTop) <= y_threshold && (parent_local_snap_rect.mTop - test_rect.mTop) * mouse_dir.mY >= 0)
2092 // {
2093 // view_rect.translate(0, parent_local_snap_rect.mTop - view_rect.mTop);
2094 // snap_view = mParentView;
2095 // y_threshold = llabs(parent_local_snap_rect.mTop - test_rect.mTop);
2096 // }
2097 //}
2098 //if (snap_type == SNAP_SIBLINGS || snap_type == SNAP_PARENT_AND_SIBLINGS)
2099 //{
2100 // for ( child_list_const_iter_t child_it = mParentView->getChildList()->begin();
2101 // child_it != mParentView->getChildList()->end(); ++child_it)
2102 // {
2103 // LLView* siblingp = *child_it;
2104
2105 // // skip non-snappable views (self, invisible views, etc)
2106 // if (!canSnapTo(siblingp)) continue;
2107
2108 // LLRect sibling_rect = siblingp->getSnapRect();
2109
2110 // if (llabs(test_rect.mRight - sibling_rect.mLeft) <= x_threshold
2111 // && (test_rect.mRight - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2112 // {
2113 // view_rect.translate(sibling_rect.mLeft - view_rect.mRight, 0);
2114 // if (llabs(test_rect.mTop - sibling_rect.mTop) <= y_threshold && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0)
2115 // {
2116 // view_rect.translate(0, sibling_rect.mTop - test_rect.mTop);
2117 // y_threshold = llabs(test_rect.mTop - sibling_rect.mTop);
2118 // }
2119 // else if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= y_threshold && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2120 // {
2121 // view_rect.translate(0, sibling_rect.mBottom - test_rect.mBottom);
2122 // y_threshold = llabs(test_rect.mBottom - sibling_rect.mBottom);
2123 // }
2124 // snap_view = siblingp;
2125 // x_threshold = llabs(test_rect.mRight - sibling_rect.mLeft);
2126 // }
2127
2128 // if (llabs(test_rect.mLeft - sibling_rect.mRight) <= x_threshold
2129 // && (test_rect.mLeft - sibling_rect.mRight) * mouse_dir.mX <= 0)
2130 // {
2131 // view_rect.translate(sibling_rect.mRight - view_rect.mLeft, 0);
2132 // if (llabs(test_rect.mTop - sibling_rect.mTop) <= y_threshold && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0)
2133 // {
2134 // view_rect.translate(0, sibling_rect.mTop - test_rect.mTop);
2135 // y_threshold = llabs(test_rect.mTop - sibling_rect.mTop);
2136 // }
2137 // else if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= y_threshold && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2138 // {
2139 // view_rect.translate(0, sibling_rect.mBottom - test_rect.mBottom);
2140 // y_threshold = llabs(test_rect.mBottom - sibling_rect.mBottom);
2141 // }
2142 // snap_view = siblingp;
2143 // x_threshold = llabs(test_rect.mLeft - sibling_rect.mRight);
2144 // }
2145
2146 // if (llabs(test_rect.mBottom - sibling_rect.mTop) <= y_threshold
2147 // && (test_rect.mBottom - sibling_rect.mTop) * mouse_dir.mY <= 0)
2148 // {
2149 // view_rect.translate(0, sibling_rect.mTop - view_rect.mBottom);
2150 // if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= x_threshold && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2151 // {
2152 // view_rect.translate(sibling_rect.mLeft - test_rect.mLeft, 0);
2153 // x_threshold = llabs(test_rect.mLeft - sibling_rect.mLeft);
2154 // }
2155 // else if (llabs(test_rect.mRight - sibling_rect.mRight) <= x_threshold && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2156 // {
2157 // view_rect.translate(sibling_rect.mRight - test_rect.mRight, 0);
2158 // x_threshold = llabs(test_rect.mRight - sibling_rect.mRight);
2159 // }
2160 // snap_view = siblingp;
2161 // y_threshold = llabs(test_rect.mBottom - sibling_rect.mTop);
2162 // }
2163
2164 // if (llabs(test_rect.mTop - sibling_rect.mBottom) <= y_threshold
2165 // && (test_rect.mTop - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2166 // {
2167 // view_rect.translate(0, sibling_rect.mBottom - view_rect.mTop);
2168 // if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= x_threshold && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2169 // {
2170 // view_rect.translate(sibling_rect.mLeft - test_rect.mLeft, 0);
2171 // x_threshold = llabs(test_rect.mLeft - sibling_rect.mLeft);
2172 // }
2173 // else if (llabs(test_rect.mRight - sibling_rect.mRight) <= x_threshold && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2174 // {
2175 // view_rect.translate(sibling_rect.mRight - test_rect.mRight, 0);
2176 // x_threshold = llabs(test_rect.mRight - sibling_rect.mRight);
2177 // }
2178 // snap_view = siblingp;
2179 // y_threshold = llabs(test_rect.mTop - sibling_rect.mBottom);
2180 // }
2181 // }
2182 //}
2183
2184 //// shrink actual view rect back down
2185 //view_rect.stretch(-padding);
2186 //new_rect = view_rect;
2187 //return snap_view;
2364} 2188}
2365 2189
2366LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding) 2190LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESnapEdge snap_edge, ESnapType snap_type, S32 threshold, S32 padding)
@@ -2396,8 +2220,8 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna
2396 LLRect test_rect = snap_rect; 2220 LLRect test_rect = snap_rect;
2397 test_rect.stretch(padding); 2221 test_rect.stretch(padding);
2398 2222
2399 BOOL snapped_x = FALSE; 2223 S32 x_threshold = threshold;
2400 BOOL snapped_y = FALSE; 2224 S32 y_threshold = threshold;
2401 2225
2402 LLRect parent_local_snap_rect = mParentView->getLocalSnapRect(); 2226 LLRect parent_local_snap_rect = mParentView->getLocalSnapRect();
2403 2227
@@ -2406,35 +2230,38 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna
2406 switch(snap_edge) 2230 switch(snap_edge)
2407 { 2231 {
2408 case SNAP_RIGHT: 2232 case SNAP_RIGHT:
2409 if (llabs(parent_local_snap_rect.mRight - test_rect.mRight) <= threshold && (parent_local_snap_rect.mRight - test_rect.mRight) * mouse_dir.mX >= 0) 2233 if (llabs(parent_local_snap_rect.mRight - test_rect.mRight) <= x_threshold
2234 && (parent_local_snap_rect.mRight - test_rect.mRight) * mouse_dir.mX >= 0)
2410 { 2235 {
2411 snap_pos = parent_local_snap_rect.mRight - padding; 2236 snap_pos = parent_local_snap_rect.mRight - padding;
2412 snap_view = mParentView; 2237 snap_view = mParentView;
2413 snapped_x = TRUE; 2238 x_threshold = llabs(parent_local_snap_rect.mRight - test_rect.mRight);
2414 } 2239 }
2415 break; 2240 break;
2416 case SNAP_LEFT: 2241 case SNAP_LEFT:
2417 if (llabs(test_rect.mLeft - parent_local_snap_rect.mLeft) <= threshold && test_rect.mLeft * mouse_dir.mX <= 0) 2242 if (llabs(test_rect.mLeft - parent_local_snap_rect.mLeft) <= x_threshold
2243 && test_rect.mLeft * mouse_dir.mX <= 0)
2418 { 2244 {
2419 snap_pos = parent_local_snap_rect.mLeft + padding; 2245 snap_pos = parent_local_snap_rect.mLeft + padding;
2420 snap_view = mParentView; 2246 snap_view = mParentView;
2421 snapped_x = TRUE; 2247 x_threshold = llabs(test_rect.mLeft - parent_local_snap_rect.mLeft);
2422 } 2248 }
2423 break; 2249 break;
2424 case SNAP_BOTTOM: 2250 case SNAP_BOTTOM:
2425 if (llabs(test_rect.mBottom - parent_local_snap_rect.mBottom) <= threshold && test_rect.mBottom * mouse_dir.mY <= 0) 2251 if (llabs(test_rect.mBottom - parent_local_snap_rect.mBottom) <= y_threshold
2252 && test_rect.mBottom * mouse_dir.mY <= 0)
2426 { 2253 {
2427 snap_pos = parent_local_snap_rect.mBottom + padding; 2254 snap_pos = parent_local_snap_rect.mBottom + padding;
2428 snap_view = mParentView; 2255 snap_view = mParentView;
2429 snapped_y = TRUE; 2256 y_threshold = llabs(test_rect.mBottom - parent_local_snap_rect.mBottom);
2430 } 2257 }
2431 break; 2258 break;
2432 case SNAP_TOP: 2259 case SNAP_TOP:
2433 if (llabs(parent_local_snap_rect.mTop - test_rect.mTop) <= threshold && (parent_local_snap_rect.mTop - test_rect.mTop) * mouse_dir.mY >= 0) 2260 if (llabs(parent_local_snap_rect.mTop - test_rect.mTop) <= y_threshold && (parent_local_snap_rect.mTop - test_rect.mTop) * mouse_dir.mY >= 0)
2434 { 2261 {
2435 snap_pos = parent_local_snap_rect.mTop - padding; 2262 snap_pos = parent_local_snap_rect.mTop - padding;
2436 snap_view = mParentView; 2263 snap_view = mParentView;
2437 snapped_y = TRUE; 2264 y_threshold = llabs(parent_local_snap_rect.mTop - test_rect.mTop);
2438 } 2265 }
2439 break; 2266 break;
2440 default: 2267 default:
@@ -2448,111 +2275,100 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna
2448 child_it != mParentView->getChildList()->end(); ++child_it) 2275 child_it != mParentView->getChildList()->end(); ++child_it)
2449 { 2276 {
2450 LLView* siblingp = *child_it; 2277 LLView* siblingp = *child_it;
2451 // skip self 2278
2452 if (siblingp == this || !siblingp->getVisible() || !canSnapTo(siblingp)) 2279 if (!canSnapTo(siblingp)) continue;
2453 {
2454 continue;
2455 }
2456 2280
2457 LLRect sibling_rect = siblingp->getSnapRect(); 2281 LLRect sibling_rect = siblingp->getSnapRect();
2458 2282
2459 switch(snap_edge) 2283 switch(snap_edge)
2460 { 2284 {
2461 case SNAP_RIGHT: 2285 case SNAP_RIGHT:
2462 if (!snapped_x) 2286 if (llabs(test_rect.mRight - sibling_rect.mLeft) <= x_threshold
2287 && (test_rect.mRight - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2463 { 2288 {
2464 if (llabs(test_rect.mRight - sibling_rect.mLeft) <= threshold && (test_rect.mRight - sibling_rect.mLeft) * mouse_dir.mX <= 0) 2289 snap_pos = sibling_rect.mLeft - padding;
2290 snap_view = siblingp;
2291 x_threshold = llabs(test_rect.mRight - sibling_rect.mLeft);
2292 }
2293 // if snapped with sibling along other axis, check for shared edge
2294 else if (llabs(sibling_rect.mTop - (test_rect.mBottom - padding)) <= y_threshold
2295 || llabs(sibling_rect.mBottom - (test_rect.mTop + padding)) <= x_threshold)
2296 {
2297 if (llabs(test_rect.mRight - sibling_rect.mRight) <= x_threshold
2298 && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2465 { 2299 {
2466 snap_pos = sibling_rect.mLeft - padding; 2300 snap_pos = sibling_rect.mRight;
2467 snap_view = siblingp; 2301 snap_view = siblingp;
2468 snapped_x = TRUE; 2302 x_threshold = llabs(test_rect.mRight - sibling_rect.mRight);
2469 }
2470 // if snapped with sibling along other axis, check for shared edge
2471 else if (llabs(sibling_rect.mTop - (test_rect.mBottom - padding)) <= threshold ||
2472 llabs(sibling_rect.mBottom - (test_rect.mTop + padding)) <= threshold)
2473 {
2474 if (llabs(test_rect.mRight - sibling_rect.mRight) <= threshold && (test_rect.mRight - sibling_rect.mRight) * mouse_dir.mX <= 0)
2475 {
2476 snap_pos = sibling_rect.mRight;
2477 snap_view = siblingp;
2478 snapped_x = TRUE;
2479 }
2480 } 2303 }
2481 } 2304 }
2482 break; 2305 break;
2483 case SNAP_LEFT: 2306 case SNAP_LEFT:
2484 if (!snapped_x) 2307 if (llabs(test_rect.mLeft - sibling_rect.mRight) <= x_threshold
2308 && (test_rect.mLeft - sibling_rect.mRight) * mouse_dir.mX <= 0)
2309 {
2310 snap_pos = sibling_rect.mRight + padding;
2311 snap_view = siblingp;
2312 x_threshold = llabs(test_rect.mLeft - sibling_rect.mRight);
2313 }
2314 // if snapped with sibling along other axis, check for shared edge
2315 else if (llabs(sibling_rect.mTop - (test_rect.mBottom - padding)) <= y_threshold
2316 || llabs(sibling_rect.mBottom - (test_rect.mTop + padding)) <= y_threshold)
2485 { 2317 {
2486 if (llabs(test_rect.mLeft - sibling_rect.mRight) <= threshold && (test_rect.mLeft - sibling_rect.mRight) * mouse_dir.mX <= 0) 2318 if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= x_threshold
2319 && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2487 { 2320 {
2488 snap_pos = sibling_rect.mRight + padding; 2321 snap_pos = sibling_rect.mLeft;
2489 snap_view = siblingp; 2322 snap_view = siblingp;
2490 snapped_x = TRUE; 2323 x_threshold = llabs(test_rect.mLeft - sibling_rect.mLeft);
2491 }
2492 // if snapped with sibling along other axis, check for shared edge
2493 else if (llabs(sibling_rect.mTop - (test_rect.mBottom - padding)) <= threshold ||
2494 llabs(sibling_rect.mBottom - (test_rect.mTop + padding)) <= threshold)
2495 {
2496 if (llabs(test_rect.mLeft - sibling_rect.mLeft) <= threshold && (test_rect.mLeft - sibling_rect.mLeft) * mouse_dir.mX <= 0)
2497 {
2498 snap_pos = sibling_rect.mLeft;
2499 snap_view = siblingp;
2500 snapped_x = TRUE;
2501 }
2502 } 2324 }
2503 } 2325 }
2504 break; 2326 break;
2505 case SNAP_BOTTOM: 2327 case SNAP_BOTTOM:
2506 if (!snapped_y) 2328 if (llabs(test_rect.mBottom - sibling_rect.mTop) <= y_threshold
2329 && (test_rect.mBottom - sibling_rect.mTop) * mouse_dir.mY <= 0)
2507 { 2330 {
2508 if (llabs(test_rect.mBottom - sibling_rect.mTop) <= threshold && (test_rect.mBottom - sibling_rect.mTop) * mouse_dir.mY <= 0) 2331 snap_pos = sibling_rect.mTop + padding;
2332 snap_view = siblingp;
2333 y_threshold = llabs(test_rect.mBottom - sibling_rect.mTop);
2334 }
2335 // if snapped with sibling along other axis, check for shared edge
2336 else if (llabs(sibling_rect.mRight - (test_rect.mLeft - padding)) <= x_threshold
2337 || llabs(sibling_rect.mLeft - (test_rect.mRight + padding)) <= x_threshold)
2338 {
2339 if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= y_threshold
2340 && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2509 { 2341 {
2510 snap_pos = sibling_rect.mTop + padding; 2342 snap_pos = sibling_rect.mBottom;
2511 snap_view = siblingp; 2343 snap_view = siblingp;
2512 snapped_y = TRUE; 2344 y_threshold = llabs(test_rect.mBottom - sibling_rect.mBottom);
2513 }
2514 // if snapped with sibling along other axis, check for shared edge
2515 else if (llabs(sibling_rect.mRight - (test_rect.mLeft - padding)) <= threshold ||
2516 llabs(sibling_rect.mLeft - (test_rect.mRight + padding)) <= threshold)
2517 {
2518 if (llabs(test_rect.mBottom - sibling_rect.mBottom) <= threshold && (test_rect.mBottom - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2519 {
2520 snap_pos = sibling_rect.mBottom;
2521 snap_view = siblingp;
2522 snapped_y = TRUE;
2523 }
2524 } 2345 }
2525 } 2346 }
2526 break; 2347 break;
2527 case SNAP_TOP: 2348 case SNAP_TOP:
2528 if (!snapped_y) 2349 if (llabs(test_rect.mTop - sibling_rect.mBottom) <= y_threshold
2350 && (test_rect.mTop - sibling_rect.mBottom) * mouse_dir.mY <= 0)
2351 {
2352 snap_pos = sibling_rect.mBottom - padding;
2353 snap_view = siblingp;
2354 y_threshold = llabs(test_rect.mTop - sibling_rect.mBottom);
2355 }
2356 // if snapped with sibling along other axis, check for shared edge
2357 else if (llabs(sibling_rect.mRight - (test_rect.mLeft - padding)) <= x_threshold
2358 || llabs(sibling_rect.mLeft - (test_rect.mRight + padding)) <= x_threshold)
2529 { 2359 {
2530 if (llabs(test_rect.mTop - sibling_rect.mBottom) <= threshold && (test_rect.mTop - sibling_rect.mBottom) * mouse_dir.mY <= 0) 2360 if (llabs(test_rect.mTop - sibling_rect.mTop) <= y_threshold
2361 && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0)
2531 { 2362 {
2532 snap_pos = sibling_rect.mBottom - padding; 2363 snap_pos = sibling_rect.mTop;
2533 snap_view = siblingp; 2364 snap_view = siblingp;
2534 snapped_y = TRUE; 2365 y_threshold = llabs(test_rect.mTop - sibling_rect.mTop);
2535 }
2536 // if snapped with sibling along other axis, check for shared edge
2537 else if (llabs(sibling_rect.mRight - (test_rect.mLeft - padding)) <= threshold ||
2538 llabs(sibling_rect.mLeft - (test_rect.mRight + padding)) <= threshold)
2539 {
2540 if (llabs(test_rect.mTop - sibling_rect.mTop) <= threshold && (test_rect.mTop - sibling_rect.mTop) * mouse_dir.mY <= 0)
2541 {
2542 snap_pos = sibling_rect.mTop;
2543 snap_view = siblingp;
2544 snapped_y = TRUE;
2545 }
2546 } 2366 }
2547 } 2367 }
2548 break; 2368 break;
2549 default: 2369 default:
2550 llerrs << "Invalid snap edge" << llendl; 2370 llerrs << "Invalid snap edge" << llendl;
2551 } 2371 }
2552 if (snapped_x && snapped_y)
2553 {
2554 break;
2555 }
2556 } 2372 }
2557 } 2373 }
2558 2374
@@ -2560,21 +2376,6 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna
2560 return snap_view; 2376 return snap_view;
2561} 2377}
2562 2378
2563bool operator==(const LLViewHandle& lhs, const LLViewHandle& rhs)
2564{
2565 return lhs.mID == rhs.mID;
2566}
2567
2568bool operator!=(const LLViewHandle& lhs, const LLViewHandle& rhs)
2569{
2570 return lhs.mID != rhs.mID;
2571}
2572
2573bool operator<(const LLViewHandle &lhs, const LLViewHandle &rhs)
2574{
2575 return lhs.mID < rhs.mID;
2576}
2577
2578//----------------------------------------------------------------------------- 2379//-----------------------------------------------------------------------------
2579// Listener dispatch functions 2380// Listener dispatch functions
2580//----------------------------------------------------------------------------- 2381//-----------------------------------------------------------------------------
@@ -2865,13 +2666,6 @@ void LLView::initFromXML(LLXMLNodePtr node, LLView* parent)
2865 setVisible(visible); 2666 setVisible(visible);
2866 } 2667 }
2867 2668
2868 if (node->hasAttribute("hidden"))
2869 {
2870 BOOL hidden;
2871 node->getAttributeBOOL("hidden", hidden);
2872 setHidden(hidden);
2873 }
2874
2875 node->getAttributeBOOL("use_bounding_rect", mUseBoundingRect); 2669 node->getAttributeBOOL("use_bounding_rect", mUseBoundingRect);
2876 node->getAttributeBOOL("mouse_opaque", mMouseOpaque); 2670 node->getAttributeBOOL("mouse_opaque", mMouseOpaque);
2877 2671
@@ -3003,12 +2797,6 @@ void LLView::setControlValue(const LLSD& value)
3003} 2797}
3004 2798
3005//virtual 2799//virtual
3006LLString LLView::getControlName() const
3007{
3008 return mControlName;
3009}
3010
3011//virtual
3012void LLView::setControlName(const LLString& control_name, LLView *context) 2800void LLView::setControlName(const LLString& control_name, LLView *context)
3013{ 2801{
3014 if (context == NULL) 2802 if (context == NULL)
@@ -3047,11 +2835,6 @@ bool LLView::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
3047 return FALSE; 2835 return FALSE;
3048} 2836}
3049 2837
3050void LLView::setValue(const LLSD& value)
3051{
3052}
3053
3054
3055void LLView::addBoolControl(LLString name, bool initial_value) 2838void LLView::addBoolControl(LLString name, bool initial_value)
3056{ 2839{
3057 mFloaterControls[name] = new LLControl(name, TYPE_BOOLEAN, initial_value, "Internal floater control"); 2840 mFloaterControls[name] = new LLControl(name, TYPE_BOOLEAN, initial_value, "Internal floater control");
@@ -3066,3 +2849,14 @@ LLControlBase *LLView::getControl(LLString name)
3066 } 2849 }
3067 return NULL; 2850 return NULL;
3068} 2851}
2852
2853//virtual
2854void LLView::setValue(const LLSD& value)
2855{
2856}
2857
2858//virtual
2859LLSD LLView::getValue() const
2860{
2861 return LLSD();
2862}