Use QBrush instead of QColor on some theme properties
Apparently, we can use QBrush -typed properties in the CSS. This just never occured to me before! So, this has several benefits. A QColor property only allows a singular RGB value, but a QBrush allows the same plus also qgradients, RGBA-colours and maybe even bitmap patterns. So I'm changing some properties to QBrush, where it makes sense to allow this additional functionality - no need to enable it for simple things like text colours or such. - Song editor background: instead of the earlier hack with 7 qproperties just to set a limited background gradient, we can use only 2 properties and allow much more flexibility with Qt's own qgradient syntax - Automation editor: background, graph colour, and the sidebar colour - @musikBear recently complained not seeing the grid through the graph, so transparency can help there, and qlineargradients in the graph can produce very cool visual effects. Grid is pointless to change, it should stay single-colour for now. - Piano roll: here, I only made the background use QBrush - we don't really have much else here that can utilize QBrush, the notes have their own gradient system... maybe the 2nd colour of the note gradient could be customizable though. There are probably more places where this change makes sense...
This commit is contained in:
@@ -847,14 +847,7 @@ void trackContentObjectView::setAutoResizeEnabled( bool _e )
|
||||
*/
|
||||
trackContentWidget::trackContentWidget( trackView * _parent ) :
|
||||
QWidget( _parent ),
|
||||
m_trackView( _parent ),
|
||||
m_darkerColor1( 0, 0, 0 ),
|
||||
m_darkerColor2( 0, 0, 0 ),
|
||||
m_darkerColor3( 0, 0, 0 ),
|
||||
m_lighterColor1( 0, 0, 0 ),
|
||||
m_lighterColor2( 0, 0, 0 ),
|
||||
m_lighterColor3( 0, 0, 0 ),
|
||||
m_gradMidPoint( 0.0f )
|
||||
m_trackView( _parent )
|
||||
{
|
||||
setAcceptDrops( true );
|
||||
|
||||
@@ -894,17 +887,8 @@ void trackContentWidget::updateBackground()
|
||||
m_background = QPixmap( w * 2, height() );
|
||||
QPainter pmp( &m_background );
|
||||
|
||||
QLinearGradient grad( 0,0, 0, h );
|
||||
grad.setColorAt( 0.0, darkerColor1() );
|
||||
grad.setColorAt( gradMidPoint(), darkerColor2() );
|
||||
grad.setColorAt( 1.0, darkerColor3() );
|
||||
pmp.fillRect( 0, 0, w, h, grad );
|
||||
|
||||
QLinearGradient grad2( 0,0, 0, h );
|
||||
grad2.setColorAt( 0.0, lighterColor1() );
|
||||
grad2.setColorAt( gradMidPoint(), lighterColor2() );
|
||||
grad2.setColorAt( 1.0, lighterColor3() );
|
||||
pmp.fillRect( w, 0, w , h, grad2 );
|
||||
pmp.fillRect( 0, 0, w, h, darkerColor() );
|
||||
pmp.fillRect( w, 0, w , h, lighterColor() );
|
||||
|
||||
// draw lines
|
||||
pmp.setPen( QPen( QColor( 0, 0, 0, 160 ), 1 ) );
|
||||
@@ -1236,61 +1220,20 @@ MidiTime trackContentWidget::endPosition( const MidiTime & _pos_start )
|
||||
|
||||
// qproperty access methods
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor1() const
|
||||
{ return m_darkerColor1; }
|
||||
QBrush trackContentWidget::darkerColor() const
|
||||
{ return m_darkerColor; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor2() const
|
||||
{ return m_darkerColor2; }
|
||||
QBrush trackContentWidget::lighterColor() const
|
||||
{ return m_lighterColor; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::darkerColor3() const
|
||||
{ return m_darkerColor3; }
|
||||
void trackContentWidget::setDarkerColor( const QBrush & c )
|
||||
{ m_darkerColor = c; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor1() const
|
||||
{ return m_lighterColor1; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor2() const
|
||||
{ return m_lighterColor2; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
QColor trackContentWidget::lighterColor3() const
|
||||
{ return m_lighterColor3; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor1( const QColor & _c )
|
||||
{ m_darkerColor1 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor2( const QColor & _c )
|
||||
{ m_darkerColor2 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setDarkerColor3( const QColor & _c )
|
||||
{ m_darkerColor3 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor1( const QColor & _c )
|
||||
{ m_lighterColor1 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor2( const QColor & _c )
|
||||
{ m_lighterColor2 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setLighterColor3( const QColor & _c )
|
||||
{ m_lighterColor3 = QColor( _c ); }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
float trackContentWidget::gradMidPoint() const
|
||||
{ return m_gradMidPoint; }
|
||||
|
||||
//! \brief CSS theming qproperty access method
|
||||
void trackContentWidget::setGradMidPoint( float _g )
|
||||
{ m_gradMidPoint = _g; }
|
||||
|
||||
void trackContentWidget::setLighterColor( const QBrush & c )
|
||||
{ m_lighterColor = c; }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -98,9 +98,9 @@ AutomationEditor::AutomationEditor() :
|
||||
m_editMode( DRAW ),
|
||||
m_scrollBack( FALSE ),
|
||||
m_gridColor( 0,0,0 ),
|
||||
m_graphColor( 0,0,0 ),
|
||||
m_graphColor(),
|
||||
m_vertexColor( 0,0,0 ),
|
||||
m_scaleColor( 0,0,0 )
|
||||
m_scaleColor()
|
||||
{
|
||||
connect( this, SIGNAL( currentPatternChanged() ),
|
||||
this, SLOT( updateAfterPatternChange() ),
|
||||
@@ -507,19 +507,19 @@ void AutomationEditor::setPauseIcon( bool pause )
|
||||
|
||||
QColor AutomationEditor::gridColor() const
|
||||
{ return m_gridColor; }
|
||||
QColor AutomationEditor::graphColor() const
|
||||
QBrush AutomationEditor::graphColor() const
|
||||
{ return m_graphColor; }
|
||||
QColor AutomationEditor::vertexColor() const
|
||||
{ return m_vertexColor; }
|
||||
QColor AutomationEditor::scaleColor() const
|
||||
QBrush AutomationEditor::scaleColor() const
|
||||
{ return m_scaleColor; }
|
||||
void AutomationEditor::setGridColor( const QColor & c )
|
||||
{ m_gridColor = c; }
|
||||
void AutomationEditor::setGraphColor( const QColor & c )
|
||||
void AutomationEditor::setGraphColor( const QBrush & c )
|
||||
{ m_graphColor = c; }
|
||||
void AutomationEditor::setVertexColor( const QColor & c )
|
||||
{ m_vertexColor = c; }
|
||||
void AutomationEditor::setScaleColor( const QColor & c )
|
||||
void AutomationEditor::setScaleColor( const QBrush & c )
|
||||
{ m_scaleColor = c; }
|
||||
|
||||
|
||||
@@ -1387,10 +1387,10 @@ void AutomationEditor::paintEvent( QPaintEvent * _pe )
|
||||
QPainter p( this );
|
||||
style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this );
|
||||
|
||||
// get foregrounf color
|
||||
// get foreground color
|
||||
QColor fgColor = p.pen().brush().color();
|
||||
// get background color and fill background
|
||||
QColor bgColor = p.background().color();
|
||||
QBrush bgColor = p.background();
|
||||
p.fillRect( 0, 0, width(), height(), bgColor );
|
||||
|
||||
// set font-size to 8
|
||||
@@ -1768,12 +1768,11 @@ void AutomationEditor::drawLevelTick( QPainter & _p, int _tick, float _level,
|
||||
rect_height = (int)( _level * m_y_delta );
|
||||
}
|
||||
|
||||
QColor current_color( graphColor() );
|
||||
if( _is_selected == TRUE )
|
||||
{
|
||||
current_color.setRgb( 0x00, 0x40, 0xC0 );
|
||||
}
|
||||
_p.fillRect( x, y_start, rect_width, rect_height, current_color );
|
||||
QBrush currentColor = _is_selected
|
||||
? QBrush( QColor( 0x00, 0x40, 0xC0 ) )
|
||||
: graphColor();
|
||||
|
||||
_p.fillRect( x, y_start, rect_width, rect_height, currentColor );
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
@@ -2887,7 +2887,7 @@ void PianoRoll::paintEvent( QPaintEvent * _pe )
|
||||
QPainter p( this );
|
||||
style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this );
|
||||
|
||||
QColor bgColor = p.background().color();
|
||||
QBrush bgColor = p.background();
|
||||
|
||||
// fill with bg color
|
||||
p.fillRect( 0,0, width(), height(), bgColor );
|
||||
|
||||
Reference in New Issue
Block a user