summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediawidget.cpp
authorsimon <simon>2002-12-14 17:30:26 (UTC)
committer simon <simon>2002-12-14 17:30:26 (UTC)
commita3b9d0a1e6ee4f1e74ac3335cb2ba67f6da30476 (patch) (side-by-side diff)
treedde78606067af08f0e3ac8f6ccabff2661b99d08 /noncore/multimedia/opieplayer2/mediawidget.cpp
parentbbdeff25bd0cc5ff59d52fd8bf25cdfbeac8f251 (diff)
downloadopie-a3b9d0a1e6ee4f1e74ac3335cb2ba67f6da30476.zip
opie-a3b9d0a1e6ee4f1e74ac3335cb2ba67f6da30476.tar.gz
opie-a3b9d0a1e6ee4f1e74ac3335cb2ba67f6da30476.tar.bz2
- kill the flickery when painting. backgroundmode is now always
NoBackground and we do full double-buffering in the paintEvent
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 702e6d7..f7a22a3 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -12,48 +12,50 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "mediawidget.h"
#include "playlistwidget.h"
#include "skin.h"
MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
: QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
{
connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
this, SLOT( setLength( long ) ) );
connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
this, SLOT( setPlaying( bool ) ) );
+
+ setBackgroundMode( NoBackground );
}
MediaWidget::~MediaWidget()
{
}
void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
const Skin &skin )
{
buttonMask = skin.buttonMask( skinInfo, buttonCount );
buttons.clear();
buttons.reserve( buttonCount );
for ( uint i = 0; i < buttonCount; ++i ) {
Button button = setupButton( skinInfo[ i ], skin );
buttons.push_back( button );
}
}
MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
{
Button button;
button.command = buttonInfo.command;
@@ -72,61 +74,53 @@ void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
{
backgroundPixmap = skin.backgroundImage();
buttonUpImage = skin.buttonUpImage();
buttonDownImage = skin.buttonDownImage();
setupButtons( skinInfo, buttonCount, skin );
}
void MediaWidget::closeEvent( QCloseEvent * )
{
mediaPlayerState.setList();
}
void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
return;
}
- if ( !pe->erased() ) {
- // Combine with background and double buffer
- QPixmap pix( pe->rect().size() );
- QPainter p( &pix );
- p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
- p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
- paintAllButtons( p );
- QPainter p2( this );
- p2.drawPixmap( pe->rect().topLeft(), pix );
- } else {
- QPainter p( this );
- paintAllButtons( p );
- }
+ QPixmap buffer( size() );
+ QPainter bufferedPainter( &buffer );
+ bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) );
+ paintAllButtons( bufferedPainter );
+ p.drawPixmap( 0, 0, buffer );
}
void MediaWidget::resizeEvent( QResizeEvent *e )
{
QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
Button &button = *it;
if ( button.mask.isNull() )
continue;
button.pixUp = addMaskToPixmap( pixUp, button.mask );
button.pixDown = addMaskToPixmap( pixDn, button.mask );
}
QWidget::resizeEvent( e );
}
MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
{
if ( position.x() <= 0 || position.y() <= 0 ||
position.x() >= buttonMask.width() ||
position.y() >= buttonMask.height() )