Skip to content

Commit 53772c0

Browse files
authored
Allow WidgetTab to use artwork tabs (@StCyr) (#3569)
* First version of artwork tabs for the InstrumentTrackWindow. This version can only display & manage artwork tabs, which breaks the InstrumentSoundShapingView as it still uses text tabs. I'm planing to improve this implementation to let these artwork tabs fall back to text mode when no artwork is given. This would solve the problem of the InstrumentSoundShapingView. * Second version of artwork tabs for the InstrumentTrackWindow. This version will draw an artwork tab when the TabWidget::addTab function is given a pixmapName. Otherwise, when pixmapName is NULL, it will fall back drawing a text tab. * Created artwork for the artwork tabs. * 1st PoC for autosizeable artwork tabs. * TabWidget is 20 pixels tall when it's going to display artwork tabs. * Added tooltip support for the TabWidget class. Atm, tooltips are simply tabs' name. * Imported artworks from RebeccaDeField * Reverted to 12px tall TabWidget * Fine tuning for the positioning of artwork tabs: Take into account the caption 'space. * New artwork for the ENV/LFO tab (has now an ADSR-based look) * 1) Tabs in TabWidget class have now a "tooltip" attribute. So that they can now show more meaningfull information then simply the tab's name. 2) Fixed the compilation problem with QT5 * Fine tuning the positioning of highlighted artwork tabs. * Fixed an issue in TabWidget's artwork tabs autosize function that makes gdb crash with SIGFPE. * TabWidget is 17 pixels tall when it's going to display artwork tabs. * Removed underscore prefix for function parameters as coding convention has changed. (Request at https://github.com/LMMS/lmms/pull/2599/files/dccf9f411996c8c866ff1086b65f15020ef08cd9#r61165005) Cyrille * Removed background gradient for TabWidget as LMMS is going to a more flat design. Cyrille * Increased the graphical TabWidget's height by 2 pixels for eye-candy. The InstrumentTrackWindow's height has been increased by the same amount. Cyrille * Removed gradient in GrouBox widgets as LMMS is going for a more flattened design. Cyrille * Made the background of TabWidget themeable Cyrille * The highlighting color for a TabWidget'selected tab is now themeable. * Made TabWidget's Title text and tab text themeable. * Added a darker background to the TabWidget's tab bar. * Further flatened the design of TabWidget * Flatened the design of the GroupBox widget * Fine tuning the placement of TabWidgets' highlighting background + some code cleaning in TabWidgets * Made the TabWidget's title background and borders themeable * TabWidget - Artwork tabs: Do not change the icon color when it is highlighted * TabWidget: Made the artworks' color themeable * Adapted format to follow LMMS coding conventions * Some more blank spaces to tabs translation to comply with LMMS coding standards. * Some more blank spaces to tabs translation to comply with LMMS coding standards. * Revert "TabWidget: Made the artworks' color themeable" This reverts commit 5b162c0. Conflicts: src/gui/widgets/TabWidget.cpp Reason: Artwork's color themeability had the side-effect that it removed the artworks' alpha channel, thus making them ugly. * Made GroupBox's background color themeable * Update background color, only use one set of images * Use name as tooltip, more descriptive names * Update icons and colors * more things * formatting fixes * Remove update() from constructor
1 parent 9bdc011 commit 53772c0

File tree

14 files changed

+286
-148
lines changed

14 files changed

+286
-148
lines changed

data/themes/default/env_lfo_tab.png

255 Bytes
Loading

data/themes/default/func_tab.png

179 Bytes
Loading

data/themes/default/fx_tab.png

292 Bytes
Loading

data/themes/default/midi_tab.png

170 Bytes
Loading

data/themes/default/misc_tab.png

188 Bytes
Loading

data/themes/default/plugin_tab.png

210 Bytes
Loading

data/themes/default/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ PianoRoll {
136136
qproperty-textShadow: #fff;
137137
}
138138

139+
TabWidget {
140+
background-color: #262b30;
141+
qproperty-tabText: rgba(255, 255, 255, 180);
142+
qproperty-tabTitleText: #fff;
143+
qproperty-tabSelected: #323940;
144+
qproperty-tabBackground: #181b1f;
145+
qproperty-tabBorder: #181b1f;
146+
}
147+
148+
GroupBox {
149+
background-color: #262b30;
150+
}
151+
139152
/* main toolbar oscilloscope - can have transparent bg now */
140153

141154
VisualizationWidget {

include/GroupBox.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GroupBox : public QWidget, public BoolModelView
5757

5858
protected:
5959
virtual void mousePressEvent( QMouseEvent * _me );
60-
virtual void resizeEvent( QResizeEvent * _re );
60+
virtual void paintEvent( QPaintEvent * _pe );
6161

6262

6363
private:

include/TabWidget.h

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,47 @@
2929
#include <QWidget>
3030
#include <QtCore/QMap>
3131

32+
const int TEXT_TAB_HEIGHT = 14;
33+
const int GRAPHIC_TAB_HEIGHT = 17;
3234

3335
class TabWidget : public QWidget
3436
{
3537
Q_OBJECT
3638
public:
37-
TabWidget( const QString & _caption, QWidget * _parent );
39+
TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false );
3840
virtual ~TabWidget();
3941

40-
void addTab( QWidget * _w, const QString & _name, int _idx = -1 );
42+
void addTab( QWidget * w, const QString & name, const char *pixmap = NULL, int idx = -1 );
4143

42-
void setActiveTab( int _idx );
44+
void setActiveTab( int idx );
45+
46+
int findTabAtPos( const QPoint *pos );
4347

4448
inline int activeTab() const
4549
{
4650
return( m_activeTab );
4751
}
4852

53+
// Themeability
54+
Q_PROPERTY( QColor tabText READ tabText WRITE setTabText)
55+
Q_PROPERTY( QColor tabTitleText READ tabTitleText WRITE setTabTitleText)
56+
Q_PROPERTY( QColor tabSelected READ tabSelected WRITE setTabSelected)
57+
Q_PROPERTY( QColor tabBackground READ tabBackground WRITE setTabBackground)
58+
Q_PROPERTY( QColor tabBorder READ tabBorder WRITE setTabBorder)
59+
60+
QColor tabText() const;
61+
void setTabText( const QColor & c );
62+
QColor tabTitleText() const;
63+
void setTabTitleText( const QColor & c );
64+
QColor tabSelected() const;
65+
void setTabSelected( const QColor & c );
66+
QColor tabBackground() const;
67+
void setTabBackground( const QColor & c );
68+
QColor tabBorder() const;
69+
void setTabBorder( const QColor & c );
4970

5071
protected:
72+
virtual bool event( QEvent * event );
5173
virtual void mousePressEvent( QMouseEvent * _me );
5274
virtual void paintEvent( QPaintEvent * _pe );
5375
virtual void resizeEvent( QResizeEvent * _re );
@@ -57,16 +79,26 @@ class TabWidget : public QWidget
5779
private:
5880
struct widgetDesc
5981
{
60-
QWidget * w; // ptr to widget
61-
QString name; // name for widget
62-
int nwidth; // width of name when painting
82+
QWidget * w; // ptr to widget
83+
const char * pixmap; // artwork for the widget
84+
QString name; // name for widget
85+
int nwidth; // width of name when painting (only valid for text tab)
6386
} ;
6487
typedef QMap<int, widgetDesc> widgetStack;
6588

6689
widgetStack m_widgets;
67-
int m_activeTab;
68-
QString m_caption;
69-
quint8 m_tabheight;
90+
91+
int m_activeTab;
92+
QString m_caption; // Tab caption, used as the tooltip text on icon tabs
93+
quint8 m_tabbarHeight; // The height of the tab bar
94+
quint8 m_tabheight; // The height of the tabs
95+
bool m_usePixmap; // true if the tabs are to be displayed with icons. False for text tabs.
96+
97+
QColor m_tabText; // The color of the tabs' text.
98+
QColor m_tabTitleText; // The color of the TabWidget's title text.
99+
QColor m_tabSelected; // The highlighting color for the selected tab.
100+
QColor m_tabBackground; // The TabWidget's background color.
101+
QColor m_tabBorder; // The TabWidget's borders color.
70102
} ;
71103

72104
#endif

src/gui/widgets/EffectRackView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ EffectRackView::EffectRackView( EffectChain* model, QWidget* parent ) :
3939
ModelView( NULL, this )
4040
{
4141
QVBoxLayout* mainLayout = new QVBoxLayout( this );
42-
mainLayout->setMargin( 0 );
42+
mainLayout->setMargin( 5 );
4343

4444
m_effectsGroupBox = new GroupBox( tr( "EFFECTS CHAIN" ) );
4545
mainLayout->addWidget( m_effectsGroupBox );

src/gui/widgets/GroupBox.cpp

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ GroupBox::GroupBox( const QString & _caption, QWidget * _parent ) :
4141
m_caption( _caption ),
4242
m_titleBarHeight( 11 )
4343
{
44-
updatePixmap();
45-
4644
m_led = new PixmapButton( this, _caption );
4745
m_led->setCheckable( true );
4846
m_led->move( 3, 0 );
@@ -84,60 +82,22 @@ void GroupBox::mousePressEvent( QMouseEvent * _me )
8482

8583

8684

87-
void GroupBox::resizeEvent( QResizeEvent * _ev )
85+
void GroupBox::paintEvent( QPaintEvent * pe )
8886
{
89-
updatePixmap();
90-
QWidget::resizeEvent( _ev );
91-
}
92-
87+
QPainter p( this );
9388

94-
95-
void GroupBox::updatePixmap()
96-
{
97-
QColor bg_color = QApplication::palette().color( QPalette::Active,
98-
QPalette::Background );
99-
QPixmap pm( size() );
100-
pm.fill( bg_color/*.dark( 132 )*/ );
101-
102-
QPainter p( &pm );
89+
// Draw background
90+
p.fillRect( 0, 0, width() - 1, height() - 1, p.background() );
10391

10492
// outer rect
105-
p.setPen( bg_color.dark( 150 ) );
93+
p.setPen( p.background().color().dark( 150 ) );
10694
p.drawRect( 0, 0, width() - 1, height() - 1 );
10795

108-
// brighter line at bottom/right
109-
p.setPen( bg_color.light( 150 ) );
110-
p.drawLine( width() - 1, 0, width() - 1, height() - 1 );
111-
p.drawLine( 0, height() - 1, width() - 1, height() - 1 );
112-
113-
// draw groupbox-titlebar
114-
QLinearGradient g( 0, 0, 0, m_titleBarHeight );
115-
g.setColorAt( 0, bg_color.darker( 250 ) );
116-
g.setColorAt( 0.1, bg_color.lighter( 120 ) );
117-
g.setColorAt( 1, bg_color.darker( 250 ) );
118-
p.fillRect( 2, 2, width() - 4, m_titleBarHeight, g );
119-
12096
// draw line below titlebar
121-
p.setPen( bg_color.dark( 400 ) );
122-
p.drawLine( 1, m_titleBarHeight + 1, width() - 3, m_titleBarHeight + 1 );
123-
124-
// black inner rect
125-
p.drawRect( 1, 1, width() - 3, height() - 3 );
97+
p.fillRect( 1, 1, width() - 2, m_titleBarHeight + 1, p.background().color().darker( 150 ) );
12698

127-
128-
//p.setPen( QColor( 255, 255, 255 ) );
99+
// draw text
129100
p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
130101
p.setFont( pointSize<8>( font() ) );
131102
p.drawText( 22, m_titleBarHeight, m_caption );
132-
133-
QPalette pal = palette();
134-
pal.setBrush( backgroundRole(), QBrush( pm ) );
135-
setPalette( pal );
136103
}
137-
138-
139-
140-
141-
142-
143-

src/gui/widgets/InstrumentSoundShapingView.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ InstrumentSoundShapingView::InstrumentSoundShapingView( QWidget * _parent ) :
7676
{
7777
m_envLfoViews[i] = new EnvelopeAndLfoView( m_targetsTabWidget );
7878
m_targetsTabWidget->addTab( m_envLfoViews[i],
79-
tr( InstrumentSoundShaping::targetNames[i][0].toUtf8().constData() ) );
79+
tr( InstrumentSoundShaping::targetNames[i][0].toUtf8().constData() ),
80+
NULL );
8081
}
8182

8283

0 commit comments

Comments
 (0)