summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-08-26 12:37:10 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2019-08-28 14:33:27 +0300
commitd8ac34450532d27a934b93673ed13a45d69a8f24 (patch)
treee77cf38f67600cd118d7ed4e6fed47bb3163973d
parent7964e25248f36b7a2454841c49c596cf61f45f20 (diff)
Correct color gradient when the timeline is scrolled
Also make the color gradient calculations completely accurate. Also remove one method and merge it into another. Change-Id: Ie097aa7afc5bb49f335b4756498fe7a1b11e7764 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp18
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h2
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp17
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h1
4 files changed, 19 insertions, 19 deletions
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
index cb8d3480..9fb338ea 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp
@@ -109,7 +109,9 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
const int currHeight = size().height() - 1;
if (m_isColorProperty && m_drawColorGradient && !m_keyframes.empty()) {
- QRectF gradRect(rowTree()->m_scene->ruler()->viewportX(), 0, widget->width(), currHeight);
+ QRect gradRect(rowTree()->m_scene->ruler()->viewportX(), 0, widget->width(), currHeight);
+ if (gradRect.x() < RULER_EDGE_OFFSET)
+ gradRect.setX(int(RULER_EDGE_OFFSET));
drawColorPropertyGradient(painter, gradRect);
} else {
// Background
@@ -380,17 +382,15 @@ void RowTimeline::toggleColorGradient()
update();
}
-void RowTimeline::drawColorPropertyGradient(QPainter *painter, const QRectF &rect)
+void RowTimeline::drawColorPropertyGradient(QPainter *painter, const QRect &rect)
{
- static const QPointF edgeOffset(RULER_EDGE_OFFSET, 0);
ITimelineItemProperty *propBinding = m_rowTree->propBinding();
-
QLinearGradient bgGradient(rect.topLeft(), rect.topRight());
- int start_x = int(qMax(rect.x(), edgeOffset.x()));
-
- for (int x = start_x; x <= rect.right(); x += 20) { // 20 = sampling step in pixels
- long time = rowTree()->m_scene->ruler()->distanceToTime(x - edgeOffset.x()); // millis
- double ratio = qBound(0.0, (x - edgeOffset.x()) / rect.width(), 1.0);
+ for (int x = rect.x(); x < rect.right() + 20; x += 20) { // 20 = sampling step in pixels
+ if (x > rect.right())
+ x = int(rect.right());
+ long time = rowTree()->m_scene->ruler()->distanceToTime(x - RULER_EDGE_OFFSET);
+ double ratio = qBound(0.0, double(x - rect.x()) / rect.width(), 1.0);
bgGradient.setColorAt(ratio, QColor::fromRgbF(
qBound(0.0, double(propBinding->GetChannelValueAtTime(0, time)), 1.0),
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
index 42a50190..c28dfdcd 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTimeline.h
@@ -100,7 +100,7 @@ private:
void updateChildrenMaxEndXRecursive(RowTree *rowTree);
void updateCommentItem();
void updateCommentItemPos();
- void drawColorPropertyGradient(QPainter *painter, const QRectF &rect);
+ void drawColorPropertyGradient(QPainter *painter, const QRect &rect);
QString formatTime(long millis) const;
void collectChildKeyframeTimes(QVector<long> &childKeyframeTimes);
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index f2d7ac4d..cb0b7470 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -1474,20 +1474,21 @@ void RowTree::togglePropertyExpanded(const QPointF &scenePos)
{
QPoint p = mapFromScene(scenePos).toPoint();
+ // check mouse over a channel button
for (int i = 0; i < m_rectChannels.size(); ++i) {
if (m_rectChannels[i].contains(p))
- return; // mouse over a channel button
+ return;
}
- if (!m_rectFitPropGraph.contains(p) && !m_rectMaximizePropGraph.contains(p)
- && !m_rectColorGradient.contains(p)) {
- setPropertyExpanded(!m_propGraphExpanded);
+ // check mouse over fit, maximize, or toggle color gradient buttons
+ if (m_rectFitPropGraph.contains(p) || m_rectMaximizePropGraph.contains(p)
+ || m_rectColorGradient.contains(p)) {
+ return;
}
-}
-void RowTree::setPropertyExpanded(bool expand)
-{
- m_propGraphExpanded = expand;
+ // toggle property graph expand
+ m_propGraphExpanded = !m_propGraphExpanded;
+
if (m_propGraphExpanded) {
// start graph in normal (not maximized) size
m_propGraphHeight = TimelineConstants::ROW_GRAPH_H;
diff --git a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
index b5191085..34a851b7 100644
--- a/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Qt3DStudio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -98,7 +98,6 @@ public:
void setPropBinding(ITimelineItemProperty *binding); // for property rows
void selectLabel();
void togglePropertyExpanded(const QPointF &scenePos = {});
- void setPropertyExpanded(bool expand);
void showDataInputSelector(const QString &propertyname, const QPoint &pos);
ITimelineItemProperty *propBinding();
void refreshPropBinding(bool forceSync = false);