diff options
Diffstat (limited to 'linden/indra/newview/llprogressview.cpp')
-rw-r--r-- | linden/indra/newview/llprogressview.cpp | 235 |
1 files changed, 152 insertions, 83 deletions
diff --git a/linden/indra/newview/llprogressview.cpp b/linden/indra/newview/llprogressview.cpp index 10b3115..b4f0704 100644 --- a/linden/indra/newview/llprogressview.cpp +++ b/linden/indra/newview/llprogressview.cpp | |||
@@ -51,6 +51,7 @@ | |||
51 | #include "llviewerimagelist.h" | 51 | #include "llviewerimagelist.h" |
52 | #include "llviewerwindow.h" | 52 | #include "llviewerwindow.h" |
53 | #include "llappviewer.h" | 53 | #include "llappviewer.h" |
54 | #include "llweb.h" | ||
54 | 55 | ||
55 | LLProgressView* LLProgressView::sInstance = NULL; | 56 | LLProgressView* LLProgressView::sInstance = NULL; |
56 | 57 | ||
@@ -66,11 +67,10 @@ const S32 ANIMATION_FRAMES = 1; //13; | |||
66 | 67 | ||
67 | // XUI:translate | 68 | // XUI:translate |
68 | LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) | 69 | LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) |
69 | : LLPanel(name, rect, FALSE) | 70 | : LLPanel(name, rect, FALSE), |
71 | mPercentDone( 0.f ), | ||
72 | mMouseDownInActiveArea( false ) | ||
70 | { | 73 | { |
71 | mPercentDone = 0.f; | ||
72 | mDrawBackground = TRUE; | ||
73 | |||
74 | const S32 CANCEL_BTN_WIDTH = 70; | 74 | const S32 CANCEL_BTN_WIDTH = 70; |
75 | const S32 CANCEL_BTN_OFFSET = 16; | 75 | const S32 CANCEL_BTN_OFFSET = 16; |
76 | LLRect r; | 76 | LLRect r; |
@@ -89,6 +89,8 @@ LLProgressView::LLProgressView(const std::string& name, const LLRect &rect) | |||
89 | mFadeTimer.stop(); | 89 | mFadeTimer.stop(); |
90 | setVisible(FALSE); | 90 | setVisible(FALSE); |
91 | 91 | ||
92 | mOutlineRect.set( 0, 0, 0, 0 ); | ||
93 | |||
92 | sInstance = this; | 94 | sInstance = this; |
93 | } | 95 | } |
94 | 96 | ||
@@ -100,14 +102,44 @@ LLProgressView::~LLProgressView() | |||
100 | sInstance = NULL; | 102 | sInstance = NULL; |
101 | } | 103 | } |
102 | 104 | ||
103 | EWidgetType LLProgressView::getWidgetType() const | 105 | BOOL LLProgressView::handleMouseDown(S32 x, S32 y, MASK mask) |
104 | { | 106 | { |
105 | return WIDGET_TYPE_PROGRESS_VIEW; | 107 | if ( mOutlineRect.pointInRect( x, y ) ) |
108 | { | ||
109 | mMouseDownInActiveArea = TRUE; | ||
110 | return TRUE; | ||
111 | }; | ||
112 | |||
113 | return LLPanel::handleMouseDown(x, y, mask); | ||
106 | } | 114 | } |
107 | 115 | ||
108 | LLString LLProgressView::getWidgetTag() const | 116 | BOOL LLProgressView::handleMouseUp(S32 x, S32 y, MASK mask) |
109 | { | 117 | { |
110 | return LL_PROGRESS_VIEW_TAG; | 118 | if ( mOutlineRect.pointInRect( x, y ) ) |
119 | { | ||
120 | if ( mMouseDownInActiveArea ) | ||
121 | { | ||
122 | if ( ! mMessage.empty() ) | ||
123 | { | ||
124 | std::string url_to_open( "" ); | ||
125 | |||
126 | size_t start_pos = mMessage.find( "http://" ); | ||
127 | if ( start_pos != std::string::npos ) | ||
128 | { | ||
129 | size_t end_pos = mMessage.find_first_of( " \n\r\t", start_pos ); | ||
130 | if ( end_pos != std::string::npos ) | ||
131 | url_to_open = mMessage.substr( start_pos, end_pos - start_pos ); | ||
132 | else | ||
133 | url_to_open = mMessage.substr( start_pos ); | ||
134 | |||
135 | LLWeb::loadURLExternal( url_to_open ); | ||
136 | }; | ||
137 | }; | ||
138 | return TRUE; | ||
139 | }; | ||
140 | }; | ||
141 | |||
142 | return LLPanel::handleMouseUp(x, y, mask); | ||
111 | } | 143 | } |
112 | 144 | ||
113 | BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask) | 145 | BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask) |
@@ -115,24 +147,27 @@ BOOL LLProgressView::handleHover(S32 x, S32 y, MASK mask) | |||
115 | if( childrenHandleHover( x, y, mask ) == NULL ) | 147 | if( childrenHandleHover( x, y, mask ) == NULL ) |
116 | { | 148 | { |
117 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLProgressView" << llendl; | 149 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLProgressView" << llendl; |
118 | gViewerWindow->setCursor(UI_CURSOR_WAIT); | 150 | if ( mOutlineRect.pointInRect( x, y ) ) |
151 | { | ||
152 | gViewerWindow->setCursor(UI_CURSOR_ARROW); | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | gViewerWindow->setCursor(UI_CURSOR_WAIT); | ||
157 | } | ||
119 | } | 158 | } |
120 | return TRUE; | 159 | return TRUE; |
121 | } | 160 | } |
122 | 161 | ||
123 | 162 | ||
124 | BOOL LLProgressView::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | 163 | BOOL LLProgressView::handleKeyHere(KEY key, MASK mask) |
125 | { | 164 | { |
126 | if( getVisible() ) | 165 | // Suck up all keystokes except CTRL-Q. |
166 | if( ('Q' == key) && (MASK_CONTROL == mask) ) | ||
127 | { | 167 | { |
128 | // Suck up all keystokes except CTRL-Q. | 168 | LLAppViewer::instance()->userQuit(); |
129 | if( ('Q' == key) && (MASK_CONTROL == mask) ) | ||
130 | { | ||
131 | LLAppViewer::instance()->userQuit(); | ||
132 | } | ||
133 | return TRUE; | ||
134 | } | 169 | } |
135 | return FALSE; | 170 | return TRUE; |
136 | } | 171 | } |
137 | 172 | ||
138 | void LLProgressView::setVisible(BOOL visible) | 173 | void LLProgressView::setVisible(BOOL visible) |
@@ -144,6 +179,7 @@ void LLProgressView::setVisible(BOOL visible) | |||
144 | else if (!getVisible() && visible) | 179 | else if (!getVisible() && visible) |
145 | { | 180 | { |
146 | gFocusMgr.setTopCtrl(this); | 181 | gFocusMgr.setTopCtrl(this); |
182 | setFocus(TRUE); | ||
147 | mFadeTimer.stop(); | 183 | mFadeTimer.stop(); |
148 | mProgressTimer.start(); | 184 | mProgressTimer.start(); |
149 | LLView::setVisible(visible); | 185 | LLView::setVisible(visible); |
@@ -169,39 +205,37 @@ void LLProgressView::draw() | |||
169 | } | 205 | } |
170 | 206 | ||
171 | // Paint bitmap if we've got one | 207 | // Paint bitmap if we've got one |
172 | if (mDrawBackground) | 208 | glPushMatrix(); |
209 | if (gStartImageGL) | ||
173 | { | 210 | { |
174 | glPushMatrix(); | 211 | LLGLSUIDefault gls_ui; |
175 | if (gStartImageGL) | 212 | LLViewerImage::bindTexture(gStartImageGL); |
213 | gGL.color4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f); | ||
214 | F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; | ||
215 | F32 view_aspect = (F32)width / (F32)height; | ||
216 | // stretch image to maintain aspect ratio | ||
217 | if (image_aspect > view_aspect) | ||
176 | { | 218 | { |
177 | LLGLSUIDefault gls_ui; | 219 | glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * width, 0.f, 0.f); |
178 | LLViewerImage::bindTexture(gStartImageGL); | 220 | glScalef(image_aspect / view_aspect, 1.f, 1.f); |
179 | gGL.color4f(1.f, 1.f, 1.f, mFadeTimer.getStarted() ? clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, FADE_IN_TIME, 1.f, 0.f) : 1.f); | ||
180 | F32 image_aspect = (F32)gStartImageWidth / (F32)gStartImageHeight; | ||
181 | F32 view_aspect = (F32)width / (F32)height; | ||
182 | // stretch image to maintain aspect ratio | ||
183 | if (image_aspect > view_aspect) | ||
184 | { | ||
185 | glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * width, 0.f, 0.f); | ||
186 | glScalef(image_aspect / view_aspect, 1.f, 1.f); | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | glTranslatef(0.f, -0.5f * (view_aspect / image_aspect - 1.f) * height, 0.f); | ||
191 | glScalef(1.f, view_aspect / image_aspect, 1.f); | ||
192 | } | ||
193 | gl_rect_2d_simple_tex( getRect().getWidth(), getRect().getHeight() ); | ||
194 | gStartImageGL->unbindTexture(0, GL_TEXTURE_2D); | ||
195 | } | 221 | } |
196 | else | 222 | else |
197 | { | 223 | { |
198 | LLGLSNoTexture gls_no_texture; | 224 | glTranslatef(0.f, -0.5f * (view_aspect / image_aspect - 1.f) * height, 0.f); |
199 | gGL.color4f(0.f, 0.f, 0.f, 1.f); | 225 | glScalef(1.f, view_aspect / image_aspect, 1.f); |
200 | gl_rect_2d(getRect()); | ||
201 | } | 226 | } |
202 | glPopMatrix(); | 227 | gl_rect_2d_simple_tex( getRect().getWidth(), getRect().getHeight() ); |
228 | gStartImageGL->unbindTexture(0, GL_TEXTURE_2D); | ||
203 | } | 229 | } |
230 | else | ||
231 | { | ||
232 | LLGLSNoTexture gls_no_texture; | ||
233 | gGL.color4f(0.f, 0.f, 0.f, 1.f); | ||
234 | gl_rect_2d(getRect()); | ||
235 | } | ||
236 | glPopMatrix(); | ||
204 | 237 | ||
238 | // Handle fade-in animation | ||
205 | if (mFadeTimer.getStarted()) | 239 | if (mFadeTimer.getStarted()) |
206 | { | 240 | { |
207 | LLView::draw(); | 241 | LLView::draw(); |
@@ -220,63 +254,96 @@ void LLProgressView::draw() | |||
220 | S32 line_two_y = line_one_y - LINE_SPACING; | 254 | S32 line_two_y = line_one_y - LINE_SPACING; |
221 | const LLFontGL* font = LLFontGL::sSansSerif; | 255 | const LLFontGL* font = LLFontGL::sSansSerif; |
222 | 256 | ||
223 | LLViewerImage* shadow_imagep = gImageList.getImage(LLUUID(gViewerArt.getString("rounded_square_soft.tga")), MIPMAP_FALSE, TRUE); | 257 | LLUIImagePtr shadow_imagep = LLUI::getUIImage("rounded_square_soft.tga"); |
224 | LLViewerImage* bar_imagep = gImageList.getImage(LLUUID(gViewerArt.getString("rounded_square.tga")), MIPMAP_FALSE, TRUE); | 258 | LLUIImagePtr bar_fg_imagep = LLUI::getUIImage("progressbar_fill.tga"); |
225 | 259 | LLUIImagePtr bar_bg_imagep = LLUI::getUIImage("progressbar_track.tga"); | |
226 | //LLColor4 background_color = gColors.getColor("DefaultShadowLight"); | 260 | LLUIImagePtr bar_imagep = LLUI::getUIImage("rounded_square.tga"); |
227 | LLColor4 background_color = LLColor4(0.3254f, 0.4f, 0.5058f, 1.0f); | 261 | |
262 | LLColor4 background_color = gColors.getColor("LoginProgressBarBgColor"); | ||
228 | 263 | ||
229 | F32 alpha = 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32())); | 264 | F32 alpha = 0.5f + 0.5f*0.5f*(1.f + (F32)sin(3.f*timer.getElapsedTimeF32())); |
230 | // background_color.mV[3] = background_color.mV[3]*alpha; | 265 | // background_color.mV[3] = background_color.mV[3]*alpha; |
231 | 266 | ||
232 | LLString top_line = LLAppViewer::instance()->getSecondLifeTitle(); | 267 | LLString top_line = LLAppViewer::instance()->getSecondLifeTitle(); |
233 | 268 | ||
269 | S32 bar_bottom = line_two_y - 30; | ||
270 | S32 bar_height = 18; | ||
271 | S32 bar_width = getRect().getWidth() * 2 / 3; | ||
272 | S32 bar_left = (getRect().getWidth() / 2) - (bar_width / 2); | ||
273 | |||
274 | // translucent outline box | ||
275 | S32 background_box_left = ( ( ( getRect().getWidth() / 2 ) - ( bar_width / 2 ) ) / 4 ) * 3; | ||
276 | S32 background_box_top = ( getRect().getHeight() / 2 ) + LINE_SPACING * 5; | ||
277 | S32 background_box_right = getRect().getWidth() - background_box_left; | ||
278 | S32 background_box_bottom = ( getRect().getHeight() / 2 ) - LINE_SPACING * 5; | ||
279 | S32 background_box_width = background_box_right - background_box_left + 1; | ||
280 | S32 background_box_height = background_box_top - background_box_bottom + 1; | ||
281 | |||
282 | // shadow_imagep->draw( background_box_left + 2, | ||
283 | // background_box_bottom - 2, | ||
284 | // background_box_width, | ||
285 | // background_box_height, | ||
286 | // gColors.getColor( "LoginProgressBoxShadowColor" ) ); | ||
287 | // bar_outline_imagep->draw( background_box_left, | ||
288 | // background_box_bottom, | ||
289 | // background_box_width, | ||
290 | // background_box_height, | ||
291 | // gColors.getColor("LoginProgressBoxBorderColor") ); | ||
292 | |||
293 | bar_imagep->draw( background_box_left + 1, | ||
294 | background_box_bottom + 1, | ||
295 | background_box_width - 2, | ||
296 | background_box_height - 2, | ||
297 | gColors.getColor("LoginProgressBoxCenterColor") ); | ||
298 | |||
299 | // we'll need this later for catching a click if it looks like it contains a link | ||
300 | if ( mMessage.find( "http://" ) != std::string::npos ) | ||
301 | mOutlineRect.set( background_box_left, background_box_top, background_box_right, background_box_bottom ); | ||
302 | else | ||
303 | mOutlineRect.set( 0, 0, 0, 0 ); | ||
304 | |||
305 | // draw loading bar | ||
234 | font->renderUTF8(top_line, 0, | 306 | font->renderUTF8(top_line, 0, |
235 | line_x, line_one_y, | 307 | line_x, line_one_y, |
236 | LLColor4::white, | 308 | //LLColor4::white, |
309 | gColors.getColor("LoginProgressBoxTextColor"), | ||
237 | LLFontGL::HCENTER, LLFontGL::BASELINE, | 310 | LLFontGL::HCENTER, LLFontGL::BASELINE, |
238 | LLFontGL::DROP_SHADOW); | 311 | LLFontGL::DROP_SHADOW); |
239 | font->renderUTF8(mText, 0, | 312 | font->renderUTF8(mText, 0, |
240 | line_x, line_two_y, | 313 | line_x, line_two_y, |
241 | LLColor4::white, | 314 | //LLColor4::white, |
315 | gColors.getColor("LoginProgressBoxTextColor"), | ||
242 | LLFontGL::HCENTER, LLFontGL::BASELINE, | 316 | LLFontGL::HCENTER, LLFontGL::BASELINE, |
243 | LLFontGL::DROP_SHADOW); | 317 | LLFontGL::DROP_SHADOW); |
244 | 318 | ||
245 | S32 bar_bottom = line_two_y - 30; | 319 | // shadow_imagep->draw( |
246 | S32 bar_height = 18; | 320 | // bar_left + 2, |
247 | S32 bar_width = getRect().getWidth() * 2 / 3; | 321 | // bar_bottom - 2, |
248 | S32 bar_left = (getRect().getWidth() / 2) - (bar_width / 2); | 322 | // bar_width, |
249 | 323 | // bar_height, | |
250 | gl_draw_scaled_image_with_border( | 324 | // gColors.getColor("LoginProgressBoxShadowColor")); |
325 | |||
326 | // bar_imagep->draw( | ||
327 | // bar_left, | ||
328 | // bar_bottom, | ||
329 | // bar_width, | ||
330 | // bar_height, | ||
331 | // LLColor4(0.7f, 0.7f, 0.8f, 1.0f)); | ||
332 | |||
333 | bar_bg_imagep->draw( | ||
251 | bar_left + 2, | 334 | bar_left + 2, |
252 | bar_bottom - 2, | 335 | bar_bottom + 2, |
253 | 16, | 336 | bar_width - 4, |
254 | 16, | 337 | bar_height - 4, |
255 | bar_width, | ||
256 | bar_height, | ||
257 | shadow_imagep, | ||
258 | gColors.getColor("ColorDropShadow")); | ||
259 | |||
260 | gl_draw_scaled_image_with_border( | ||
261 | bar_left, | ||
262 | bar_bottom, | ||
263 | 16, | ||
264 | 16, | ||
265 | bar_width, | ||
266 | bar_height, | ||
267 | bar_imagep, | ||
268 | LLColor4(0.7f, 0.7f, 0.8f, 1.0f)); | ||
269 | |||
270 | gl_draw_scaled_image_with_border(bar_left + 2, bar_bottom + 2, 16, 16, | ||
271 | bar_width - 4, bar_height - 4, | ||
272 | bar_imagep, | ||
273 | background_color); | 338 | background_color); |
274 | 339 | ||
275 | LLColor4 bar_color = LLColor4(0.5764f, 0.6627f, 0.8352f, 1.0f); | 340 | LLColor4 bar_color = gColors.getColor("LoginProgressBarFgColor"); |
276 | bar_color.mV[3] = alpha; | 341 | bar_color.mV[3] = alpha; |
277 | gl_draw_scaled_image_with_border(bar_left + 2, bar_bottom + 2, 16, 16, | 342 | bar_fg_imagep->draw( |
278 | llround((bar_width - 4) * (mPercentDone / 100.f)), bar_height - 4, | 343 | bar_left + 2, |
279 | bar_imagep, | 344 | bar_bottom + 2, |
345 | llround((bar_width - 4) * (mPercentDone / 100.f)), | ||
346 | bar_height - 4, | ||
280 | bar_color); | 347 | bar_color); |
281 | 348 | ||
282 | S32 line_three_y = line_two_y - LINE_SPACING * 3; | 349 | S32 line_three_y = line_two_y - LINE_SPACING * 3; |
@@ -284,6 +351,7 @@ void LLProgressView::draw() | |||
284 | // draw the message if there is one | 351 | // draw the message if there is one |
285 | if(!mMessage.empty()) | 352 | if(!mMessage.empty()) |
286 | { | 353 | { |
354 | LLColor4 text_message_color = gColors.getColor("LoginProgressBoxTextColor"); | ||
287 | LLWString wmessage = utf8str_to_wstring(mMessage); | 355 | LLWString wmessage = utf8str_to_wstring(mMessage); |
288 | const F32 MAX_PIXELS = 640.0f; | 356 | const F32 MAX_PIXELS = 640.0f; |
289 | S32 chars_left = wmessage.length(); | 357 | S32 chars_left = wmessage.length(); |
@@ -298,7 +366,8 @@ void LLProgressView::draw() | |||
298 | LLWString wbuffer = wmessage.substr(msgidx, chars_this_time); | 366 | LLWString wbuffer = wmessage.substr(msgidx, chars_this_time); |
299 | font->render(wbuffer, 0, | 367 | font->render(wbuffer, 0, |
300 | (F32)line_x, (F32)line_three_y, | 368 | (F32)line_x, (F32)line_three_y, |
301 | LLColor4::white, | 369 | //LLColor4::white, |
370 | gColors.getColor("LoginProgressBoxTextColor"), | ||
302 | LLFontGL::HCENTER, LLFontGL::BASELINE, | 371 | LLFontGL::HCENTER, LLFontGL::BASELINE, |
303 | LLFontGL::DROP_SHADOW); | 372 | LLFontGL::DROP_SHADOW); |
304 | msgidx += chars_this_time; | 373 | msgidx += chars_this_time; |