Skip to content

Commit

Permalink
Refactor the drawing of TCO's; Get rid of hardcoded colors in TCOs; M…
Browse files Browse the repository at this point in the history
…ake TCO gradient configurable; Even out the color scheme
  • Loading branch information
Umcaruje committed Feb 28, 2016
1 parent 8841b89 commit db46bed
Show file tree
Hide file tree
Showing 12 changed files with 440 additions and 303 deletions.
30 changes: 18 additions & 12 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ PianoRoll {
qproperty-noteColor: rgb( 119, 199, 216 );
qproperty-noteBorderRadiusX: 5;
qproperty-noteBorderRadiusY: 2;
qproperty-selectedNoteColor: rgb( 0, 64, 192 );
qproperty-selectedNoteColor: rgb( 0, 125, 255 );
qproperty-barColor: #4afd85;
qproperty-markedSemitoneColor: rgba( 40, 40, 40, 200 );
/* Text on the white piano keys */
Expand Down Expand Up @@ -537,31 +537,37 @@ TrackContainerView QLabel

/* Patterns */

/* common pattern colors */
TrackContentObjectView {
qproperty-mutedColor: rgb( 128, 128, 128 );
qproperty-mutedBackgroundColor: rgb( 80, 80, 80 );
qproperty-selectedColor: rgb( 0, 125, 255 );
qproperty-textColor: rgb( 255, 255, 255 );
qproperty-textShadowColor: rgb( 0, 0, 0 );
qproperty-gradient: false;
}

/* instrument pattern */
PatternView {
color: rgb( 119, 199, 216 );
qproperty-fgColor: rgb( 187, 227, 236 );
qproperty-textColor: rgb( 255, 255, 255 );
background-color: rgb( 119, 199, 216 );
color: rgb( 187, 227, 236 );
}

/* sample track pattern */
SampleTCOView {
color: rgb( 74, 253, 133 );
qproperty-fgColor: rgb( 187, 227, 236 );
qproperty-textColor: rgb( 255, 60, 60 );
background-color: rgb( 74, 253, 133 );
color: rgb( 187, 227, 236 );
}

/* automation pattern */
AutomationPatternView {
color: #99afff;
qproperty-fgColor: rgb( 204, 215, 255 );
qproperty-textColor: rgb( 255, 255, 255 );
background-color: #99afff;
color: rgb( 204, 215, 255 );
}

/* bb-pattern */
BBTCOView {
color: rgb( 128, 182, 175 ); /* default colour for bb-tracks, used when the colour hasn't been defined by the user */
qproperty-textColor: rgb( 255, 255, 255 );
background-color: rgb( 128, 182, 175 ); /* default colour for bb-tracks */
}

/* Plugins */
Expand Down
7 changes: 4 additions & 3 deletions include/AutomationPatternView.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef AUTOMATION_PATTERN_VIEW_H
#define AUTOMATION_PATTERN_VIEW_H

#include <QStaticText>

#include "Track.h"

class AutomationPattern;
Expand All @@ -34,9 +36,6 @@ class AutomationPatternView : public TrackContentObjectView
{
Q_OBJECT

// theming qproperties
Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )

public:
AutomationPatternView( AutomationPattern * _pat, TrackView * _parent );
Expand Down Expand Up @@ -74,6 +73,8 @@ protected slots:
QPixmap m_paintPixmap;
bool m_needsUpdate;

QStaticText m_staticTextName;

static QPixmap * s_pat_rec;

void scaleTimemapToFit( float oldMin, float oldMax );
Expand Down
13 changes: 12 additions & 1 deletion include/BBTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QStaticText>

#include "Track.h"

Expand Down Expand Up @@ -97,6 +98,8 @@ class BBTCOView : public TrackContentObjectView
}
void setColor( QColor _new_color );

public slots:
virtual void update();

protected slots:
void openInBBEditor();
Expand All @@ -108,13 +111,21 @@ protected slots:

protected:
void paintEvent( QPaintEvent * );
void resizeEvent( QResizeEvent * re )
{
m_needsUpdate = true;
TrackContentObjectView::resizeEvent( re );
}
void mouseDoubleClickEvent( QMouseEvent * _me );
virtual void constructContextMenu( QMenu * );


private:
BBTCO * m_bbTCO;

QPixmap m_paintPixmap;
bool m_needsUpdate;

QStaticText m_staticTextName;
} ;


Expand Down
6 changes: 3 additions & 3 deletions include/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QDialog>
#include <QtCore/QThread>
#include <QPixmap>
#include <QStaticText>


#include "Note.h"
Expand Down Expand Up @@ -159,9 +160,6 @@ class PatternView : public TrackContentObjectView
{
Q_OBJECT

// theming qproperties
Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
public:
PatternView( Pattern* pattern, TrackView* parent );
virtual ~PatternView();
Expand Down Expand Up @@ -200,6 +198,8 @@ protected slots:
Pattern* m_pat;
QPixmap m_paintPixmap;
bool m_needsUpdate;

QStaticText m_staticTextName;
} ;


Expand Down
13 changes: 9 additions & 4 deletions include/SampleTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ public slots:
class SampleTCOView : public TrackContentObjectView
{
Q_OBJECT

// theming qproperties
Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )

public:
SampleTCOView( SampleTCO * _tco, TrackView * _tv );
Expand All @@ -100,6 +96,8 @@ class SampleTCOView : public TrackContentObjectView

public slots:
void updateSample();
virtual void update();



protected:
Expand All @@ -109,10 +107,17 @@ public slots:
virtual void dropEvent( QDropEvent * _de );
virtual void mouseDoubleClickEvent( QMouseEvent * );
virtual void paintEvent( QPaintEvent * );
virtual void resizeEvent( QResizeEvent * re )
{
m_needsUpdate = true;
TrackContentObjectView::resizeEvent( re );
}


private:
SampleTCO * m_tco;
QPixmap m_paintPixmap;
bool m_needsUpdate;
} ;


Expand Down
24 changes: 20 additions & 4 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ class TrackContentObjectView : public selectableObject, public ModelView
Q_OBJECT

// theming qproperties
Q_PROPERTY( QColor fgColor READ fgColor WRITE setFgColor )
Q_PROPERTY( QColor mutedColor READ mutedColor WRITE setMutedColor )
Q_PROPERTY( QColor mutedBackgroundColor READ mutedBackgroundColor WRITE setMutedBackgroundColor )
Q_PROPERTY( QColor selectedColor READ selectedColor WRITE setSelectedColor )
Q_PROPERTY( QColor textColor READ textColor WRITE setTextColor )
Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor )
Q_PROPERTY( bool gradient READ gradient WRITE setGradient )

public:
TrackContentObjectView( TrackContentObject * tco, TrackView * tv );
Expand All @@ -205,10 +209,18 @@ class TrackContentObjectView : public selectableObject, public ModelView
return m_tco;
}
// qproperty access func
QColor fgColor() const;
QColor mutedColor() const;
QColor mutedBackgroundColor() const;
QColor selectedColor() const;
QColor textColor() const;
void setFgColor( const QColor & c );
QColor textShadowColor() const;
bool gradient() const;
void setMutedColor( const QColor & c );
void setMutedBackgroundColor( const QColor & c );
void setSelectedColor( const QColor & c );
void setTextColor( const QColor & c );
void setTextShadowColor( const QColor & c );
void setGradient( const bool & b );

public slots:
virtual bool close();
Expand Down Expand Up @@ -267,8 +279,12 @@ protected slots:
MidiTime m_oldTime;// used for undo/redo while mouse-button is pressed

// qproperty fields
QColor m_fgColor;
QColor m_mutedColor;
QColor m_mutedBackgroundColor;
QColor m_selectedColor;
QColor m_textColor;
QColor m_textShadowColor;
bool m_gradient;

inline void setInitialMousePos( QPoint pos )
{
Expand Down
4 changes: 1 addition & 3 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,7 @@ void SampleBuffer::visualize( QPainter & _p, const QRect & _dr,

const bool focus_on_range = _to_frame <= m_frames
&& 0 <= _from_frame && _from_frame < _to_frame;
// _p.setClipRect( _clip );
// _p.setPen( QColor( 0x22, 0xFF, 0x44 ) );
//_p.setPen( QColor( 64, 224, 160 ) );
//_p.setClipRect( _clip );
const int w = _dr.width();
const int h = _dr.height();

Expand Down
57 changes: 42 additions & 15 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
m_initialMousePos( QPoint( 0, 0 ) ),
m_initialMouseGlobalPos( QPoint( 0, 0 ) ),
m_hint( NULL ),
m_fgColor( 0, 0, 0 ),
m_textColor( 0, 0, 0 )
m_mutedColor( 0, 0, 0 ),
m_mutedBackgroundColor( 0, 0, 0 ),
m_selectedColor( 0, 0, 0 ),
m_textColor( 0, 0, 0 ),
m_textShadowColor( 0, 0, 0 ),
m_gradient( true )
{
if( s_textFloat == NULL )
{
Expand All @@ -264,10 +268,10 @@ TrackContentObjectView::TrackContentObjectView( TrackContentObject * tco,
setAttribute( Qt::WA_DeleteOnClose, true );
setFocusPolicy( Qt::StrongFocus );
setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) );
move( 0, 1 );
move( 0, 0 );
show();

setFixedHeight( tv->getTrackContentWidget()->height() - 2 );
setFixedHeight( tv->getTrackContentWidget()->height() - 1);
setAcceptDrops( true );
setMouseTracking( true );

Expand Down Expand Up @@ -319,21 +323,43 @@ bool TrackContentObjectView::fixedTCOs()

// qproperty access functions, to be inherited & used by TCOviews
//! \brief CSS theming qproperty access method
QColor TrackContentObjectView::fgColor() const
{ return m_fgColor; }
QColor TrackContentObjectView::mutedColor() const
{ return m_mutedColor; }

QColor TrackContentObjectView::mutedBackgroundColor() const
{ return m_mutedBackgroundColor; }

QColor TrackContentObjectView::selectedColor() const
{ return m_selectedColor; }

//! \brief CSS theming qproperty access method
QColor TrackContentObjectView::textColor() const
{ return m_textColor; }

//! \brief CSS theming qproperty access method
void TrackContentObjectView::setFgColor( const QColor & c )
{ m_fgColor = QColor( c ); }
QColor TrackContentObjectView::textShadowColor() const
{ return m_textShadowColor; }

bool TrackContentObjectView::gradient() const
{ return m_gradient; }

//! \brief CSS theming qproperty access method
void TrackContentObjectView::setMutedColor( const QColor & c )
{ m_mutedColor = QColor( c ); }

void TrackContentObjectView::setMutedBackgroundColor( const QColor & c )
{ m_mutedBackgroundColor = QColor( c ); }

void TrackContentObjectView::setSelectedColor( const QColor & c )
{ m_selectedColor = QColor( c ); }

void TrackContentObjectView::setTextColor( const QColor & c )
{ m_textColor = QColor( c ); }

void TrackContentObjectView::setTextShadowColor( const QColor & c )
{ m_textShadowColor = QColor( c ); }

void TrackContentObjectView::setGradient( const bool & b )
{ m_gradient = b; }


/*! \brief Close a trackContentObjectView
*
Expand Down Expand Up @@ -1047,11 +1073,8 @@ void TrackContentWidget::updateBackground()
pmp.fillRect( w, 0, w , h, lighterColor() );

// draw lines
pmp.setPen( QPen( gridColor(), 1 ) );
// horizontal line
pmp.drawLine( 0, h-1, w*2, h-1 );

// vertical lines
pmp.setPen( QPen( gridColor(), 1 ) );
for( float x = 0; x < w * 2; x += ppt )
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
Expand All @@ -1062,6 +1085,10 @@ void TrackContentWidget::updateBackground()
{
pmp.drawLine( QLineF( x, 0.0, x, h ) );
}

// horizontal line
pmp.setPen( QPen( gridColor(), 1 ) );
pmp.drawLine( 0, h-1, w*2, h-1 );

pmp.end();

Expand Down Expand Up @@ -1122,7 +1149,7 @@ void TrackContentWidget::update()
for( tcoViewVector::iterator it = m_tcoViews.begin();
it != m_tcoViews.end(); ++it )
{
( *it )->setFixedHeight( height() - 2 );
( *it )->setFixedHeight( height() - 1 );
( *it )->update();
}
QWidget::update();
Expand Down
Loading

0 comments on commit db46bed

Please sign in to comment.