More work on glossy TCOs, add hover-effects

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@2015 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2009-02-11 04:38:35 +00:00
parent d5234ed7a2
commit 9f4ea82a39
4 changed files with 18 additions and 7 deletions

View File

@@ -59,6 +59,7 @@ protected:
TrackItem * m_trackItem;
trackContentObject * m_tco;
bool m_hover;
};
#endif

View File

@@ -10,6 +10,8 @@
#include "gui/tracks/track_item.h"
#include "track.h"
// Just some stuff while playing with theming ideas,
// will be moved to lmmsStyle
namespace BBTcoStuff {
QLinearGradient getGradient( const QColor & _col, const QRectF & _rect )
{
@@ -42,7 +44,7 @@ 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.darker(160);
stops[i].second = color.lighter(150);
}
QLinearGradient g = _gradient;
@@ -85,7 +87,7 @@ void drawPath( QPainter *p, const QPainterPath &path,
// highlight
if (dark)
p->strokePath(path, QPen(col.lighter(160).darker(160), 2));
p->strokePath(path, QPen(col.lighter(160).lighter(160), 2));
else
p->strokePath(path, QPen(col.lighter(160), 2));
@@ -121,7 +123,7 @@ void BbTrackContentObjectItem::paint( QPainter * _painter,
QPainterPath path;
path.addRoundedRect(2, 2, rc.width()-4, rc.height()-4, 4, 4);
drawPath( _painter, path, col, "hah", false );
drawPath( _painter, path, col, "hah", m_hover );
const float cellW = TrackContainerScene::DEFAULT_CELL_WIDTH;
_painter->setOpacity(0.2);

View File

@@ -10,6 +10,8 @@
#include "gui/tracks/track_item.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 )
{
@@ -42,7 +44,7 @@ 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.darker(160);
stops[i].second = color.lighter(150);
}
QLinearGradient g = _gradient;
@@ -86,7 +88,7 @@ void drawPath( QPainter *p, const QPainterPath &path,
// highlight
if (dark)
p->strokePath(path, QPen(borderCol.darker(160), 2));
p->strokePath(path, QPen(borderCol.lighter(150), 2));
else
p->strokePath(path, QPen(borderCol, 2));
@@ -126,7 +128,7 @@ void PatternItem::paint( QPainter * _painter,
QPainterPath path;
path.addRoundedRect(2, 2, rc.width()-4, rc.height()-4, 4, 4);
drawPath( _painter, path, col0, colBorder, false );
drawPath( _painter, path, col0, colBorder, m_hover );
_painter->restore();

View File

@@ -15,10 +15,12 @@ TrackContentObjectItem::TrackContentObjectItem( TrackItem * _track, trackContent
QGraphicsItem(),
m_trackItem( _track ),
m_tco( _object ),
m_snapBackAnimation( NULL )
m_snapBackAnimation( NULL ),
m_hover( false )
{
//m_object = _object;
setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
setAcceptHoverEvents( true );
setCursor( Qt::OpenHandCursor );
midiTime startPos = _object->startPosition();
@@ -205,7 +207,9 @@ void TrackContentObjectItem::mouseReleaseEvent( QGraphicsSceneMouseEvent * event
void TrackContentObjectItem::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
{
m_hover = true;
QGraphicsItem::hoverEnterEvent( event );
update();
}
@@ -213,6 +217,8 @@ void TrackContentObjectItem::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
void TrackContentObjectItem::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
{
QGraphicsItem::hoverLeaveEvent( event );
m_hover = false;
update();
}