author | simon <simon> | 2002-12-09 14:29:48 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 14:29:48 (UTC) |
commit | 3f88070b9be5209cdd88caa0afd7f7294d3b1764 (patch) (side-by-side diff) | |
tree | fe1c3c224e6d6930cef0756f4e23aded980d692f | |
parent | 8746877e7ed89fc4c227d5d79d63c35c69ceacd6 (diff) | |
download | opie-3f88070b9be5209cdd88caa0afd7f7294d3b1764.zip opie-3f88070b9be5209cdd88caa0afd7f7294d3b1764.tar.gz opie-3f88070b9be5209cdd88caa0afd7f7294d3b1764.tar.bz2 |
- merged the separate mask and pixmap arrays into the Button structure
and the buttons vector
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 9 |
2 files changed, 15 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 6e9c14a..87e06ee 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -95,54 +95,49 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency QString skinPath = "opieplayer2/skins/" + skin; pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); buttonMask.fill( 0 ); - masks.reserve( buttonCount ); - - for ( uint i = 0; i < masks.capacity(); i++ ) { + for ( uint i = 0; i < buttons.size(); i++ ) { QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); - masks.push_back( QBitmap( filename ) ); + buttons[ i ].mask =QBitmap( filename ); - if ( !masks[i].isNull() ) { - QImage imgMask = masks[i].convertToImage(); + if ( !buttons[i].mask.isNull() ) { + QImage imgMask = buttons[i].mask.convertToImage(); uchar **dest = buttonMask.jumpTable(); for ( int y = 0; y < imgUp.height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp.width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } - buttonPixUp.resize( masks.size(), QPixmap() ); - buttonPixDown.resize( masks.size(), QPixmap() ); - setBackgroundPixmap( pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); // songInfo.setForegroundColor(Qt::white); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( pixBg ); // Config cofg("qpe"); @@ -202,36 +197,36 @@ void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; QPoint p = upperLeftOfButtonMask; QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); - for ( uint i = 0; i < masks.size(); i++ ) { - if ( !masks[i].isNull() ) { - buttonPixUp[i] = maskPixToMask( pixUp, masks[i] ); - buttonPixDown[i] = maskPixToMask( pixDn, masks[i] ); + for ( uint i = 0; i < buttons.size(); i++ ) { + if ( !buttons[i].mask.isNull() ) { + buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); + buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); } } } void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider.width() == 0 ) return; long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); mediaPlayerState.setPosition( val ); } @@ -309,35 +304,35 @@ void AudioWidget::updateSlider( long i, long max ) { if ( slider.maxValue() != width ) { slider.setMaxValue( width ); } } } void AudioWidget::setToggleButton( int i, bool down ) { qDebug("setToggleButton %d", i); if ( down != buttons[i].isDown ) { toggleButton( i ); } } void AudioWidget::paintButton( QPainter &p, int i ) { if ( buttons[i].isDown ) { - p.drawPixmap( upperLeftOfButtonMask, buttonPixDown[i] ); + p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixDown ); } else { - p.drawPixmap( upperLeftOfButtonMask, buttonPixUp[i] ); + p.drawPixmap( upperLeftOfButtonMask, buttons[i].pixUp ); } } void AudioWidget::skipFor() { skipDirection = +1; startTimer( 50 ); mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); } void AudioWidget::skipBack() { skipDirection = -1; startTimer( 50 ); mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); } diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 2641df6..504b705 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -11,52 +11,57 @@ This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MEDIAWIDGET_H #define MEDIAWIDGET_H #include <qwidget.h> +#include <qmap.h> #include "mediaplayerstate.h" #include "playlistwidget.h" #include <vector> class MediaWidget : public QWidget { Q_OBJECT public: enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; enum ButtonType { NormalButton, ToggleButton }; struct Button { Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} ButtonType type : 1; bool isHeld : 1; bool isDown : 1; + + QBitmap mask; + QPixmap pixUp; + QPixmap pixDown; }; typedef std::vector<Button> ButtonVector; struct SkinButtonInfo { Command command; const char *fileName; ButtonType type; }; typedef std::vector<QBitmap> MaskVector; typedef std::vector<QPixmap> PixmapVector; MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); virtual ~MediaWidget(); @@ -77,26 +82,22 @@ protected: void handleCommand( Command command, bool buttonDown ); bool isOverButton( const QPoint &position, int buttonId ) const; void paintButton( int buttonId ); virtual void paintButton( QPainter &p, int i ) = 0; void toggleButton( int buttonId ); MediaPlayerState &mediaPlayerState; PlayListWidget &playList; ButtonVector buttons; QImage buttonMask; - MaskVector masks; - PixmapVector buttonPixUp; - PixmapVector buttonPixDown; - QPoint upperLeftOfButtonMask; }; #endif // MEDIAWIDGET_H /* vim: et sw=4 ts=4 */ |