aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llcontainerview.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/newview/llcontainerview.cpp
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llcontainerview.cpp108
1 files changed, 74 insertions, 34 deletions
diff --git a/linden/indra/newview/llcontainerview.cpp b/linden/indra/newview/llcontainerview.cpp
index 53c8e92..730da17 100644
--- a/linden/indra/newview/llcontainerview.cpp
+++ b/linden/indra/newview/llcontainerview.cpp
@@ -39,12 +39,15 @@
39#include "llui.h" 39#include "llui.h"
40#include "llresmgr.h" 40#include "llresmgr.h"
41#include "llstring.h" 41#include "llstring.h"
42#include "llscrollcontainer.h"
42 43
43LLContainerView::LLContainerView(const std::string& name, const LLRect& rect) 44LLContainerView::LLContainerView(const std::string& name, const LLRect& rect)
44: LLView(name, rect, FALSE) 45: LLView(name, rect, FALSE)
45{ 46{
47 mShowLabel = TRUE;
46 mCollapsible = TRUE; 48 mCollapsible = TRUE;
47 mDisplayChildren = TRUE; 49 mDisplayChildren = TRUE;
50 mScrollContainer = NULL;
48} 51}
49 52
50LLContainerView::~LLContainerView() 53LLContainerView::~LLContainerView()
@@ -52,77 +55,107 @@ LLContainerView::~LLContainerView()
52 // Children all cleaned up by default view destructor. 55 // Children all cleaned up by default view destructor.
53} 56}
54 57
55EWidgetType LLContainerView::getWidgetType() const
56{
57 return WIDGET_TYPE_CONTAINER_VIEW;
58}
59
60LLString LLContainerView::getWidgetTag() const
61{
62 return LL_CONTAINER_VIEW_TAG;
63}
64
65BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask) 58BOOL LLContainerView::handleMouseDown(S32 x, S32 y, MASK mask)
66{ 59{
67 BOOL handled = FALSE; 60 BOOL handled = FALSE;
68 if (mDisplayChildren) 61 if (mDisplayChildren)
69 { 62 {
70 handled = LLView::childrenHandleMouseDown(x, y, mask) != NULL; 63 handled = (LLView::childrenHandleMouseDown(x, y, mask) != NULL);
71 } 64 }
72 if (!handled) 65 if (!handled)
73 { 66 {
74 if( mCollapsible && (y >= getRect().getHeight() - 10) ) 67 if( mCollapsible && mShowLabel && (y >= getRect().getHeight() - 10) )
75 { 68 {
76 setDisplayChildren(!mDisplayChildren); 69 setDisplayChildren(!mDisplayChildren);
77 reshape(getRect().getWidth(), getRect().getHeight(), FALSE); 70 reshape(getRect().getWidth(), getRect().getHeight(), FALSE);
71 handled = TRUE;
78 } 72 }
79 } 73 }
80 return TRUE; 74 return handled;
81} 75}
82 76
83BOOL LLContainerView::handleMouseUp(S32 x, S32 y, MASK mask) 77BOOL LLContainerView::handleMouseUp(S32 x, S32 y, MASK mask)
84{ 78{
79 BOOL handled = FALSE;
85 if (mDisplayChildren) 80 if (mDisplayChildren)
86 { 81 {
87 LLView::childrenHandleMouseUp(x, y, mask); 82 handled = (LLView::childrenHandleMouseUp(x, y, mask) != NULL);
88 } 83 }
89 return TRUE; 84 return handled;
90} 85}
91 86
87
92void LLContainerView::draw() 88void LLContainerView::draw()
93{ 89{
94 if (!getVisible())
95 {
96 return;
97 }
98
99 { 90 {
100 LLGLSNoTexture gls_no_texture; 91 LLGLSNoTexture gls_no_texture;
101 92
102 gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); 93 gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
103 } 94 }
104 95
105 // Draw the label. 96 // Draw the label
106 gResMgr->getRes( LLFONT_OCRA )->renderUTF8(mLabel, 0, 2, getRect().getHeight() - 2, LLColor4(1,1,1,1), LLFontGL::LEFT, LLFontGL::TOP); 97 if (mShowLabel)
98 {
99 LLResMgr::getInstance()->getRes( LLFONT_OCRA )->renderUTF8(mLabel, 0, 2, getRect().getHeight() - 2, LLColor4(1,1,1,1), LLFontGL::LEFT, LLFontGL::TOP);
100 }
107 101
108 LLView::draw(); 102 LLView::draw();
109} 103}
110 104
105
111void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent) 106void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent)
112{ 107{
108 S32 desired_width = width;
109 S32 desired_height = height;
110
111 if (mScrollContainer)
112 {
113 BOOL dum_bool;
114 mScrollContainer->calcVisibleSize(&desired_width, &desired_height, &dum_bool, &dum_bool);
115 }
116 else
117 {
118 // if we're uncontained - make height as small as possible
119 desired_height = 0;
120 }
121
122 arrange(desired_width, desired_height, called_from_parent);
123
124 // sometimes, after layout, our container will change size (scrollbars popping in and out)
125 // if so, attempt another layout
126 if (mScrollContainer)
127 {
128 S32 new_container_width;
129 S32 new_container_height;
130 BOOL dum_bool;
131 mScrollContainer->calcVisibleSize(&new_container_width, &new_container_height, &dum_bool, &dum_bool);
132
133 if ((new_container_width != desired_width) ||
134 (new_container_height != desired_height)) // the container size has changed, attempt to arrange again
135 {
136 arrange(new_container_width, new_container_height, called_from_parent);
137 }
138 }
139}
140
141void LLContainerView::arrange(S32 width, S32 height, BOOL called_from_parent)
142{
113 // Determine the sizes and locations of all contained views 143 // Determine the sizes and locations of all contained views
114 U32 total_height = 0; 144 S32 total_height = 0;
115 U32 top, left, right, bottom; 145 S32 top, left, right, bottom;
116 //LLView *childp; 146 //LLView *childp;
117 147
118 // These will be used for the children 148 // These will be used for the children
119 left = 4; 149 left = 4;
120 top = getRect().getHeight() - 4; 150 top = getRect().getHeight() - 4;
121 right = getRect().getWidth() - 2; 151 right = width - 2;
122 bottom = top; 152 bottom = top;
123 153
124 // Leave some space for the top label/grab handle 154 // Leave some space for the top label/grab handle
125 total_height += 20; 155 if (mShowLabel)
156 {
157 total_height += 20;
158 }
126 159
127 if (mDisplayChildren) 160 if (mDisplayChildren)
128 { 161 {
@@ -142,7 +175,9 @@ void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent)
142 } 175 }
143 total_height += child_height; 176 total_height += child_height;
144 } 177 }
145 178
179 if (total_height < height)
180 total_height = height;
146 181
147 if (followsTop()) 182 if (followsTop())
148 { 183 {
@@ -157,7 +192,12 @@ void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent)
157 // HACK: casting away const. Should use setRect or some helper function instead. 192 // HACK: casting away const. Should use setRect or some helper function instead.
158 const_cast<LLRect&>(getRect()).mRight = getRect().mLeft + width; 193 const_cast<LLRect&>(getRect()).mRight = getRect().mLeft + width;
159 194
160 top = total_height - 20; 195 top = total_height;
196 if (mShowLabel)
197 {
198 top -= 20;
199 }
200
161 bottom = top; 201 bottom = top;
162 202
163 if (mDisplayChildren) 203 if (mDisplayChildren)
@@ -184,6 +224,7 @@ void LLContainerView::reshape(S32 width, S32 height, BOOL called_from_parent)
184 getParent()->reshape(getParent()->getRect().getWidth(), getParent()->getRect().getHeight(), FALSE); 224 getParent()->reshape(getParent()->getRect().getWidth(), getParent()->getRect().getHeight(), FALSE);
185 } 225 }
186 } 226 }
227
187} 228}
188 229
189LLRect LLContainerView::getRequiredRect() 230LLRect LLContainerView::getRequiredRect()
@@ -196,10 +237,14 @@ LLRect LLContainerView::getRequiredRect()
196 237
197 // Leave some space for the top label/grab handle 238 // Leave some space for the top label/grab handle
198 239
199 if (mDisplayChildren) 240 if (mShowLabel)
200 { 241 {
201 total_height = 20; 242 total_height = 20;
243 }
202 244
245
246 if (mDisplayChildren)
247 {
203 // Determine total height 248 // Determine total height
204 U32 child_height = 0; 249 U32 child_height = 0;
205 for (child_list_const_iter_t child_iter = getChildList()->begin(); 250 for (child_list_const_iter_t child_iter = getChildList()->begin();
@@ -213,11 +258,6 @@ LLRect LLContainerView::getRequiredRect()
213 258
214 total_height += child_height; 259 total_height += child_height;
215 } 260 }
216 else
217 {
218 total_height = 20;
219 }
220
221 req_rect.mTop = total_height; 261 req_rect.mTop = total_height;
222 return req_rect; 262 return req_rect;
223} 263}