Commit ffc4c2a3 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

GraphicsItems: Reworking ZValue handling.

parent 20868819
......@@ -122,6 +122,9 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos ) = 0;
virtual Workflow::Helper *helper() = 0;
virtual qint32 zSelected() const = 0;
virtual qint32 zNotSelected() const = 0;
protected:
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
......@@ -157,8 +160,6 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
virtual qint64 maxEnd() const { return -1; }
protected:
static const quint32 ZSelected = 4;
static const quint32 ZNotSelected = 3;
static const quint32 RounderRectRadius = 5;
/// This pointer will be set when inserted in the tracksView.
......
......@@ -306,3 +306,15 @@ AbstractGraphicsMediaItem::itemHeight() const
{
return 35;
}
qint32
AbstractGraphicsMediaItem::zSelected() const
{
return 100;
}
qint32
AbstractGraphicsMediaItem::zNotSelected() const
{
return 50;
}
......@@ -62,6 +62,8 @@ public:
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos );
virtual qint64 itemHeight() const;
virtual qint32 zSelected() const;
virtual qint32 zNotSelected() const;
protected:
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent* event );
......
......@@ -141,7 +141,7 @@ GraphicsAudioItem::paintRect( QPainter* painter, const QStyleOptionGraphicsItem*
if ( isSelected() )
{
setZValue( AbstractGraphicsItem::ZSelected );
setZValue( zSelected() );
painter->setPen( Qt::yellow );
painter->setBrush( Qt::NoBrush );
mapped.adjust( 0, 0, 0, -1 );
......@@ -152,7 +152,7 @@ GraphicsAudioItem::paintRect( QPainter* painter, const QStyleOptionGraphicsItem*
painter->drawRect( mapped );
}
else
setZValue( AbstractGraphicsItem::ZSelected );
setZValue( zNotSelected() );
}
void
......
......@@ -150,6 +150,7 @@ GraphicsEffectItem::paintRect( QPainter* painter, const QStyleOptionGraphicsItem
if ( isSelected() )
{
setZValue( zSelected() );
painter->setPen( Qt::yellow );
painter->setBrush( Qt::NoBrush );
mapped.adjust( 0, 0, 0, -1 );
......@@ -159,6 +160,8 @@ GraphicsEffectItem::paintRect( QPainter* painter, const QStyleOptionGraphicsItem
else
painter->drawRect( mapped );
}
else
setZValue( zNotSelected() );
}
......@@ -248,3 +251,16 @@ GraphicsEffectItem::triggerResize( TrackWorkflow *, Workflow::Helper *helper,
return ;
Commands::trigger( new Commands::Effect::Resize( eh, newBegin, newEnd ) );
}
qint32
GraphicsEffectItem::zSelected() const
{
return 300;
}
qint32
GraphicsEffectItem::zNotSelected() const
{
return 200;
}
......@@ -51,6 +51,8 @@ class GraphicsEffectItem : public AbstractGraphicsItem
virtual void triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
qint64 newBegin, qint64 newEnd, qint64 pos );
virtual qint64 itemHeight() const;
virtual qint32 zSelected() const;
virtual qint32 zNotSelected() const;
protected:
virtual bool hasResizeBoundaries() const;
/**
......
......@@ -134,7 +134,7 @@ void GraphicsMovieItem::paintRect( QPainter* painter, const QStyleOptionGraphics
if ( isSelected() )
{
setZValue( AbstractGraphicsItem::ZSelected );
setZValue( zSelected() );
painter->setPen( Qt::yellow );
painter->setBrush( Qt::NoBrush );
mapped.adjust( 0, 0, 0, -1 );
......@@ -145,7 +145,7 @@ void GraphicsMovieItem::paintRect( QPainter* painter, const QStyleOptionGraphics
painter->drawRect( mapped );
}
else
setZValue( AbstractGraphicsItem::ZSelected );
setZValue( zNotSelected() );
}
void GraphicsMovieItem::paintTitle( QPainter* painter, const QStyleOptionGraphicsItem* option )
......
......@@ -385,7 +385,6 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
m_dragEffectItem->setWidth( item->clipHelper()->length() );
m_dragEffectItem->setStartPos( item->startPos() );
m_dragEffectItem->setTrack( getTrack( m_dragEffectItem->trackType(), 0 ) );
m_dragEffectItem->setZValue( 100 );
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment