diff options
Diffstat (limited to 'linden/indra/llui/lldraghandle.cpp')
-rw-r--r-- | linden/indra/llui/lldraghandle.cpp | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/linden/indra/llui/lldraghandle.cpp b/linden/indra/llui/lldraghandle.cpp index 032cb91..516afc6 100644 --- a/linden/indra/llui/lldraghandle.cpp +++ b/linden/indra/llui/lldraghandle.cpp | |||
@@ -74,7 +74,24 @@ LLDragHandle::LLDragHandle( const LLString& name, const LLRect& rect, const LLSt | |||
74 | 74 | ||
75 | void LLDragHandle::setTitleVisible(BOOL visible) | 75 | void LLDragHandle::setTitleVisible(BOOL visible) |
76 | { | 76 | { |
77 | mTitleBox->setVisible(visible); | 77 | if(mTitleBox) |
78 | { | ||
79 | mTitleBox->setVisible(visible); | ||
80 | } | ||
81 | } | ||
82 | |||
83 | void LLDragHandle::setTitleBox(LLTextBox* titlebox) | ||
84 | { | ||
85 | if( mTitleBox ) | ||
86 | { | ||
87 | removeChild(mTitleBox); | ||
88 | delete mTitleBox; | ||
89 | } | ||
90 | mTitleBox = titlebox; | ||
91 | if(mTitleBox) | ||
92 | { | ||
93 | addChild( mTitleBox ); | ||
94 | } | ||
78 | } | 95 | } |
79 | 96 | ||
80 | LLDragHandleTop::LLDragHandleTop(const LLString& name, const LLRect &rect, const LLString& title) | 97 | LLDragHandleTop::LLDragHandleTop(const LLString& name, const LLRect &rect, const LLString& title) |
@@ -113,46 +130,28 @@ LLString LLDragHandleLeft::getWidgetTag() const | |||
113 | 130 | ||
114 | void LLDragHandleTop::setTitle(const LLString& title) | 131 | void LLDragHandleTop::setTitle(const LLString& title) |
115 | { | 132 | { |
116 | if( mTitleBox ) | ||
117 | { | ||
118 | removeChild(mTitleBox); | ||
119 | delete mTitleBox; | ||
120 | } | ||
121 | |||
122 | LLString trimmed_title = title; | 133 | LLString trimmed_title = title; |
123 | LLString::trim(trimmed_title); | 134 | LLString::trim(trimmed_title); |
124 | 135 | ||
125 | const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); | 136 | const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); |
126 | mTitleBox = new LLTextBox( "Drag Handle Title", mRect, trimmed_title, font ); | 137 | LLTextBox* titlebox = new LLTextBox( "Drag Handle Title", getRect(), trimmed_title, font ); |
127 | mTitleBox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); | 138 | titlebox->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT | FOLLOWS_RIGHT); |
128 | mTitleBox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); | 139 | titlebox->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); |
129 | reshapeTitleBox(); | ||
130 | 140 | ||
131 | // allow empty titles, as default behavior replaces them with title box name | 141 | setTitleBox(titlebox); |
132 | if (trimmed_title.empty()) | 142 | reshapeTitleBox(); |
133 | { | ||
134 | mTitleBox->setText(LLString::null); | ||
135 | } | ||
136 | addChild( mTitleBox ); | ||
137 | } | 143 | } |
138 | 144 | ||
139 | 145 | ||
140 | const LLString& LLDragHandleTop::getTitle() const | 146 | const LLString& LLDragHandleTop::getTitle() const |
141 | { | 147 | { |
142 | return mTitleBox->getText(); | 148 | return getTitleBox() == NULL ? LLString::null : getTitleBox()->getText(); |
143 | } | 149 | } |
144 | 150 | ||
145 | 151 | ||
146 | void LLDragHandleLeft::setTitle(const LLString& ) | 152 | void LLDragHandleLeft::setTitle(const LLString& ) |
147 | { | 153 | { |
148 | if( mTitleBox ) | 154 | setTitleBox(NULL); |
149 | { | ||
150 | removeChild(mTitleBox); | ||
151 | delete mTitleBox; | ||
152 | } | ||
153 | |||
154 | mTitleBox = NULL; | ||
155 | |||
156 | /* no title on left edge */ | 155 | /* no title on left edge */ |
157 | } | 156 | } |
158 | 157 | ||
@@ -166,14 +165,14 @@ const LLString& LLDragHandleLeft::getTitle() const | |||
166 | void LLDragHandleTop::draw() | 165 | void LLDragHandleTop::draw() |
167 | { | 166 | { |
168 | /* Disable lines. Can drag anywhere in most windows. JC | 167 | /* Disable lines. Can drag anywhere in most windows. JC |
169 | if( getVisible() && mEnabled && mForeground) | 168 | if( getVisible() && getEnabled() && mForeground) |
170 | { | 169 | { |
171 | const S32 BORDER_PAD = 2; | 170 | const S32 BORDER_PAD = 2; |
172 | const S32 HPAD = 2; | 171 | const S32 HPAD = 2; |
173 | const S32 VPAD = 2; | 172 | const S32 VPAD = 2; |
174 | S32 left = BORDER_PAD + HPAD; | 173 | S32 left = BORDER_PAD + HPAD; |
175 | S32 top = mRect.getHeight() - 2 * VPAD; | 174 | S32 top = getRect().getHeight() - 2 * VPAD; |
176 | S32 right = mRect.getWidth() - HPAD; | 175 | S32 right = getRect().getWidth() - HPAD; |
177 | // S32 bottom = VPAD; | 176 | // S32 bottom = VPAD; |
178 | 177 | ||
179 | // draw lines for drag areas | 178 | // draw lines for drag areas |
@@ -183,7 +182,7 @@ void LLDragHandleTop::draw() | |||
183 | 182 | ||
184 | LLRect title_rect = mTitleBox->getRect(); | 183 | LLRect title_rect = mTitleBox->getRect(); |
185 | S32 title_right = title_rect.mLeft + mTitleWidth; | 184 | S32 title_right = title_rect.mLeft + mTitleWidth; |
186 | BOOL show_right_side = title_right < mRect.getWidth(); | 185 | BOOL show_right_side = title_right < getRect().getWidth(); |
187 | 186 | ||
188 | for( S32 i=0; i<4; i++ ) | 187 | for( S32 i=0; i<4; i++ ) |
189 | { | 188 | { |
@@ -204,9 +203,9 @@ void LLDragHandleTop::draw() | |||
204 | */ | 203 | */ |
205 | 204 | ||
206 | // Colorize the text to match the frontmost state | 205 | // Colorize the text to match the frontmost state |
207 | if (mTitleBox) | 206 | if (getTitleBox()) |
208 | { | 207 | { |
209 | mTitleBox->setEnabled(mForeground); | 208 | getTitleBox()->setEnabled(getForeground()); |
210 | } | 209 | } |
211 | 210 | ||
212 | LLView::draw(); | 211 | LLView::draw(); |
@@ -217,7 +216,7 @@ void LLDragHandleTop::draw() | |||
217 | void LLDragHandleLeft::draw() | 216 | void LLDragHandleLeft::draw() |
218 | { | 217 | { |
219 | /* Disable lines. Can drag anywhere in most windows. JC | 218 | /* Disable lines. Can drag anywhere in most windows. JC |
220 | if( getVisible() && mEnabled && mForeground ) | 219 | if( getVisible() && getEnabled() && mForeground ) |
221 | { | 220 | { |
222 | const S32 BORDER_PAD = 2; | 221 | const S32 BORDER_PAD = 2; |
223 | // const S32 HPAD = 2; | 222 | // const S32 HPAD = 2; |
@@ -225,8 +224,8 @@ void LLDragHandleLeft::draw() | |||
225 | const S32 LINE_SPACING = 3; | 224 | const S32 LINE_SPACING = 3; |
226 | 225 | ||
227 | S32 left = BORDER_PAD + LINE_SPACING; | 226 | S32 left = BORDER_PAD + LINE_SPACING; |
228 | S32 top = mRect.getHeight() - 2 * VPAD; | 227 | S32 top = getRect().getHeight() - 2 * VPAD; |
229 | // S32 right = mRect.getWidth() - HPAD; | 228 | // S32 right = getRect().getWidth() - HPAD; |
230 | S32 bottom = VPAD; | 229 | S32 bottom = VPAD; |
231 | 230 | ||
232 | // draw lines for drag areas | 231 | // draw lines for drag areas |
@@ -234,7 +233,7 @@ void LLDragHandleLeft::draw() | |||
234 | // no titles yet | 233 | // no titles yet |
235 | //LLRect title_rect = mTitleBox->getRect(); | 234 | //LLRect title_rect = mTitleBox->getRect(); |
236 | //S32 title_right = title_rect.mLeft + mTitleWidth; | 235 | //S32 title_right = title_rect.mLeft + mTitleWidth; |
237 | //BOOL show_right_side = title_right < mRect.getWidth(); | 236 | //BOOL show_right_side = title_right < getRect().getWidth(); |
238 | 237 | ||
239 | S32 line = left; | 238 | S32 line = left; |
240 | for( S32 i=0; i<4; i++ ) | 239 | for( S32 i=0; i<4; i++ ) |
@@ -249,9 +248,9 @@ void LLDragHandleLeft::draw() | |||
249 | */ | 248 | */ |
250 | 249 | ||
251 | // Colorize the text to match the frontmost state | 250 | // Colorize the text to match the frontmost state |
252 | if (mTitleBox) | 251 | if (getTitleBox()) |
253 | { | 252 | { |
254 | mTitleBox->setEnabled(mForeground); | 253 | getTitleBox()->setEnabled(getForeground()); |
255 | } | 254 | } |
256 | 255 | ||
257 | LLView::draw(); | 256 | LLView::draw(); |
@@ -259,19 +258,23 @@ void LLDragHandleLeft::draw() | |||
259 | 258 | ||
260 | void LLDragHandleTop::reshapeTitleBox() | 259 | void LLDragHandleTop::reshapeTitleBox() |
261 | { | 260 | { |
261 | if( ! getTitleBox()) | ||
262 | { | ||
263 | return; | ||
264 | } | ||
262 | const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); | 265 | const LLFontGL* font = gResMgr->getRes( LLFONT_SANSSERIF ); |
263 | S32 title_width = font->getWidth( mTitleBox->getText() ) + TITLE_PAD; | 266 | S32 title_width = font->getWidth( getTitleBox()->getText() ) + TITLE_PAD; |
264 | if (mMaxTitleWidth > 0) | 267 | if (getMaxTitleWidth() > 0) |
265 | title_width = llmin(title_width, mMaxTitleWidth); | 268 | title_width = llmin(title_width, getMaxTitleWidth()); |
266 | S32 title_height = llround(font->getLineHeight()); | 269 | S32 title_height = llround(font->getLineHeight()); |
267 | LLRect title_rect; | 270 | LLRect title_rect; |
268 | title_rect.setLeftTopAndSize( | 271 | title_rect.setLeftTopAndSize( |
269 | LEFT_PAD, | 272 | LEFT_PAD, |
270 | mRect.getHeight() - BORDER_PAD, | 273 | getRect().getHeight() - BORDER_PAD, |
271 | mRect.getWidth() - LEFT_PAD - RIGHT_PAD, | 274 | getRect().getWidth() - LEFT_PAD - RIGHT_PAD, |
272 | title_height); | 275 | title_height); |
273 | 276 | ||
274 | mTitleBox->setRect( title_rect ); | 277 | getTitleBox()->setRect( title_rect ); |
275 | } | 278 | } |
276 | 279 | ||
277 | void LLDragHandleTop::reshape(S32 width, S32 height, BOOL called_from_parent) | 280 | void LLDragHandleTop::reshape(S32 width, S32 height, BOOL called_from_parent) |