[vlmc-devel] commit: GraphicsItems: Reworking ZValue handling. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Fri Sep 10 19:24:54 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Fri Sep 10 17:54:50 2010 +0200| [ffc4c2a3cfe9b5747e7af5ecedab0842047d9441] | committer: Hugo Beauzée-Luyssen
GraphicsItems: Reworking ZValue handling.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ffc4c2a3cfe9b5747e7af5ecedab0842047d9441
---
src/Gui/timeline/AbstractGraphicsItem.h | 5 +++--
src/Gui/timeline/AbstractGraphicsMediaItem.cpp | 12 ++++++++++++
src/Gui/timeline/AbstractGraphicsMediaItem.h | 2 ++
src/Gui/timeline/GraphicsAudioItem.cpp | 4 ++--
src/Gui/timeline/GraphicsEffectItem.cpp | 16 ++++++++++++++++
src/Gui/timeline/GraphicsEffectItem.h | 2 ++
src/Gui/timeline/GraphicsMovieItem.cpp | 4 ++--
src/Gui/timeline/TracksView.cpp | 1 -
8 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/src/Gui/timeline/AbstractGraphicsItem.h b/src/Gui/timeline/AbstractGraphicsItem.h
index 6bc6bb4..f177f9c 100644
--- a/src/Gui/timeline/AbstractGraphicsItem.h
+++ b/src/Gui/timeline/AbstractGraphicsItem.h
@@ -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.
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
index 9901b5e..8d618c4 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.cpp
@@ -306,3 +306,15 @@ AbstractGraphicsMediaItem::itemHeight() const
{
return 35;
}
+
+qint32
+AbstractGraphicsMediaItem::zSelected() const
+{
+ return 100;
+}
+
+qint32
+AbstractGraphicsMediaItem::zNotSelected() const
+{
+ return 50;
+}
diff --git a/src/Gui/timeline/AbstractGraphicsMediaItem.h b/src/Gui/timeline/AbstractGraphicsMediaItem.h
index 240063a..876903f 100644
--- a/src/Gui/timeline/AbstractGraphicsMediaItem.h
+++ b/src/Gui/timeline/AbstractGraphicsMediaItem.h
@@ -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 );
diff --git a/src/Gui/timeline/GraphicsAudioItem.cpp b/src/Gui/timeline/GraphicsAudioItem.cpp
index aacbd7b..8c8c5f4 100644
--- a/src/Gui/timeline/GraphicsAudioItem.cpp
+++ b/src/Gui/timeline/GraphicsAudioItem.cpp
@@ -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
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index a9e8ba8..214bd31 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -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;
+}
+
diff --git a/src/Gui/timeline/GraphicsEffectItem.h b/src/Gui/timeline/GraphicsEffectItem.h
index 4c10e13..f0ee2c1 100644
--- a/src/Gui/timeline/GraphicsEffectItem.h
+++ b/src/Gui/timeline/GraphicsEffectItem.h
@@ -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;
/**
diff --git a/src/Gui/timeline/GraphicsMovieItem.cpp b/src/Gui/timeline/GraphicsMovieItem.cpp
index be954f9..fd6a466 100644
--- a/src/Gui/timeline/GraphicsMovieItem.cpp
+++ b/src/Gui/timeline/GraphicsMovieItem.cpp
@@ -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 )
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index d916285..54bf197 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -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
{
More information about the Vlmc-devel
mailing list