diff options
Diffstat (limited to 'linden/indra/newview/llfloatersnapshot.cpp')
-rw-r--r-- | linden/indra/newview/llfloatersnapshot.cpp | 809 |
1 files changed, 489 insertions, 320 deletions
diff --git a/linden/indra/newview/llfloatersnapshot.cpp b/linden/indra/newview/llfloatersnapshot.cpp index 88e9235..20b4510 100644 --- a/linden/indra/newview/llfloatersnapshot.cpp +++ b/linden/indra/newview/llfloatersnapshot.cpp | |||
@@ -53,7 +53,7 @@ | |||
53 | #include "llsliderctrl.h" | 53 | #include "llsliderctrl.h" |
54 | #include "llspinctrl.h" | 54 | #include "llspinctrl.h" |
55 | #include "llviewercontrol.h" | 55 | #include "llviewercontrol.h" |
56 | #include "llvieweruictrlfactory.h" | 56 | #include "lluictrlfactory.h" |
57 | #include "llviewerstats.h" | 57 | #include "llviewerstats.h" |
58 | #include "llviewercamera.h" | 58 | #include "llviewercamera.h" |
59 | #include "llviewerwindow.h" | 59 | #include "llviewerwindow.h" |
@@ -75,10 +75,14 @@ | |||
75 | ///---------------------------------------------------------------------------- | 75 | ///---------------------------------------------------------------------------- |
76 | /// Local function declarations, constants, enums, and typedefs | 76 | /// Local function declarations, constants, enums, and typedefs |
77 | ///---------------------------------------------------------------------------- | 77 | ///---------------------------------------------------------------------------- |
78 | S32 LLFloaterSnapshot::sUIWinHeightLong = 526 ; | ||
79 | S32 LLFloaterSnapshot::sUIWinHeightShort = LLFloaterSnapshot::sUIWinHeightLong - 230 ; | ||
80 | S32 LLFloaterSnapshot::sUIWinWidth = 215 ; | ||
78 | 81 | ||
79 | LLSnapshotFloaterView* gSnapshotFloaterView = NULL; | 82 | LLSnapshotFloaterView* gSnapshotFloaterView = NULL; |
80 | 83 | ||
81 | LLFloaterSnapshot* LLFloaterSnapshot::sInstance = NULL; | 84 | LLFloaterSnapshot* LLFloaterSnapshot::sInstance = NULL; |
85 | |||
82 | const F32 SNAPSHOT_TIME_DELAY = 1.f; | 86 | const F32 SNAPSHOT_TIME_DELAY = 1.f; |
83 | 87 | ||
84 | F32 SHINE_TIME = 0.5f; | 88 | F32 SHINE_TIME = 0.5f; |
@@ -88,7 +92,7 @@ F32 FALL_TIME = 0.6f; | |||
88 | S32 BORDER_WIDTH = 6; | 92 | S32 BORDER_WIDTH = 6; |
89 | 93 | ||
90 | const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte | 94 | const S32 MAX_POSTCARD_DATASIZE = 1024 * 1024; // one megabyte |
91 | #define MAX_TEXTURE_SIZE 512 //max upload texture size 512 * 512 | 95 | const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 |
92 | ///---------------------------------------------------------------------------- | 96 | ///---------------------------------------------------------------------------- |
93 | /// Class LLSnapshotLivePreview | 97 | /// Class LLSnapshotLivePreview |
94 | ///---------------------------------------------------------------------------- | 98 | ///---------------------------------------------------------------------------- |
@@ -105,9 +109,6 @@ public: | |||
105 | LLSnapshotLivePreview(const LLRect& rect); | 109 | LLSnapshotLivePreview(const LLRect& rect); |
106 | ~LLSnapshotLivePreview(); | 110 | ~LLSnapshotLivePreview(); |
107 | 111 | ||
108 | virtual EWidgetType getWidgetType() const; | ||
109 | virtual LLString getWidgetTag() const; | ||
110 | |||
111 | /*virtual*/ void draw(); | 112 | /*virtual*/ void draw(); |
112 | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); | 113 | /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent); |
113 | 114 | ||
@@ -120,19 +121,30 @@ public: | |||
120 | ESnapshotType getSnapshotType() const { return mSnapshotType; } | 121 | ESnapshotType getSnapshotType() const { return mSnapshotType; } |
121 | BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } | 122 | BOOL getSnapshotUpToDate() const { return mSnapshotUpToDate; } |
122 | BOOL isSnapshotActive() { return mSnapshotActive; } | 123 | BOOL isSnapshotActive() { return mSnapshotActive; } |
124 | LLImageGL* getThumbnailImage() const { return mThumbnailImage ; } | ||
125 | S32 getThumbnailWidth() const { return mThumbnailWidth ; } | ||
126 | S32 getThumbnailHeight() const { return mThumbnailHeight ; } | ||
127 | BOOL getThumbnailLock() const { return mThumbnailUpdateLock ; } | ||
128 | BOOL getThumbnailUpToDate() const { return mThumbnailUpToDate ;} | ||
123 | LLImageGL* getCurrentImage(); | 129 | LLImageGL* getCurrentImage(); |
124 | F32 getImageAspect(); | 130 | F32 getImageAspect(); |
131 | F32 getAspect() ; | ||
125 | LLRect getImageRect(); | 132 | LLRect getImageRect(); |
126 | BOOL isImageScaled(); | 133 | BOOL isImageScaled(); |
127 | 134 | ||
128 | void setSnapshotType(ESnapshotType type) { mSnapshotType = type; } | 135 | void setSnapshotType(ESnapshotType type) { mSnapshotType = type; } |
129 | void setSnapshotQuality(S32 quality); | 136 | void setSnapshotQuality(S32 quality); |
130 | void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } | 137 | void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } |
131 | void updateSnapshot(BOOL new_snapshot); | 138 | void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE); |
132 | LLFloaterPostcard* savePostcard(); | 139 | LLFloaterPostcard* savePostcard(); |
133 | void saveTexture(); | 140 | void saveTexture(); |
134 | BOOL saveLocal(); | 141 | BOOL saveLocal(); |
135 | 142 | ||
143 | BOOL setThumbnailImageSize() ; | ||
144 | void generateThumbnailImage(BOOL force_update = FALSE) ; | ||
145 | void resetThumbnailImage() { mThumbnailImage = NULL ; } | ||
146 | void drawPreviewRect(S32 offset_x, S32 offset_y) ; | ||
147 | |||
136 | static void onIdle( void* snapshot_preview ); | 148 | static void onIdle( void* snapshot_preview ); |
137 | 149 | ||
138 | protected: | 150 | protected: |
@@ -144,6 +156,14 @@ protected: | |||
144 | BOOL mImageScaled[2]; | 156 | BOOL mImageScaled[2]; |
145 | S32 mMaxImageSize ; | 157 | S32 mMaxImageSize ; |
146 | 158 | ||
159 | //thumbnail image | ||
160 | LLPointer<LLImageGL> mThumbnailImage ; | ||
161 | S32 mThumbnailWidth ; | ||
162 | S32 mThumbnailHeight ; | ||
163 | LLRect mPreviewRect ; | ||
164 | BOOL mThumbnailUpdateLock ; | ||
165 | BOOL mThumbnailUpToDate ; | ||
166 | |||
147 | S32 mCurImageIndex; | 167 | S32 mCurImageIndex; |
148 | LLPointer<LLImageRaw> mRawImage; | 168 | LLPointer<LLImageRaw> mRawImage; |
149 | LLPointer<LLImageRaw> mRawImageEncoded; | 169 | LLPointer<LLImageRaw> mRawImageEncoded; |
@@ -170,12 +190,12 @@ public: | |||
170 | }; | 190 | }; |
171 | 191 | ||
172 | std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; | 192 | std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; |
173 | |||
174 | LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : | 193 | LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : |
175 | LLView("snapshot_live_preview", rect, FALSE), | 194 | LLView("snapshot_live_preview", rect, FALSE), |
176 | mColor(1.f, 0.f, 0.f, 0.5f), | 195 | mColor(1.f, 0.f, 0.f, 0.5f), |
177 | mCurImageIndex(0), | 196 | mCurImageIndex(0), |
178 | mRawImage(NULL), | 197 | mRawImage(NULL), |
198 | mThumbnailImage(NULL) , | ||
179 | mRawImageEncoded(NULL), | 199 | mRawImageEncoded(NULL), |
180 | mJPEGImage(NULL), | 200 | mJPEGImage(NULL), |
181 | mShineCountdown(0), | 201 | mShineCountdown(0), |
@@ -185,8 +205,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : | |||
185 | mDataSize(0), | 205 | mDataSize(0), |
186 | mSnapshotType(SNAPSHOT_POSTCARD), | 206 | mSnapshotType(SNAPSHOT_POSTCARD), |
187 | mSnapshotUpToDate(FALSE), | 207 | mSnapshotUpToDate(FALSE), |
188 | mCameraPos(gCamera->getOrigin()), | 208 | mCameraPos(LLViewerCamera::getInstance()->getOrigin()), |
189 | mCameraRot(gCamera->getQuaternion()), | 209 | mCameraRot(LLViewerCamera::getInstance()->getQuaternion()), |
190 | mSnapshotActive(FALSE), | 210 | mSnapshotActive(FALSE), |
191 | mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR) | 211 | mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR) |
192 | { | 212 | { |
@@ -204,6 +224,8 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLRect& rect) : | |||
204 | 224 | ||
205 | mMaxImageSize = MAX_IMAGE_SIZE ; | 225 | mMaxImageSize = MAX_IMAGE_SIZE ; |
206 | mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; | 226 | mKeepAspectRatio = gSavedSettings.getBOOL("KeepAspectForSnapshot") ; |
227 | mThumbnailUpdateLock = FALSE ; | ||
228 | mThumbnailUpToDate = FALSE ; | ||
207 | } | 229 | } |
208 | 230 | ||
209 | LLSnapshotLivePreview::~LLSnapshotLivePreview() | 231 | LLSnapshotLivePreview::~LLSnapshotLivePreview() |
@@ -234,13 +256,8 @@ LLImageGL* LLSnapshotLivePreview::getCurrentImage() | |||
234 | return mViewerImage[mCurImageIndex]; | 256 | return mViewerImage[mCurImageIndex]; |
235 | } | 257 | } |
236 | 258 | ||
237 | F32 LLSnapshotLivePreview::getImageAspect() | 259 | F32 LLSnapshotLivePreview::getAspect() |
238 | { | 260 | { |
239 | if (!mViewerImage[mCurImageIndex]) | ||
240 | { | ||
241 | return 0.f; | ||
242 | } | ||
243 | |||
244 | F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]); | 261 | F32 image_aspect_ratio = ((F32)mWidth[mCurImageIndex]) / ((F32)mHeight[mCurImageIndex]); |
245 | F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight()); | 262 | F32 window_aspect_ratio = ((F32)getRect().getWidth()) / ((F32)getRect().getHeight()); |
246 | 263 | ||
@@ -254,6 +271,16 @@ F32 LLSnapshotLivePreview::getImageAspect() | |||
254 | } | 271 | } |
255 | } | 272 | } |
256 | 273 | ||
274 | F32 LLSnapshotLivePreview::getImageAspect() | ||
275 | { | ||
276 | if (!mViewerImage[mCurImageIndex]) | ||
277 | { | ||
278 | return 0.f; | ||
279 | } | ||
280 | |||
281 | return getAspect() ; | ||
282 | } | ||
283 | |||
257 | LLRect LLSnapshotLivePreview::getImageRect() | 284 | LLRect LLSnapshotLivePreview::getImageRect() |
258 | { | 285 | { |
259 | return mImageRect[mCurImageIndex]; | 286 | return mImageRect[mCurImageIndex]; |
@@ -264,7 +291,7 @@ BOOL LLSnapshotLivePreview::isImageScaled() | |||
264 | return mImageScaled[mCurImageIndex]; | 291 | return mImageScaled[mCurImageIndex]; |
265 | } | 292 | } |
266 | 293 | ||
267 | void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot) | 294 | void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail) |
268 | { | 295 | { |
269 | if (mSnapshotUpToDate) | 296 | if (mSnapshotUpToDate) |
270 | { | 297 | { |
@@ -272,15 +299,9 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot) | |||
272 | mCurImageIndex = (mCurImageIndex + 1) % 2; | 299 | mCurImageIndex = (mCurImageIndex + 1) % 2; |
273 | mWidth[mCurImageIndex] = mWidth[old_image_index]; | 300 | mWidth[mCurImageIndex] = mWidth[old_image_index]; |
274 | mHeight[mCurImageIndex] = mHeight[old_image_index]; | 301 | mHeight[mCurImageIndex] = mHeight[old_image_index]; |
275 | mFallAnimTimer.start(); | 302 | mFallAnimTimer.start(); |
276 | } | ||
277 | mSnapshotUpToDate = FALSE; | ||
278 | mShineAnimTimer.stop(); | ||
279 | if (new_snapshot) | ||
280 | { | ||
281 | mSnapshotDelayTimer.start(); | ||
282 | mSnapshotDelayTimer.setTimerExpirySec(SNAPSHOT_TIME_DELAY); | ||
283 | } | 303 | } |
304 | mSnapshotUpToDate = FALSE; | ||
284 | 305 | ||
285 | LLRect& rect = mImageRect[mCurImageIndex]; | 306 | LLRect& rect = mImageRect[mCurImageIndex]; |
286 | rect.set(0, getRect().getHeight(), getRect().getWidth(), 0); | 307 | rect.set(0, getRect().getHeight(), getRect().getWidth(), 0); |
@@ -305,6 +326,21 @@ void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot) | |||
305 | rect.mRight -= (getRect().getWidth() - new_width) / 2; | 326 | rect.mRight -= (getRect().getWidth() - new_width) / 2; |
306 | } | 327 | } |
307 | } | 328 | } |
329 | |||
330 | mShineAnimTimer.stop(); | ||
331 | if (new_snapshot) | ||
332 | { | ||
333 | mSnapshotDelayTimer.start(); | ||
334 | mSnapshotDelayTimer.setTimerExpirySec(SNAPSHOT_TIME_DELAY); | ||
335 | } | ||
336 | else if(new_thumbnail) | ||
337 | { | ||
338 | mThumbnailUpToDate = FALSE ; | ||
339 | } | ||
340 | else | ||
341 | { | ||
342 | setThumbnailImageSize() ; | ||
343 | } | ||
308 | } | 344 | } |
309 | 345 | ||
310 | void LLSnapshotLivePreview::setSnapshotQuality(S32 quality) | 346 | void LLSnapshotLivePreview::setSnapshotQuality(S32 quality) |
@@ -316,198 +352,224 @@ void LLSnapshotLivePreview::setSnapshotQuality(S32 quality) | |||
316 | } | 352 | } |
317 | } | 353 | } |
318 | 354 | ||
319 | EWidgetType LLSnapshotLivePreview::getWidgetType() const | 355 | void LLSnapshotLivePreview::drawPreviewRect(S32 offset_x, S32 offset_y) |
320 | { | 356 | { |
321 | return WIDGET_TYPE_SNAPSHOT_LIVE_PREVIEW; | 357 | F32 line_width ; |
322 | } | 358 | glGetFloatv(GL_LINE_WIDTH, &line_width) ; |
359 | glLineWidth(2.0f * line_width) ; | ||
360 | LLColor4 color(0.0f, 0.0f, 0.0f, 1.0f) ; | ||
361 | gl_rect_2d( mPreviewRect.mLeft + offset_x, mPreviewRect.mTop + offset_y, | ||
362 | mPreviewRect.mRight + offset_x, mPreviewRect.mBottom + offset_y, color, FALSE ) ; | ||
363 | glLineWidth(line_width) ; | ||
364 | |||
365 | //draw four alpha rectangles to cover areas outside of the snapshot image | ||
366 | if(!mKeepAspectRatio) | ||
367 | { | ||
368 | LLColor4 alpha_color(0.5f, 0.5f, 0.5f, 0.8f) ; | ||
369 | S32 dwl = 0, dwr = 0 ; | ||
370 | if(mThumbnailWidth > mPreviewRect.getWidth()) | ||
371 | { | ||
372 | dwl = (mThumbnailWidth - mPreviewRect.getWidth()) >> 1 ; | ||
373 | dwr = mThumbnailWidth - mPreviewRect.getWidth() - dwl ; | ||
323 | 374 | ||
324 | LLString LLSnapshotLivePreview::getWidgetTag() const | 375 | gl_rect_2d(mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mTop + offset_y, |
325 | { | 376 | mPreviewRect.mLeft + offset_x, mPreviewRect.mBottom + offset_y, alpha_color, TRUE ) ; |
326 | return LL_SNAPSHOT_LIVE_PREVIEW_TAG; | 377 | gl_rect_2d( mPreviewRect.mRight + offset_x, mPreviewRect.mTop + offset_y, |
378 | mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y, alpha_color, TRUE ) ; | ||
379 | } | ||
380 | |||
381 | if(mThumbnailHeight > mPreviewRect.getHeight()) | ||
382 | { | ||
383 | S32 dh = (mThumbnailHeight - mPreviewRect.getHeight()) >> 1 ; | ||
384 | gl_rect_2d(mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mBottom + offset_y , | ||
385 | mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mBottom + offset_y - dh, alpha_color, TRUE ) ; | ||
386 | |||
387 | dh = mThumbnailHeight - mPreviewRect.getHeight() - dh ; | ||
388 | gl_rect_2d( mPreviewRect.mLeft + offset_x - dwl, mPreviewRect.mTop + offset_y + dh, | ||
389 | mPreviewRect.mRight + offset_x + dwr, mPreviewRect.mTop + offset_y, alpha_color, TRUE ) ; | ||
390 | } | ||
391 | } | ||
327 | } | 392 | } |
328 | 393 | ||
329 | void LLSnapshotLivePreview::draw() | 394 | void LLSnapshotLivePreview::draw() |
330 | { | 395 | { |
331 | if(getVisible()) | 396 | if (mViewerImage[mCurImageIndex].notNull() && |
332 | { | 397 | mRawImageEncoded.notNull() && |
333 | if (mViewerImage[mCurImageIndex].notNull() && | 398 | mSnapshotUpToDate) |
334 | mRawImageEncoded.notNull() && | 399 | { |
335 | mSnapshotUpToDate) | 400 | LLColor4 bg_color(0.f, 0.f, 0.3f, 0.4f); |
401 | gl_rect_2d(getRect(), bg_color); | ||
402 | LLRect &rect = mImageRect[mCurImageIndex]; | ||
403 | LLRect shadow_rect = mImageRect[mCurImageIndex]; | ||
404 | shadow_rect.stretch(BORDER_WIDTH); | ||
405 | gl_drop_shadow(shadow_rect.mLeft, shadow_rect.mTop, shadow_rect.mRight, shadow_rect.mBottom, LLColor4(0.f, 0.f, 0.f, mNeedsFlash ? 0.f :0.5f), 10); | ||
406 | |||
407 | LLColor4 image_color(1.f, 1.f, 1.f, 1.f); | ||
408 | gGL.color4fv(image_color.mV); | ||
409 | LLViewerImage::bindTexture(mViewerImage[mCurImageIndex]); | ||
410 | // calculate UV scale | ||
411 | F32 uv_width = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mWidth[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f); | ||
412 | F32 uv_height = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mHeight[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f); | ||
413 | glPushMatrix(); | ||
336 | { | 414 | { |
337 | LLColor4 bg_color(0.f, 0.f, 0.3f, 0.4f); | 415 | glTranslatef((F32)rect.mLeft, (F32)rect.mBottom, 0.f); |
338 | gl_rect_2d(getRect(), bg_color); | 416 | gGL.begin(GL_QUADS); |
339 | LLRect &rect = mImageRect[mCurImageIndex]; | ||
340 | LLRect shadow_rect = mImageRect[mCurImageIndex]; | ||
341 | shadow_rect.stretch(BORDER_WIDTH); | ||
342 | gl_drop_shadow(shadow_rect.mLeft, shadow_rect.mTop, shadow_rect.mRight, shadow_rect.mBottom, LLColor4(0.f, 0.f, 0.f, mNeedsFlash ? 0.f :0.5f), 10); | ||
343 | |||
344 | LLColor4 image_color(1.f, 1.f, 1.f, 1.f); | ||
345 | gGL.color4fv(image_color.mV); | ||
346 | LLViewerImage::bindTexture(mViewerImage[mCurImageIndex]); | ||
347 | // calculate UV scale | ||
348 | F32 uv_width = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mWidth[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f); | ||
349 | F32 uv_height = mImageScaled[mCurImageIndex] ? 1.f : llmin((F32)mHeight[mCurImageIndex] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f); | ||
350 | glPushMatrix(); | ||
351 | { | 417 | { |
352 | glTranslatef((F32)rect.mLeft, (F32)rect.mBottom, 0.f); | 418 | gGL.texCoord2f(uv_width, uv_height); |
353 | gGL.begin(GL_QUADS); | 419 | gGL.vertex2i(rect.getWidth(), rect.getHeight() ); |
354 | { | ||
355 | gGL.texCoord2f(uv_width, uv_height); | ||
356 | gGL.vertex2i(rect.getWidth(), rect.getHeight() ); | ||
357 | 420 | ||
358 | gGL.texCoord2f(0.f, uv_height); | 421 | gGL.texCoord2f(0.f, uv_height); |
359 | gGL.vertex2i(0, rect.getHeight() ); | 422 | gGL.vertex2i(0, rect.getHeight() ); |
360 | 423 | ||
361 | gGL.texCoord2f(0.f, 0.f); | 424 | gGL.texCoord2f(0.f, 0.f); |
362 | gGL.vertex2i(0, 0); | 425 | gGL.vertex2i(0, 0); |
363 | 426 | ||
364 | gGL.texCoord2f(uv_width, 0.f); | 427 | gGL.texCoord2f(uv_width, 0.f); |
365 | gGL.vertex2i(rect.getWidth(), 0); | 428 | gGL.vertex2i(rect.getWidth(), 0); |
366 | } | ||
367 | gGL.end(); | ||
368 | } | 429 | } |
369 | glPopMatrix(); | 430 | gGL.end(); |
431 | } | ||
432 | glPopMatrix(); | ||
370 | 433 | ||
371 | gGL.color4f(1.f, 1.f, 1.f, mFlashAlpha); | 434 | gGL.color4f(1.f, 1.f, 1.f, mFlashAlpha); |
372 | gl_rect_2d(getRect()); | 435 | gl_rect_2d(getRect()); |
373 | if (mNeedsFlash) | 436 | if (mNeedsFlash) |
437 | { | ||
438 | if (mFlashAlpha < 1.f) | ||
374 | { | 439 | { |
375 | if (mFlashAlpha < 1.f) | 440 | mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f)); |
376 | { | ||
377 | mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f)); | ||
378 | } | ||
379 | else | ||
380 | { | ||
381 | mNeedsFlash = FALSE; | ||
382 | } | ||
383 | } | 441 | } |
384 | else | 442 | else |
385 | { | 443 | { |
386 | mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f)); | 444 | mNeedsFlash = FALSE; |
387 | } | 445 | } |
446 | } | ||
447 | else | ||
448 | { | ||
449 | mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f)); | ||
450 | } | ||
388 | 451 | ||
389 | if (mShineCountdown > 0) | 452 | if (mShineCountdown > 0) |
453 | { | ||
454 | mShineCountdown--; | ||
455 | if (mShineCountdown == 0) | ||
390 | { | 456 | { |
391 | mShineCountdown--; | 457 | mShineAnimTimer.start(); |
392 | if (mShineCountdown == 0) | ||
393 | { | ||
394 | mShineAnimTimer.start(); | ||
395 | } | ||
396 | } | 458 | } |
397 | else if (mShineAnimTimer.getStarted()) | 459 | } |
460 | else if (mShineAnimTimer.getStarted()) | ||
461 | { | ||
462 | //LLDebugVarMessageBox::show("Shine time", &SHINE_TIME, 10.f, 0.1f); | ||
463 | //LLDebugVarMessageBox::show("Shine width", &SHINE_WIDTH, 2.f, 0.05f); | ||
464 | //LLDebugVarMessageBox::show("Shine opacity", &SHINE_OPACITY, 1.f, 0.05f); | ||
465 | |||
466 | F32 shine_interp = llmin(1.f, mShineAnimTimer.getElapsedTimeF32() / SHINE_TIME); | ||
467 | |||
468 | // draw "shine" effect | ||
469 | LLLocalClipRect clip(getLocalRect()); | ||
398 | { | 470 | { |
399 | //LLDebugVarMessageBox::show("Shine time", &SHINE_TIME, 10.f, 0.1f); | 471 | // draw diagonal stripe with gradient that passes over screen |
400 | //LLDebugVarMessageBox::show("Shine width", &SHINE_WIDTH, 2.f, 0.05f); | 472 | S32 x1 = gViewerWindow->getWindowWidth() * llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); |
401 | //LLDebugVarMessageBox::show("Shine opacity", &SHINE_OPACITY, 1.f, 0.05f); | 473 | S32 x2 = x1 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); |
402 | 474 | S32 x3 = x2 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); | |
403 | F32 shine_interp = llmin(1.f, mShineAnimTimer.getElapsedTimeF32() / SHINE_TIME); | 475 | S32 y1 = 0; |
404 | 476 | S32 y2 = gViewerWindow->getWindowHeight(); | |
405 | // draw "shine" effect | 477 | |
406 | LLLocalClipRect clip(getLocalRect()); | 478 | LLGLSNoTexture no_texture; |
479 | gGL.begin(GL_QUADS); | ||
407 | { | 480 | { |
408 | // draw diagonal stripe with gradient that passes over screen | 481 | gGL.color4f(1.f, 1.f, 1.f, 0.f); |
409 | S32 x1 = gViewerWindow->getWindowWidth() * llround((clamp_rescale(shine_interp, 0.f, 1.f, -1.f - SHINE_WIDTH, 1.f))); | 482 | gGL.vertex2i(x1, y1); |
410 | S32 x2 = x1 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); | 483 | gGL.vertex2i(x1 + gViewerWindow->getWindowWidth(), y2); |
411 | S32 x3 = x2 + llround(gViewerWindow->getWindowWidth() * SHINE_WIDTH); | 484 | gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); |
412 | S32 y1 = 0; | 485 | gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); |
413 | S32 y2 = gViewerWindow->getWindowHeight(); | 486 | gGL.vertex2i(x2, y1); |
414 | 487 | ||
415 | LLGLSNoTexture no_texture; | 488 | gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); |
416 | gGL.begin(GL_QUADS); | 489 | gGL.vertex2i(x2, y1); |
417 | { | 490 | gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); |
418 | gGL.color4f(1.f, 1.f, 1.f, 0.f); | 491 | gGL.color4f(1.f, 1.f, 1.f, 0.f); |
419 | gGL.vertex2i(x1, y1); | 492 | gGL.vertex2i(x3 + gViewerWindow->getWindowWidth(), y2); |
420 | gGL.vertex2i(x1 + gViewerWindow->getWindowWidth(), y2); | 493 | gGL.vertex2i(x3, y1); |
421 | gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); | ||
422 | gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); | ||
423 | gGL.vertex2i(x2, y1); | ||
424 | |||
425 | gGL.color4f(1.f, 1.f, 1.f, SHINE_OPACITY); | ||
426 | gGL.vertex2i(x2, y1); | ||
427 | gGL.vertex2i(x2 + gViewerWindow->getWindowWidth(), y2); | ||
428 | gGL.color4f(1.f, 1.f, 1.f, 0.f); | ||
429 | gGL.vertex2i(x3 + gViewerWindow->getWindowWidth(), y2); | ||
430 | gGL.vertex2i(x3, y1); | ||
431 | } | ||
432 | gGL.end(); | ||
433 | } | 494 | } |
495 | gGL.end(); | ||
496 | } | ||
434 | 497 | ||
435 | if (mShineAnimTimer.getElapsedTimeF32() > SHINE_TIME) | 498 | if (mShineAnimTimer.getElapsedTimeF32() > SHINE_TIME) |
436 | { | 499 | { |
437 | mShineAnimTimer.stop(); | 500 | mShineAnimTimer.stop(); |
438 | } | ||
439 | } | 501 | } |
440 | } | 502 | } |
503 | } | ||
441 | 504 | ||
442 | // draw framing rectangle | 505 | // draw framing rectangle |
506 | { | ||
507 | LLGLSNoTexture no_texture; | ||
508 | gGL.color4f(1.f, 1.f, 1.f, 1.f); | ||
509 | LLRect outline_rect = mImageRect[mCurImageIndex]; | ||
510 | gGL.begin(GL_QUADS); | ||
443 | { | 511 | { |
444 | LLGLSNoTexture no_texture; | 512 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); |
445 | gGL.color4f(1.f, 1.f, 1.f, 1.f); | 513 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); |
446 | LLRect outline_rect = mImageRect[mCurImageIndex]; | 514 | gGL.vertex2i(outline_rect.mRight, outline_rect.mTop); |
447 | gGL.begin(GL_QUADS); | 515 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop); |
448 | { | 516 | |
449 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); | 517 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom); |
450 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); | 518 | gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom); |
451 | gGL.vertex2i(outline_rect.mRight, outline_rect.mTop); | 519 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); |
452 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop); | 520 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); |
453 | 521 | ||
454 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom); | 522 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop); |
455 | gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom); | 523 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom); |
456 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); | 524 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); |
457 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); | 525 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); |
458 | 526 | ||
459 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mTop); | 527 | gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom); |
460 | gGL.vertex2i(outline_rect.mLeft, outline_rect.mBottom); | 528 | gGL.vertex2i(outline_rect.mRight, outline_rect.mTop); |
461 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); | 529 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); |
462 | gGL.vertex2i(outline_rect.mLeft - BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); | 530 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); |
463 | |||
464 | gGL.vertex2i(outline_rect.mRight, outline_rect.mBottom); | ||
465 | gGL.vertex2i(outline_rect.mRight, outline_rect.mTop); | ||
466 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mTop + BORDER_WIDTH); | ||
467 | gGL.vertex2i(outline_rect.mRight + BORDER_WIDTH, outline_rect.mBottom - BORDER_WIDTH); | ||
468 | } | ||
469 | gGL.end(); | ||
470 | } | 531 | } |
532 | gGL.end(); | ||
533 | } | ||
471 | 534 | ||
472 | // draw old image dropping away | 535 | // draw old image dropping away |
473 | if (mFallAnimTimer.getStarted()) | 536 | if (mFallAnimTimer.getStarted()) |
537 | { | ||
538 | S32 old_image_index = (mCurImageIndex + 1) % 2; | ||
539 | if (mViewerImage[old_image_index].notNull() && mFallAnimTimer.getElapsedTimeF32() < FALL_TIME) | ||
474 | { | 540 | { |
475 | S32 old_image_index = (mCurImageIndex + 1) % 2; | 541 | F32 fall_interp = mFallAnimTimer.getElapsedTimeF32() / FALL_TIME; |
476 | if (mViewerImage[old_image_index].notNull() && mFallAnimTimer.getElapsedTimeF32() < FALL_TIME) | 542 | F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f); |
543 | LLColor4 image_color(1.f, 1.f, 1.f, alpha); | ||
544 | gGL.color4fv(image_color.mV); | ||
545 | LLViewerImage::bindTexture(mViewerImage[old_image_index]); | ||
546 | // calculate UV scale | ||
547 | // *FIX get this to work with old image | ||
548 | BOOL rescale = !mImageScaled[old_image_index] && mViewerImage[mCurImageIndex].notNull(); | ||
549 | F32 uv_width = rescale ? llmin((F32)mWidth[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f) : 1.f; | ||
550 | F32 uv_height = rescale ? llmin((F32)mHeight[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f) : 1.f; | ||
551 | glPushMatrix(); | ||
477 | { | 552 | { |
478 | F32 fall_interp = mFallAnimTimer.getElapsedTimeF32() / FALL_TIME; | 553 | LLRect& rect = mImageRect[old_image_index]; |
479 | F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f); | 554 | glTranslatef((F32)rect.mLeft, (F32)rect.mBottom - llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); |
480 | LLColor4 image_color(1.f, 1.f, 1.f, alpha); | 555 | glRotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); |
481 | gGL.color4fv(image_color.mV); | 556 | gGL.begin(GL_QUADS); |
482 | LLViewerImage::bindTexture(mViewerImage[old_image_index]); | ||
483 | // calculate UV scale | ||
484 | // *FIX get this to work with old image | ||
485 | BOOL rescale = !mImageScaled[old_image_index] && mViewerImage[mCurImageIndex].notNull(); | ||
486 | F32 uv_width = rescale ? llmin((F32)mWidth[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getWidth(), 1.f) : 1.f; | ||
487 | F32 uv_height = rescale ? llmin((F32)mHeight[old_image_index] / (F32)mViewerImage[mCurImageIndex]->getHeight(), 1.f) : 1.f; | ||
488 | glPushMatrix(); | ||
489 | { | 557 | { |
490 | LLRect& rect = mImageRect[old_image_index]; | 558 | gGL.texCoord2f(uv_width, uv_height); |
491 | glTranslatef((F32)rect.mLeft, (F32)rect.mBottom - llround(getRect().getHeight() * 2.f * (fall_interp * fall_interp)), 0.f); | 559 | gGL.vertex2i(rect.getWidth(), rect.getHeight() ); |
492 | glRotatef(-45.f * fall_interp, 0.f, 0.f, 1.f); | 560 | |
493 | gGL.begin(GL_QUADS); | 561 | gGL.texCoord2f(0.f, uv_height); |
494 | { | 562 | gGL.vertex2i(0, rect.getHeight() ); |
495 | gGL.texCoord2f(uv_width, uv_height); | 563 | |
496 | gGL.vertex2i(rect.getWidth(), rect.getHeight() ); | 564 | gGL.texCoord2f(0.f, 0.f); |
497 | 565 | gGL.vertex2i(0, 0); | |
498 | gGL.texCoord2f(0.f, uv_height); | 566 | |
499 | gGL.vertex2i(0, rect.getHeight() ); | 567 | gGL.texCoord2f(uv_width, 0.f); |
500 | 568 | gGL.vertex2i(rect.getWidth(), 0); | |
501 | gGL.texCoord2f(0.f, 0.f); | ||
502 | gGL.vertex2i(0, 0); | ||
503 | |||
504 | gGL.texCoord2f(uv_width, 0.f); | ||
505 | gGL.vertex2i(rect.getWidth(), 0); | ||
506 | } | ||
507 | gGL.end(); | ||
508 | } | 569 | } |
509 | glPopMatrix(); | 570 | gGL.end(); |
510 | } | 571 | } |
572 | glPopMatrix(); | ||
511 | } | 573 | } |
512 | } | 574 | } |
513 | } | 575 | } |
@@ -519,17 +581,140 @@ void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_pare | |||
519 | LLView::reshape(width, height, called_from_parent); | 581 | LLView::reshape(width, height, called_from_parent); |
520 | if (old_rect.getWidth() != width || old_rect.getHeight() != height) | 582 | if (old_rect.getWidth() != width || old_rect.getHeight() != height) |
521 | { | 583 | { |
522 | updateSnapshot(getSnapshotUpToDate()); | 584 | updateSnapshot(FALSE, TRUE); |
523 | } | 585 | } |
524 | } | 586 | } |
525 | 587 | ||
588 | BOOL LLSnapshotLivePreview::setThumbnailImageSize() | ||
589 | { | ||
590 | if(mWidth[mCurImageIndex] < 10 || mHeight[mCurImageIndex] < 10) | ||
591 | { | ||
592 | return FALSE ; | ||
593 | } | ||
594 | S32 window_width = gViewerWindow->getWindowDisplayWidth() ; | ||
595 | S32 window_height = gViewerWindow->getWindowDisplayHeight() ; | ||
596 | |||
597 | F32 window_aspect_ratio = ((F32)window_width) / ((F32)window_height); | ||
598 | |||
599 | // UI size for thumbnail | ||
600 | S32 max_width = LLFloaterSnapshot::getUIWinWidth() - 20; | ||
601 | S32 max_height = 90; | ||
602 | |||
603 | if (window_aspect_ratio > (F32)max_width / max_height) | ||
604 | { | ||
605 | // image too wide, shrink to width | ||
606 | mThumbnailWidth = max_width; | ||
607 | mThumbnailHeight = llround((F32)max_width / window_aspect_ratio); | ||
608 | } | ||
609 | else | ||
610 | { | ||
611 | // image too tall, shrink to height | ||
612 | mThumbnailHeight = max_height; | ||
613 | mThumbnailWidth = llround((F32)max_height * window_aspect_ratio); | ||
614 | } | ||
615 | |||
616 | if(mThumbnailWidth > window_width || mThumbnailHeight > window_height) | ||
617 | { | ||
618 | return FALSE ;//if the window is too small, ignore thumbnail updating. | ||
619 | } | ||
620 | |||
621 | S32 left = 0 , top = mThumbnailHeight, right = mThumbnailWidth, bottom = 0 ; | ||
622 | if(!mKeepAspectRatio) | ||
623 | { | ||
624 | F32 ratio_x = (F32)mWidth[mCurImageIndex] / window_width ; | ||
625 | F32 ratio_y = (F32)mHeight[mCurImageIndex] / window_height ; | ||
626 | |||
627 | //if(mWidth[mCurImageIndex] > window_width || | ||
628 | // mHeight[mCurImageIndex] > window_height ) | ||
629 | { | ||
630 | if(ratio_x > ratio_y) | ||
631 | { | ||
632 | top = (S32)(top * ratio_y / ratio_x) ; | ||
633 | } | ||
634 | else | ||
635 | { | ||
636 | right = (S32)(right * ratio_x / ratio_y) ; | ||
637 | } | ||
638 | } | ||
639 | //else | ||
640 | //{ | ||
641 | // right = (S32)(right * ratio_x) ; | ||
642 | // top = (S32)(top * ratio_y) ; | ||
643 | //} | ||
644 | left = (S32)((mThumbnailWidth - right) * 0.5f) ; | ||
645 | bottom = (S32)((mThumbnailHeight - top) * 0.5f) ; | ||
646 | top += bottom ; | ||
647 | right += left ; | ||
648 | } | ||
649 | mPreviewRect.set(left - 1, top + 1, right + 1, bottom - 1) ; | ||
650 | |||
651 | return TRUE ; | ||
652 | } | ||
653 | |||
654 | void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) | ||
655 | { | ||
656 | if(mThumbnailUpdateLock) //in the process of updating | ||
657 | { | ||
658 | return ; | ||
659 | } | ||
660 | if(mThumbnailUpToDate && !force_update)//already updated | ||
661 | { | ||
662 | return ; | ||
663 | } | ||
664 | if(mWidth[mCurImageIndex] < 10 || mHeight[mCurImageIndex] < 10) | ||
665 | { | ||
666 | return ; | ||
667 | } | ||
668 | |||
669 | ////lock updating | ||
670 | mThumbnailUpdateLock = TRUE ; | ||
671 | |||
672 | if(!setThumbnailImageSize()) | ||
673 | { | ||
674 | mThumbnailUpdateLock = FALSE ; | ||
675 | mThumbnailUpToDate = TRUE ; | ||
676 | return ; | ||
677 | } | ||
678 | |||
679 | if(mThumbnailImage) | ||
680 | { | ||
681 | resetThumbnailImage() ; | ||
682 | } | ||
683 | |||
684 | LLPointer<LLImageRaw> raw = NULL ; | ||
685 | S32 w , h ; | ||
686 | w = get_nearest_power_two(mThumbnailWidth, 512) * 2 ; | ||
687 | h = get_nearest_power_two(mThumbnailHeight, 512) * 2 ; | ||
688 | |||
689 | { | ||
690 | raw = new LLImageRaw ; | ||
691 | if(!gViewerWindow->thumbnailSnapshot(raw, | ||
692 | w, h, | ||
693 | gSavedSettings.getBOOL("RenderUIInSnapshot"), | ||
694 | FALSE, | ||
695 | mSnapshotBufferType) ) | ||
696 | { | ||
697 | raw = NULL ; | ||
698 | } | ||
699 | } | ||
700 | |||
701 | if(raw) | ||
702 | { | ||
703 | mThumbnailImage = new LLImageGL(raw, FALSE); | ||
704 | mThumbnailUpToDate = TRUE ; | ||
705 | } | ||
706 | |||
707 | //unlock updating | ||
708 | mThumbnailUpdateLock = FALSE ; | ||
709 | } | ||
710 | |||
526 | //static | 711 | //static |
527 | void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) | 712 | void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) |
528 | { | 713 | { |
529 | LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)snapshot_preview; | 714 | LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)snapshot_preview; |
530 | 715 | ||
531 | LLVector3 new_camera_pos = gCamera->getOrigin(); | 716 | LLVector3 new_camera_pos = LLViewerCamera::getInstance()->getOrigin(); |
532 | LLQuaternion new_camera_rot = gCamera->getQuaternion(); | 717 | LLQuaternion new_camera_rot = LLViewerCamera::getInstance()->getQuaternion(); |
533 | if (gSavedSettings.getBOOL("FreezeTime") && | 718 | if (gSavedSettings.getBOOL("FreezeTime") && |
534 | (new_camera_pos != previewp->mCameraPos || dot(new_camera_rot, previewp->mCameraRot) < 0.995f)) | 719 | (new_camera_pos != previewp->mCameraPos || dot(new_camera_rot, previewp->mCameraRot) < 0.995f)) |
535 | { | 720 | { |
@@ -543,7 +728,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) | |||
543 | previewp->mSnapshotDelayTimer.hasExpired()); | 728 | previewp->mSnapshotDelayTimer.hasExpired()); |
544 | 729 | ||
545 | // don't take snapshots while ALT-zoom active | 730 | // don't take snapshots while ALT-zoom active |
546 | if (gToolCamera->hasMouseCapture()) | 731 | if (LLToolCamera::getInstance()->hasMouseCapture()) |
547 | { | 732 | { |
548 | previewp->mSnapshotActive = FALSE; | 733 | previewp->mSnapshotActive = FALSE; |
549 | } | 734 | } |
@@ -637,6 +822,7 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) | |||
637 | previewp->mViewerImage[previewp->mCurImageIndex]->setClamp(TRUE, TRUE); | 822 | previewp->mViewerImage[previewp->mCurImageIndex]->setClamp(TRUE, TRUE); |
638 | 823 | ||
639 | previewp->mSnapshotUpToDate = TRUE; | 824 | previewp->mSnapshotUpToDate = TRUE; |
825 | previewp->generateThumbnailImage(TRUE) ; | ||
640 | 826 | ||
641 | previewp->mPosTakenGlobal = gAgent.getCameraPositionGlobal(); | 827 | previewp->mPosTakenGlobal = gAgent.getCameraPositionGlobal(); |
642 | previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame | 828 | previewp->mShineCountdown = 4; // wait a few frames to avoid animation glitch due to readback this frame |
@@ -647,6 +833,10 @@ void LLSnapshotLivePreview::onIdle( void* snapshot_preview ) | |||
647 | previewp->mSnapshotDelayTimer.stop(); | 833 | previewp->mSnapshotDelayTimer.stop(); |
648 | previewp->mSnapshotActive = FALSE; | 834 | previewp->mSnapshotActive = FALSE; |
649 | } | 835 | } |
836 | if(!previewp->getThumbnailUpToDate()) | ||
837 | { | ||
838 | previewp->generateThumbnailImage() ; | ||
839 | } | ||
650 | } | 840 | } |
651 | 841 | ||
652 | void LLSnapshotLivePreview::setSize(S32 w, S32 h) | 842 | void LLSnapshotLivePreview::setSize(S32 w, S32 h) |
@@ -718,7 +908,7 @@ void LLSnapshotLivePreview::saveTexture() | |||
718 | llwarns << "Error encoding snapshot" << llendl; | 908 | llwarns << "Error encoding snapshot" << llendl; |
719 | } | 909 | } |
720 | 910 | ||
721 | gViewerStats->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); | 911 | LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT ); |
722 | } | 912 | } |
723 | 913 | ||
724 | BOOL LLSnapshotLivePreview::saveLocal() | 914 | BOOL LLSnapshotLivePreview::saveLocal() |
@@ -759,7 +949,8 @@ public: | |||
759 | static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); | 949 | static void onCommitLayerTypes(LLUICtrl* ctrl, void*data); |
760 | static void onCommitSnapshotType(LLUICtrl* ctrl, void* data); | 950 | static void onCommitSnapshotType(LLUICtrl* ctrl, void* data); |
761 | static void onCommitCustomResolution(LLUICtrl *ctrl, void* data); | 951 | static void onCommitCustomResolution(LLUICtrl *ctrl, void* data); |
762 | static void checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); | 952 | static void resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) ; |
953 | static BOOL checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value); | ||
763 | 954 | ||
764 | static LLSnapshotLivePreview* getPreviewView(LLFloaterSnapshot *floater); | 955 | static LLSnapshotLivePreview* getPreviewView(LLFloaterSnapshot *floater); |
765 | static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname); | 956 | static void setResolution(LLFloaterSnapshot* floater, const std::string& comboname); |
@@ -773,7 +964,7 @@ private: | |||
773 | static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater); | 964 | static LLSnapshotLivePreview::ESnapshotType getTypeIndex(LLFloaterSnapshot* floater); |
774 | static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater); | 965 | static LLViewerWindow::ESnapshotType getLayerType(LLFloaterSnapshot* floater); |
775 | static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname); | 966 | static void comboSetCustom(LLFloaterSnapshot *floater, const std::string& comboname); |
776 | static void checkAutoSnapshot(LLSnapshotLivePreview* floater); | 967 | static void checkAutoSnapshot(LLSnapshotLivePreview* floater, BOOL update_thumbnail = FALSE); |
777 | static void checkAspectRatio(LLFloaterSnapshot *view, S32 index) ; | 968 | static void checkAspectRatio(LLFloaterSnapshot *view, S32 index) ; |
778 | 969 | ||
779 | public: | 970 | public: |
@@ -827,7 +1018,7 @@ LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSna | |||
827 | // static | 1018 | // static |
828 | void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshot* floater, const std::string& comboname) | 1019 | void LLFloaterSnapshot::Impl::setResolution(LLFloaterSnapshot* floater, const std::string& comboname) |
829 | { | 1020 | { |
830 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(floater, comboname); | 1021 | LLComboBox* combo = floater->getChild<LLComboBox>(comboname); |
831 | if (combo) | 1022 | if (combo) |
832 | { | 1023 | { |
833 | combo->setVisible(TRUE); | 1024 | combo->setVisible(TRUE); |
@@ -840,22 +1031,22 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) | |||
840 | { | 1031 | { |
841 | LLSnapshotLivePreview* previewp = getPreviewView(floaterp); | 1032 | LLSnapshotLivePreview* previewp = getPreviewView(floaterp); |
842 | 1033 | ||
843 | S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : -230 ; | 1034 | S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : floaterp->getUIWinHeightShort() - floaterp->getUIWinHeightLong() ; |
844 | 1035 | ||
845 | LLComboBox* combo; | 1036 | LLComboBox* combo; |
846 | if(!gSavedSettings.getBOOL("AdvanceSnapshot")) //set to original window resolution | 1037 | if(!gSavedSettings.getBOOL("AdvanceSnapshot")) //set to original window resolution |
847 | { | 1038 | { |
848 | previewp->mKeepAspectRatio = TRUE ; | 1039 | previewp->mKeepAspectRatio = TRUE ; |
849 | 1040 | ||
850 | combo = LLUICtrlFactory::getComboBoxByName(floaterp, "postcard_size_combo"); | 1041 | combo = floaterp->getChild<LLComboBox>("postcard_size_combo"); |
851 | combo->setCurrentByIndex(0) ; | 1042 | combo->setCurrentByIndex(0) ; |
852 | gSavedSettings.setS32("SnapshotPostcardLastResolution", 0) ; | 1043 | gSavedSettings.setS32("SnapshotPostcardLastResolution", 0) ; |
853 | 1044 | ||
854 | combo = LLUICtrlFactory::getComboBoxByName(floaterp, "texture_size_combo"); | 1045 | combo = floaterp->getChild<LLComboBox>("texture_size_combo"); |
855 | combo->setCurrentByIndex(0) ; | 1046 | combo->setCurrentByIndex(0) ; |
856 | gSavedSettings.setS32("SnapshotTextureLastResolution", 0) ; | 1047 | gSavedSettings.setS32("SnapshotTextureLastResolution", 0) ; |
857 | 1048 | ||
858 | combo = LLUICtrlFactory::getComboBoxByName(floaterp, "local_size_combo"); | 1049 | combo = floaterp->getChild<LLComboBox>("local_size_combo"); |
859 | combo->setCurrentByIndex(0) ; | 1050 | combo->setCurrentByIndex(0) ; |
860 | gSavedSettings.setS32("SnapshotLocalLastResolution", 0) ; | 1051 | gSavedSettings.setS32("SnapshotLocalLastResolution", 0) ; |
861 | 1052 | ||
@@ -869,7 +1060,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) | |||
869 | floaterp->getParent()->setMouseOpaque(TRUE); | 1060 | floaterp->getParent()->setMouseOpaque(TRUE); |
870 | 1061 | ||
871 | // shrink to smaller layout | 1062 | // shrink to smaller layout |
872 | floaterp->reshape(floaterp->getRect().getWidth(), 526 + delta_height); | 1063 | floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getUIWinHeightLong() + delta_height); |
873 | 1064 | ||
874 | // can see and interact with fullscreen preview now | 1065 | // can see and interact with fullscreen preview now |
875 | if (previewp) | 1066 | if (previewp) |
@@ -890,19 +1081,16 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) | |||
890 | // freeze everything else | 1081 | // freeze everything else |
891 | gSavedSettings.setBOOL("FreezeTime", TRUE); | 1082 | gSavedSettings.setBOOL("FreezeTime", TRUE); |
892 | 1083 | ||
893 | if (gToolMgr->getCurrentToolset() != gCameraToolset) | 1084 | if (LLToolMgr::getInstance()->getCurrentToolset() != gCameraToolset) |
894 | { | 1085 | { |
895 | sInstance->impl.mLastToolset = gToolMgr->getCurrentToolset(); | 1086 | sInstance->impl.mLastToolset = LLToolMgr::getInstance()->getCurrentToolset(); |
896 | if (gToolMgr) | 1087 | LLToolMgr::getInstance()->setCurrentToolset(gCameraToolset); |
897 | { | ||
898 | gToolMgr->setCurrentToolset(gCameraToolset); | ||
899 | } | ||
900 | } | 1088 | } |
901 | } | 1089 | } |
902 | else // turning off freeze frame mode | 1090 | else // turning off freeze frame mode |
903 | { | 1091 | { |
904 | floaterp->getParent()->setMouseOpaque(FALSE); | 1092 | floaterp->getParent()->setMouseOpaque(FALSE); |
905 | floaterp->reshape(floaterp->getRect().getWidth(), 526 + delta_height); | 1093 | floaterp->reshape(floaterp->getRect().getWidth(), floaterp->getUIWinHeightLong() + delta_height); |
906 | if (previewp) | 1094 | if (previewp) |
907 | { | 1095 | { |
908 | previewp->setVisible(FALSE); | 1096 | previewp->setVisible(FALSE); |
@@ -918,10 +1106,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) | |||
918 | // restore last tool (e.g. pie menu, etc) | 1106 | // restore last tool (e.g. pie menu, etc) |
919 | if (sInstance->impl.mLastToolset) | 1107 | if (sInstance->impl.mLastToolset) |
920 | { | 1108 | { |
921 | if (gToolMgr) | 1109 | LLToolMgr::getInstance()->setCurrentToolset(sInstance->impl.mLastToolset); |
922 | { | ||
923 | gToolMgr->setCurrentToolset(sInstance->impl.mLastToolset); | ||
924 | } | ||
925 | } | 1110 | } |
926 | } | 1111 | } |
927 | } | 1112 | } |
@@ -931,8 +1116,7 @@ void LLFloaterSnapshot::Impl::updateLayout(LLFloaterSnapshot* floaterp) | |||
931 | void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) | 1116 | void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) |
932 | { | 1117 | { |
933 | BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot") ; | 1118 | BOOL is_advance = gSavedSettings.getBOOL("AdvanceSnapshot") ; |
934 | 1119 | LLRadioGroup* snapshot_type_radio = floater->getChild<LLRadioGroup>("snapshot_type_radio"); | |
935 | LLRadioGroup* snapshot_type_radio = LLUICtrlFactory::getRadioGroupByName(floater, "snapshot_type_radio"); | ||
936 | snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType")); | 1120 | snapshot_type_radio->setSelectedIndex(gSavedSettings.getS32("LastSnapshotType")); |
937 | LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater); | 1121 | LLSnapshotLivePreview::ESnapshotType shot_type = getTypeIndex(floater); |
938 | LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); | 1122 | LLViewerWindow::ESnapshotType layer_type = getLayerType(floater); |
@@ -942,11 +1126,11 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) | |||
942 | floater->childSetVisible("local_size_combo", FALSE); | 1126 | floater->childSetVisible("local_size_combo", FALSE); |
943 | 1127 | ||
944 | LLComboBox* combo; | 1128 | LLComboBox* combo; |
945 | combo = LLUICtrlFactory::getComboBoxByName(floater, "postcard_size_combo"); | 1129 | combo = floater->getChild<LLComboBox>("postcard_size_combo"); |
946 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution")); | 1130 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotPostcardLastResolution")); |
947 | combo = LLUICtrlFactory::getComboBoxByName(floater, "texture_size_combo"); | 1131 | combo = floater->getChild<LLComboBox>("texture_size_combo"); |
948 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution")); | 1132 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotTextureLastResolution")); |
949 | combo = LLUICtrlFactory::getComboBoxByName(floater, "local_size_combo"); | 1133 | combo = floater->getChild<LLComboBox>("local_size_combo"); |
950 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution")); | 1134 | if (combo) combo->selectNthItem(gSavedSettings.getS32("SnapshotLocalLastResolution")); |
951 | 1135 | ||
952 | floater->childSetVisible("upload_btn", FALSE); | 1136 | floater->childSetVisible("upload_btn", FALSE); |
@@ -1051,11 +1235,11 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater) | |||
1051 | } | 1235 | } |
1052 | 1236 | ||
1053 | // static | 1237 | // static |
1054 | void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp) | 1238 | void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp, BOOL update_thumbnail) |
1055 | { | 1239 | { |
1056 | if (previewp) | 1240 | if (previewp) |
1057 | { | 1241 | { |
1058 | previewp->updateSnapshot(gSavedSettings.getBOOL("AutoSnapshot")); | 1242 | previewp->updateSnapshot(gSavedSettings.getBOOL("AutoSnapshot"), update_thumbnail); |
1059 | } | 1243 | } |
1060 | } | 1244 | } |
1061 | 1245 | ||
@@ -1143,16 +1327,13 @@ void LLFloaterSnapshot::Impl::onClickAutoSnap(LLUICtrl *ctrl, void* data) | |||
1143 | 1327 | ||
1144 | void LLFloaterSnapshot::Impl::onClickMore(void* data) | 1328 | void LLFloaterSnapshot::Impl::onClickMore(void* data) |
1145 | { | 1329 | { |
1146 | //floater->childSetVisible("more_btn", FALSE); | ||
1147 | //floater->childSetVisible("less_btn", TRUE); | ||
1148 | |||
1149 | gSavedSettings.setBOOL( "AdvanceSnapshot", TRUE ); | 1330 | gSavedSettings.setBOOL( "AdvanceSnapshot", TRUE ); |
1150 | 1331 | ||
1151 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; | 1332 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; |
1152 | if (view) | 1333 | if (view) |
1153 | { | 1334 | { |
1154 | view->translate( 0, -230 ); | 1335 | view->translate( 0, view->getUIWinHeightShort() - view->getUIWinHeightLong() ); |
1155 | view->reshape(view->getRect().getWidth(), 526); | 1336 | view->reshape(view->getRect().getWidth(), view->getUIWinHeightLong()); |
1156 | 1337 | ||
1157 | updateControls(view) ; | 1338 | updateControls(view) ; |
1158 | updateLayout(view) ; | 1339 | updateLayout(view) ; |
@@ -1160,40 +1341,24 @@ void LLFloaterSnapshot::Impl::onClickMore(void* data) | |||
1160 | } | 1341 | } |
1161 | void LLFloaterSnapshot::Impl::onClickLess(void* data) | 1342 | void LLFloaterSnapshot::Impl::onClickLess(void* data) |
1162 | { | 1343 | { |
1163 | //floater->childSetVisible("less_btn", FALSE); | ||
1164 | //floater->childSetVisible("more_btn", TRUE); | ||
1165 | |||
1166 | gSavedSettings.setBOOL( "AdvanceSnapshot", FALSE ); | 1344 | gSavedSettings.setBOOL( "AdvanceSnapshot", FALSE ); |
1167 | 1345 | ||
1168 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; | 1346 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; |
1169 | if (view) | 1347 | if (view) |
1170 | { | 1348 | { |
1171 | view->translate( 0, 230 ); | 1349 | view->translate( 0, view->getUIWinHeightLong() - view->getUIWinHeightShort() ); |
1172 | view->reshape(view->getRect().getWidth(), 294); | 1350 | view->reshape(view->getRect().getWidth(), view->getUIWinHeightShort()); |
1173 | 1351 | ||
1174 | updateControls(view) ; | 1352 | updateControls(view) ; |
1175 | updateLayout(view) ; | 1353 | updateLayout(view) ; |
1354 | |||
1355 | if(getPreviewView(view)) | ||
1356 | { | ||
1357 | getPreviewView(view)->setThumbnailImageSize() ; | ||
1358 | } | ||
1176 | } | 1359 | } |
1177 | } | 1360 | } |
1178 | 1361 | ||
1179 | //void LLFloaterSnapshot::Impl::onClickAdvanceSnap(LLUICtrl *ctrl, void* data) | ||
1180 | //{ | ||
1181 | // LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl; | ||
1182 | // gSavedSettings.setBOOL( "AdvanceSnapshot", check->get() ); | ||
1183 | // | ||
1184 | // LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; | ||
1185 | // if (view) | ||
1186 | // { | ||
1187 | // S32 delta_height = gSavedSettings.getBOOL("AdvanceSnapshot") ? 0 : -230 ; | ||
1188 | // | ||
1189 | // view->translate( 0, delta_height ? 230 : -230 ); | ||
1190 | // view->reshape(view->getRect().getWidth(), 526 + delta_height); | ||
1191 | // | ||
1192 | // updateControls(view) ; | ||
1193 | // updateLayout(view) ; | ||
1194 | // } | ||
1195 | //} | ||
1196 | |||
1197 | // static | 1362 | // static |
1198 | void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) | 1363 | void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) |
1199 | { | 1364 | { |
@@ -1203,7 +1368,7 @@ void LLFloaterSnapshot::Impl::onClickUICheck(LLUICtrl *ctrl, void* data) | |||
1203 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; | 1368 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; |
1204 | if (view) | 1369 | if (view) |
1205 | { | 1370 | { |
1206 | checkAutoSnapshot(getPreviewView(view)); | 1371 | checkAutoSnapshot(getPreviewView(view), TRUE); |
1207 | } | 1372 | } |
1208 | } | 1373 | } |
1209 | 1374 | ||
@@ -1216,7 +1381,7 @@ void LLFloaterSnapshot::Impl::onClickHUDCheck(LLUICtrl *ctrl, void* data) | |||
1216 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; | 1381 | LLFloaterSnapshot *view = (LLFloaterSnapshot *)data; |
1217 | if (view) | 1382 | if (view) |
1218 | { | 1383 | { |
1219 | checkAutoSnapshot(getPreviewView(view)); | 1384 | checkAutoSnapshot(getPreviewView(view), TRUE); |
1220 | } | 1385 | } |
1221 | } | 1386 | } |
1222 | 1387 | ||
@@ -1244,23 +1409,13 @@ void LLFloaterSnapshot::Impl::onClickKeepAspectCheck(LLUICtrl* ctrl, void* data) | |||
1244 | 1409 | ||
1245 | S32 w, h ; | 1410 | S32 w, h ; |
1246 | previewp->getSize(w, h) ; | 1411 | previewp->getSize(w, h) ; |
1247 | checkImageSize(previewp, w, h, TRUE, previewp->getMaxImageSize()) ; | 1412 | if(checkImageSize(previewp, w, h, TRUE, previewp->getMaxImageSize())) |
1248 | previewp->setSize(w, h) ; | ||
1249 | |||
1250 | //update textbox | ||
1251 | LLSpinCtrl *sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_width") ; | ||
1252 | if(sctrl) | ||
1253 | { | 1413 | { |
1254 | sctrl->setValue(w) ; | 1414 | resetSnapshotSizeOnUI(view, w, h) ; |
1255 | } | 1415 | } |
1256 | 1416 | ||
1257 | sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_height") ; | 1417 | previewp->setSize(w, h) ; |
1258 | if(sctrl) | 1418 | checkAutoSnapshot(previewp, TRUE); |
1259 | { | ||
1260 | sctrl->setValue(h) ; | ||
1261 | } | ||
1262 | |||
1263 | checkAutoSnapshot(previewp); | ||
1264 | } | 1419 | } |
1265 | } | 1420 | } |
1266 | } | 1421 | } |
@@ -1276,7 +1431,7 @@ void LLFloaterSnapshot::Impl::onCommitQuality(LLUICtrl* ctrl, void* data) | |||
1276 | { | 1431 | { |
1277 | previewp->setSnapshotQuality(quality_val); | 1432 | previewp->setSnapshotQuality(quality_val); |
1278 | } | 1433 | } |
1279 | checkAutoSnapshot(previewp); | 1434 | checkAutoSnapshot(previewp, TRUE); |
1280 | } | 1435 | } |
1281 | 1436 | ||
1282 | // static | 1437 | // static |
@@ -1300,6 +1455,12 @@ void LLFloaterSnapshot::Impl::checkAspectRatio(LLFloaterSnapshot *view, S32 inde | |||
1300 | { | 1455 | { |
1301 | LLSnapshotLivePreview *previewp = getPreviewView(view) ; | 1456 | LLSnapshotLivePreview *previewp = getPreviewView(view) ; |
1302 | 1457 | ||
1458 | if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE == getTypeIndex(view)) | ||
1459 | { | ||
1460 | previewp->mKeepAspectRatio = FALSE ; | ||
1461 | return ; | ||
1462 | } | ||
1463 | |||
1303 | if(!index) //current window size | 1464 | if(!index) //current window size |
1304 | { | 1465 | { |
1305 | sAspectRatioCheckOff = TRUE ; | 1466 | sAspectRatioCheckOff = TRUE ; |
@@ -1350,11 +1511,11 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) | |||
1350 | 1511 | ||
1351 | // save off all selected resolution values | 1512 | // save off all selected resolution values |
1352 | LLComboBox* combo; | 1513 | LLComboBox* combo; |
1353 | combo = LLUICtrlFactory::getComboBoxByName(view, "postcard_size_combo"); | 1514 | combo = view->getChild<LLComboBox>("postcard_size_combo"); |
1354 | gSavedSettings.setS32("SnapshotPostcardLastResolution", combo->getCurrentIndex()); | 1515 | gSavedSettings.setS32("SnapshotPostcardLastResolution", combo->getCurrentIndex()); |
1355 | combo = LLUICtrlFactory::getComboBoxByName(view, "texture_size_combo"); | 1516 | combo = view->getChild<LLComboBox>("texture_size_combo"); |
1356 | gSavedSettings.setS32("SnapshotTextureLastResolution", combo->getCurrentIndex()); | 1517 | gSavedSettings.setS32("SnapshotTextureLastResolution", combo->getCurrentIndex()); |
1357 | combo = LLUICtrlFactory::getComboBoxByName(view, "local_size_combo"); | 1518 | combo = view->getChild<LLComboBox>("local_size_combo"); |
1358 | gSavedSettings.setS32("SnapshotLocalLastResolution", combo->getCurrentIndex()); | 1519 | gSavedSettings.setS32("SnapshotLocalLastResolution", combo->getCurrentIndex()); |
1359 | 1520 | ||
1360 | std::string sdstring = combobox->getSelectedValue(); | 1521 | std::string sdstring = combobox->getSelectedValue(); |
@@ -1385,13 +1546,17 @@ void LLFloaterSnapshot::Impl::onCommitResolution(LLUICtrl* ctrl, void* data) | |||
1385 | checkAspectRatio(view, width) ; | 1546 | checkAspectRatio(view, width) ; |
1386 | 1547 | ||
1387 | previewp->getSize(width, height); | 1548 | previewp->getSize(width, height); |
1388 | checkImageSize(previewp, width, height, TRUE, previewp->getMaxImageSize()) ; | 1549 | |
1550 | if(checkImageSize(previewp, width, height, TRUE, previewp->getMaxImageSize())) | ||
1551 | { | ||
1552 | resetSnapshotSizeOnUI(view, width, height) ; | ||
1553 | } | ||
1389 | previewp->setSize(width, height); | 1554 | previewp->setSize(width, height); |
1390 | 1555 | ||
1391 | view->childSetValue("snapshot_width", width); | 1556 | view->childSetValue("snapshot_width", width); |
1392 | view->childSetValue("snapshot_height", height); | 1557 | view->childSetValue("snapshot_height", height); |
1393 | // hide old preview as the aspect ratio could be wrong | 1558 | // hide old preview as the aspect ratio could be wrong |
1394 | checkAutoSnapshot(previewp); | 1559 | checkAutoSnapshot(previewp, FALSE); |
1395 | } | 1560 | } |
1396 | } | 1561 | } |
1397 | 1562 | ||
@@ -1409,7 +1574,7 @@ void LLFloaterSnapshot::Impl::onCommitLayerTypes(LLUICtrl* ctrl, void*data) | |||
1409 | { | 1574 | { |
1410 | previewp->setSnapshotBufferType((LLViewerWindow::ESnapshotType)combobox->getCurrentIndex()); | 1575 | previewp->setSnapshotBufferType((LLViewerWindow::ESnapshotType)combobox->getCurrentIndex()); |
1411 | } | 1576 | } |
1412 | checkAutoSnapshot(previewp); | 1577 | checkAutoSnapshot(previewp, TRUE); |
1413 | } | 1578 | } |
1414 | } | 1579 | } |
1415 | 1580 | ||
@@ -1428,7 +1593,7 @@ void LLFloaterSnapshot::Impl::onCommitSnapshotType(LLUICtrl* ctrl, void* data) | |||
1428 | // static | 1593 | // static |
1429 | void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname) | 1594 | void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const std::string& comboname) |
1430 | { | 1595 | { |
1431 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(floater, comboname); | 1596 | LLComboBox* combo = floater->getChild<LLComboBox>(comboname); |
1432 | if (combo) | 1597 | if (combo) |
1433 | { | 1598 | { |
1434 | combo->setCurrentByIndex(combo->getItemCount() - 1); | 1599 | combo->setCurrentByIndex(combo->getItemCount() - 1); |
@@ -1440,8 +1605,11 @@ void LLFloaterSnapshot::Impl::comboSetCustom(LLFloaterSnapshot* floater, const s | |||
1440 | 1605 | ||
1441 | 1606 | ||
1442 | //static | 1607 | //static |
1443 | void LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value) | 1608 | BOOL LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S32& width, S32& height, BOOL isWidthChanged, S32 max_value) |
1444 | { | 1609 | { |
1610 | S32 w = width ; | ||
1611 | S32 h = height ; | ||
1612 | |||
1445 | //if texture, ignore aspect ratio setting, round image size to power of 2. | 1613 | //if texture, ignore aspect ratio setting, round image size to power of 2. |
1446 | if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE == gSavedSettings.getS32("LastSnapshotType")) | 1614 | if(LLSnapshotLivePreview::SNAPSHOT_TEXTURE == gSavedSettings.getS32("LastSnapshotType")) |
1447 | { | 1615 | { |
@@ -1457,15 +1625,12 @@ void LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 | |||
1457 | //round to nearest power of 2 | 1625 | //round to nearest power of 2 |
1458 | width = get_nearest_power_two(width, MAX_TEXTURE_SIZE) ; | 1626 | width = get_nearest_power_two(width, MAX_TEXTURE_SIZE) ; |
1459 | height = get_nearest_power_two(height, MAX_TEXTURE_SIZE) ; | 1627 | height = get_nearest_power_two(height, MAX_TEXTURE_SIZE) ; |
1460 | |||
1461 | return ; | ||
1462 | } | 1628 | } |
1463 | 1629 | else if(previewp && previewp->mKeepAspectRatio) | |
1464 | if(previewp && previewp->mKeepAspectRatio) | ||
1465 | { | 1630 | { |
1466 | if(gViewerWindow->getWindowDisplayWidth() < 1 || gViewerWindow->getWindowDisplayHeight() < 1) | 1631 | if(gViewerWindow->getWindowDisplayWidth() < 1 || gViewerWindow->getWindowDisplayHeight() < 1) |
1467 | { | 1632 | { |
1468 | return ; | 1633 | return FALSE ; |
1469 | } | 1634 | } |
1470 | 1635 | ||
1471 | //aspect ratio of the current window | 1636 | //aspect ratio of the current window |
@@ -1499,7 +1664,27 @@ void LLFloaterSnapshot::Impl::checkImageSize(LLSnapshotLivePreview* previewp, S3 | |||
1499 | else | 1664 | else |
1500 | { | 1665 | { |
1501 | } | 1666 | } |
1502 | return ; | 1667 | |
1668 | return (w != width || h != height) ; | ||
1669 | } | ||
1670 | |||
1671 | //static | ||
1672 | void LLFloaterSnapshot::Impl::resetSnapshotSizeOnUI(LLFloaterSnapshot *view, S32 width, S32 height) | ||
1673 | { | ||
1674 | LLSpinCtrl *sctrl = view->getChild<LLSpinCtrl>("snapshot_width") ; | ||
1675 | if(sctrl) | ||
1676 | { | ||
1677 | sctrl->setValue(width) ; | ||
1678 | } | ||
1679 | |||
1680 | sctrl = view->getChild<LLSpinCtrl>("snapshot_height") ; | ||
1681 | if(sctrl) | ||
1682 | { | ||
1683 | sctrl->setValue(height) ; | ||
1684 | } | ||
1685 | |||
1686 | gSavedSettings.setS32("LastSnapshotWidth", width); | ||
1687 | gSavedSettings.setS32("LastSnapshotHeight", height); | ||
1503 | } | 1688 | } |
1504 | 1689 | ||
1505 | //static | 1690 | //static |
@@ -1522,35 +1707,14 @@ void LLFloaterSnapshot::Impl::onCommitCustomResolution(LLUICtrl *ctrl, void* dat | |||
1522 | 1707 | ||
1523 | if (w != curw || h != curh) | 1708 | if (w != curw || h != curh) |
1524 | { | 1709 | { |
1525 | S32 width = w ; | ||
1526 | S32 height = h ; | ||
1527 | |||
1528 | previewp->setMaxImageSize((S32)((LLSpinCtrl *)ctrl)->getMaxValue()) ; | 1710 | previewp->setMaxImageSize((S32)((LLSpinCtrl *)ctrl)->getMaxValue()) ; |
1529 | checkImageSize(previewp, width, height, width != curw, previewp->getMaxImageSize()) ; | 1711 | if(checkImageSize(previewp, w, h, w != curw, previewp->getMaxImageSize())) |
1530 | |||
1531 | if(width != w || height != h) | ||
1532 | { | 1712 | { |
1533 | LLSpinCtrl *sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_width") ; | 1713 | resetSnapshotSizeOnUI(view, w, h) ; |
1534 | if(sctrl) | ||
1535 | { | ||
1536 | sctrl->setValue(width) ; | ||
1537 | } | ||
1538 | |||
1539 | sctrl = LLViewerUICtrlFactory::getSpinnerByName(view, "snapshot_height") ; | ||
1540 | if(sctrl) | ||
1541 | { | ||
1542 | sctrl->setValue(height) ; | ||
1543 | } | ||
1544 | |||
1545 | w = width ; | ||
1546 | h = height ; | ||
1547 | |||
1548 | gSavedSettings.setS32("LastSnapshotWidth", w); | ||
1549 | gSavedSettings.setS32("LastSnapshotHeight", h); | ||
1550 | } | 1714 | } |
1551 | 1715 | ||
1552 | previewp->setSize(w,h); | 1716 | previewp->setSize(w,h); |
1553 | checkAutoSnapshot(previewp); | 1717 | checkAutoSnapshot(previewp, FALSE); |
1554 | comboSetCustom(view, "postcard_size_combo"); | 1718 | comboSetCustom(view, "postcard_size_combo"); |
1555 | comboSetCustom(view, "texture_size_combo"); | 1719 | comboSetCustom(view, "texture_size_combo"); |
1556 | comboSetCustom(view, "local_size_combo"); | 1720 | comboSetCustom(view, "local_size_combo"); |
@@ -1585,10 +1749,7 @@ LLFloaterSnapshot::~LLFloaterSnapshot() | |||
1585 | 1749 | ||
1586 | if (impl.mLastToolset) | 1750 | if (impl.mLastToolset) |
1587 | { | 1751 | { |
1588 | if (gToolMgr) | 1752 | LLToolMgr::getInstance()->setCurrentToolset(impl.mLastToolset); |
1589 | { | ||
1590 | gToolMgr->setCurrentToolset(impl.mLastToolset); | ||
1591 | } | ||
1592 | } | 1753 | } |
1593 | 1754 | ||
1594 | delete &impl; | 1755 | delete &impl; |
@@ -1664,13 +1825,13 @@ void LLFloaterSnapshot::draw() | |||
1664 | { | 1825 | { |
1665 | LLSnapshotLivePreview* previewp = impl.getPreviewView(this); | 1826 | LLSnapshotLivePreview* previewp = impl.getPreviewView(this); |
1666 | 1827 | ||
1667 | if (previewp && previewp->isSnapshotActive()) | 1828 | if (previewp && (previewp->isSnapshotActive() || previewp->getThumbnailLock())) |
1668 | { | 1829 | { |
1669 | // don't render snapshot window in snapshot, even if "show ui" is turned on | 1830 | // don't render snapshot window in snapshot, even if "show ui" is turned on |
1670 | return; | 1831 | return; |
1671 | } | 1832 | } |
1672 | 1833 | ||
1673 | if(getVisible() && !isMinimized()) | 1834 | if(!isMinimized()) |
1674 | { | 1835 | { |
1675 | if (previewp && previewp->getDataSize() > 0) | 1836 | if (previewp && previewp->getDataSize() > 0) |
1676 | { | 1837 | { |
@@ -1692,7 +1853,7 @@ void LLFloaterSnapshot::draw() | |||
1692 | if (previewp->getSnapshotUpToDate()) | 1853 | if (previewp->getSnapshotUpToDate()) |
1693 | { | 1854 | { |
1694 | LLString bytes_string; | 1855 | LLString bytes_string; |
1695 | gResMgr->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); | 1856 | LLResMgr::getInstance()->getIntegerString(bytes_string, (previewp->getDataSize()) >> 10 ); |
1696 | childSetTextArg("file_size_label", "[SIZE]", bytes_string); | 1857 | childSetTextArg("file_size_label", "[SIZE]", bytes_string); |
1697 | } | 1858 | } |
1698 | else | 1859 | else |
@@ -1720,7 +1881,7 @@ void LLFloaterSnapshot::draw() | |||
1720 | LLFloater::draw(); | 1881 | LLFloater::draw(); |
1721 | 1882 | ||
1722 | // draw snapshot thumbnail if not in fullscreen preview mode | 1883 | // draw snapshot thumbnail if not in fullscreen preview mode |
1723 | if (/*!gSavedSettings.getBOOL("UseFreezeFrame") &&*/ previewp && previewp->getCurrentImage() && previewp->getSnapshotUpToDate()) | 1884 | /*if (previewp && previewp->getCurrentImage() && previewp->getSnapshotUpToDate()) |
1724 | { | 1885 | { |
1725 | F32 aspect = previewp->getImageAspect(); | 1886 | F32 aspect = previewp->getImageAspect(); |
1726 | // UI size for thumbnail | 1887 | // UI size for thumbnail |
@@ -1757,6 +1918,21 @@ void LLFloaterSnapshot::draw() | |||
1757 | glMatrixMode(GL_TEXTURE); | 1918 | glMatrixMode(GL_TEXTURE); |
1758 | glPopMatrix(); | 1919 | glPopMatrix(); |
1759 | glMatrixMode(GL_MODELVIEW); | 1920 | glMatrixMode(GL_MODELVIEW); |
1921 | }*/ | ||
1922 | if (previewp) | ||
1923 | { | ||
1924 | if(previewp->getThumbnailImage()) | ||
1925 | { | ||
1926 | S32 offset_x = (getRect().getWidth() - previewp->getThumbnailWidth()) / 2 ; | ||
1927 | S32 offset_y = getRect().getHeight() - 205 + (90 - previewp->getThumbnailHeight()) / 2 ; | ||
1928 | |||
1929 | glMatrixMode(GL_MODELVIEW); | ||
1930 | gl_draw_scaled_image(offset_x, offset_y, | ||
1931 | previewp->getThumbnailWidth(), previewp->getThumbnailHeight(), | ||
1932 | previewp->getThumbnailImage(), LLColor4::white); | ||
1933 | |||
1934 | previewp->drawPreviewRect(offset_x, offset_y) ; | ||
1935 | } | ||
1760 | } | 1936 | } |
1761 | } | 1937 | } |
1762 | 1938 | ||
@@ -1773,7 +1949,7 @@ void LLFloaterSnapshot::show(void*) | |||
1773 | { | 1949 | { |
1774 | sInstance = new LLFloaterSnapshot(); | 1950 | sInstance = new LLFloaterSnapshot(); |
1775 | 1951 | ||
1776 | gUICtrlFactory->buildFloater(sInstance, "floater_snapshot.xml", NULL, FALSE); | 1952 | LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_snapshot.xml", NULL, FALSE); |
1777 | //move snapshot floater to special purpose snapshotfloaterview | 1953 | //move snapshot floater to special purpose snapshotfloaterview |
1778 | gFloaterView->removeChild(sInstance); | 1954 | gFloaterView->removeChild(sInstance); |
1779 | gSnapshotFloaterView->addChild(sInstance); | 1955 | gSnapshotFloaterView->addChild(sInstance); |
@@ -1825,24 +2001,17 @@ BOOL LLSnapshotFloaterView::handleKey(KEY key, MASK mask, BOOL called_from_paren | |||
1825 | return LLFloaterView::handleKey(key, mask, called_from_parent); | 2001 | return LLFloaterView::handleKey(key, mask, called_from_parent); |
1826 | } | 2002 | } |
1827 | 2003 | ||
1828 | if (!getEnabled()) | 2004 | if (called_from_parent) |
1829 | { | 2005 | { |
1830 | return FALSE; | 2006 | // pass all keystrokes down |
2007 | LLFloaterView::handleKey(key, mask, called_from_parent); | ||
1831 | } | 2008 | } |
1832 | else | 2009 | else |
1833 | { | 2010 | { |
1834 | if (called_from_parent) | 2011 | // bounce keystrokes back down |
1835 | { | 2012 | LLFloaterView::handleKey(key, mask, TRUE); |
1836 | // pass all keystrokes down | ||
1837 | LLFloaterView::handleKey(key, mask, called_from_parent); | ||
1838 | } | ||
1839 | else | ||
1840 | { | ||
1841 | // bounce keystrokes back down | ||
1842 | LLFloaterView::handleKey(key, mask, TRUE); | ||
1843 | } | ||
1844 | return TRUE; | ||
1845 | } | 2013 | } |
2014 | return TRUE; | ||
1846 | } | 2015 | } |
1847 | 2016 | ||
1848 | BOOL LLSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) | 2017 | BOOL LLSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) |
@@ -1855,7 +2024,7 @@ BOOL LLSnapshotFloaterView::handleMouseDown(S32 x, S32 y, MASK mask) | |||
1855 | // give floater a change to handle mouse, else camera tool | 2024 | // give floater a change to handle mouse, else camera tool |
1856 | if (childrenHandleMouseDown(x, y, mask) == NULL) | 2025 | if (childrenHandleMouseDown(x, y, mask) == NULL) |
1857 | { | 2026 | { |
1858 | gToolMgr->getCurrentTool()->handleMouseDown( x, y, mask ); | 2027 | LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ); |
1859 | } | 2028 | } |
1860 | return TRUE; | 2029 | return TRUE; |
1861 | } | 2030 | } |
@@ -1870,7 +2039,7 @@ BOOL LLSnapshotFloaterView::handleMouseUp(S32 x, S32 y, MASK mask) | |||
1870 | // give floater a change to handle mouse, else camera tool | 2039 | // give floater a change to handle mouse, else camera tool |
1871 | if (childrenHandleMouseUp(x, y, mask) == NULL) | 2040 | if (childrenHandleMouseUp(x, y, mask) == NULL) |
1872 | { | 2041 | { |
1873 | gToolMgr->getCurrentTool()->handleMouseUp( x, y, mask ); | 2042 | LLToolMgr::getInstance()->getCurrentTool()->handleMouseUp( x, y, mask ); |
1874 | } | 2043 | } |
1875 | return TRUE; | 2044 | return TRUE; |
1876 | } | 2045 | } |
@@ -1885,7 +2054,7 @@ BOOL LLSnapshotFloaterView::handleHover(S32 x, S32 y, MASK mask) | |||
1885 | // give floater a change to handle mouse, else camera tool | 2054 | // give floater a change to handle mouse, else camera tool |
1886 | if (childrenHandleHover(x, y, mask) == NULL) | 2055 | if (childrenHandleHover(x, y, mask) == NULL) |
1887 | { | 2056 | { |
1888 | gToolMgr->getCurrentTool()->handleHover( x, y, mask ); | 2057 | LLToolMgr::getInstance()->getCurrentTool()->handleHover( x, y, mask ); |
1889 | } | 2058 | } |
1890 | return TRUE; | 2059 | return TRUE; |
1891 | } | 2060 | } |