forked from qt-creator/qt-creator
Timeline: Allow setting orientation lines in the timeline
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 <pasi.petajajarvi@theqtcompany.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -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
|
||||
|
128
src/libs/timeline/qml/TimelineRulers.qml
Normal file
128
src/libs/timeline/qml/TimelineRulers.qml
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,5 +30,6 @@
|
||||
<file>SynchronousReloader.qml</file>
|
||||
<file>TimelineText.qml</file>
|
||||
<file>ImageToolButton.qml</file>
|
||||
<file>TimelineRulers.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user