[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/sheetcanvas Cursors.cpp Cursors.h ...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/sheetcanvas Cursors.cpp Cursors.h ... |
Date: |
Mon, 02 Feb 2009 20:24:12 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 09/02/02 20:24:12
Modified files:
src/sheetcanvas: Cursors.cpp Cursors.h MarkerView.cpp
PositionIndicator.cpp
Log message:
* fix painting issues when using >= Qt 4.4
* properly implement animated scroll, it now works again and more
reliably
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/Cursors.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/Cursors.h?cvsroot=traverso&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/MarkerView.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/PositionIndicator.cpp?cvsroot=traverso&r1=1.1&r2=1.2
Patches:
Index: Cursors.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/Cursors.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Cursors.cpp 29 Dec 2008 20:45:20 -0000 1.5
+++ Cursors.cpp 2 Feb 2009 20:24:11 -0000 1.6
@@ -27,7 +27,6 @@
#include <Config.h>
#include <Themer.h>
-#include <QApplication>
#include <QPen>
#include <QScrollBar>
@@ -50,7 +49,7 @@
// TODO: Make duration scale with scalefactor? (nonlinerly?)
m_animation.setDuration(ANIME_DURATION);
- m_animation.setCurveShape(QTimeLine::SineCurve);
+ m_animation.setCurveShape(QTimeLine::EaseInOutCurve);
connect(m_sheet, SIGNAL(transferStarted()), this, SLOT(play_start()));
connect(m_sheet, SIGNAL(transferStopped()), this, SLOT(play_stop()));
@@ -60,7 +59,6 @@
connect(&m_animation, SIGNAL(frameChanged(int)), this,
SLOT(set_animation_value(int)));
connect(&m_animation, SIGNAL(finished()), this,
SLOT(animation_finished()));
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
setZValue(99);
}
@@ -145,6 +143,7 @@
}
newPos.setX(newXPos);
+
if (int(newPos.x()) != int(pos().x()) && (m_animation.state() !=
QTimeLine::Running)) {
setPos(newPos);
} else {
@@ -157,7 +156,9 @@
int vpWidth = m_vp->viewport()->width();
- if (m_mode == CENTERED) {
+ // When timeref_scalefactor is below 5120, the playhead moves faster
then teh view scrolls
+ // so it's better to keep the view centered around the playhead.
+ if (m_mode == CENTERED || (m_sv->timeref_scalefactor <= 10280) ) {
m_sv->set_hscrollbar_value(int(scenePos().x()) - (int)(0.5 *
vpWidth));
return;
}
@@ -177,10 +178,9 @@
if (m_mode == ANIMATED_FLIP_PAGE) {
if (m_animation.state() != QTimeLine::Running) {
m_animFrameRange = (int)(vpWidth * (1.0 -
(AUTO_SCROLL_MARGIN * 2)));
- m_totalAnimValue = 0;
m_animation.setFrameRange(0, m_animFrameRange);
- calculate_total_anim_frames();
m_animationScrollStartPos =
m_sv->hscrollbar_value();
+ m_animScaleFactor = m_sv->timeref_scalefactor;
//during the animation, we stop the play update
timer
// to avoid unnecessary update/paint events
play_stop();
@@ -194,14 +194,24 @@
void PlayHead::set_animation_value(int value)
{
+ // When the scalefactor changed, stop the animation here as it's no
longer valid to run
+ // and reset the animation timeline time back to 0.
+ if (m_animScaleFactor != m_sv->timeref_scalefactor) {
+ m_animation.stop();
+ m_animation.setCurrentTime(0);
+ animation_finished();
+ return;
+ }
+
QPointF newPos(m_sheet->get_transport_location() /
m_sv->timeref_scalefactor, 0);
- // calculate the motion distance of the playhead.
- qreal deltaX = newPos.x() - pos().x();
// calculate the animation x diff.
- int diff = (int)(0.5 + ((float)(value) / m_totalAnimFrames) *
m_animFrameRange);
- m_totalAnimValue += (int)(diff + deltaX);
- int newXPos = (int)(m_animationScrollStartPos + m_totalAnimValue);
+ int diff = m_animation.currentValue() * m_animFrameRange;
+
+ // compensate for the playhead movement.
+ m_animationScrollStartPos += newPos.x() - pos().x();
+
+ int newXPos = (int)(m_animationScrollStartPos + diff);
if (newPos != pos()) {
setPos(newPos);
@@ -212,16 +222,6 @@
}
}
-void PlayHead::calculate_total_anim_frames()
-{
- int count = (ANIME_DURATION / 40);
- m_totalAnimFrames = 0;
- for (int i=0; i<count; ++i) {
- m_totalAnimFrames += m_animation.frameForTime(i*40);
- }
-}
-
-
void PlayHead::animation_finished()
{
if (m_sheet->is_transport_rolling()) {
@@ -271,7 +271,6 @@
, m_sheet(sheet)
, m_sv(sv)
{
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
setZValue(100);
}
Index: Cursors.h
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/Cursors.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Cursors.h 21 Jan 2008 16:17:28 -0000 1.1
+++ Cursors.h 2 Feb 2009 20:24:11 -0000 1.2
@@ -63,10 +63,7 @@
PlayHeadMode m_mode;
int m_animationScrollStartPos;
int m_animFrameRange;
- int m_totalAnimFrames;
- int m_totalAnimValue;
-
- void calculate_total_anim_frames();
+ qreal m_animScaleFactor;
private slots:
void check_config();
Index: MarkerView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/MarkerView.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- MarkerView.cpp 21 Nov 2008 06:41:06 -0000 1.5
+++ MarkerView.cpp 2 Feb 2009 20:24:11 -0000 1.6
@@ -52,8 +52,6 @@
m_width = fm.width("NI"); //Â use any two letters to set the width of
the marker indicator
m_line->setPos(m_width / 2, m_ascent);
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
-
load_theme_data();
Index: PositionIndicator.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/PositionIndicator.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PositionIndicator.cpp 21 Jan 2008 16:17:29 -0000 1.1
+++ PositionIndicator.cpp 2 Feb 2009 20:24:12 -0000 1.2
@@ -30,7 +30,6 @@
: ViewItem(parentView, 0)
{
calculate_bounding_rect();
- setFlag(QGraphicsItem::ItemIgnoresTransformations);
setZValue(100);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/sheetcanvas Cursors.cpp Cursors.h ...,
Remon Sijrier <=