aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui')
-rw-r--r--linden/indra/llui/lldraghandle.cpp14
-rw-r--r--linden/indra/llui/llfloater.cpp79
-rw-r--r--linden/indra/llui/llfloater.h3
3 files changed, 49 insertions, 47 deletions
diff --git a/linden/indra/llui/lldraghandle.cpp b/linden/indra/llui/lldraghandle.cpp
index a3d28ad..3497f0d 100644
--- a/linden/indra/llui/lldraghandle.cpp
+++ b/linden/indra/llui/lldraghandle.cpp
@@ -328,7 +328,12 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask)
328 // Resize the parent 328 // Resize the parent
329 S32 delta_x = screen_x - mDragLastScreenX; 329 S32 delta_x = screen_x - mDragLastScreenX;
330 S32 delta_y = screen_y - mDragLastScreenY; 330 S32 delta_y = screen_y - mDragLastScreenY;
331 getParent()->translate(delta_x, delta_y); 331
332 LLRect original_rect = getParent()->getRect();
333 LLRect translated_rect = getParent()->getRect();
334 translated_rect.translate(delta_x, delta_y);
335 // temporarily slam dragged window to new position
336 getParent()->setRect(translated_rect);
332 S32 pre_snap_x = getParent()->getRect().mLeft; 337 S32 pre_snap_x = getParent()->getRect().mLeft;
333 S32 pre_snap_y = getParent()->getRect().mBottom; 338 S32 pre_snap_y = getParent()->getRect().mBottom;
334 mDragLastScreenX = screen_x; 339 mDragLastScreenX = screen_x;
@@ -348,7 +353,12 @@ BOOL LLDragHandle::handleHover(S32 x, S32 y, MASK mask)
348 getParent()->snappedTo(snap_view); 353 getParent()->snappedTo(snap_view);
349 delta_x = new_rect.mLeft - pre_snap_x; 354 delta_x = new_rect.mLeft - pre_snap_x;
350 delta_y = new_rect.mBottom - pre_snap_y; 355 delta_y = new_rect.mBottom - pre_snap_y;
351 getParent()->translate(delta_x, delta_y); 356 translated_rect.translate(delta_x, delta_y);
357
358 // restore original rect so delta are detected, then call user reshape method to handle snapped floaters, etc
359 getParent()->setRect(original_rect);
360 getParent()->userSetShape(translated_rect);
361
352 mDragLastScreenX += delta_x; 362 mDragLastScreenX += delta_x;
353 mDragLastScreenY += delta_y; 363 mDragLastScreenY += delta_y;
354 364
diff --git a/linden/indra/llui/llfloater.cpp b/linden/indra/llui/llfloater.cpp
index 1613fd7..df44a58 100644
--- a/linden/indra/llui/llfloater.cpp
+++ b/linden/indra/llui/llfloater.cpp
@@ -675,25 +675,6 @@ const LLString& LLFloater::getTitle() const
675 return mDragHandle ? mDragHandle->getTitle() : LLString::null; 675 return mDragHandle ? mDragHandle->getTitle() : LLString::null;
676} 676}
677 677
678void LLFloater::translate(S32 x, S32 y)
679{
680 LLPanel::translate(x, y);
681
682 if (x != 0 || y != 0)
683 {
684 for(handle_set_iter_t dependent_it = mDependents.begin();
685 dependent_it != mDependents.end(); ++dependent_it)
686 {
687 LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it);
688 // is a dependent snapped to us?
689 if (floaterp && floaterp->getSnapTarget() == mViewHandle)
690 {
691 floaterp->translate(x, y);
692 }
693 }
694 }
695}
696
697BOOL LLFloater::canSnapTo(LLView* other_view) 678BOOL LLFloater::canSnapTo(LLView* other_view)
698{ 679{
699 if (NULL == other_view) 680 if (NULL == other_view)
@@ -731,14 +712,13 @@ void LLFloater::snappedTo(LLView* snap_view)
731 } 712 }
732} 713}
733 714
734void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent) 715void LLFloater::userSetShape(const LLRect& new_rect)
735{ 716{
736 S32 old_width = mRect.getWidth(); 717 LLRect old_rect = mRect;
737 S32 old_height = mRect.getHeight(); 718 LLView::userSetShape(new_rect);
738
739 LLView::reshape(width, height, called_from_parent);
740 719
741 if (width != old_width || height != old_height) 720 // if not minimized, adjust all snapped dependents to new shape
721 if (!isMinimized())
742 { 722 {
743 // gather all snapped dependents 723 // gather all snapped dependents
744 for(handle_set_iter_t dependent_it = mDependents.begin(); 724 for(handle_set_iter_t dependent_it = mDependents.begin();
@@ -750,22 +730,27 @@ void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
750 { 730 {
751 S32 delta_x = 0; 731 S32 delta_x = 0;
752 S32 delta_y = 0; 732 S32 delta_y = 0;
753 // check to see if it snapped to right or top 733 // check to see if it snapped to right or top, and move if dependee floater is resizing
754 LLRect floater_rect = floaterp->getRect(); 734 LLRect dependent_rect = floaterp->getRect();
755 if (floater_rect.mLeft - mRect.mLeft >= old_width || 735 if (dependent_rect.mLeft - mRect.mLeft >= old_rect.getWidth() || // dependent on my right?
756 floater_rect.mRight == mRect.mLeft + old_width) 736 dependent_rect.mRight == mRect.mLeft + old_rect.getWidth()) // dependent aligned with my right
757 { 737 {
758 // was snapped directly onto right side or aligned with it 738 // was snapped directly onto right side or aligned with it
759 delta_x += width - old_width; 739 delta_x += new_rect.getWidth() - old_rect.getWidth();
760 } 740 }
761 if (floater_rect.mBottom - mRect.mBottom >= old_height || 741 if (dependent_rect.mBottom - mRect.mBottom >= old_rect.getHeight() ||
762 floater_rect.mTop == mRect.mBottom + old_height) 742 dependent_rect.mTop == mRect.mBottom + old_rect.getHeight())
763 { 743 {
764 // was snapped directly onto top side or aligned with it 744 // was snapped directly onto top side or aligned with it
765 delta_y += height - old_height; 745 delta_y += new_rect.getHeight() - old_rect.getHeight();
766 } 746 }
767 747
768 floaterp->translate(delta_x, delta_y); 748 // take translation of dependee floater into account as well
749 delta_x += new_rect.mLeft - old_rect.mLeft;
750 delta_y += new_rect.mBottom - old_rect.mBottom;
751
752 dependent_rect.translate(delta_x, delta_y);
753 floaterp->userSetShape(dependent_rect);
769 } 754 }
770 } 755 }
771 } 756 }
@@ -812,28 +797,33 @@ void LLFloater::setMinimized(BOOL minimize)
812 setBorderVisible(TRUE); 797 setBorderVisible(TRUE);
813 798
814 for(handle_set_iter_t dependent_it = mDependents.begin(); 799 for(handle_set_iter_t dependent_it = mDependents.begin();
815 dependent_it != mDependents.end(); ) 800 dependent_it != mDependents.end();
801 ++dependent_it)
816 { 802 {
817 LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); 803 LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it);
818 if (floaterp) 804 if (floaterp)
819 { 805 {
820 floaterp->setVisible(FALSE); 806 if (floaterp->isMinimizeable())
807 {
808 floaterp->setMinimized(TRUE);
809 }
810 else if (!floaterp->isMinimized())
811 {
812 floaterp->setVisible(FALSE);
813 }
821 } 814 }
822 ++dependent_it;
823 } 815 }
824 816
825 mMinimized = TRUE;
826
827 // Lose keyboard focus when minimized 817 // Lose keyboard focus when minimized
828 releaseFocus(); 818 releaseFocus();
819
820 mMinimized = TRUE;
829 } 821 }
830 else 822 else
831 { 823 {
832 reshape( mPreviousRect.getWidth(), mPreviousRect.getHeight(), TRUE ); 824 reshape( mPreviousRect.getWidth(), mPreviousRect.getHeight(), TRUE );
833 setOrigin( mPreviousRect.mLeft, mPreviousRect.mBottom ); 825 setOrigin( mPreviousRect.mLeft, mPreviousRect.mBottom );
834 826
835 mMinimized = FALSE;
836
837 if (mButtonsEnabled[BUTTON_RESTORE]) 827 if (mButtonsEnabled[BUTTON_RESTORE])
838 { 828 {
839 mButtonsEnabled[BUTTON_MINIMIZE] = TRUE; 829 mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
@@ -857,15 +847,18 @@ void LLFloater::setMinimized(BOOL minimize)
857 847
858 // show dependent floater 848 // show dependent floater
859 for(handle_set_iter_t dependent_it = mDependents.begin(); 849 for(handle_set_iter_t dependent_it = mDependents.begin();
860 dependent_it != mDependents.end(); ) 850 dependent_it != mDependents.end();
851 ++dependent_it)
861 { 852 {
862 LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it); 853 LLFloater* floaterp = LLFloater::getFloaterByHandle(*dependent_it);
863 if (floaterp) 854 if (floaterp)
864 { 855 {
856 floaterp->setMinimized(FALSE);
865 floaterp->setVisible(TRUE); 857 floaterp->setVisible(TRUE);
866 } 858 }
867 ++dependent_it;
868 } 859 }
860
861 mMinimized = FALSE;
869 } 862 }
870 make_ui_sound("UISndWindowClose"); 863 make_ui_sound("UISndWindowClose");
871 updateButtons(); 864 updateButtons();
diff --git a/linden/indra/llui/llfloater.h b/linden/indra/llui/llfloater.h
index e752d8b..cd45762 100644
--- a/linden/indra/llui/llfloater.h
+++ b/linden/indra/llui/llfloater.h
@@ -108,8 +108,7 @@ public:
108 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); 108 static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory);
109 void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE); 109 void initFloaterXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory, BOOL open = TRUE);
110 110
111 /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = 1); 111 /*virtual*/ void userSetShape(const LLRect& new_rect);
112 /*virtual*/ void translate(S32 x, S32 y);
113 /*virtual*/ BOOL canSnapTo(LLView* other_view); 112 /*virtual*/ BOOL canSnapTo(LLView* other_view);
114 /*virtual*/ void snappedTo(LLView* snap_view); 113 /*virtual*/ void snappedTo(LLView* snap_view);
115 /*virtual*/ void setFocus( BOOL b ); 114 /*virtual*/ void setFocus( BOOL b );