Commit 61eaf43b authored by Enrico Ros's avatar Enrico Ros

Implemented all missing PDF 1.4 transitions. Added: blinds(2), box(2),

wipe(4), dissolve(1), glitter(4). Between parenthesis the number of
variants. Try it on (Tobias Koenig's testcase):
http://robotics.dei.unipd.it/~koral/KDE/transition_test.pdf
Fixuifiles script on configuration dialogs, icons in Performance Dialog,
fixed spacing on dialogs to look the same way.

svn path=/trunk/kdegraphics/kpdf/; revision=376348
parent 6e13b885
......@@ -8,13 +8,10 @@
<rect>
<x>0</x>
<y>0</y>
<width>289</width>
<height>169</height>
<width>320</width>
<height>143</height>
</rect>
</property>
<property name="caption">
<string>DlgGeneral</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
......
......@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>252</width>
<height>218</height>
<width>284</width>
<height>222</height>
</rect>
</property>
<vbox>
......@@ -34,35 +34,11 @@
<property name="title">
<string>Memory Usage</string>
</property>
<vbox>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QRadioButton">
<property name="name">
<cstring>lowRadio</cstring>
</property>
<property name="text">
<string>&amp;Low</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>normalRadio</cstring>
</property>
<property name="text">
<string>&amp;Normal (default)</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>aggressiveRadio</cstring>
</property>
<property name="text">
<string>&amp;Aggressive</string>
</property>
</widget>
<widget class="QLabel">
<widget class="QLabel" row="1" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>descLabel</cstring>
</property>
......@@ -76,7 +52,84 @@
<set>WordBreak|AlignVCenter</set>
</property>
</widget>
</vbox>
<widget class="QLayoutWidget" row="0" column="0">
<property name="name">
<cstring>layout5</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QRadioButton">
<property name="name">
<cstring>lowRadio</cstring>
</property>
<property name="text">
<string>&amp;Low</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>normalRadio</cstring>
</property>
<property name="text">
<string>&amp;Normal (default)</string>
</property>
</widget>
<widget class="QRadioButton">
<property name="name">
<cstring>aggressiveRadio</cstring>
</property>
<property name="text">
<string>&amp;Aggressive</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget" row="0" column="1">
<property name="name">
<cstring>layout6</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>pixmapLabel1</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap>"kcmmemory", 32</pixmap>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer7</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>21</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</grid>
</widget>
<widget class="QGroupBox">
<property name="name">
......@@ -93,27 +146,80 @@
<property name="title">
<string>CPU Usage</string>
</property>
<vbox>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<widget class="QLayoutWidget">
<property name="name">
<cstring>kcfg_DisableCompositing</cstring>
</property>
<property name="text">
<string>Disable &amp;transparency effects</string>
<cstring>layout9</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_DisableCompositing</cstring>
</property>
<property name="text">
<string>Disable &amp;transparency effects</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>kcfg_DisableThreading</cstring>
</property>
<property name="text">
<string>Disable &amp;asyncronous generation</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QCheckBox">
<widget class="QLayoutWidget">
<property name="name">
<cstring>kcfg_DisableThreading</cstring>
</property>
<property name="text">
<string>Disable &amp;asyncronous generation</string>
<cstring>layout6_2</cstring>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel">
<property name="name">
<cstring>pixmapLabel1_2</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap>"kcmprocessor", 32</pixmap>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer7_2</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Minimum</enum>
</property>
<property name="sizeHint">
<size>
<width>21</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
</vbox>
</hbox>
</widget>
<spacer>
<property name="name">
......@@ -128,7 +234,7 @@
<property name="sizeHint">
<size>
<width>21</width>
<height>20</height>
<height>16</height>
</size>
</property>
</spacer>
......@@ -156,6 +262,7 @@
</connections>
<includes>
<include location="global" impldecl="in implementation">kdialog.h</include>
<include location="global" impldecl="in implementation">kiconloader.h</include>
<include location="local" impldecl="in implementation">dlgperformance.ui.h</include>
</includes>
<slots>
......@@ -166,5 +273,6 @@
<functions>
<function access="private">init()</function>
</functions>
<pixmapfunction>DesktopIcon</pixmapfunction>
<layoutdefaults spacing="6" margin="11"/>
</UI>
......@@ -8,17 +8,17 @@
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>298</height>
<width>294</width>
<height>261</height>
</rect>
</property>
<property name="caption">
<string>DlgPresentation</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
......@@ -207,9 +207,6 @@
<property name="text">
<string>Show s&amp;ummary page</string>
</property>
<property name="accel">
<string>Alt+U</string>
</property>
</widget>
<widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="2">
<property name="name">
......@@ -218,16 +215,28 @@
<property name="text">
<string>Show &amp;progress indicator</string>
</property>
<property name="accel">
<string>Alt+P</string>
</property>
</widget>
</grid>
</widget>
<spacer>
<property name="name">
<cstring>bspace</cstring>
</property>
<property name="orientation">
<enum>Vertical</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>1</height>
</size>
</property>
</spacer>
</vbox>
</widget>
<customwidgets>
</customwidgets>
<connections>
<connection>
<sender>kcfg_SlidesAdvance</sender>
......
......@@ -59,10 +59,10 @@ class KPDFPageTransition
// Get direction in which the transition effect moves.
inline int angle() const { return m_angle; }
// Get starting or ending scale.
// Get starting or ending scale. (Fly only)
inline double scale() const { return m_scale; }
// Returns true if the area to be flown is rectangular and opaque.
// Returns true if the area to be flown is rectangular and opaque. (Fly only)
inline bool isRectangular() const { return m_rectangular; }
inline void setType( Type type ) { m_type = type; }
......
......@@ -253,6 +253,8 @@ void PresentationWidget::paintEvent( QPaintEvent * pe )
for ( uint i = 0; i < numRects; i++ )
{
const QRect & r = allRects[i];
if ( !r.isValid() )
continue;
#ifdef ENABLE_PROGRESS_OVERLAY
if ( Settings::slidesShowProgress() && r.intersects( m_overlayGeometry ) )
{
......@@ -560,7 +562,12 @@ void PresentationWidget::slotHideOverlay()
void PresentationWidget::slotTransitionStep()
{
if ( m_transitionRects.empty() )
{
// it's better to fix the transition to cover the whole screen than
// enabling the following line that wastes cpu for nothing
//update();
return;
}
for ( int i = 0; i < m_transitionMul && !m_transitionRects.empty(); i++ )
{
......@@ -617,40 +624,233 @@ const KPDFPageTransition PresentationWidget::defaultTransition() const
/** ONLY the TRANSITIONS GENERATION function from here on **/
void PresentationWidget::initTransition( const KPDFPageTransition *transition )
{
// if it's just a 'replace' transition, repaint the screen
if ( transition->type() == KPDFPageTransition::Replace )
{
update();
return;
}
const bool isInward = transition->direction() == KPDFPageTransition::Inward;
const bool isHorizontal = transition->alignment() == KPDFPageTransition::Horizontal;
const float totalTime = transition->duration();
m_transitionRects.clear();
const int gridXstep = 50;
const int gridYstep = 38;
switch( transition->type() )
{
// TODO: implement missing transitions
case KPDFPageTransition::Replace:
update();
return;
// split: horizontal / vertical and inward / outward
case KPDFPageTransition::Split:
update();
return;
{
const int steps = isHorizontal ? 100 : 75;
if ( isHorizontal )
{
if ( isInward )
{
int xPosition = 0;
for ( int i = 0; i < steps; i++ )
{
int xNext = ((i + 1) * m_width) / (2 * steps);
m_transitionRects.push_back( QRect( xPosition, 0, xNext - xPosition, m_height ) );
m_transitionRects.push_back( QRect( m_width - xNext, 0, xNext - xPosition, m_height ) );
xPosition = xNext;
}
}
else
{
int xPosition = m_width / 2;
for ( int i = 0; i < steps; i++ )
{
int xNext = ((steps - (i + 1)) * m_width) / (2 * steps);
m_transitionRects.push_back( QRect( xNext, 0, xPosition - xNext, m_height ) );
m_transitionRects.push_back( QRect( m_width - xPosition, 0, xPosition - xNext, m_height ) );
xPosition = xNext;
}
}
}
else
{
if ( isInward )
{
int yPosition = 0;
for ( int i = 0; i < steps; i++ )
{
int yNext = ((i + 1) * m_height) / (2 * steps);
m_transitionRects.push_back( QRect( 0, yPosition, m_width, yNext - yPosition ) );
m_transitionRects.push_back( QRect( 0, m_height - yNext, m_width, yNext - yPosition ) );
yPosition = yNext;
}
}
else
{
int yPosition = m_height / 2;
for ( int i = 0; i < steps; i++ )
{
int yNext = ((steps - (i + 1)) * m_height) / (2 * steps);
m_transitionRects.push_back( QRect( 0, yNext, m_width, yPosition - yNext ) );
m_transitionRects.push_back( QRect( 0, m_height - yPosition, m_width, yPosition - yNext ) );
yPosition = yNext;
}
}
}
m_transitionMul = 2;
m_transitionDelay = (int)( (totalTime * 1000) / steps );
} break;
// blinds: horizontal(l-to-r) / vertical(t-to-b)
case KPDFPageTransition::Blinds:
update();
return;
{
const int blinds = isHorizontal ? 8 : 6;
const int steps = m_width / (4 * blinds);
if ( isHorizontal )
{
int xPosition[ blinds ];
for ( int b = 0; b < blinds; b++ )
xPosition[ b ] = (b * m_width) / blinds;
for ( int i = 0; i < steps; i++ )
{
int stepOffset = (int)( ((float)i * (float)m_width) / ((float)blinds * (float)steps) );
for ( int b = 0; b < blinds; b++ )
{
m_transitionRects.push_back( QRect( xPosition[ b ], 0, stepOffset, m_height ) );
xPosition[ b ] = stepOffset + (b * m_width) / blinds;
}
}
}
else
{
int yPosition[ blinds ];
for ( int b = 0; b < blinds; b++ )
yPosition[ b ] = (b * m_height) / blinds;
for ( int i = 0; i < steps; i++ )
{
int stepOffset = (int)( ((float)i * (float)m_height) / ((float)blinds * (float)steps) );
for ( int b = 0; b < blinds; b++ )
{
m_transitionRects.push_back( QRect( 0, yPosition[ b ], m_width, stepOffset ) );
yPosition[ b ] = stepOffset + (b * m_height) / blinds;
}
}
}
m_transitionMul = blinds;
m_transitionDelay = (int)( (totalTime * 1000) / steps );
} break;
// box: inward / outward
case KPDFPageTransition::Box:
update();
return;
{
const int steps = m_width / 10;
if ( isInward )
{
int L = 0, T = 0, R = m_width, B = m_height;
for ( int i = 0; i < steps; i++ )
{
// compure shrinked box coords
int newL = ((i + 1) * m_width) / (2 * steps);
int newT = ((i + 1) * m_height) / (2 * steps);
int newR = m_width - newL;
int newB = m_height - newT;
// add left, right, topcenter, bottomcenter rects
m_transitionRects.push_back( QRect( L, T, newL - L, B - T ) );
m_transitionRects.push_back( QRect( newR, T, R - newR, B - T ) );
m_transitionRects.push_back( QRect( newL, T, newR - newL, newT - T ) );
m_transitionRects.push_back( QRect( newL, newB, newR - newL, B - newB ) );
L = newL; T = newT; R = newR, B = newB;
}
}
else
{
int L = m_width / 2, T = m_height / 2, R = L, B = T;
for ( int i = 0; i < steps; i++ )
{
// compure shrinked box coords
int newL = ((steps - (i + 1)) * m_width) / (2 * steps);
int newT = ((steps - (i + 1)) * m_height) / (2 * steps);
int newR = m_width - newL;
int newB = m_height - newT;
// add left, right, topcenter, bottomcenter rects
m_transitionRects.push_back( QRect( newL, newT, L - newL, newB - newT ) );
m_transitionRects.push_back( QRect( R, newT, newR - R, newB - newT ) );
m_transitionRects.push_back( QRect( L, newT, R - L, T - newT ) );
m_transitionRects.push_back( QRect( L, B, R - L, newB - B ) );
L = newL; T = newT; R = newR, B = newB;
}
}
m_transitionMul = 4;
m_transitionDelay = (int)( (totalTime * 1000) / steps );
} break;
// wipe: implemented for 4 canonical angles
case KPDFPageTransition::Wipe:
update();
return;
{
const int angle = transition->angle();
const int steps = (angle == 0) || (angle == 180) ? m_width / 8 : m_height / 8;
if ( angle == 0 )
{
int xPosition = 0;
for ( int i = 0; i < steps; i++ )
{
int xNext = ((i + 1) * m_width) / steps;
m_transitionRects.push_back( QRect( xPosition, 0, xNext - xPosition, m_height ) );
xPosition = xNext;
}
}
else if ( angle == 90 )
{
int yPosition = m_height;
for ( int i = 0; i < steps; i++ )
{
int yNext = ((steps - (i + 1)) * m_height) / steps;
m_transitionRects.push_back( QRect( 0, yNext, m_width, yPosition - yNext ) );
yPosition = yNext;
}
}
else if ( angle == 180 )
{
int xPosition = m_width;
for ( int i = 0; i < steps; i++ )
{
int xNext = ((steps - (i + 1)) * m_width) / steps;
m_transitionRects.push_back( QRect( xNext, 0, xPosition - xNext, m_height ) );
xPosition = xNext;
}
}
else if ( angle == 270 )
{
int yPosition = 0;
for ( int i = 0; i < steps; i++ )
{
int yNext = ((i + 1) * m_height) / steps;
m_transitionRects.push_back( QRect( 0, yPosition, m_width, yNext - yPosition ) );
yPosition = yNext;
}
}
else
{
update();
return;
}
m_transitionMul = 1;
m_transitionDelay = (int)( (totalTime * 1000) / steps );
} break;
// dissolve: replace 'random' rects
case KPDFPageTransition::Dissolve:
update();
return;
case KPDFPageTransition::Glitter: {
int oldX = 0,
oldY = 0;
{
const int gridXsteps = 50;
const int gridYsteps = 38;
const int steps = gridXsteps * gridYsteps;
int oldX = 0;
int oldY = 0;
// create a grid of gridXstep by gridYstep QRects
for ( int y = 0; y < gridYstep; y++ )
for ( int y = 0; y < gridYsteps; y++ )
{
int newY = (int)( m_height * ((float)(y+1) / (float)gridYstep) );
for ( int x = 0; x < gridXstep; x++