summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp24
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp36
-rw-r--r--noncore/multimedia/opieplayer2/skin.h7
4 files changed, 41 insertions, 27 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 4de7ea9..da0706e 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -47,6 +47,5 @@ void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount
const Skin &skin, const QSize &buttonAreaSize )
{
- buttonMask = QImage( buttonAreaSize, 8, 255 );
- buttonMask.fill( 0 );
+ buttonMask = skin.buttonMask( skinInfo, buttonCount, buttonAreaSize );
buttons.clear();
@@ -64,28 +63,9 @@ MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo,
button.command = buttonInfo.command;
button.type = buttonInfo.type;
-
- button.mask = setupButtonMask( button.command, skin.buttonMaskImage( buttonInfo.fileName ) );
+ button.mask = skin.buttonMaskImage( buttonInfo.fileName );
return button;
}
-QBitmap MediaWidget::setupButtonMask( const Command &command, const QImage &maskImage )
-{
- if ( maskImage.isNull() )
- return QBitmap();
-
- uchar **dest = buttonMask.jumpTable();
- for ( int y = 0; y < buttonMask.height(); y++ ) {
- uchar *line = dest[y];
- for ( int x = 0; x < buttonMask.width(); x++ )
- if ( !qRed( maskImage.pixel( x, y ) ) )
- line[x] = command + 1;
- }
-
- // ### grmbl qt2. use constructor when switching to qt3.
- QBitmap bm; bm = maskImage;
- return bm;
-}
-
void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix )
{
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 0d635aa..4bd8760 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -105,5 +105,4 @@ protected:
const Skin &skin, const QSize &buttonAreaSize );
Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
- QBitmap setupButtonMask( const Command &command, const QImage &maskImage );
void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null );
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index 7d05d80..ef70957 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -10,11 +10,10 @@ Skin::Skin( const QString &name, const QString &fileNameInfix )
}
-void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount )
+void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize )
{
backgroundImage();
buttonUpImage();
buttonDownImage();
- for ( uint i = 0; i < buttonCount; ++i )
- ( void )buttonMaskImage( skinButtonInfo[ i ].fileName );
+ ( void )buttonMask( skinButtonInfo, buttonCount, buttonAreaSize );
}
@@ -40,4 +39,35 @@ QImage Skin::buttonDownImage() const
}
+QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize ) const
+{
+ if ( buttonAreaSize != m_buttonMask.size() )
+ m_buttonMask = QImage();
+
+ if ( !m_buttonMask.isNull() )
+ return m_buttonMask;
+
+ m_buttonMask = QImage( buttonAreaSize, 8, 255 );
+ m_buttonMask.fill( 0 );
+
+ for ( uint i = 0; i < buttonCount; ++i )
+ addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) );
+
+ return m_buttonMask;
+}
+
+void Skin::addButtonToMask( int tag, const QImage &maskImage ) const
+{
+ if ( maskImage.isNull() )
+ return;
+
+ uchar **dest = m_buttonMask.jumpTable();
+ for ( int y = 0; y < m_buttonMask.height(); y++ ) {
+ uchar *line = dest[y];
+ for ( int x = 0; x < m_buttonMask.width(); x++ )
+ if ( !qRed( maskImage.pixel( x, y ) ) )
+ line[x] = tag;
+ }
+}
+
QImage Skin::buttonMaskImage( const QString &fileName ) const
{
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index 9276a5b..14873e7 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -13,5 +13,5 @@ public:
Skin( const QString &name, const QString &fileNameInfix );
- void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
+ void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize );
QImage backgroundImage() const;
@@ -19,7 +19,11 @@ public:
QImage buttonDownImage() const;
+ QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount, const QSize &buttonAreaSize ) const;
+
QImage buttonMaskImage( const QString &fileName ) const;
private:
+ void addButtonToMask( int tag, const QImage &maskImage ) const;
+
QString m_name;
QString m_fileNameInfix;
@@ -31,4 +35,5 @@ private:
mutable QImage m_buttonUpImage;
mutable QImage m_buttonDownImage;
+ mutable QImage m_buttonMask;
mutable ButtonMaskImageMap m_buttonMasks;