Add classic-TCO back, enhance song editor, cleanup code
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@2059 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
41
ChangeLog
41
ChangeLog
@@ -1,3 +1,44 @@
|
||||
2009-02-19 Paul Giblock <drfaygo/at/gmail/dot/com>
|
||||
|
||||
* include/track.h:
|
||||
* include/pattern.h:
|
||||
Fixed constness
|
||||
|
||||
* include/lmms_style.h:
|
||||
* include/classic_style.h:
|
||||
* include/cusis_style.h:
|
||||
* src/gui/tracks/track_content_object_item.cpp:
|
||||
* src/gui/tracks/bb_tco_item.cpp:
|
||||
* src/gui/tracks/pattern_item.cpp:
|
||||
Move TCO drawing into LMMS style
|
||||
|
||||
* include/lcd_spinbox.h:
|
||||
* include/combobox.h:
|
||||
Update copyright
|
||||
|
||||
* include/gui/tracks/pattern_item.h:
|
||||
* include/gui/tracks/track_content_object_item.h:
|
||||
* include/gui/tracks/track_item.h:
|
||||
* include/gui/tracks/track_container_scene.h:
|
||||
* include/gui/tracks/bb_tco_item.h:
|
||||
* src/gui/tracks/track_content_object_item.cpp:
|
||||
* src/gui/tracks/track_item.cpp:
|
||||
* src/gui/tracks/track_container_scene.cpp:
|
||||
* src/gui/main_window.cpp:
|
||||
Code style and cleanup
|
||||
|
||||
* src/gui/main_window.cpp:
|
||||
Update for model move and resize
|
||||
|
||||
* src/gui/classic_style.cpp:
|
||||
Add Classic TCO style back, unoptimized at the moment
|
||||
|
||||
* src/gui/cusis_style.cpp:
|
||||
Move Shiny-TCO to Cusis and add pixmap caching
|
||||
|
||||
|
||||
|
||||
|
||||
2009-02-19 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/fade_button.h:
|
||||
|
||||
@@ -66,6 +66,9 @@ public:
|
||||
|
||||
virtual QColor color(LmmsStyle::ColorRole _role) const;
|
||||
|
||||
virtual void drawTrackContentObject( QPainter * _painter, const trackContentObject * _model,
|
||||
const LmmsStyleOptionTCO * _options );
|
||||
|
||||
private:
|
||||
QImage colorizeXpm( const char * const * xpm, const QBrush & fill ) const;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* combobox.h - class comboBox, a very cool combo-box
|
||||
*
|
||||
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2008-2009 Paul Giblock <pgib/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
|
||||
@@ -68,6 +68,9 @@ public:
|
||||
virtual void drawTrackContentBackground( QPainter * _painter,
|
||||
const QSize & _size, const int _pixelsPerTact );
|
||||
|
||||
virtual void drawTrackContentObject( QPainter * _painter, const trackContentObject * _model,
|
||||
const LmmsStyleOptionTCO * _options );
|
||||
|
||||
virtual QColor color( LmmsStyle::ColorRole _role ) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,17 +19,17 @@ class BbTrackContentObjectItem : public TrackContentObjectItem
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BbTrackContentObjectItem( TrackItem * _track, trackContentObject * _object );
|
||||
BbTrackContentObjectItem( TrackItem * _track, trackContentObject * _object );
|
||||
|
||||
void paint( QPainter * _painter, const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget );
|
||||
|
||||
QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
virtual void paint( QPainter * _painter, const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget );
|
||||
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,27 +10,26 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "gui/tracks/track_content_object_item.h"
|
||||
#include "gui/tracks/track_item.h"
|
||||
|
||||
class trackContentObject;
|
||||
class TrackItem;
|
||||
|
||||
class PatternItem : public TrackContentObjectItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PatternItem( TrackItem * _track, trackContentObject * _object );
|
||||
PatternItem( TrackItem * _track, trackContentObject * _object );
|
||||
|
||||
void paint( QPainter * _painter, const QStyleOptionGraphicsItem * _option,
|
||||
virtual void paint( QPainter * _painter, const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget );
|
||||
|
||||
QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
// virtual QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _TRACK_CONTAINER_SCENE_H
|
||||
#define _TRACK_CONTAINER_SCENE_H
|
||||
|
||||
@@ -103,12 +104,6 @@ protected:
|
||||
virtual void keyPressEvent( QKeyEvent * event );
|
||||
|
||||
private:
|
||||
/*
|
||||
enum Actions
|
||||
{
|
||||
AddTrack,
|
||||
RemoveTrack
|
||||
} ;*/
|
||||
|
||||
|
||||
//signals:
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <QPainter>
|
||||
#include <math.h>
|
||||
|
||||
#include "lmms_basics.h"
|
||||
|
||||
class trackContentObject;
|
||||
class TrackItem;
|
||||
|
||||
@@ -19,47 +21,53 @@ class TrackContentObjectItem : public QObject, public QGraphicsItem
|
||||
friend class TrackContainerScene;
|
||||
|
||||
public:
|
||||
TrackContentObjectItem( TrackItem * _track, trackContentObject * _object );
|
||||
TrackContentObjectItem( TrackItem * _track, trackContentObject * _object );
|
||||
|
||||
virtual ~TrackContentObjectItem()
|
||||
{
|
||||
if( m_snapBackAnimation != NULL )
|
||||
{
|
||||
delete m_snapBackAnimation;
|
||||
}
|
||||
};
|
||||
virtual ~TrackContentObjectItem()
|
||||
{
|
||||
if( m_snapBackAnimation != NULL )
|
||||
{
|
||||
delete m_snapBackAnimation;
|
||||
}
|
||||
};
|
||||
|
||||
QRectF boundingRect() const;
|
||||
|
||||
void paint( QPainter * _painter, const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget );
|
||||
|
||||
QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
QWidget * _widget );
|
||||
|
||||
|
||||
virtual qreal zValue() const;
|
||||
virtual qreal zValue() const;
|
||||
|
||||
// For TrackItem to call
|
||||
void updateGeometry();
|
||||
// For TrackItem to call
|
||||
void updateGeometry();
|
||||
|
||||
protected:
|
||||
void prepareSnapBackAnimation( QTimeLine * timeLine );
|
||||
void prepareSnapBackAnimation( QTimeLine * timeLine, int newX );
|
||||
virtual QVariant itemChange( GraphicsItemChange _change, const QVariant & _value );
|
||||
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
|
||||
|
||||
void prepareSnapBackAnimation( QTimeLine * timeLine );
|
||||
void prepareSnapBackAnimation( QTimeLine * timeLine, int newX );
|
||||
|
||||
protected slots:
|
||||
void updateLength( void );
|
||||
void updatePosition( void );
|
||||
|
||||
virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
|
||||
|
||||
protected:
|
||||
QPointF m_lastPos;
|
||||
QPointF m_lastDest;
|
||||
QGraphicsItemAnimation * m_snapBackAnimation;
|
||||
static QTimeLine s_snapBackTimeLine;
|
||||
tact m_length;
|
||||
QGraphicsItemAnimation * m_snapBackAnimation;
|
||||
static QTimeLine s_snapBackTimeLine;
|
||||
|
||||
TrackItem * m_trackItem;
|
||||
trackContentObject * m_tco;
|
||||
bool m_hover;
|
||||
bool m_hover;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/*
|
||||
* track_item.h
|
||||
*
|
||||
* Created on: Jan 27, 2009
|
||||
* Author: llama
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TRACK_ITEM_H_
|
||||
#define TRACK_ITEM_H_
|
||||
@@ -44,4 +39,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif /* TRACK_ITEM_H_ */
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* lcd_spinbox.h - class lcdSpinBox, an improved QLCDNumber
|
||||
*
|
||||
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2008-2009 Paul Giblock <pgib/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
|
||||
@@ -28,8 +28,17 @@
|
||||
#define _LMMS_STYLE_H
|
||||
|
||||
|
||||
// Defines for widgets
|
||||
#include "fx_mixer_view.h"
|
||||
#include <QColor>
|
||||
#include <QRect>
|
||||
#include "lmms_basics.h"
|
||||
|
||||
class QPainter;
|
||||
class QSize;
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
class LmmsStyleOptionTCO;
|
||||
class trackContentObject;
|
||||
|
||||
|
||||
class LmmsStyle
|
||||
@@ -87,8 +96,32 @@ public:
|
||||
virtual void drawTrackContentBackground(QPainter * _painter,
|
||||
const QSize & _size, const int _pixelsPerTact) = 0;
|
||||
|
||||
virtual void drawTrackContentObject( QPainter * _painter, const trackContentObject * _model,
|
||||
const LmmsStyleOptionTCO * _options ) = 0;
|
||||
|
||||
virtual QColor color(ColorRole _role) const = 0;
|
||||
|
||||
} ;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LmmsStyleOptionTCO
|
||||
{
|
||||
public:
|
||||
enum TcoTypes
|
||||
{
|
||||
BbTco,
|
||||
Pattern,
|
||||
NumTcoTypes
|
||||
};
|
||||
TcoTypes type;
|
||||
|
||||
QRectF rect;
|
||||
bool selected;
|
||||
bool hovered;
|
||||
QColor userColor;
|
||||
tick duration;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void rearrangeAllNotes( void );
|
||||
void clearNotes( void );
|
||||
|
||||
inline const noteVector & notes( void )
|
||||
inline const noteVector & notes( void ) const
|
||||
{
|
||||
return m_notes;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
return "pattern";
|
||||
}
|
||||
|
||||
inline instrumentTrack * getInstrumentTrack( void )
|
||||
inline instrumentTrack * getInstrumentTrack( void ) const
|
||||
{
|
||||
return m_instrumentTrack;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
trackContentObject( track * _track );
|
||||
virtual ~trackContentObject();
|
||||
|
||||
inline track * getTrack( void )
|
||||
inline track * getTrack( void ) const
|
||||
{
|
||||
return( m_track );
|
||||
}
|
||||
|
||||
@@ -33,6 +33,13 @@
|
||||
#include "lmms_style.h"
|
||||
#include "classic_style.h"
|
||||
#include "gui_templates.h"
|
||||
#include "track.h"
|
||||
#include "gui/tracks/track_container_scene.h"
|
||||
#include "embed.h"
|
||||
#include "bb_track.h"
|
||||
#include "pattern.h"
|
||||
#include "instrument_track.h"
|
||||
|
||||
|
||||
|
||||
ClassicStyle::ClassicStyle() :
|
||||
@@ -331,3 +338,279 @@ void ClassicStyle::drawTrackContentBackground(QPainter * _painter,
|
||||
}
|
||||
_painter->drawLine( 0, h-2, w*2, h-2 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ClassicStyle::drawTrackContentObject( QPainter * _painter,
|
||||
const trackContentObject * _model, const LmmsStyleOptionTCO * _option )
|
||||
{
|
||||
QRectF rc = _option->rect.adjusted( 0, 2, 0, -2 );
|
||||
if( const bbTCO * bbTco = dynamic_cast<const bbTCO *>( _model ) )
|
||||
{
|
||||
QColor col( bbTco->color() );
|
||||
|
||||
if( _model->getTrack()->isMuted() || _model->isMuted() )
|
||||
{
|
||||
col = QColor( 160, 160, 160 );
|
||||
}
|
||||
if( _option->selected )
|
||||
{
|
||||
col = QColor( qMax( col.red() - 128, 0 ),
|
||||
qMax( col.green() - 128, 0 ), 255 );
|
||||
}
|
||||
if( _option->hovered )
|
||||
{
|
||||
col = col.light(120);
|
||||
}
|
||||
|
||||
QLinearGradient lingrad( 0, 0, 0, rc.height() );
|
||||
lingrad.setColorAt( 0, col.light( 130 ) );
|
||||
lingrad.setColorAt( 1, col.light( 70 ) );
|
||||
_painter->fillRect( rc, lingrad );
|
||||
|
||||
const float cellW = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
const tick t = _option->duration;
|
||||
if( _model->length() > midiTime::ticksPerTact() && t > 0 )
|
||||
{
|
||||
for( int x = t * cellW; x < rc.width()-2; x += t * cellW )
|
||||
{
|
||||
_painter->setPen( col.light( 80 ) );
|
||||
_painter->drawLine( x, 3, x, 7 );
|
||||
_painter->setPen( col.light( 120 ) );
|
||||
_painter->drawLine( x, rc.height() - 4,
|
||||
x, rc.height() - 0 );
|
||||
}
|
||||
}
|
||||
|
||||
_painter->setPen( col.dark() );
|
||||
_painter->drawRect( rc );
|
||||
|
||||
_painter->setFont( pointSize<7>( _painter->font() ) );
|
||||
_painter->setPen( QColor( 0, 0, 0 ) );
|
||||
_painter->setClipRect( rc );
|
||||
_painter->drawText( QPointF( rc.left(), _painter->fontMetrics().height() + rc.top() ), _model->name() );
|
||||
_painter->setClipping( false );
|
||||
|
||||
if( _model->isMuted() )
|
||||
{
|
||||
_painter->drawPixmap( 3, _painter->fontMetrics().height() + 1,
|
||||
embed::getIconPixmap( "muted", 16, 16 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if( const pattern * pat = dynamic_cast<const pattern *>( _model ) )
|
||||
{
|
||||
QPainter * p = _painter;
|
||||
QLinearGradient lingrad( 0, 0, 0, rc.height() );
|
||||
QColor c = _option->selected ?
|
||||
QColor( 0, 0, 224 ) :
|
||||
QColor( 96, 96, 96 );
|
||||
if( _option->hovered )
|
||||
{
|
||||
c = c.light(120);
|
||||
}
|
||||
lingrad.setColorAt( 0, c );
|
||||
lingrad.setColorAt( 0.5, Qt::black );
|
||||
lingrad.setColorAt( 1, c );
|
||||
p->setBrush( lingrad );
|
||||
p->setPen( QColor( 0, 0, 0 ) );
|
||||
//p.drawRect( 0, 0, width() - 1, height() - 1 );
|
||||
p->drawRect( rc );
|
||||
|
||||
const float ppt = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
const float TCO_BORDER_WIDTH = 1.0f;
|
||||
/*
|
||||
const float ppt;
|
||||
if( fixedTCOs() )
|
||||
{
|
||||
ppt = ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH )
|
||||
/ (float) m_pat->length().getTact();
|
||||
}
|
||||
else
|
||||
{
|
||||
pixelsPerTact();
|
||||
}
|
||||
*/
|
||||
|
||||
const float x_base = TCO_BORDER_WIDTH + rc.top();
|
||||
p->setPen( QColor( 0, 0, 0 ) );
|
||||
|
||||
for( tact t = 1; t < pat->length().getTact(); ++t )
|
||||
{
|
||||
p->drawLine( x_base + static_cast<int>( ppt * t ) - 1,
|
||||
TCO_BORDER_WIDTH, x_base + static_cast<int>(
|
||||
ppt * t ) - 1, 5 );
|
||||
p->drawLine( x_base + static_cast<int>( ppt * t ) - 1,
|
||||
rc.height() - ( 4 + 2 * TCO_BORDER_WIDTH ),
|
||||
x_base + static_cast<int>( ppt * t ) - 1,
|
||||
rc.height() - 2 * TCO_BORDER_WIDTH );
|
||||
}
|
||||
|
||||
if( pat->type() == pattern::MelodyPattern )
|
||||
{
|
||||
int central_key = 0;
|
||||
p->setClipRect( rc.adjusted( 1, 1, -1, -1 ) );
|
||||
if( pat->notes().size() > 0 )
|
||||
{
|
||||
// first determine the central tone so that we can
|
||||
// display the area where most of the notes are
|
||||
int total_notes = 0;
|
||||
for( noteVector::const_iterator it = pat->notes().begin();
|
||||
it != pat->notes().end(); ++it )
|
||||
{
|
||||
if( ( *it )->length() > 0 )
|
||||
{
|
||||
central_key += ( *it )->key();
|
||||
++total_notes;
|
||||
}
|
||||
}
|
||||
|
||||
if( total_notes > 0 )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
central_key = central_key / total_notes;
|
||||
|
||||
const float central_y = rc.height() / 2.0f;
|
||||
float y_base = central_y + TCO_BORDER_WIDTH - 1.0f;
|
||||
|
||||
if( pat->getTrack()->isMuted() ||
|
||||
pat->isMuted() )
|
||||
{
|
||||
p->setPen( color( LmmsStyle::PianoRollMutedNote ) );
|
||||
}
|
||||
else if( pat->frozen() )
|
||||
{
|
||||
p->setPen( color( LmmsStyle::PianoRollFrozenNote ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
p->setPen( color( LmmsStyle::PianoRollDefaultNote ) );
|
||||
}
|
||||
|
||||
for( noteVector::const_iterator it =
|
||||
pat->notes().begin();
|
||||
it != pat->notes().end(); ++it )
|
||||
{
|
||||
const float y_pos = central_key -
|
||||
( *it )->key();
|
||||
|
||||
if( ( *it )->length() > 0 &&
|
||||
y_pos > -central_y &&
|
||||
y_pos < central_y )
|
||||
{
|
||||
const float x1 = 2 * x_base +
|
||||
( *it )->pos() * ppt /
|
||||
midiTime::ticksPerTact();
|
||||
const float x2 =
|
||||
( ( *it )->pos() + ( *it )->length() ) *
|
||||
ppt / midiTime::ticksPerTact();
|
||||
|
||||
p->drawLine( x1, y_base + y_pos,
|
||||
x2, y_base + y_pos );
|
||||
}
|
||||
}
|
||||
|
||||
p->setRenderHint( QPainter::Antialiasing, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
else if( pat->type() == pattern::BeatPattern &&
|
||||
( fixedTCOs() ||
|
||||
ppt >= 96 ||
|
||||
pat->m_steps != midiTime::stepsPerTact() ) )
|
||||
{
|
||||
QPixmap stepon;
|
||||
QPixmap stepoverlay;
|
||||
QPixmap stepoff;
|
||||
QPixmap stepoffl;
|
||||
const int steps = m_pat->length() / DefaultBeatsPerTact;
|
||||
const int w = width() - 2 * TCO_BORDER_WIDTH;
|
||||
stepon = s_stepBtnOn->scaled( w / steps,
|
||||
s_stepBtnOn->height(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
stepoverlay = s_stepBtnOverlay->scaled( w / steps,
|
||||
s_stepBtnOn->height(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
stepoff = s_stepBtnOff->scaled( w / steps,
|
||||
s_stepBtnOff->height(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
stepoffl = s_stepBtnOffLight->scaled( w / steps,
|
||||
s_stepBtnOffLight->height(),
|
||||
Qt::IgnoreAspectRatio,
|
||||
Qt::SmoothTransformation );
|
||||
for( noteVector::iterator it = m_pat->m_notes.begin();
|
||||
it != m_pat->m_notes.end(); ++it )
|
||||
{
|
||||
const int no = ( *it )->pos() / DefaultBeatsPerTact;
|
||||
const int x = TCO_BORDER_WIDTH + static_cast<int>( no *
|
||||
w / steps );
|
||||
const int y = height() - s_stepBtnOff->height() - 1;
|
||||
|
||||
const int vol = ( *it )->getVolume();
|
||||
|
||||
if( ( *it )->length() < 0 )
|
||||
{
|
||||
p.drawPixmap( x, y, stepoff );
|
||||
for( int i = 0; i < vol / 5 + 1; ++i )
|
||||
{
|
||||
p.drawPixmap( x, y, stepon );
|
||||
}
|
||||
for( int i = 0; i < ( 25 + ( vol - 75 ) ) / 5;
|
||||
++i )
|
||||
{
|
||||
p.drawPixmap( x, y, stepoverlay );
|
||||
}
|
||||
}
|
||||
else if( ( no / 4 ) % 2 )
|
||||
{
|
||||
p.drawPixmap( x, y, stepoff );
|
||||
}
|
||||
else
|
||||
{
|
||||
p.drawPixmap( x, y, stepoffl );
|
||||
}
|
||||
}
|
||||
}
|
||||
END BEAT TRACK */
|
||||
|
||||
p->setFont( pointSize<7>( p->font() ) );
|
||||
if( pat->isMuted() || pat->getTrack()->isMuted() )
|
||||
{
|
||||
p->setPen( QColor( 192, 192, 192 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
p->setPen( QColor( 32, 240, 32 ) );
|
||||
}
|
||||
|
||||
if( pat->name() != pat->getInstrumentTrack()->name() )
|
||||
{
|
||||
p->drawText( 2, p->fontMetrics().height() - 1, pat->name() );
|
||||
}
|
||||
|
||||
if( pat->isMuted() )
|
||||
{
|
||||
p->drawPixmap( 3, p->fontMetrics().height() + 1,
|
||||
embed::getIconPixmap( "muted", 16, 16 ) );
|
||||
}
|
||||
else if( pat->frozen() )
|
||||
{
|
||||
p->setBrush( QBrush() );
|
||||
p->setPen( QColor( 0, 224, 255 ) );
|
||||
p->drawRect( rc );
|
||||
/* TODO:
|
||||
p->drawPixmap( rc.left() + 3,
|
||||
rc.top() + height() - s_frozen->height() - 4,
|
||||
*s_frozen );
|
||||
*/
|
||||
}
|
||||
|
||||
p->setClipping( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ const int BUTTON_LENGTH = 24;
|
||||
#include "cusis_style.h"
|
||||
#include "gui_templates.h"
|
||||
|
||||
// For TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
#include "gui/tracks/track_container_scene.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits.h>
|
||||
|
||||
@@ -111,6 +114,94 @@ static const char * const s_scrollbarArrowLeftXpm[] = {
|
||||
|
||||
|
||||
|
||||
QLinearGradient getGradient( const QColor & _col, const QRectF & _rect )
|
||||
{
|
||||
QLinearGradient g( _rect.topLeft(), _rect.bottomLeft() );
|
||||
|
||||
qreal hue = _col.hueF();
|
||||
qreal value = _col.valueF();
|
||||
qreal saturation = _col.saturationF();
|
||||
|
||||
QColor c = _col;
|
||||
c.setHsvF( hue, 0.42 * saturation, 0.98 * value ); // TODO: pattern: 1.08
|
||||
g.setColorAt( 0, c );
|
||||
c.setHsvF( hue, 0.58 * saturation, 0.95 * value ); // TODO: pattern: 1.05
|
||||
g.setColorAt( 0.25, c );
|
||||
c.setHsvF( hue, 0.70 * saturation, 0.93 * value ); // TODO: pattern: 1.03
|
||||
g.setColorAt( 0.5, c );
|
||||
|
||||
c.setHsvF( hue, 0.95 * saturation, 0.9 * value );
|
||||
g.setColorAt( 0.501, c );
|
||||
c.setHsvF( hue * 0.95, 0.95 * saturation, 0.95 * value );
|
||||
g.setColorAt( 0.75, c );
|
||||
c.setHsvF( hue * 0.90, 0.95 * saturation, 1 * value );
|
||||
g.setColorAt( 1.0, c );
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QLinearGradient darken( const QLinearGradient & _gradient )
|
||||
{
|
||||
QGradientStops stops = _gradient.stops();
|
||||
for (int i = 0; i < stops.size(); ++i) {
|
||||
QColor color = stops.at(i).second;
|
||||
stops[i].second = color.lighter(150);
|
||||
}
|
||||
|
||||
QLinearGradient g = _gradient;
|
||||
g.setStops(stops);
|
||||
return g;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void drawPath( QPainter *p, const QPainterPath &path,
|
||||
const QColor &col, const QColor &borderCol,
|
||||
bool dark = false )
|
||||
{
|
||||
const QRectF pathRect = path.boundingRect();
|
||||
|
||||
const QLinearGradient baseGradient = getGradient(col, pathRect);
|
||||
const QLinearGradient darkGradient = darken(baseGradient);
|
||||
|
||||
p->setOpacity(0.25);
|
||||
|
||||
// glow
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(darkGradient, 4));
|
||||
else
|
||||
p->strokePath(path, QPen(baseGradient, 4));
|
||||
|
||||
p->setOpacity(1.0);
|
||||
|
||||
// fill
|
||||
if (dark)
|
||||
p->fillPath(path, darkGradient);
|
||||
else
|
||||
p->fillPath(path, baseGradient);
|
||||
|
||||
// TODO: Remove??
|
||||
/*
|
||||
QLinearGradient g(pathRect.topLeft(), pathRect.topRight());
|
||||
g.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
|
||||
p->setOpacity(0.2);
|
||||
p->fillPath(path, g);*/
|
||||
// END: Remove??
|
||||
|
||||
p->setOpacity(0.5);
|
||||
|
||||
// highlight (bb)
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(borderCol.lighter(150), 2));
|
||||
else
|
||||
p->strokePath(path, QPen(borderCol, 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static QString getCacheKey( const QString & _key,
|
||||
const QStyleOption * _option, const QSize & _size )
|
||||
{
|
||||
@@ -129,6 +220,21 @@ static QString getCacheKey( const QString & _key,
|
||||
}
|
||||
|
||||
|
||||
static QString getTcoCacheKey( const QString & _key,
|
||||
const LmmsStyleOptionTCO * _option )
|
||||
{
|
||||
QString tmp;
|
||||
tmp.sprintf( "%s,%d,%d,%d,%s,%.3fx%.3f",
|
||||
_key.toLatin1().constData(),
|
||||
_option->type,
|
||||
_option->selected,
|
||||
_option->hovered,
|
||||
_option->userColor.name().constData(),
|
||||
_option->rect.width(),
|
||||
_option->rect.height() );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
CusisStyle::CusisStyle() :
|
||||
QPlastiqueStyle(), LmmsStyle()
|
||||
@@ -798,6 +904,74 @@ void CusisStyle::drawTrackContentBackground( QPainter * _painter, const QSize &
|
||||
|
||||
|
||||
|
||||
void CusisStyle::drawTrackContentObject( QPainter * _painter,
|
||||
const trackContentObject * _model, const LmmsStyleOptionTCO * _option )
|
||||
{
|
||||
QString pixmapName = getTcoCacheKey( "tco", _option );
|
||||
QPixmap cache;
|
||||
|
||||
if( !QPixmapCache::find( pixmapName, cache ) )
|
||||
{
|
||||
printf("Creating pixmap\n");
|
||||
const QRectF & rc = _option->rect;
|
||||
|
||||
// TODO: Consider matrix m11 and m22 for scaling the pixmap
|
||||
cache = QPixmap( rc.width(), rc.height() );
|
||||
cache.fill( Qt::transparent );
|
||||
QPainter painter( &cache );
|
||||
|
||||
QColor col;
|
||||
if( !_option->selected )
|
||||
{
|
||||
col = QColor( 0x00, 0x33, 0x99 );
|
||||
}
|
||||
else
|
||||
{
|
||||
col = QColor( 0x00, 0x99, 0x33 );
|
||||
}
|
||||
|
||||
QColor colBorder = col.lighter(160);
|
||||
QColor col0;
|
||||
if( _option->type == LmmsStyleOptionTCO::BbTco )
|
||||
col0 = col;
|
||||
else
|
||||
col0 = col.darker(400);
|
||||
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect( 2, 2, rc.width()-4, rc.height()-4, 4, 4 );
|
||||
drawPath( &painter, path, col0, colBorder, _option->hovered );
|
||||
|
||||
const float cellW = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
const tick t = _option->duration;
|
||||
|
||||
if( _model->length() > midiTime::ticksPerTact() && t > 0 )
|
||||
{
|
||||
painter.setOpacity(0.2);
|
||||
painter.setRenderHint( QPainter::Antialiasing, false );
|
||||
painter.setPen( QColor(0, 0, 0) );
|
||||
|
||||
for( float x = t * cellW; x < rc.width()-2; x += t * cellW )
|
||||
{
|
||||
painter.drawLine(x, 3, x, rc.height()-5);
|
||||
}
|
||||
|
||||
painter.translate( 1, 0 );
|
||||
painter.setPen( col.lighter(160) );
|
||||
for( float x = t * cellW; x < rc.width()-2; x += t * cellW )
|
||||
{
|
||||
painter.drawLine(x, 2, x, rc.height()-5);
|
||||
}
|
||||
}
|
||||
|
||||
QPixmapCache::insert( pixmapName, cache );
|
||||
}
|
||||
_painter->drawPixmap( 0, 0, cache );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QColor CusisStyle::color( LmmsStyle::ColorRole _role ) const
|
||||
{
|
||||
return m_colors[_role];
|
||||
|
||||
@@ -314,6 +314,7 @@ mainWindow::mainWindow( void ) :
|
||||
//view->scale(2.0, 1.0);
|
||||
|
||||
QMdiSubWindow * subWin = workspace()->addSubWindow( view );
|
||||
|
||||
/// END HACK TO CREATE EXTRA SONG EDITOR FOR NOW ///
|
||||
|
||||
|
||||
|
||||
@@ -8,175 +8,77 @@
|
||||
#include "gui/tracks/track_content_object_item.h"
|
||||
#include "gui/tracks/track_container_scene.h"
|
||||
#include "gui/tracks/track_item.h"
|
||||
#include "lmms_style.h"
|
||||
#include "bb_track.h"
|
||||
#include "bb_track_container.h"
|
||||
#include "track.h"
|
||||
#include "engine.h"
|
||||
|
||||
// Just some stuff while playing with theming ideas,
|
||||
// will be moved to lmmsStyle
|
||||
namespace BBTcoStuff {
|
||||
QLinearGradient getGradient( const QColor & _col, const QRectF & _rect )
|
||||
{
|
||||
QLinearGradient g( _rect.topLeft(), _rect.bottomLeft() );
|
||||
|
||||
qreal hue = _col.hueF();
|
||||
qreal value = _col.valueF();
|
||||
qreal saturation = _col.saturationF();
|
||||
|
||||
QColor c = _col;
|
||||
c.setHsvF( hue, 0.42 * saturation, 0.98 * value );
|
||||
g.setColorAt( 0, c );
|
||||
c.setHsvF( hue, 0.58 * saturation, 0.95 * value );
|
||||
g.setColorAt( 0.25, c );
|
||||
c.setHsvF( hue, 0.70 * saturation, 0.93 * value );
|
||||
g.setColorAt( 0.5, c );
|
||||
|
||||
c.setHsvF( hue, 0.95 * saturation, 0.9 * value );
|
||||
g.setColorAt( 0.501, c );
|
||||
c.setHsvF( hue * 0.95, 0.95 * saturation, 0.95 * value );
|
||||
g.setColorAt( 0.75, c );
|
||||
c.setHsvF( hue * 0.90, 0.95 * saturation, 1 * value );
|
||||
g.setColorAt( 1.0, c );
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
QLinearGradient darken( const QLinearGradient & _gradient )
|
||||
{
|
||||
QGradientStops stops = _gradient.stops();
|
||||
for (int i = 0; i < stops.size(); ++i) {
|
||||
QColor color = stops.at(i).second;
|
||||
stops[i].second = color.lighter(150);
|
||||
}
|
||||
|
||||
QLinearGradient g = _gradient;
|
||||
g.setStops(stops);
|
||||
return g;
|
||||
}
|
||||
|
||||
void drawPath( QPainter *p, const QPainterPath &path,
|
||||
const QColor &col, const QString &name,
|
||||
bool dark = false )
|
||||
{
|
||||
const QRectF pathRect = path.boundingRect();
|
||||
|
||||
const QLinearGradient baseGradient = getGradient(col, pathRect);
|
||||
const QLinearGradient darkGradient = darken(baseGradient);
|
||||
|
||||
p->setOpacity(0.25);
|
||||
|
||||
// glow
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(darkGradient, 4));
|
||||
else
|
||||
p->strokePath(path, QPen(baseGradient, 4));
|
||||
|
||||
p->setOpacity(1.0);
|
||||
|
||||
// fill
|
||||
if (dark)
|
||||
p->fillPath(path, darkGradient);
|
||||
else
|
||||
p->fillPath(path, baseGradient);
|
||||
|
||||
QLinearGradient g(pathRect.topLeft(), pathRect.topRight());
|
||||
g.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
|
||||
p->setOpacity(0.2);
|
||||
p->fillPath(path, g);
|
||||
|
||||
p->setOpacity(0.5);
|
||||
|
||||
// highlight
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(col.lighter(160).lighter(160), 2));
|
||||
else
|
||||
p->strokePath(path, QPen(col.lighter(160), 2));
|
||||
|
||||
}
|
||||
}
|
||||
using namespace BBTcoStuff;
|
||||
|
||||
BbTrackContentObjectItem::BbTrackContentObjectItem( TrackItem * _track, trackContentObject * _object ) :
|
||||
TrackContentObjectItem( _track, _object )
|
||||
BbTrackContentObjectItem::BbTrackContentObjectItem(
|
||||
TrackItem * _track,
|
||||
trackContentObject * _object ) :
|
||||
TrackContentObjectItem( _track, _object )
|
||||
{
|
||||
}
|
||||
|
||||
void BbTrackContentObjectItem::paint( QPainter * _painter,
|
||||
const QStyleOptionGraphicsItem * _option, QWidget * _widget )
|
||||
|
||||
|
||||
void BbTrackContentObjectItem::paint(
|
||||
QPainter * _painter,
|
||||
const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget )
|
||||
{
|
||||
|
||||
QColor col;
|
||||
if( !isSelected() )
|
||||
{
|
||||
col = QColor( 0x00, 0x33, 0x99 );
|
||||
}
|
||||
else
|
||||
{
|
||||
col = QColor( 0x00, 0x99, 0x33 );
|
||||
}
|
||||
|
||||
QRectF rc = boundingRect();
|
||||
|
||||
qreal xscale = _option->matrix.m11();
|
||||
qreal xscale = _option->matrix.m11();
|
||||
_painter->save();
|
||||
_painter->scale( 1.0f/xscale, 1.0f );
|
||||
rc.setWidth( rc.width() * xscale );
|
||||
_painter->scale( 1.0f/xscale, 1.0f );
|
||||
rc.setWidth( rc.width() * xscale );
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(2, 2, rc.width()-4, rc.height()-4, 4, 4);
|
||||
drawPath( _painter, path, col, "hah", m_hover );
|
||||
// TODO: Use a proxy class
|
||||
LmmsStyleOptionTCO * options = new LmmsStyleOptionTCO();
|
||||
options->type = LmmsStyleOptionTCO::BbTco;
|
||||
options->rect = rc;
|
||||
options->selected = isSelected();
|
||||
options->hovered = m_hover;
|
||||
|
||||
const float cellW = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
bbTCO * bbTco = (bbTCO*)m_tco;
|
||||
int trackNum = bbTrack::numOfBBTrack( bbTco->getTrack() );
|
||||
options->duration = engine::getBBTrackContainer()->lengthOfBB( trackNum );
|
||||
|
||||
bbTCO * bbTco = (bbTCO*)m_tco;
|
||||
tact t = engine::getBBTrackContainer()->lengthOfBB(
|
||||
bbTrack::numOfBBTrack( bbTco->getTrack() ) );
|
||||
engine::getLmmsStyle()->drawTrackContentObject( _painter, m_tco, options );
|
||||
|
||||
if( bbTco->length() > midiTime::ticksPerTact() && t > 0 )
|
||||
{
|
||||
_painter->setOpacity(0.2);
|
||||
_painter->setRenderHint( QPainter::Antialiasing, false );
|
||||
_painter->setPen( QColor(0, 0, 0) );
|
||||
|
||||
for( float x = t * cellW; x < rc.width()-2; x += t * cellW )
|
||||
{
|
||||
_painter->drawLine(x, 3, x, rc.height()-5);
|
||||
}
|
||||
|
||||
_painter->translate( 1, 0 );
|
||||
_painter->setPen( col.lighter(160) );
|
||||
for( float x = t * cellW; x < rc.width()-2; x += t * cellW )
|
||||
{
|
||||
_painter->drawLine(x, 2, x, rc.height()-5);
|
||||
}
|
||||
|
||||
_painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
}
|
||||
|
||||
_painter->restore();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant BbTrackContentObjectItem::itemChange( GraphicsItemChange _change, const QVariant & _value )
|
||||
{
|
||||
return TrackContentObjectItem::itemChange( _change, _value );
|
||||
}
|
||||
|
||||
|
||||
void BbTrackContentObjectItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
TrackContentObjectItem::mousePressEvent( event );
|
||||
_painter->restore();
|
||||
delete options;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BbTrackContentObjectItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
|
||||
QVariant BbTrackContentObjectItem::itemChange(
|
||||
GraphicsItemChange _change,
|
||||
const QVariant & _value )
|
||||
{
|
||||
TrackContentObjectItem::mouseReleaseEvent( event );
|
||||
}
|
||||
|
||||
return TrackContentObjectItem::itemChange( _change, _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BbTrackContentObjectItem::mousePressEvent(
|
||||
QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
TrackContentObjectItem::mousePressEvent( event );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BbTrackContentObjectItem::mouseReleaseEvent(
|
||||
QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
TrackContentObjectItem::mouseReleaseEvent( event );
|
||||
}
|
||||
|
||||
|
||||
#include "gui/tracks/moc_bb_tco_item.cxx"
|
||||
|
||||
@@ -8,166 +8,57 @@
|
||||
#include "gui/tracks/track_content_object_item.h"
|
||||
#include "gui/tracks/track_container_scene.h"
|
||||
#include "gui/tracks/track_item.h"
|
||||
#include "engine.h"
|
||||
#include "lmms_style.h"
|
||||
#include "track.h"
|
||||
|
||||
// Just some stuff while playing with theming ideas,
|
||||
// will be moved to lmmsStyle
|
||||
namespace PatternItemStuff {
|
||||
QLinearGradient getGradient( const QColor & _col, const QRectF & _rect )
|
||||
{
|
||||
QLinearGradient g( _rect.topLeft(), _rect.bottomLeft() );
|
||||
|
||||
qreal hue = _col.hueF();
|
||||
qreal value = _col.valueF();
|
||||
qreal saturation = _col.saturationF();
|
||||
|
||||
QColor c = _col;
|
||||
c.setHsvF( hue, 0.42 * saturation, 1.08 * value );
|
||||
g.setColorAt( 0, c );
|
||||
c.setHsvF( hue, 0.58 * saturation, 1.05 * value );
|
||||
g.setColorAt( 0.25, c );
|
||||
c.setHsvF( hue, 0.70 * saturation, 1.03 * value );
|
||||
g.setColorAt( 0.5, c );
|
||||
|
||||
c.setHsvF( hue, 0.95 * saturation, 0.9 * value );
|
||||
g.setColorAt( 0.501, c );
|
||||
c.setHsvF( hue * 0.95, 0.95 * saturation, 0.95 * value );
|
||||
g.setColorAt( 0.75, c );
|
||||
c.setHsvF( hue * 0.90, 0.95 * saturation, 1 * value );
|
||||
g.setColorAt( 1.0, c );
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
QLinearGradient darken( const QLinearGradient & _gradient )
|
||||
{
|
||||
QGradientStops stops = _gradient.stops();
|
||||
for (int i = 0; i < stops.size(); ++i) {
|
||||
QColor color = stops.at(i).second;
|
||||
stops[i].second = color.lighter(150);
|
||||
}
|
||||
|
||||
QLinearGradient g = _gradient;
|
||||
g.setStops(stops);
|
||||
return g;
|
||||
}
|
||||
|
||||
void drawPath( QPainter *p, const QPainterPath &path,
|
||||
const QColor &col, const QColor &borderCol,
|
||||
bool dark = false )
|
||||
{
|
||||
const QRectF pathRect = path.boundingRect();
|
||||
|
||||
const QLinearGradient baseGradient = getGradient(col, pathRect);
|
||||
const QLinearGradient darkGradient = darken(baseGradient);
|
||||
|
||||
p->setOpacity(0.25);
|
||||
|
||||
// glow
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(darkGradient, 4));
|
||||
else
|
||||
p->strokePath(path, QPen(baseGradient, 4));
|
||||
|
||||
p->setOpacity(1.0);
|
||||
|
||||
// fill
|
||||
if (dark)
|
||||
p->fillPath(path, darkGradient);
|
||||
else
|
||||
p->fillPath(path, baseGradient);
|
||||
|
||||
/*
|
||||
QLinearGradient g(pathRect.topLeft(), pathRect.topRight());
|
||||
g.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
|
||||
p->setOpacity(0.2);
|
||||
p->fillPath(path, g);
|
||||
*/
|
||||
p->setOpacity(0.5);
|
||||
|
||||
// highlight
|
||||
if (dark)
|
||||
p->strokePath(path, QPen(borderCol.lighter(150), 2));
|
||||
else
|
||||
p->strokePath(path, QPen(borderCol, 2));
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
using namespace PatternItemStuff;
|
||||
|
||||
|
||||
PatternItem::PatternItem( TrackItem * _track, trackContentObject * _object ) :
|
||||
TrackContentObjectItem( _track, _object )
|
||||
TrackContentObjectItem( _track, _object )
|
||||
{
|
||||
}
|
||||
|
||||
void PatternItem::paint( QPainter * _painter,
|
||||
const QStyleOptionGraphicsItem * _option, QWidget * _widget )
|
||||
void PatternItem::paint(
|
||||
QPainter * _painter,
|
||||
const QStyleOptionGraphicsItem * _option,
|
||||
QWidget * _widget )
|
||||
{
|
||||
|
||||
QColor col;
|
||||
if( !isSelected() )
|
||||
{
|
||||
col = QColor( 0x00, 0x33, 0x99 );
|
||||
}
|
||||
else
|
||||
{
|
||||
col = QColor( 0x00, 0x99, 0x33 );
|
||||
}
|
||||
QColor colBorder = col.lighter(160);
|
||||
QColor col0 = col.darker(400);
|
||||
|
||||
QRectF rc = boundingRect();
|
||||
|
||||
qreal xscale = _option->matrix.m11();
|
||||
qreal xscale = _option->matrix.m11();
|
||||
_painter->save();
|
||||
_painter->scale( 1.0f/xscale, 1.0f );
|
||||
rc.setWidth( rc.width() * xscale );
|
||||
_painter->scale( 1.0f/xscale, 1.0f );
|
||||
rc.setWidth( rc.width() * xscale );
|
||||
|
||||
QPainterPath path;
|
||||
path.addRoundedRect(2, 2, rc.width()-4, rc.height()-4, 4, 4);
|
||||
drawPath( _painter, path, col0, colBorder, m_hover );
|
||||
// TODO: Use a proxy class
|
||||
LmmsStyleOptionTCO * options = new LmmsStyleOptionTCO();
|
||||
options->type = LmmsStyleOptionTCO::Pattern;
|
||||
options->rect = rc;
|
||||
options->selected = isSelected();
|
||||
options->hovered = m_hover;
|
||||
options->duration = 0;
|
||||
|
||||
_painter->restore();
|
||||
|
||||
return;
|
||||
|
||||
QColor col0a = col.darker( 300 );
|
||||
QColor col1 = col.light( 70 );
|
||||
QColor col2 = col.light( 40 );
|
||||
|
||||
QLinearGradient lingrad( 0, 0, 0, rc.height() );
|
||||
lingrad.setColorAt( 0, col0 );
|
||||
lingrad.setColorAt( 1, col0a );
|
||||
|
||||
QLinearGradient bordergrad( 0, 0, 0, rc.height() );
|
||||
bordergrad.setColorAt( 1, col2 );
|
||||
bordergrad.setColorAt( 0, col1 );
|
||||
|
||||
|
||||
rc.adjust( 0, 0, -1, -1 );
|
||||
|
||||
|
||||
_painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
_painter->setBrush( lingrad );
|
||||
_painter->setPen( QPen( bordergrad, 1.5 ) ); // QColor( 6, 6, 6 ) );
|
||||
_painter->drawRoundedRect( rc, 4, 4 );
|
||||
_painter->setRenderHint( QPainter::Antialiasing, false );
|
||||
engine::getLmmsStyle()->drawTrackContentObject( _painter, m_tco, options );
|
||||
|
||||
_painter->restore();
|
||||
delete options;
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant PatternItem::itemChange( GraphicsItemChange _change, const QVariant & _value )
|
||||
|
||||
|
||||
/*
|
||||
QVariant PatternItem::itemChange( QGraphicsItemChange _change, const QVariant & _value )
|
||||
{
|
||||
return TrackContentObjectItem::itemChange( _change, _value );
|
||||
}
|
||||
return TrackContentObjectItem::itemChange( _change, _value );
|
||||
}*/
|
||||
|
||||
|
||||
void PatternItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
TrackContentObjectItem::mousePressEvent( event );
|
||||
TrackContentObjectItem::mousePressEvent( event );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,18 +10,16 @@
|
||||
#include "track_container.h"
|
||||
|
||||
TrackContainerScene::TrackContainerScene( QObject * parent, trackContainer * _tc ) :
|
||||
QGraphicsScene( parent ),
|
||||
//modelView( NULL, this ),
|
||||
//journallingObject(),
|
||||
//serializingObjectHook(),
|
||||
m_trackContainer( _tc ),
|
||||
m_ppt( 16 )
|
||||
QGraphicsScene( parent ),
|
||||
m_trackContainer( _tc ),
|
||||
m_ppt( 16 )
|
||||
{
|
||||
connect( m_trackContainer, SIGNAL( trackAdded( track * ) ),
|
||||
this, SLOT( addTrack( track * ) ),
|
||||
Qt::QueuedConnection );
|
||||
connect( m_trackContainer, SIGNAL( trackRemoved( track * ) ),
|
||||
this, SLOT( removeTrack( track * ) ) );
|
||||
this, SLOT( addTrack( track * ) ),
|
||||
Qt::QueuedConnection );
|
||||
|
||||
connect( m_trackContainer, SIGNAL( trackRemoved( track * ) ),
|
||||
this, SLOT( removeTrack( track * ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -51,23 +49,22 @@ void TrackContainerScene::addTrack( track * _t )
|
||||
|
||||
void TrackContainerScene::removeTrack( track * _t )
|
||||
{
|
||||
QMap<track*, TrackItem*>::iterator i =
|
||||
m_trackItems.find( _t );
|
||||
QMap<track*, TrackItem*>::iterator i = m_trackItems.find( _t );
|
||||
|
||||
if( i != m_trackItems.end() && i.key() == _t )
|
||||
{
|
||||
TrackItem * item = i.value();
|
||||
qreal h = item->height();
|
||||
qreal h = item->height();
|
||||
|
||||
i = m_trackItems.erase(i);
|
||||
delete item;
|
||||
|
||||
// Now move everything after back up
|
||||
while( i != m_trackItems.end() )
|
||||
{
|
||||
(*i)->setY( (*i)->y() - h );
|
||||
++i;
|
||||
}
|
||||
// Now move everything after back up
|
||||
while( i != m_trackItems.end() )
|
||||
{
|
||||
(*i)->setY( (*i)->y() - h );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,44 +72,41 @@ void TrackContainerScene::removeTrack( track * _t )
|
||||
|
||||
void TrackContainerScene::keyPressEvent( QKeyEvent * event )
|
||||
{
|
||||
if( event->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
const qreal cellWidth = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
if( event->modifiers() == Qt::ShiftModifier )
|
||||
{
|
||||
const qreal cellWidth = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
|
||||
if( event->key() == Qt::Key_Left )
|
||||
{
|
||||
}
|
||||
else if( event->key() == Qt::Key_Right )
|
||||
{
|
||||
QTimeLine * timeLine = new QTimeLine();
|
||||
if( event->key() == Qt::Key_Left )
|
||||
{
|
||||
}
|
||||
else if( event->key() == Qt::Key_Right )
|
||||
{
|
||||
QTimeLine * timeLine = new QTimeLine();
|
||||
|
||||
// TODO: Cleanup the friendly references
|
||||
QList<QGraphicsItem*> selItems = selectedItems();
|
||||
for( QList<QGraphicsItem *>::iterator it = selItems.begin();
|
||||
it != selItems.end(); ++it )
|
||||
{
|
||||
TrackContentObjectItem * tcoItem =
|
||||
dynamic_cast<TrackContentObjectItem*>( *it );
|
||||
if( tcoItem )
|
||||
{
|
||||
qreal destPos = tcoItem->m_snapBackAnimation->posAt( 1.0 ).x();
|
||||
tcoItem->prepareSnapBackAnimation( timeLine, destPos + cellWidth );
|
||||
}
|
||||
}
|
||||
// TODO: Cleanup the friendly references
|
||||
QList<QGraphicsItem*> selItems = selectedItems();
|
||||
for( QList<QGraphicsItem *>::iterator it = selItems.begin();
|
||||
it != selItems.end(); ++it )
|
||||
{
|
||||
TrackContentObjectItem * tcoItem =
|
||||
dynamic_cast<TrackContentObjectItem*>( *it );
|
||||
if( tcoItem )
|
||||
{
|
||||
qreal destPos = tcoItem->m_snapBackAnimation->posAt( 1.0 ).x();
|
||||
tcoItem->prepareSnapBackAnimation( timeLine, destPos + cellWidth );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
timeLine->setCurrentTime( 0.0f );
|
||||
timeLine->setDuration( 300 );
|
||||
timeLine->setCurveShape( QTimeLine::EaseInOutCurve );
|
||||
connect( timeLine, SIGNAL(finished()), timeLine, SLOT(deleteLater()));
|
||||
timeLine->start();
|
||||
}
|
||||
}
|
||||
timeLine->setCurrentTime( 0.0f );
|
||||
timeLine->setDuration( 300 );
|
||||
timeLine->setCurveShape( QTimeLine::EaseInOutCurve );
|
||||
connect( timeLine, SIGNAL(finished()), timeLine, SLOT(deleteLater()));
|
||||
timeLine->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "gui/tracks/moc_track_container_scene.cxx"
|
||||
|
||||
|
||||
@@ -10,110 +10,103 @@
|
||||
#include "track.h"
|
||||
|
||||
|
||||
TrackContentObjectItem::TrackContentObjectItem( TrackItem * _track, trackContentObject * _object ) :
|
||||
QObject(),
|
||||
QGraphicsItem(),
|
||||
m_trackItem( _track ),
|
||||
m_tco( _object ),
|
||||
m_snapBackAnimation( NULL ),
|
||||
m_hover( false )
|
||||
TrackContentObjectItem::TrackContentObjectItem(
|
||||
TrackItem * _track,
|
||||
trackContentObject * _object ) :
|
||||
QObject(),
|
||||
QGraphicsItem(),
|
||||
m_trackItem( _track ),
|
||||
m_tco( _object ),
|
||||
m_snapBackAnimation( NULL ),
|
||||
m_hover( false )
|
||||
{
|
||||
//m_object = _object;
|
||||
setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
|
||||
setAcceptHoverEvents( true );
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
setAcceptHoverEvents( true );
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
|
||||
// TODO: We will do our own caching to allow common-TCOs to share pixmaps
|
||||
// But this works for now
|
||||
setCacheMode( QGraphicsItem::DeviceCoordinateCache );
|
||||
updateLength();
|
||||
updatePosition();
|
||||
|
||||
midiTime startPos = _object->startPosition();
|
||||
float x = TrackContainerScene::DEFAULT_CELL_WIDTH *
|
||||
startPos.getTicks() / midiTime::ticksPerTact();
|
||||
setPos( x, _track->y() );
|
||||
setZValue(x);
|
||||
m_snapBackAnimation = new QGraphicsItemAnimation();
|
||||
m_snapBackAnimation->setItem( this );
|
||||
|
||||
|
||||
connect( m_tco, SIGNAL( lengthChanged( void ) ),
|
||||
this, SLOT( updateLength( void ) ), Qt::QueuedConnection );
|
||||
|
||||
connect( m_tco, SIGNAL( positionChanged( void ) ),
|
||||
this, SLOT( updatePosition( void ) ), Qt::QueuedConnection );
|
||||
|
||||
m_snapBackAnimation = new QGraphicsItemAnimation();
|
||||
m_snapBackAnimation->setItem( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::updateLength( void )
|
||||
{
|
||||
// TODO: only change if different?
|
||||
prepareGeometryChange();
|
||||
m_length = m_tco->length().getTicks() / midiTime::ticksPerTact();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::updatePosition( void )
|
||||
{
|
||||
midiTime startPos = m_tco->startPosition();
|
||||
float x = TrackContainerScene::DEFAULT_CELL_WIDTH *
|
||||
startPos.getTicks() / midiTime::ticksPerTact();
|
||||
setPos( x, m_trackItem->y() );
|
||||
setZValue(x);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QRectF TrackContentObjectItem::boundingRect() const
|
||||
{
|
||||
qreal penWidth = 1;
|
||||
// Must not call tco->length directly since boundingRect must
|
||||
// not change until after a call to prepareGeometryChange()
|
||||
// TODO: Calculate based on track length and an adjustable height.
|
||||
/*return QRectF( -64 - penWidth / 2, -16 - penWidth / 2,
|
||||
128 + penWidth / 2, 32 + penWidth / 2 );*/
|
||||
QRectF rc = QRectF( 0, 0, TrackContainerScene::DEFAULT_CELL_WIDTH *
|
||||
m_tco->length().getTicks() / midiTime::ticksPerTact(), m_trackItem->height() );
|
||||
return rc;
|
||||
QRectF rc = QRectF( 0, 0, TrackContainerScene::DEFAULT_CELL_WIDTH *
|
||||
m_length,
|
||||
m_trackItem->height() );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
qreal TrackContentObjectItem::zValue() const
|
||||
{
|
||||
//return x();
|
||||
//return m_tco->startPotion().getTicks();
|
||||
return QGraphicsItem::zValue();
|
||||
return QGraphicsItem::zValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::updateGeometry()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
prepareGeometryChange();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::paint( QPainter * _painter,
|
||||
const QStyleOptionGraphicsItem * _option, QWidget * _widget )
|
||||
{
|
||||
|
||||
QColor col;
|
||||
if( !isSelected() )
|
||||
{
|
||||
col = QColor( 0x00, 0x33, 0x99 );
|
||||
}
|
||||
else
|
||||
{
|
||||
col = QColor( 0x99, 0x33, 0x00 );
|
||||
}
|
||||
QColor col0 = col.light( 130 );
|
||||
QColor col1 = col.light( 70 );
|
||||
QColor col2 = col.light( 40 );
|
||||
|
||||
QRectF rc = boundingRect();
|
||||
|
||||
qreal xscale = _option->matrix.m11();
|
||||
_painter->save();
|
||||
_painter->scale( 1.0f/xscale, 1.0f );
|
||||
rc.setWidth( rc.width() * xscale );
|
||||
|
||||
QLinearGradient lingrad( 0, 0, 0, rc.height() );
|
||||
lingrad.setColorAt( 0, col0 );
|
||||
lingrad.setColorAt( 1, col1 );
|
||||
|
||||
QLinearGradient bordergrad( 0, 0, 0, rc.height() );
|
||||
bordergrad.setColorAt( 1, col2 );
|
||||
bordergrad.setColorAt( 0, col1 );
|
||||
|
||||
|
||||
rc.adjust( 0, 0, -1, -1 );
|
||||
|
||||
|
||||
_painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
_painter->setBrush( lingrad );
|
||||
_painter->setPen( QPen( bordergrad, 1.5 ) ); // QColor( 6, 6, 6 ) );
|
||||
_painter->drawRoundedRect( rc, 4, 4 );
|
||||
_painter->setRenderHint( QPainter::Antialiasing, false );
|
||||
|
||||
_painter->restore();
|
||||
}
|
||||
|
||||
QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, const QVariant & _value )
|
||||
|
||||
|
||||
QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change,
|
||||
const QVariant & _value )
|
||||
{
|
||||
if( _change == ItemPositionChange && scene( ) )
|
||||
{
|
||||
// value is the new position
|
||||
QPointF newPos = _value.toPointF( );
|
||||
|
||||
//printf("TCO %lld: itemChange (%.2f %.2f) -> ", m_tco, newPos.x(), newPos.y());
|
||||
//printf("TCO %lld: itemChange (%.2f %.2f) -> ", m_tco, newPos.x(), newPos.y());
|
||||
|
||||
if( newPos.x() < 0 )
|
||||
{
|
||||
@@ -124,106 +117,107 @@ QVariant TrackContentObjectItem::itemChange( GraphicsItemChange _change, const Q
|
||||
newPos.setY( 0 );
|
||||
}
|
||||
|
||||
/* Let's just short-circuit the Y for now
|
||||
/* Let's just short-circuit the Y for now
|
||||
if( fmod( newPos.y(), 32 ) != 16 )
|
||||
{
|
||||
newPos.setY( newPos.y() + 16 - ( fmod( newPos.y(), 32 ) ) );
|
||||
} */
|
||||
newPos.setY( m_trackItem->y() );
|
||||
newPos.setY( m_trackItem->y() );
|
||||
|
||||
/*
|
||||
if( fmod( newPos.x(), 16 ) != 0 )
|
||||
/*
|
||||
if( fmod( newPos.x(), 16 ) != 0 )
|
||||
{
|
||||
newPos.setX( newPos.x() - ( fmod( newPos.x(), 16 ) ) );
|
||||
}
|
||||
|
||||
if( newPos.x() != x() ) {
|
||||
setZValue(newPos.x());
|
||||
}*/
|
||||
|
||||
if( newPos.x() != x() ) {
|
||||
setZValue(newPos.x());
|
||||
}*/
|
||||
|
||||
//printf("(%.2f %.2f)\n", newPos.x(), newPos.y());
|
||||
|
||||
//printf("(%.2f %.2f)\n", newPos.x(), newPos.y());
|
||||
|
||||
|
||||
return newPos;
|
||||
}
|
||||
else if( _change == QGraphicsItem::ItemSelectedChange && scene() )
|
||||
{
|
||||
bool sel = _value.toBool();
|
||||
if( sel )
|
||||
{
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
else
|
||||
{
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
update();
|
||||
}
|
||||
else if( _change == QGraphicsItem::ItemSelectedChange && scene() )
|
||||
{
|
||||
bool sel = _value.toBool();
|
||||
if( sel )
|
||||
{
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
else
|
||||
{
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
return QGraphicsItem::itemChange( _change, _value );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::mousePressEvent( QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
QGraphicsItem::mousePressEvent( event );
|
||||
QGraphicsItem::mousePressEvent( event );
|
||||
|
||||
if( isSelected() )
|
||||
{
|
||||
setCursor( Qt::ClosedHandCursor );
|
||||
}
|
||||
if( isSelected() )
|
||||
{
|
||||
setCursor( Qt::ClosedHandCursor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event )
|
||||
{
|
||||
QGraphicsItem::mouseReleaseEvent( event );
|
||||
QGraphicsItem::mouseReleaseEvent( event );
|
||||
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
setCursor( Qt::OpenHandCursor );
|
||||
|
||||
QTimeLine * timeLine = new QTimeLine();
|
||||
prepareSnapBackAnimation( timeLine );
|
||||
QTimeLine * timeLine = new QTimeLine();
|
||||
prepareSnapBackAnimation( timeLine );
|
||||
|
||||
if( isSelected() ) {
|
||||
QList<QGraphicsItem*> selItems = scene()->selectedItems();
|
||||
for( QList<QGraphicsItem *>::iterator it = selItems.begin();
|
||||
it != selItems.end(); ++it )
|
||||
{
|
||||
TrackContentObjectItem * tcoItem =
|
||||
dynamic_cast<TrackContentObjectItem*>( *it );
|
||||
if( tcoItem )
|
||||
{
|
||||
tcoItem->prepareSnapBackAnimation( timeLine );
|
||||
}
|
||||
}
|
||||
if( isSelected() ) {
|
||||
QList<QGraphicsItem*> selItems = scene()->selectedItems();
|
||||
for( QList<QGraphicsItem *>::iterator it = selItems.begin();
|
||||
it != selItems.end(); ++it )
|
||||
{
|
||||
TrackContentObjectItem * tcoItem =
|
||||
dynamic_cast<TrackContentObjectItem*>( *it );
|
||||
if( tcoItem )
|
||||
{
|
||||
tcoItem->prepareSnapBackAnimation( timeLine );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
timeLine->setCurrentTime( 0.0f );
|
||||
timeLine->setDuration( 300 );
|
||||
timeLine->setCurveShape( QTimeLine::EaseInOutCurve );
|
||||
connect( timeLine, SIGNAL(finished()), timeLine, SLOT(deleteLater()));
|
||||
timeLine->start();
|
||||
timeLine->setCurrentTime( 0.0f );
|
||||
timeLine->setDuration( 300 );
|
||||
timeLine->setCurveShape( QTimeLine::EaseInOutCurve );
|
||||
connect( timeLine, SIGNAL(finished()), timeLine, SLOT(deleteLater()));
|
||||
timeLine->start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
m_hover = true;
|
||||
QGraphicsItem::hoverEnterEvent( event );
|
||||
update();
|
||||
m_hover = true;
|
||||
QGraphicsItem::hoverEnterEvent( event );
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
|
||||
{
|
||||
QGraphicsItem::hoverLeaveEvent( event );
|
||||
m_hover = false;
|
||||
update();
|
||||
QGraphicsItem::hoverLeaveEvent( event );
|
||||
m_hover = false;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -231,21 +225,21 @@ void TrackContentObjectItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
|
||||
|
||||
void TrackContentObjectItem::prepareSnapBackAnimation( QTimeLine * timeLine )
|
||||
{
|
||||
prepareSnapBackAnimation( timeLine, x() );
|
||||
prepareSnapBackAnimation( timeLine, x() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrackContentObjectItem::prepareSnapBackAnimation( QTimeLine * timeLine, int newX )
|
||||
{
|
||||
const qreal cellWidth = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
const qreal xVal = newX + TrackContainerScene::DEFAULT_CELL_WIDTH * 0.5f;
|
||||
const qreal cellWidth = TrackContainerScene::DEFAULT_CELL_WIDTH;
|
||||
const qreal xVal = newX + TrackContainerScene::DEFAULT_CELL_WIDTH * 0.5f;
|
||||
|
||||
QPointF newPos( xVal - ( fmod( xVal, cellWidth) ), y() );
|
||||
|
||||
m_snapBackAnimation->setTimeLine( timeLine );
|
||||
m_snapBackAnimation->setPosAt( 0.0, pos() );
|
||||
m_snapBackAnimation->setPosAt( 1.0, newPos );
|
||||
m_snapBackAnimation->setTimeLine( timeLine );
|
||||
m_snapBackAnimation->setPosAt( 0.0, pos() );
|
||||
m_snapBackAnimation->setPosAt( 1.0, newPos );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,60 +17,59 @@ TrackItem::TrackItem( TrackContainerScene * _scene, track * _track )
|
||||
|
||||
// create views for already existing TCOs
|
||||
const track::tcoVector & tcos = m_track->getTCOs();
|
||||
for( track::tcoVector::const_iterator it = tcos.begin(); it != tcos.end(); ++it )
|
||||
for (track::tcoVector::const_iterator it = tcos.begin(); it != tcos.end(); ++it)
|
||||
{
|
||||
addTCO( *it );
|
||||
}
|
||||
|
||||
QObject * obj = _track;
|
||||
connect( obj, SIGNAL( trackContentObjectAdded( trackContentObject * ) ),
|
||||
this, SLOT( addTCO( trackContentObject * ) ),
|
||||
Qt::QueuedConnection );
|
||||
this, SLOT( addTCO( trackContentObject * ) ),
|
||||
Qt::QueuedConnection );
|
||||
|
||||
connect( obj, SIGNAL( trackContentObjectRemoved( trackContentObject * ) ),
|
||||
this, SLOT( removeTCO( trackContentObject * ) ) );
|
||||
this, SLOT( removeTCO( trackContentObject * ) ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* WTF?!?! */
|
||||
TrackItem::~TrackItem()
|
||||
{
|
||||
for( QMap<trackContentObject*, TrackContentObjectItem*>::iterator i = m_tcoItems.begin();
|
||||
i != m_tcoItems.end(); ++i )
|
||||
{
|
||||
for (QMap<trackContentObject*, TrackContentObjectItem*>::iterator i = m_tcoItems.begin();
|
||||
i != m_tcoItems.end(); ++i)
|
||||
{
|
||||
TrackContentObjectItem * item = i.value();
|
||||
m_scene->removeItem(item);
|
||||
m_scene->removeItem(item);
|
||||
m_tcoItems.erase(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TrackItem::addTCO( trackContentObject * _tco )
|
||||
{
|
||||
// TODO move into a factory?
|
||||
TrackContentObjectItem * tcoItem;
|
||||
// TODO move into a factory?
|
||||
TrackContentObjectItem * tcoItem;
|
||||
|
||||
if( bbTCO * bbTco = dynamic_cast<bbTCO *>( _tco ) )
|
||||
{
|
||||
tcoItem = new BbTrackContentObjectItem( this, (trackContentObject*)bbTco );
|
||||
}
|
||||
else if( pattern * pat = dynamic_cast<pattern *>( _tco ) )
|
||||
{
|
||||
tcoItem = new PatternItem( this, (trackContentObject*)pat );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Whoa.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO refactor to private updateTCOGeometry
|
||||
tcoItem->setPos( tcoItem->x(), y() );
|
||||
if( bbTCO * bbTco = dynamic_cast<bbTCO *>( _tco ) )
|
||||
{
|
||||
tcoItem = new BbTrackContentObjectItem( this, (trackContentObject*)bbTco );
|
||||
}
|
||||
else if( pattern * pat = dynamic_cast<pattern *>( _tco ) )
|
||||
{
|
||||
tcoItem = new PatternItem( this, (trackContentObject*)pat );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Whoa.
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO refactor to private updateTCOGeometry
|
||||
tcoItem->setPos( tcoItem->x(), y() );
|
||||
|
||||
m_tcoItems.insert( _tco, tcoItem );
|
||||
m_scene->addItem( tcoItem );
|
||||
m_tcoItems.insert( _tco, tcoItem );
|
||||
m_scene->addItem( tcoItem );
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +82,7 @@ void TrackItem::removeTCO( trackContentObject * _tco )
|
||||
if( i != m_tcoItems.end() && i.key() == _tco )
|
||||
{
|
||||
TrackContentObjectItem * item = i.value();
|
||||
m_scene->removeItem(*i);
|
||||
m_scene->removeItem(*i);
|
||||
m_tcoItems.erase(i);
|
||||
delete item;
|
||||
}
|
||||
@@ -97,7 +96,7 @@ void TrackItem::setHeight( float _height )
|
||||
it != m_tcoItems.constEnd(); ++it )
|
||||
{
|
||||
(*it)->updateGeometry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,11 +105,11 @@ void TrackItem::setY( float _y )
|
||||
{
|
||||
//printf("TRK %lld: setY(%.2f)\n", m_track, _y);
|
||||
m_rect.moveTop( _y );
|
||||
for( QMap<trackContentObject*, TrackContentObjectItem*>::const_iterator it = m_tcoItems.constBegin();
|
||||
for( QMap<trackContentObject*, TrackContentObjectItem*>::const_iterator it = m_tcoItems.constBegin();
|
||||
it != m_tcoItems.constEnd(); ++it )
|
||||
{
|
||||
(*it)->setPos( (*it)->x(), y() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user