aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpreviewtexture.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llpreviewtexture.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llpreviewtexture.cpp166
1 files changed, 135 insertions, 31 deletions
diff --git a/linden/indra/newview/llpreviewtexture.cpp b/linden/indra/newview/llpreviewtexture.cpp
index 7948db4..99d0959 100644
--- a/linden/indra/newview/llpreviewtexture.cpp
+++ b/linden/indra/newview/llpreviewtexture.cpp
@@ -29,19 +29,21 @@
29 29
30#include "llpreviewtexture.h" 30#include "llpreviewtexture.h"
31 31
32#include "llviewerimage.h"
33#include "llviewerimagelist.h"
34#include "llresmgr.h"
35#include "llagent.h" 32#include "llagent.h"
36#include "llbutton.h" 33#include "llbutton.h"
37#include "llui.h" 34#include "llfilepicker.h"
35#include "llimagetga.h"
38#include "llinventoryview.h" 36#include "llinventoryview.h"
39#include "llinventory.h" 37#include "llinventory.h"
40#include "llviewerwindow.h" 38#include "llresmgr.h"
41#include "lltextbox.h" 39#include "lltextbox.h"
42#include "llimagetga.h" 40#include "lltextureview.h"
43#include "llfilepicker.h" 41#include "llui.h"
42#include "llviewerimage.h"
43#include "llviewerimagelist.h"
44#include "llvieweruictrlfactory.h" 44#include "llvieweruictrlfactory.h"
45#include "llviewerwindow.h"
46#include "lllineeditor.h"
45 47
46const S32 PREVIEW_TEXTURE_MIN_WIDTH = 300; 48const S32 PREVIEW_TEXTURE_MIN_WIDTH = 300;
47const S32 PREVIEW_TEXTURE_MIN_HEIGHT = 120; 49const S32 PREVIEW_TEXTURE_MIN_HEIGHT = 120;
@@ -185,6 +187,105 @@ void LLPreviewTexture::init()
185 } 187 }
186} 188}
187 189
190void LLPreviewTexture::draw()
191{
192 if( getVisible() )
193 {
194 updateAspectRatio();
195
196 LLPreview::draw();
197
198 if (!mMinimized)
199 {
200 LLGLSUIDefault gls_ui;
201 LLGLSNoTexture gls_notex;
202
203 const LLRect& border = mClientRect;
204 LLRect interior = mClientRect;
205 interior.stretch( -PREVIEW_BORDER_WIDTH );
206
207 // ...border
208 gl_rect_2d( border, LLColor4(0.f, 0.f, 0.f, 1.f));
209 gl_rect_2d_checkerboard( interior );
210
211 if ( mImage.notNull() )
212 {
213 LLGLSTexture gls_no_texture;
214 // Draw the texture
215 glColor3f( 1.f, 1.f, 1.f );
216 gl_draw_scaled_image(interior.mLeft,
217 interior.mBottom,
218 interior.getWidth(),
219 interior.getHeight(),
220 mImage);
221
222 // Pump the texture priority
223 F32 pixel_area = mLoadingFullImage ? (F32)MAX_IMAGE_AREA : (F32)(interior.getWidth() * interior.getHeight() );
224 mImage->addTextureStats( pixel_area );
225
226 // Don't bother decoding more than we can display, unless
227 // we're loading the full image.
228 if (!mLoadingFullImage)
229 {
230 S32 int_width = interior.getWidth();
231 S32 int_height = interior.getHeight();
232 mImage->setKnownDrawSize(int_width, int_height);
233 }
234 else
235 {
236 // Don't use this feature
237 mImage->setKnownDrawSize(0, 0);
238 }
239
240 if( mLoadingFullImage )
241 {
242 LLFontGL::sSansSerif->renderUTF8("Receiving:", 0,
243 interior.mLeft + 4,
244 interior.mBottom + 4,
245 LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
246 LLFontGL::DROP_SHADOW);
247
248 F32 data_progress = mImage->mDownloadProgress;
249
250 // Draw the progress bar.
251 const S32 BAR_HEIGHT = 12;
252 const S32 BAR_LEFT_PAD = 80;
253 S32 left = interior.mLeft + 4 + BAR_LEFT_PAD;
254 S32 bar_width = mRect.getWidth() - left - RESIZE_HANDLE_WIDTH - 2;
255 S32 top = interior.mBottom + 4 + BAR_HEIGHT;
256 S32 right = left + bar_width;
257 S32 bottom = top - BAR_HEIGHT;
258
259 LLColor4 background_color(0.f, 0.f, 0.f, 0.75f);
260 LLColor4 decoded_color(0.f, 1.f, 0.f, 1.0f);
261 LLColor4 downloaded_color(0.f, 0.5f, 0.f, 1.0f);
262
263 gl_rect_2d(left, top, right, bottom, background_color);
264
265 if (data_progress > 0.0f)
266 {
267 // Downloaded bytes
268 right = left + llfloor(data_progress * (F32)bar_width);
269 if (right > left)
270 {
271 gl_rect_2d(left, top, right, bottom, downloaded_color);
272 }
273 }
274 }
275 else
276 if( !mSavedFileTimer.hasExpired() )
277 {
278 LLFontGL::sSansSerif->renderUTF8("File Saved", 0,
279 interior.mLeft + 4,
280 interior.mBottom + 4,
281 LLColor4::white, LLFontGL::LEFT, LLFontGL::BOTTOM,
282 LLFontGL::DROP_SHADOW);
283 }
284 }
285 }
286 }
287}
288
188 289
189// virtual 290// virtual
190BOOL LLPreviewTexture::canSaveAs() 291BOOL LLPreviewTexture::canSaveAs()
@@ -330,43 +431,46 @@ void LLPreviewTexture::updateAspectRatio()
330 button_height = BTN_HEIGHT + PREVIEW_PAD; 431 button_height = BTN_HEIGHT + PREVIEW_PAD;
331 } 432 }
332 433
333 LLRect window_rect(0, mRect.getHeight(), mRect.getWidth(), 0); 434 if (client_height != mLastHeight || client_width != mLastWidth)
334 window_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD);
335 window_rect.mBottom += PREVIEW_BORDER + button_height + CLIENT_RECT_VPAD + info_height + CLIENT_RECT_VPAD;
336 LLMultiFloater* hostp = getHost();
337 if (hostp)
338 { 435 {
339 // try to keep aspect ratio when hosted, as hosting view can resize without user input 436 mLastWidth = client_width;
340 mClientRect.setLeftTopAndSize(window_rect.getCenterX() - (client_width / 2), window_rect.mTop, client_width, client_height); 437 mLastHeight = client_height;
341 }
342 else
343 {
344 mClientRect.setLeftTopAndSize(LLPANEL_BORDER_WIDTH + PREVIEW_PAD + 6,
345 mRect.getHeight() - (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD),
346 mRect.getWidth() - horiz_pad,
347 mRect.getHeight() - (view_height - client_height) - 8);
348 }
349
350 if (mImage->mFullHeight > mLastHeight && mImage->mFullWidth > mLastWidth)
351 {
352 mLastWidth = image_width;
353 mLastHeight = image_height;
354 438
355 S32 old_top = mRect.mTop; 439 S32 old_top = mRect.mTop;
356 S32 old_left = mRect.mLeft; 440 S32 old_left = mRect.mLeft;
357 if (hostp) 441 if (getHost())
358 { 442 {
359 hostp->growToFit(this, view_width, view_height); 443 getHost()->growToFit(this, view_width, view_height);
360 } 444 }
361 else 445 else
362 { 446 {
363 reshape( view_width, view_height ); 447 reshape( view_width, view_height );
364 S32 new_bottom = old_top - mRect.getHeight(); 448 S32 new_bottom = old_top - mRect.getHeight();
365 setOrigin( old_left, new_bottom ); 449 setOrigin( old_left, new_bottom );
450 // Try to keep whole view onscreen, don't allow partial offscreen.
451 gFloaterView->adjustToFitScreen(this, FALSE);
366 } 452 }
453 }
454
455 // clamp texture size to fit within actual size of floater after attempting resize
456 client_width = llmin(client_width, mRect.getWidth() - horiz_pad);
457 client_height = llmin(client_height, mRect.getHeight() - PREVIEW_HEADER_SIZE - (2 * CLIENT_RECT_VPAD) - LLPANEL_BORDER_WIDTH - info_height);
367 458
368 // Try to keep whole view onscreen, don't allow partial offscreen. 459 LLRect window_rect(0, mRect.getHeight(), mRect.getWidth(), 0);
369 gFloaterView->adjustToFitScreen(this, FALSE); 460 window_rect.mTop -= (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD);
461 window_rect.mBottom += PREVIEW_BORDER + button_height + CLIENT_RECT_VPAD + info_height + CLIENT_RECT_VPAD;
462
463 if (getHost())
464 {
465 // try to keep aspect ratio when hosted, as hosting view can resize without user input
466 mClientRect.setLeftTopAndSize(window_rect.getCenterX() - (client_width / 2), window_rect.mTop, client_width, client_height);
467 }
468 else
469 {
470 mClientRect.setLeftTopAndSize(LLPANEL_BORDER_WIDTH + PREVIEW_PAD + 6,
471 mRect.getHeight() - (PREVIEW_HEADER_SIZE + CLIENT_RECT_VPAD),
472 mRect.getWidth() - horiz_pad,
473 client_height);
370 } 474 }
371} 475}
372 476