diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-08-30 10:38:06 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-09-02 10:45:49 +0300 |
commit | 747f520cc2e16a97d38c3caf28ecb1880ae1aa4c (patch) | |
tree | 67ef832b1557e1999fc2e79590bf8ab0189c1d0c /src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp | |
parent | cd88fefac16b842d938f154d574330fcc0ed2432 (diff) |
Timeline ruler and scaling enhancements
- Make timeline scaling smoother and allow further scale values.
- Implement non linear scaling strategy which improve UX.
- Double clicking the scale head resets the scale to the default value
- Optimize drawing by only drawing the visible part of the ruler.
- Other assorted small tweaks
Change-Id: I5fbf729f3b5e098a60e26978af6bc82bb5f307ae
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp')
-rw-r--r-- | src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp index 3ddfdcad..1a847112 100644 --- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp +++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/PlayHead.cpp @@ -54,7 +54,8 @@ void PlayHead::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, static const QPixmap pixHead2x = QPixmap(":/images/PlaybackHead@2x.png"); static const int PLAY_HEAD_H = 999999; // theoretically big enough height - painter->drawPixmap(-TimelineConstants::PLAYHEAD_W * .5, 0, hiResIcons ? pixHead2x : pixHead); + painter->drawPixmap(int(-TimelineConstants::PLAYHEAD_W * .5f), 0, hiResIcons ? pixHead2x + : pixHead); painter->setPen(CStudioPreferences::timelinePlayheadLineColor()); painter->drawLine(0, 0, 0, PLAY_HEAD_H); } @@ -75,21 +76,9 @@ void PlayHead::setTime(long time) updatePosition(); } -void PlayHead::setPosition(double posX) -{ - posX = qBound(TimelineConstants::RULER_EDGE_OFFSET, posX, m_ruler->duration() - * TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale() - + TimelineConstants::RULER_EDGE_OFFSET); - - setX(m_ruler->x() + posX); - m_time = (posX - TimelineConstants::RULER_EDGE_OFFSET) - / (TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale()); -} - void PlayHead::updatePosition() { - setX(m_ruler->x() + TimelineConstants::RULER_EDGE_OFFSET - + m_time * TimelineConstants::RULER_MILLI_W * m_ruler->timelineScale()); + setX(m_ruler->x() + TimelineConstants::RULER_EDGE_OFFSET + m_ruler->timeToDistance(m_time)); } long PlayHead::time() const |