From 11eb66643c68783837edcd270a44dc365f0d9da8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Sep 2016 13:51:19 +0200 Subject: [PATCH] Timeline: Allow setting orientation lines in the timeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It can be hard to figure out how events in different categories relate to each other chronologically. This change allows you to insert vertical orientation lines by clicking the time labels at the top of the timeline. Change-Id: I4fcac032988b2d523a8cd25fda17820c54e4b493 Reviewed-by: Pasi Petäjäjärvi Reviewed-by: Christian Kandeler Reviewed-by: Ulf Hermann --- src/libs/timeline/qml/MainView.qml | 11 ++ src/libs/timeline/qml/TimelineRulers.qml | 128 +++++++++++++++++++++++ src/libs/timeline/qml/timeline.qrc | 1 + 3 files changed, 140 insertions(+) create mode 100644 src/libs/timeline/qml/TimelineRulers.qml diff --git a/src/libs/timeline/qml/MainView.qml b/src/libs/timeline/qml/MainView.qml index 43c818adc1c..543691e5bab 100644 --- a/src/libs/timeline/qml/MainView.qml +++ b/src/libs/timeline/qml/MainView.qml @@ -318,6 +318,17 @@ Rectangle { } } + TimelineRulers { + contentX: buttonsBar.width - content.x - content.flickableItem.x + content.contentX + anchors.left: buttonsBar.right + anchors.right: parent.right + anchors.top: parent.top + height: content.flickableItem.height + buttonsBar.height + windowStart: zoomControl.windowStart + viewTimePerPixel: selectionRange.viewTimePerPixel + scaleHeight: buttonsBar.height + } + SelectionRangeDetails { z: 3 x: 200 diff --git a/src/libs/timeline/qml/TimelineRulers.qml b/src/libs/timeline/qml/TimelineRulers.qml new file mode 100644 index 00000000000..8ee08fc401c --- /dev/null +++ b/src/libs/timeline/qml/TimelineRulers.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: rulersParent + property int scaleHeight + property double viewTimePerPixel: 1 + property double contentX + property double windowStart + clip: true + + ListModel { + id: rulersModel + } + + MouseArea { + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: scaleHeight + + onClicked: { + rulersModel.append({ + timestamp: (mouse.x + contentX) * viewTimePerPixel + windowStart + }); + } + } + + Item { + id: dragDummy + property int index: -1 + onXChanged: { + if (index >= 0) { + rulersModel.setProperty( + index, "timestamp", + (x + contentX) * viewTimePerPixel + windowStart); + } + } + } + + Repeater { + model: rulersModel + + Item { + id: ruler + x: (timestamp - windowStart) / viewTimePerPixel - 1 - contentX + y: 0 + width: 2 + height: rulersParent.height + Rectangle { + id: arrow + height: scaleHeight + width: scaleHeight + rotation: 45 + anchors.verticalCenter: parent.top + anchors.horizontalCenter: parent.horizontalCenter + color: creatorTheme.Timeline_HandleColor + MouseArea { + cursorShape: pressed ? Qt.DragMoveCursor : Qt.OpenHandCursor + anchors.fill: parent + drag.target: dragDummy + drag.axis: Drag.XAxis + drag.smoothed: false + onPressedChanged: { + if (!pressed) { + dragDummy.index = -1 + } else { + dragDummy.x = ruler.x + 1 + dragDummy.index = index + } + } + } + } + + Rectangle { + anchors.left: parent.left + anchors.top: arrow.bottom + anchors.bottom: parent.bottom + width: 2 + color: creatorTheme.Timeline_HandleColor + } + + Rectangle { + anchors.top: arrow.bottom + anchors.horizontalCenter: ruler.horizontalCenter + width: scaleHeight / 4 + height: width + color: creatorTheme.Timeline_PanelBackgroundColor + + Rectangle { + anchors.centerIn: parent + width: parent.width - 2 + height: 1 + color: creatorTheme.Timeline_TextColor + } + + MouseArea { + anchors.fill: parent + onClicked: rulersModel.remove(index, 1) + } + } + } + } +} diff --git a/src/libs/timeline/qml/timeline.qrc b/src/libs/timeline/qml/timeline.qrc index 090ffcdc1c3..18a1933c6f6 100644 --- a/src/libs/timeline/qml/timeline.qrc +++ b/src/libs/timeline/qml/timeline.qrc @@ -30,5 +30,6 @@ SynchronousReloader.qml TimelineText.qml ImageToolButton.qml + TimelineRulers.qml