Ticket #5897: gallery_scale.patch
File gallery_scale.patch, 7.9 KB (added by , 12 years ago) |
---|
-
mythplugins/mythgallery/mythgallery/glsingleview.cpp
75 75 // General 76 76 m_source_x(0.0f), 77 77 m_source_y(0.0f), 78 m_scaleMax( false),78 m_scaleMax(kScaleToFit), 79 79 80 80 // Texture variables (for display and effects) 81 81 m_texMaxDim(512), … … 96 96 m_effect_cube_yrot(0.0f), 97 97 m_effect_cube_zrot(0.0f) 98 98 { 99 m_scaleMax = ( gContext->GetNumSetting("GalleryScaleMax", 0) >0);99 m_scaleMax = (ScaleMax) gContext->GetNumSetting("GalleryScaleMax", 0); 100 100 101 101 m_slideshow_timer = new QTimer(this); 102 102 RegisterEffects(); … … 139 139 GLSingleView::~GLSingleView() 140 140 { 141 141 // save the current m_scaleMax setting so we can restore it later 142 gContext->SaveSetting("GalleryScaleMax", (m_scaleMax ? "1" : "0"));142 gContext->SaveSetting("GalleryScaleMax", m_scaleMax); 143 143 CleanUp(); 144 144 } 145 145 … … 457 457 } 458 458 else if (action == "FULLSCREEN") 459 459 { 460 m_scaleMax = !m_scaleMax;460 m_scaleMax = (ScaleMax) ((m_scaleMax + 1) % kScaleMaxCount); 461 461 m_source_x = 0; 462 462 m_source_y = 0; 463 463 SetZoom(1.0f); -
mythplugins/mythgallery/mythgallery/galleryutil.h
24 24 25 25 #include "iconview.h" 26 26 27 typedef enum { 28 kScaleToFit, 29 kScaleToFill, 30 kReduceToFit, 31 kScaleMaxCount // must be last 32 } ScaleMax; 33 27 34 class GalleryUtil 28 35 { 29 36 public: … … 41 48 int sortorder, bool recurse, 42 49 ThumbHash *itemHash, ThumbGenerator *thumbGen); 43 50 44 static QSize ScaleToDest(const QSize &sz, const QSize &dest, boolscaleMax);51 static QSize ScaleToDest(const QSize &sz, const QSize &dest, ScaleMax scaleMax); 45 52 46 53 static bool CopyMove(const QFileInfo &src, QFileInfo &dst, bool move) 47 54 { if (move) return Move(src, dst); else return Copy(src, dst); } -
mythplugins/mythgallery/mythgallery/glsingleview.h
107 107 // General 108 108 float m_source_x; 109 109 float m_source_y; 110 boolm_scaleMax;110 ScaleMax m_scaleMax; 111 111 112 112 // Texture variables (for display and effects) 113 113 int m_texMaxDim; -
mythplugins/mythgallery/mythgallery/singleview.cpp
61 61 m_pixmap(NULL), 62 62 m_angle(0), 63 63 m_source_loc(0,0), 64 m_scaleMax( false),64 m_scaleMax(kScaleToFit), 65 65 66 66 // Info variables 67 67 m_info_pixmap(NULL), … … 93 93 m_effect_milti_circle_out_points(4), 94 94 m_effect_circle_out_points(4) 95 95 { 96 m_scaleMax = ( gContext->GetNumSetting("GalleryScaleMax", 0) >0);96 m_scaleMax = (ScaleMax) gContext->GetNumSetting("GalleryScaleMax", 0); 97 97 98 98 m_slideshow_timer = new QTimer(this); 99 99 RegisterEffects(); … … 175 175 } 176 176 177 177 // save the current m_scaleMax setting so we can restore it later 178 gContext->SaveSetting("GalleryScaleMax", (m_scaleMax ? "1" : "0"));178 gContext->SaveSetting("GalleryScaleMax", m_scaleMax); 179 179 } 180 180 181 181 void SingleView::paintEvent(QPaintEvent *) … … 516 516 } 517 517 else if (action == "FULLSCREEN") 518 518 { 519 m_scaleMax = !m_scaleMax;519 m_scaleMax = (ScaleMax) ((m_scaleMax + 1) % kScaleMaxCount); 520 520 m_source_loc = QPoint(0, 0); 521 521 SetZoom(1.0f); 522 522 } -
mythplugins/mythgallery/mythgallery/singleview.h
36 36 // MythTV plugin headers 37 37 #include <mythtv/mythdialogs.h> 38 38 39 #include "galleryutil.h" 39 40 #include "imageview.h" 40 41 #include "iconview.h" 41 42 #include "sequence.h" … … 109 110 QImage m_image; 110 111 int m_angle; 111 112 QPoint m_source_loc; 112 boolm_scaleMax;113 ScaleMax m_scaleMax; 113 114 114 115 // Info variables 115 116 QPixmap *m_info_pixmap; -
mythplugins/mythgallery/mythgallery/gltexture.cpp
84 84 glEnd(); 85 85 } 86 86 87 void GLTexture::ScaleTo(const QSize &dest, boolscaleMax)87 void GLTexture::ScaleTo(const QSize &dest, ScaleMax scaleMax) 88 88 { 89 89 QSize sz = GalleryUtil::ScaleToDest(GetSize(), dest, scaleMax); 90 90 if ((sz.width() > 0) && (sz.height() > 0) && -
mythplugins/mythgallery/mythgallery/gltexture.h
27 27 #include <QtOpenGL> 28 28 #include <QSize> 29 29 30 // MythGallery headers 31 #include "galleryutil.h" 32 30 33 class ThumbItem; 31 34 32 35 class GLTexture … … 50 53 { width = sz.width(); height = sz.height(); } 51 54 void SetScale(float x, float y) 52 55 { cx = x; cy = y; } 53 void ScaleTo(const QSize &dest, boolscaleMax);56 void ScaleTo(const QSize &dest, ScaleMax scaleMax); 54 57 void SetAngle(int newangle) { angle = newangle; } 55 58 56 59 // Gets -
mythplugins/mythgallery/mythgallery/galleryutil.cpp
460 460 return false; 461 461 } 462 462 463 QSize GalleryUtil::ScaleToDest(const QSize &src, const QSize &dest, boolscaleMax)463 QSize GalleryUtil::ScaleToDest(const QSize &src, const QSize &dest, ScaleMax scaleMax) 464 464 { 465 465 QSize sz = src; 466 466 … … 472 472 if ((sz.width() > 0) && (sz.height() > 0)) 473 473 imageAspect = (double)sz.width() / (double)sz.height(); 474 474 475 int scaleWidth; 476 int scaleHeight; 477 if (scaleMax) 475 int scaleWidth = sz.width(); 476 int scaleHeight = sz.height(); 477 478 switch (scaleMax) 478 479 { 480 case kScaleToFill: 479 481 // scale-max to dest width for most images 480 482 scaleWidth = dest.width(); 481 483 scaleHeight = (int)((float)dest.width() * pixelAspect / imageAspect); … … 485 487 scaleWidth = (int)((float)dest.height() * imageAspect / pixelAspect); 486 488 scaleHeight = dest.height(); 487 489 } 488 } 489 else 490 { 490 break; 491 492 case kReduceToFit: 493 // Reduce to fit (but never enlarge) 494 if (scaleWidth <= dest.width() && scaleHeight <= dest.height()) 495 break; 496 // Fall through 497 498 case kScaleToFit: 491 499 // scale-min to dest height for most images 492 500 scaleWidth = (int)((float)dest.height() * imageAspect / pixelAspect); 493 501 scaleHeight = dest.height(); … … 497 505 scaleWidth = dest.width(); 498 506 scaleHeight = (int)((float)dest.width() * pixelAspect / imageAspect); 499 507 } 508 break; 509 510 default: 511 break; 500 512 } 501 513 502 sz.scale(scaleWidth, scaleHeight, Qt::KeepAspectRatio); 514 if (scaleWidth != sz.width() || scaleHeight != sz.height()) 515 sz.scale(scaleWidth, scaleHeight, Qt::KeepAspectRatio); 503 516 return sz; 504 517 } 505 518