Index: mythgallery/glsingleview.cpp =================================================================== --- mythgallery/glsingleview.cpp (revision 10014) +++ mythgallery/glsingleview.cpp (working copy) @@ -25,12 +25,14 @@ using namespace std; #include +#include #include #include #include #include #include #include +#include #include #include @@ -131,7 +133,7 @@ QString transType = gContext->GetSetting("SlideshowOpenGLTransition"); if (!transType.isEmpty() && m_effectMap.contains(transType)) m_effectMethod = m_effectMap[transType]; - + m_transTimeout = gContext->GetNumSetting("SlideshowOpenGLTransitionLength", 0); if (!m_effectMethod || transType == QString("random (gl)")) { m_effectMethod = getRandomEffect(); @@ -156,6 +158,7 @@ // --------------------------------------------------------------- m_timer = new QTimer(this); + m_time = new QTime(); connect(m_timer, SIGNAL(timeout()), SLOT(slotTimeOut())); @@ -217,6 +220,7 @@ m_timer->stop(); delete m_timer; + delete m_time; if (m_texItem[0].tex) glDeleteTextures(1, &m_texItem[0].tex); @@ -294,9 +298,7 @@ (this->*m_effectMethod)(); } else - { paintTexture(); - } if (glGetError()) VERBOSE(VB_GENERAL, LOC_ERR + "OpenGL error detected"); @@ -780,7 +782,7 @@ void GLSingleView::effectBlend(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0*m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -790,6 +792,7 @@ int a = (m_curr == 0) ? 1 : 0; int b = m_curr; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); TexItem& ta = m_texItem[a]; TexItem& tb = m_texItem[b]; @@ -819,7 +822,7 @@ glBegin(GL_QUADS); { - glColor4f(0.0f, 0.0f, 0.0f, 1.0f / (100.0f) * (float)m_i); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f * t); glVertex3f(-1.0f, -1.0f, 0.0f); glVertex3f(+1.0f, -1.0f, 0.0f); glVertex3f(+1.0f, +1.0f, 0.0f); @@ -835,7 +838,7 @@ glBegin(GL_QUADS); { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f / (100.0f) * (float)m_i); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f * t); glTexCoord2f(0.0f, 0.0f); glVertex3f(-tb.cx, -tb.cy, 0.0f); @@ -855,14 +858,13 @@ void GLSingleView::effectZoomBlend(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; m_tmout = -1; return; } - int a = (m_curr == 0) ? 1 : 0; int b = m_curr; float zf = 0.75f; @@ -873,7 +875,7 @@ glMatrixMode(GL_TEXTURE); glLoadIdentity(); glRotatef(ta.angle, 0.0f, 0.0f, 1.0f); - float t = 1.0f / (100.00f) * (float)m_i; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); glBindTexture(GL_TEXTURE_2D, ta.tex); glBegin(GL_QUADS); @@ -901,7 +903,7 @@ glBegin(GL_QUADS); { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f / (100.0f) * (float) m_i); + glColor4f(1.0f, 1.0f, 1.0f, 0.0f + t); glTexCoord2f(0.0f, 0.0f); glVertex3f(-tb.cx, -tb.cy, 0.0f); @@ -921,7 +923,7 @@ void GLSingleView::effectRotate(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -934,6 +936,7 @@ int a = (m_curr == 0) ? 1 : 0; int b = m_curr; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); TexItem& ta = m_texItem[a]; TexItem& tb = m_texItem[b]; @@ -962,10 +965,10 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - float rotate = 360.0f/100.0f*(float)m_i; + float rotate = 360.0f * t; glRotatef(((m_dir == 0) ? -1 : 1) * rotate, 0.0f, 0.0f, 1.0f); - float scale = 1.0f/100.0f*(100.0f-(float)(m_i)); + float scale = 1.0f * (1.0f - t); glScalef(scale, scale, 1.0f); glMatrixMode(GL_TEXTURE); @@ -996,7 +999,7 @@ void GLSingleView::effectBend(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1009,6 +1012,7 @@ int a = (m_curr == 0) ? 1 : 0; int b = m_curr; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); TexItem& ta = m_texItem[a]; TexItem& tb = m_texItem[b]; @@ -1037,7 +1041,7 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glRotatef(90.0f/100.0f*(float)m_i, + glRotatef(90.0f * t, (m_dir == 0) ? 1.0f : 0.0f, (m_dir == 1) ? 1.0f : 0.0f, 0.0f); @@ -1069,7 +1073,7 @@ void GLSingleView::effectFade(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1079,13 +1083,15 @@ int a; float opacity; - if (m_i <= 50) + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); + + if (m_time->elapsed() < 1000.0f * m_transTimeout * 0.5f) { a = (m_curr == 0) ? 1 : 0; - opacity = 1.0f - 1.0f/50.0f*(float)(m_i); + opacity = 1.0f - (2.0f * t); } else { - opacity = 1.0f/50.0f*(float)(m_i-50.0f); + opacity = 2.0f * (t - 0.5); a = m_curr; } @@ -1120,7 +1126,7 @@ void GLSingleView::effectInOut(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1135,7 +1141,8 @@ int a; bool out; - if (m_i <= 50) + float tt = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); + if (m_time->elapsed() <= 1000.0f * m_transTimeout * 0.5f) { a = (m_curr == 0) ? 1 : 0; out = 1; @@ -1151,8 +1158,8 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); float t = (out) ? - 1.0f / 50.0f * (50.0f - m_i) : - 1.0f / 50.0f * (m_i - 50.0f); + 1.0f / 0.5f * (0.5f - tt) : + 1.0f / 0.5f * (tt - 0.5f); glScalef(t, t, 1.0f); t = 1.0f - t; @@ -1190,7 +1197,7 @@ void GLSingleView::effectSlide(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1203,6 +1210,7 @@ int a = (m_curr == 0) ? 1 : 0; int b = m_curr; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); TexItem& ta = m_texItem[a]; TexItem& tb = m_texItem[b]; @@ -1231,7 +1239,7 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - float trans = 2.0f/100.0f*(float)m_i; + float trans = 2.0f * t; glTranslatef((m_dir % 2 == 0) ? ((m_dir == 2)? 1 : -1) * trans : 0.0f, (m_dir % 2 == 1) ? ((m_dir == 1)? 1 : -1) * trans : 0.0f, 0.0f); @@ -1265,7 +1273,7 @@ void GLSingleView::effectFlutter(void) { - if (m_i > 100) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1275,6 +1283,7 @@ int a = (m_curr == 0) ? 1 : 0; int b = m_curr; + float t = 1.0f * (float)m_time->elapsed() / (1000.0f * m_transTimeout); TexItem& ta = m_texItem[a]; TexItem& tb = m_texItem[b]; @@ -1318,11 +1327,11 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - float rotate = 60.0f/100.0f*(float)m_i; + float rotate = 60.0f*t; glRotatef(rotate, 1.0f, 0.0f, 0.0f); - float scale = 1.0f/100.0f*(100.0f-(float)m_i); + float scale = 1.0f*(1-t); glScalef(scale, scale, scale); - glTranslatef(1.0f/100.0f*(float)m_i, 1.0f/100.0f*(float)m_i, 0.0f); + glTranslatef(1.0f*t, 1.0f*t, 0.0f); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -1386,10 +1395,10 @@ void GLSingleView::effectCube(void) { - int tot = 200; - int rotStart = 50; + float tot = 1000.0f * m_transTimeout; + float rotStart = 250.0f * m_transTimeout; - if (m_i > tot) + if (m_time->elapsed() > 1000.0f * m_transTimeout) { paintTexture(); m_effectRunning = false; @@ -1435,7 +1444,7 @@ glLoadIdentity(); float trans = 5.0f * - (float) ((m_i <= tot / 2) ? m_i : tot - m_i) / (float)tot; + (float) (((float)m_time->elapsed() <= tot / 2) ? (float)m_time->elapsed() : tot - (float)m_time->elapsed()) / (float)tot; glTranslatef(0.0f, 0.0f, -znear - 1.0f - trans); @@ -1547,10 +1556,10 @@ } glEnd(); - if (m_i >= rotStart && m_i < (tot-rotStart)) + if ((float)m_time->elapsed() >= rotStart && (float)m_time->elapsed() < (tot-rotStart)) { - xrot += 360.0f / (float)(tot - 2 * rotStart); - yrot += 180.0f / (float)(tot - 2 * rotStart); + xrot = 360.0f * ((float)m_time->elapsed() - ( rotStart))/(tot - 2 * rotStart); + yrot = 180.0f * ((float)m_time->elapsed() - ( rotStart))/(tot - 2 * rotStart); } m_i++; @@ -1602,7 +1611,9 @@ m_tmout = 10; m_effectRunning = true; m_i = 0; + m_disp = 0; } + m_time->restart(); } } Index: mythgallery/glsingleview.h =================================================================== --- mythgallery/glsingleview.h (revision 10014) +++ mythgallery/glsingleview.h (working copy) @@ -30,6 +30,7 @@ class QImage; class QTimer; +class QTime; class GLSingleView; @@ -94,12 +95,14 @@ float m_sx, m_sy; QTimer *m_timer; + QTime *m_time; int m_tmout; int m_delay; + float m_transTimeout; bool m_effectRunning; bool m_running; int m_slideShow; - + int m_disp; GLuint m_texInfo; bool m_showInfo; int m_maxTexDim; Index: mythgallery/gallerysettings.cpp =================================================================== --- mythgallery/gallerysettings.cpp (revision 10014) +++ mythgallery/gallerysettings.cpp (working copy) @@ -92,6 +92,17 @@ return gc; }; +static HostSpinBox *SlideshowOpenGLTransitionLength() +{ + HostSpinBox *gc = new HostSpinBox("SlideshowOpenGLTransitionLength", 1, 10, 1); + gc->setLabel(QObject::tr("Durration of OpenGL Transition (seconds)")); + gc->setValue(2); + gc->setHelpText(QObject::tr("This is the durration of the OpenGL transition " + "selected above, in seconds.")); + return gc; +}; + + #endif /* OPENGL_SUPPORT */ static HostComboBox *SlideshowTransition() @@ -129,7 +140,6 @@ "picture in single view mode.")); return gc; }; - static HostSpinBox *SlideshowDelay() { HostSpinBox *gc = new HostSpinBox("SlideshowDelay", 1, 600, 1); @@ -172,6 +182,7 @@ ConfigurationGroup* openGLConfig = new VerticalConfigurationGroup(false); openGLConfig->addChild(SlideshowOpenGLTransition()); + openGLConfig->addChild(SlideshowOpenGLTransitionLength()); addTarget("1", openGLConfig); ConfigurationGroup* regularConfig = new VerticalConfigurationGroup(false);