From cdb223228479e97d9cfe7d80d0afef0d99179d24 Mon Sep 17 00:00:00 2001
From: richard <none@none>
Date: Wed, 25 Nov 2009 18:24:39 -0800
Subject: [PATCH] created container for LLFloaterView for future z-swapping
 with sidetray floaters can now overlap sidetray fixed text selection
 background color to be inverse of text fg color EXT-2713 	Script editor
 automatically scrolls to the top of script text when text is longer than the
 window.

reviewed by James
---
 indra/llui/llfloater.cpp                      |  5 ++-
 indra/llui/llscrollcontainer.cpp              |  5 +--
 indra/llui/llscrollcontainer.h                |  2 +-
 indra/llui/lltextbase.cpp                     | 34 +++++++++----------
 indra/llui/lltooltip.cpp                      |  5 ++-
 indra/newview/llchathistory.cpp               |  2 +-
 indra/newview/llchiclet.cpp                   |  2 +-
 indra/newview/llviewerwindow.cpp              |  6 ++--
 indra/newview/llviewerwindow.h                |  5 ++-
 .../skins/default/xui/en/main_view.xml        | 18 +++++++---
 .../default/xui/en/panel_chat_header.xml      | 28 ++++++++-------
 11 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 8cf65fe76a4..36a9e0a6505 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2347,8 +2347,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
 	}
 	LLRect::tCoordType screen_width = getSnapRect().getWidth();
 	LLRect::tCoordType screen_height = getSnapRect().getHeight();
-	// convert to local coordinate frame
-	LLRect snap_rect_local = getLocalSnapRect();
+
 
 	// only automatically resize non-minimized, resizable floaters
 	if( floater->isResizable() && !floater->isMinimized() )
@@ -2388,7 +2387,7 @@ void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_out
 	}
 
 	// move window fully onscreen
-	if (floater->translateIntoRect( snap_rect_local, allow_partial_outside ))
+	if (floater->translateIntoRect( getLocalRect(), allow_partial_outside ))
 	{
 		floater->clearSnapTarget();
 	}
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index 5e17372fe94..53c5a8d07d3 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -584,8 +584,9 @@ LLRect LLScrollContainer::getVisibleContentRect()
 	return visible_rect;
 }
 
-LLRect LLScrollContainer::getContentWindowRect() const
+LLRect LLScrollContainer::getContentWindowRect()
 {
+	updateScroll();
 	LLRect scroller_view_rect;
 	S32 visible_width = 0;
 	S32 visible_height = 0;
@@ -625,7 +626,7 @@ void LLScrollContainer::scrollToShowRect(const LLRect& rect, const LLRect& const
 								rect_to_constrain.mTop - constraint.mTop);
 
 	// translate from allowable region for lower left corner to upper left corner
-	allowable_scroll_rect.translate(0, content_window_rect.getHeight());
+	allowable_scroll_rect.translate(0, content_window_rect.getHeight() - 1);
 
 	S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(), 
 					mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll
diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h
index ac8ffe52583..25dcd071aba 100644
--- a/indra/llui/llscrollcontainer.h
+++ b/indra/llui/llscrollcontainer.h
@@ -96,7 +96,7 @@ class LLScrollContainer : public LLUICtrl
 
 	void			setReserveScrollCorner( BOOL b ) { mReserveScrollCorner = b; }
 	LLRect			getVisibleContentRect();
-	LLRect			getContentWindowRect() const;
+	LLRect			getContentWindowRect();
 	const LLRect&	getScrolledViewRect() const { return mScrolledView ? mScrolledView->getRect() : LLRect::null; }
 	void			pageUp(S32 overlap = 0);
 	void			pageDown(S32 overlap = 0);
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 7bf10d774c3..6f9f98187ca 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -379,10 +379,10 @@ void LLTextBase::drawSelectionBackground()
 		
 		// Draw the selection box (we're using a box instead of reversing the colors on the selected text).
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		const LLColor4& color = mReadOnly ? mReadOnlyBgColor.get() : mWriteableBgColor.get();
+		const LLColor4& color = mReadOnly ? mReadOnlyFgColor.get() : mFgColor.get();
 		F32 alpha = hasFocus() ? 0.7f : 0.3f;
 		alpha *= getDrawContext().mAlpha;
-		gGL.color4f( 1.f - color.mV[0], 1.f - color.mV[1], 1.f - color.mV[2], alpha );
+		LLColor4 selection_color(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], alpha);
 
 		for (std::vector<LLRect>::iterator rect_it = selection_rects.begin();
 			rect_it != selection_rects.end();
@@ -390,7 +390,7 @@ void LLTextBase::drawSelectionBackground()
 		{
 			LLRect selection_rect = *rect_it;
 			selection_rect.translate(mTextRect.mLeft - content_display_rect.mLeft, mTextRect.mBottom - content_display_rect.mBottom);
-			gl_rect_2d(selection_rect);
+			gl_rect_2d(selection_rect, selection_color);
 		}
 	}
 }
@@ -1080,6 +1080,8 @@ void LLTextBase::reflow(S32 start_index)
 			mScrollIndex = mLineInfoList[first_line].mDocIndexStart;
 		}
 		LLRect first_char_rect = getLocalRectFromDocIndex(mScrollIndex);
+		// subtract off effect of horizontal scrollbar from local position of first char
+		first_char_rect.translate(-mTextRect.mLeft, -mTextRect.mBottom);
 
 		S32 cur_top = 0;
 
@@ -1195,7 +1197,6 @@ void LLTextBase::reflow(S32 start_index)
 		// apply scroll constraints after reflowing text
 		if (!hasMouseCapture() && mScroller)
 		{
-			LLRect visible_content_rect = getVisibleDocumentRect();
 			if (scrolled_to_bottom && mTrackEnd)
 			{
 				// keep bottom of text buffer visible
@@ -1204,18 +1205,16 @@ void LLTextBase::reflow(S32 start_index)
 			else if (hasSelection() && follow_selection)
 			{
 				// keep cursor in same vertical position on screen when selecting text
-				LLRect new_cursor_rect_doc = getLocalRectFromDocIndex(mCursorPos);
-				new_cursor_rect_doc.translate(visible_content_rect.mLeft, visible_content_rect.mBottom);
-				mScroller->scrollToShowRect(new_cursor_rect_doc, old_cursor_rect);
-				//llassert_always(getLocalRectFromDocIndex(mCursorPos).mBottom == old_cursor_rect.mBottom);
+				LLRect new_cursor_rect_doc = getDocRectFromDocIndex(mCursorPos);
+				LLRect old_cursor_rect_scroller = old_cursor_rect;
+				old_cursor_rect.translate(-mTextRect.mLeft, -mTextRect.mBottom);
+				mScroller->scrollToShowRect(new_cursor_rect_doc, old_cursor_rect_scroller);
 			}
 			else
 			{
 				// keep first line of text visible
-				LLRect new_first_char_rect = getLocalRectFromDocIndex(mScrollIndex);
-				new_first_char_rect.translate(visible_content_rect.mLeft, visible_content_rect.mBottom);
+				LLRect new_first_char_rect = getDocRectFromDocIndex(mScrollIndex);
 				mScroller->scrollToShowRect(new_first_char_rect, first_char_rect);
-				//llassert_always(getLocalRectFromDocIndex(mScrollIndex).mBottom == first_char_rect.mBottom);
 			}
 		}
 
@@ -1464,14 +1463,16 @@ void LLTextBase::setText(const LLStringExplicit &utf8str ,const LLStyle::Params&
 	clearSegments();
 //	createDefaultSegment();
 
-	startOfDoc();
 	deselect();
 
 	// append the new text (supports Url linking)
 	std::string text(utf8str);
 	LLStringUtil::removeCRLF(text);
 
+	// appendText modifies mCursorPos...
 	appendText(text, false, input_params);
+	// ...so move cursor to top after appending text
+	startOfDoc();
 
 	onValueChange(0, getLength());
 }
@@ -2065,16 +2066,15 @@ void LLTextBase::updateRects()
 			mContentsRect.unionWith(line_iter->mRect);
 		}
 
-		S32 delta_pos_x = -mContentsRect.mLeft;
 		mContentsRect.mTop += mVPad;
 
 		S32 delta_pos = -mContentsRect.mBottom;
 		// move line segments to fit new document rect
 		for (line_list_t::iterator it = mLineInfoList.begin(); it != mLineInfoList.end(); ++it)
 		{
-			it->mRect.translate(delta_pos_x, delta_pos);
+			it->mRect.translate(0, delta_pos);
 		}
-		mContentsRect.translate(delta_pos_x, delta_pos);
+		mContentsRect.translate(0, delta_pos);
 	}
 
 	// update document container dimensions according to text contents
@@ -2281,7 +2281,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
 					LLFontGL::LEFT, LLFontGL::TOP, 
 					0, 
 					LLFontGL::NO_SHADOW, 
-					length, rect.mRight, 
+					length, rect.getWidth(), 
 					&right_x, 
 					mEditor.getUseEllipses());
 	}
@@ -2298,7 +2298,7 @@ F32 LLNormalTextSegment::drawClippedSegment(S32 seg_start, S32 seg_end, S32 sele
 					LLFontGL::LEFT, LLFontGL::TOP, 
 					0, 
 					mStyle->getShadowType(), 
-					length, rect.mRight, 
+					length, rect.getWidth(), 
 					&right_x, 
 					mEditor.getUseEllipses());
 	}
diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp
index 959313a5b66..cf135997b29 100644
--- a/indra/llui/lltooltip.cpp
+++ b/indra/llui/lltooltip.cpp
@@ -300,9 +300,8 @@ void LLToolTip::initFromParams(const LLToolTip::Params& p)
 		mTextBox->setText(p.message());
 	}
 
-	LLRect text_contents_rect = mTextBox->getContentsRect();
-	S32 text_width = llmin(p.max_width(), text_contents_rect.getWidth());
-	S32 text_height = text_contents_rect.getHeight();
+	S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth());
+	S32 text_height = mTextBox->getTextPixelHeight();
 	mTextBox->reshape(text_width, text_height);
 
 	// reshape tooltip panel to fit text box
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 2c9b38b82a2..d08be335c37 100644
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -284,7 +284,7 @@ class LLChatHistoryHeader: public LLPanel
 		time_box->translate(delta_pos_x, delta_pos_y);
 
 		//... & change width of the name control
-		LLTextBox* user_name = getChild<LLTextBox>("user_name");
+		LLUICtrl* user_name = getChild<LLUICtrl>("user_name");
 		const LLRect& user_rect = user_name->getRect();
 		user_name->reshape(user_rect.getWidth() + delta_pos_x, user_rect.getHeight());
 	}
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index f41e326dd00..9aef02c5c89 100644
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -1362,7 +1362,7 @@ void LLChicletNotificationCounterCtrl::setCounter(S32 counter)
 LLRect LLChicletNotificationCounterCtrl::getRequiredRect()
 {
 	LLRect rc;
-	S32 text_width = getContentsRect().getWidth();
+	S32 text_width = getTextPixelWidth();
 
 	rc.mRight = rc.mLeft + llmax(text_width, mInitialWidth);
 	
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index f12937194db..9ba056a17c0 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1417,10 +1417,12 @@ void LLViewerWindow::initBase()
 
 	// placeholder widget that controls where "world" is rendered
 	mWorldViewPlaceholder = main_view->getChildView("world_view_rect")->getHandle();
+	mNonSideTrayView = main_view->getChildView("non_side_tray_view")->getHandle();
+	mFloaterViewHolder = main_view->getChildView("floater_view_holder")->getHandle();
 
 	// Constrain floaters to inside the menu and status bar regions.
-	gFloaterView = getRootView()->getChild<LLFloaterView>("Floater View");
-	gSnapshotFloaterView = getRootView()->getChild<LLSnapshotFloaterView>("Snapshot Floater View");
+	gFloaterView = main_view->getChild<LLFloaterView>("Floater View");
+	gSnapshotFloaterView = main_view->getChild<LLSnapshotFloaterView>("Snapshot Floater View");
 	
 	// Console
 	llassert( !gConsole );
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 747fd3b2536..1d564a13383 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -298,7 +298,8 @@ class LLViewerWindow : public LLWindowCallbacks
 	void				updateKeyboardFocus();		
 
 	void			updateWorldViewRect(bool use_full_window=false);
-
+	LLView*			getNonSideTrayView() { return mNonSideTrayView.get(); }
+	LLView*			getFloaterViewHolder() { return mFloaterViewHolder.get(); }
 	BOOL			handleKey(KEY key, MASK mask);
 	void			handleScrollWheel	(S32 clicks);
 
@@ -459,6 +460,8 @@ class LLViewerWindow : public LLWindowCallbacks
 	std::string		mInitAlert;			// Window / GL initialization requires an alert
 
 	LLHandle<LLView> mWorldViewPlaceholder;	// widget that spans the portion of screen dedicated to rendering the 3d world
+	LLHandle<LLView> mNonSideTrayView;		// parent of world view + bottom bar, etc...everything but the side tray
+	LLHandle<LLView> mFloaterViewHolder;	// container for floater_view
 	
 	class LLDebugText* mDebugText; // Internal class for debug text
 	
diff --git a/indra/newview/skins/default/xui/en/main_view.xml b/indra/newview/skins/default/xui/en/main_view.xml
index 3bf7f50a2c2..d99205b2fea 100644
--- a/indra/newview/skins/default/xui/en/main_view.xml
+++ b/indra/newview/skins/default/xui/en/main_view.xml
@@ -48,7 +48,7 @@
                height="500"
                layout="topleft"
                mouse_opaque="false"
-               name="main_view"
+               name="non_side_tray_view"
                user_resize="true"
                width="500">
           <view bottom="500"
@@ -108,15 +108,25 @@
                       visible="false"
                       width="333"/>
       </layout_stack>
-      <floater_view follows="all"
+      <panel follows="all"
                     height="500"
                     left="0"
                     mouse_opaque="false"
-                    name="Floater View"
+                    name="floater_view_holder"
                     tab_group="-1"
                     tab_stop="false"
                     top="0"
-                    width="1024"/>
+                    width="1024">
+        <floater_view follows="all"
+                      height="500"
+                      left="0"
+                      mouse_opaque="false"
+                      name="Floater View"
+                      tab_group="-1"
+                      tab_stop="false"
+                      top="0"
+                      width="1024"/>
+      </panel>
       <debug_view follows="all"
                   left="0"
                   top="0"
diff --git a/indra/newview/skins/default/xui/en/panel_chat_header.xml b/indra/newview/skins/default/xui/en/panel_chat_header.xml
index c1090a16865..95d8b9cb1ec 100644
--- a/indra/newview/skins/default/xui/en/panel_chat_header.xml
+++ b/indra/newview/skins/default/xui/en/panel_chat_header.xml
@@ -20,19 +20,21 @@
          top="3"
          width="18" />
     <text_editor
-	 v_pad = "0"
-	 read_only = "true"
-     follows="left|right"
-	 font.style="BOLD"
-	 height="12"
-	 layout="topleft"
-	 left_pad="5"
-     right="-60"
-     name="user_name"
-     text_color="white"
-	 top="8"
-	 use_ellipses="true"
-	 value="Ericag Vader" />
+      allow_scroll="false" 
+      v_pad = "0"
+      read_only = "true"
+      follows="left|right"
+      font.style="BOLD"
+      height="12"
+      layout="topleft"
+      left_pad="5"
+      right="-60"
+      name="user_name"
+      text_color="white"
+      bg_readonly_color="black"
+      top="8"
+      use_ellipses="true"
+      value="Ericag Vader" />
     <text
             font="SansSerifSmall"
          follows="right"
-- 
GitLab