diff --git a/data/themes/default/fx_active.png b/data/themes/default/fx_active.png index b9cbd6485..80680b092 100644 Binary files a/data/themes/default/fx_active.png and b/data/themes/default/fx_active.png differ diff --git a/data/themes/default/fx_inactive.png b/data/themes/default/fx_inactive.png index 901f730ad..3f8754196 100644 Binary files a/data/themes/default/fx_inactive.png and b/data/themes/default/fx_inactive.png differ diff --git a/data/themes/default/midi_active.png b/data/themes/default/midi_active.png index f7ea1e830..a1333d080 100644 Binary files a/data/themes/default/midi_active.png and b/data/themes/default/midi_active.png differ diff --git a/data/themes/default/midi_inactive.png b/data/themes/default/midi_inactive.png index 2bafb3217..94b89d7fb 100644 Binary files a/data/themes/default/midi_inactive.png and b/data/themes/default/midi_inactive.png differ diff --git a/data/themes/default/miscellaneous_active.png b/data/themes/default/miscellaneous_active.png index e0823df29..e9c5fb576 100644 Binary files a/data/themes/default/miscellaneous_active.png and b/data/themes/default/miscellaneous_active.png differ diff --git a/data/themes/default/miscellaneous_inactive.png b/data/themes/default/miscellaneous_inactive.png index af5052159..e02105331 100644 Binary files a/data/themes/default/miscellaneous_inactive.png and b/data/themes/default/miscellaneous_inactive.png differ diff --git a/include/TabWidget.h b/include/TabWidget.h index f7d76a437..c8a9365fc 100644 --- a/include/TabWidget.h +++ b/include/TabWidget.h @@ -29,16 +29,14 @@ #include #include -#include - class TabWidget : public QWidget { Q_OBJECT public: - TabWidget( const QString & _caption, QWidget * _parent ); + TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false ); virtual ~TabWidget(); - void addTab( QWidget * _w, const QString & _name, const char * pixmapName, int _idx = -1 ); + void addTab( QWidget *_w, const QString &_name, const char *activePixmap = NULL, const char *inactivePixmap = NULL, int _idx = -1 ); void setActiveTab( int _idx ); @@ -58,17 +56,20 @@ protected: private: struct widgetDesc { - QWidget * w; // ptr to widget - const char *pixmapName; // artwork for the widget - QString name; // name for widget - int nwidth; // width of name when painting + QWidget * w; // ptr to widget + const char *activePixmap; // artwork for the widget + const char *inactivePixmap; // artwork for the widget + QString name; // name for widget + int nwidth; // width of name when painting (only valid for text tab) } ; typedef QMap widgetStack; widgetStack m_widgets; - int m_activeTab; + + int m_activeTab; QString m_caption; - quint8 m_tabheight; + quint8 m_tabheight; + bool m_usePixmap; // true if the tabs are to be displayed with icons. False for text tabs. } ; #endif diff --git a/src/gui/widgets/TabWidget.cpp b/src/gui/widgets/TabWidget.cpp index 9eaed1a7d..cb41f771e 100644 --- a/src/gui/widgets/TabWidget.cpp +++ b/src/gui/widgets/TabWidget.cpp @@ -33,14 +33,27 @@ #include "gui_templates.h" #include "embed.h" +const int GRAPHICAL_TAB_HEIGHT = 20; +const int TEXT_TAB_HEIGHT = 14; - -TabWidget::TabWidget( const QString & _caption, QWidget * _parent ) : +TabWidget::TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap ) : QWidget( _parent ), m_activeTab( 0 ), m_caption( _caption ), m_tabheight( _caption.isEmpty() ? 11: 10 ) { + + // TabWidget with artwork tabs have a height of 20 pixels + if ( usePixmap ) + { + m_usePixmap = true; + m_tabheight = GRAPHICAL_TAB_HEIGHT; + } else + { + m_usePixmap = false; + m_tabheight = _caption.isEmpty() ? TEXT_TAB_HEIGHT - 3 : TEXT_TAB_HEIGHT - 4; + } + setFont( pointSize<8>( font() ) ); setAutoFillBackground( true ); @@ -62,7 +75,7 @@ TabWidget::~TabWidget() -void TabWidget::addTab( QWidget * _w, const QString & _name, const char * pixmapName, int _idx ) +void TabWidget::addTab( QWidget * _w, const QString & _name, const char *activePixmap, const char *inactivePixmap, int _idx ) { setFont( pointSize<8>( font() ) ); @@ -78,14 +91,21 @@ void TabWidget::addTab( QWidget * _w, const QString & _name, const char * pixma int w = fontMetrics().width( _name ) + 10; // Register new tab - widgetDesc d = { _w, pixmapName, _name, w } ; + widgetDesc d = { _w, activePixmap, inactivePixmap, _name, w } ; m_widgets[_idx] = d; - // Initialize tab's window - _w->setFixedSize( width() - 4, height() - 14 ); - _w->move( 2, 13 ); + // Position tab's window + if (m_usePixmap) { + _w->setFixedSize( width() - 4, height() - GRAPHICAL_TAB_HEIGHT ); + _w->move( 2, GRAPHICAL_TAB_HEIGHT -1 ); + } else + { + _w->setFixedSize( width() - 4, height() - TEXT_TAB_HEIGHT ); + _w->move( 2, TEXT_TAB_HEIGHT - 1 ); + } _w->hide(); + // Show tab's window if it's active if( m_widgets.contains( m_activeTab ) ) { // make sure new tab doesn't overlap current widget @@ -119,7 +139,9 @@ void TabWidget::setActiveTab( int _idx ) void TabWidget::mousePressEvent( QMouseEvent * _me ) { - if( _me->y() > 1 && _me->y() < 13 ) + int height = ( m_usePixmap ? GRAPHICAL_TAB_HEIGHT -1 : TEXT_TAB_HEIGHT -1 ); + + if( _me->y() > 1 && _me->y() < height ) { int cx = ( ( m_caption == "" ) ? 4 : 14 ) + fontMetrics().width( m_caption ); @@ -146,7 +168,12 @@ void TabWidget::resizeEvent( QResizeEvent * ) for( widgetStack::iterator it = m_widgets.begin(); it != m_widgets.end(); ++it ) { - ( *it ).w->setFixedSize( width() - 4, height() - 14 ); + if ( m_usePixmap ) { + ( *it ).w->setFixedSize( width() - 4, height() - GRAPHICAL_TAB_HEIGHT ); + } else + { + ( *it ).w->setFixedSize( width() - 4, height() - TEXT_TAB_HEIGHT ); + } } } @@ -206,19 +233,38 @@ void TabWidget::paintEvent( QPaintEvent * _pe ) // Draw all tabs widgetStack::iterator first = m_widgets.begin(); widgetStack::iterator last = m_widgets.end(); - int size = std::distance(first,last); for( widgetStack::iterator it = first ; it != last ; ++it ) { - // Draw a text tab when no artwork has been defined for the tab. - if ( (*it ).pixmapName == NULL ) + // Draw a text tab or a artwork tab. + if ( m_usePixmap ) { + // Recompute tab's width, because original size is only correct for text tabs + int size = std::distance(first,last); + ( *it ).nwidth = width() / size; + + // Get active or inactive artwork + QPixmap *artwork; + if( it.key() == m_activeTab ) + { + artwork = new QPixmap( embed::getIconPixmap( ( *it ).activePixmap ) ); + p.fillRect( tab_x_offset, 1, width() / size, GRAPHICAL_TAB_HEIGHT, cap_col ); + } else + { + artwork = new QPixmap( embed::getIconPixmap( ( *it ).inactivePixmap ) ); + } + + // Draw artwork + p.drawPixmap(tab_x_offset + ( ( *it ).nwidth - ( *artwork ).width() ) / 2, 1, *artwork ); + + } else + { // Highlight tab when active if( it.key() == m_activeTab ) { p.setPen( QColor( 32, 48, 64 ) ); - p.fillRect( tab_x_offset, 2, ( *it ).nwidth - 6, 10, cap_col ); + p.fillRect( tab_x_offset, 2, ( *it ).nwidth - 6, TEXT_TAB_HEIGHT - 4, cap_col ); } // Draw text @@ -226,24 +272,6 @@ void TabWidget::paintEvent( QPaintEvent * _pe ) // Reset text color p.setPen( cap_col ); - - - } else - { - // Get artwork - QPixmap *artwork = new QPixmap( embed::getIconPixmap( ( *it ).pixmapName ) ); - - if( it.key() == m_activeTab ) - { - p.fillRect( tab_x_offset, 1, width() / size, 12, cap_col ); - } - - // Draw artwork - p.drawPixmap(tab_x_offset + ( width() / ( size * 2 ) ) - 7, 0, *artwork ); - - // Recompute tab's width, because original size is only correct for text tabs - ( *it).nwidth = width() / size; - } // Next tab's horizontal position diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index eee8b98f2..2bb6d945f 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1406,8 +1406,8 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : generalSettingsLayout->addLayout( basicControlsLayout ); - m_tabWidget = new TabWidget( "", this ); - m_tabWidget->setFixedHeight( INSTRUMENT_HEIGHT + 10 ); + m_tabWidget = new TabWidget( "", this, true ); + m_tabWidget->setFixedHeight( INSTRUMENT_HEIGHT + 16 ); // create tab-widgets @@ -1434,11 +1434,11 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : m_miscView = new InstrumentMiscView( m_track, m_tabWidget ); - m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), "env_lfo", 1 ); - m_tabWidget->addTab( instrumentFunctions, tr( "FUNC" ), "functions", 2 ); - m_tabWidget->addTab( m_effectView, tr( "FX" ), "fx", 3 ); - m_tabWidget->addTab( m_midiView, tr( "MIDI" ), "midi_inactive", 4 ); - m_tabWidget->addTab( m_miscView, tr( "MISC" ), "miscellaneous", 5 ); + m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), "env_lfo_active", "env_lfo_inactive", 1 ); + m_tabWidget->addTab( instrumentFunctions, tr( "FUNC" ), "functions_active", "functions_inactive", 2 ); + m_tabWidget->addTab( m_effectView, tr( "FX" ), "fx_active", "fx_inactive", 3 ); + m_tabWidget->addTab( m_midiView, tr( "MIDI" ), "midi_active", "midi_inactive", 4 ); + m_tabWidget->addTab( m_miscView, tr( "MISC" ), "miscellaneous_active", "miscellaneous_inactive", 5 ); // setup piano-widget m_pianoView = new PianoView( this ); @@ -1611,7 +1611,7 @@ void InstrumentTrackWindow::updateInstrumentView() if( m_track->m_instrument != NULL ) { m_instrumentView = m_track->m_instrument->createView( m_tabWidget ); - m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), "plugin", 0 ); + m_tabWidget->addTab( m_instrumentView, tr( "PLUGIN" ), "plugin_active", "plugin_inactive", 0 ); m_tabWidget->setActiveTab( 0 ); m_ssView->setFunctionsHidden( m_track->m_instrument->flags().testFlag( Instrument::IsSingleStreamed ) );