import QtQuick 1.0 import HxQMLComponents 1.0 // // This file described a time rule with 3 time draggers (current time, start time and end time). // Item { id: timeDraggersContainer // // This item contains the 3 time draggers and can be dragged to update the position of these 3 draggers at the same time. // Item { id: timeDraggersContainerDraggableArea objectName: "timeDraggersContainerDraggableArea" signal positionChanged // // Rectangle between the start and end time draggers used to drag the 3 time draggers at the same time. // Rectangle { id: timeDraggersGlobalDragger objectName: "timeDraggersGlobalDragger" height: draggerStartTime.height - 0.5 anchors.left: draggerStartTime.right anchors.right: draggerEndTime.left gradient: Gradient { GradientStop { position: 0.0; color: "#505050" } GradientStop { position: 1.0; color: "#6A6A6A" } } border.color: "black" y: 7 QxCursorShapeArea { id: timeDraggersGlobalDraggerCursor anchors.fill: parent cursorShape: Qt.OpenHandCursor } MouseArea { anchors.fill: parent drag.target: timeDraggersContainerDraggableArea drag.axis: "XAxis" drag.minimumX: timeDraggersContainer.x - draggerStartTime.x - draggerStartTime.width onPositionChanged: { timeDraggersContainerDraggableArea.positionChanged(); } onPressed: { timeDraggersGlobalDraggerCursor.cursorShape = Qt.ClosedHandCursor; draggerCurrentTime.canBeSnapped = true; draggerStartTime.canBeSnapped = true; draggerEndTime.canBeSnapped = true } onReleased: { timeDraggersGlobalDraggerCursor.cursorShape = Qt.OpenHandCursor; draggerCurrentTime.canBeSnapped = false; draggerStartTime.canBeSnapped = false; draggerEndTime.canBeSnapped = false } } } // // Rectangle used to visualize the time range before the start time. // Rectangle { id: indicatorBeforeStartTime objectName: "indicatorBeforeStartTime" color: "lightsteelblue" opacity: 0.25 x: -timeDraggersContainerDraggableArea.x - draggerStartTime.width y: 0 width: timeDraggersContainerDraggableArea.x + draggerStartTime.x + draggerStartTime.width + draggerStartTime.width } // // Rectangle used to visualize the time range after the end time. // Rectangle { id: indicatorAfterEndTime objectName: "indicatorAfterEndTime" color: "lightsteelblue" opacity: 0.25 x: draggerEndTime.x y: 0 } // // Start time dragger. // Image { id: draggerStartTime objectName: "draggerStartTime" source: "DraggerStartTime.png" property bool canBeSnapped: false signal positionChanged y: 7 MouseArea { anchors.fill: parent drag.target: parent drag.axis: "XAxis" drag.minimumX: timeDraggersContainer.x - timeDraggersContainerDraggableArea.x - width drag.maximumX: draggerCurrentTime.x + draggerCurrentTime.width / 2 - width - 0.5 onPositionChanged: parent.positionChanged() onPressed: { parent.source = "DraggerStartTimeOn.png"; parent.canBeSnapped = true } onReleased: { parent.source = "DraggerStartTime.png"; parent.canBeSnapped = false } } QxCursorShapeArea { anchors.fill: parent cursorShape: Qt.SizeHorCursor } } // // End time dragger. // Image { id: draggerEndTime objectName: "draggerEndTime" source: "DraggerEndTime.png" property bool canBeSnapped: false signal positionChanged y: 7 MouseArea { anchors.fill: parent drag.target: parent drag.axis: "XAxis" drag.minimumX: draggerCurrentTime.x + draggerCurrentTime.width / 2 - 0.5 onPositionChanged: parent.positionChanged() onPressed: { parent.source = "DraggerEndTimeOn.png"; parent.canBeSnapped = true } onReleased: { parent.source = "DraggerEndTime.png"; parent.canBeSnapped = false } } QxCursorShapeArea { anchors.fill: parent cursorShape: Qt.SizeHorCursor } } // // Current time dragger. // Image { id: draggerCurrentTime objectName: "draggerCurrentTime" source: "DraggerCurrentTime.png" property bool canBeSnapped: false signal positionChanged y: 3 Rectangle { id: indicatorCurrentTime objectName: "indicatorCurrentTime" anchors.top: draggerCurrentTime.bottom x: draggerCurrentTime.width / 2 width: 1 color: "orange" } MouseArea { anchors.fill: parent drag.target: parent drag.axis: "XAxis" drag.minimumX: draggerStartTime.x + draggerStartTime.width - width / 2 + 0.5 drag.maximumX: draggerEndTime.x - width / 2 + 0.5 onPositionChanged: parent.positionChanged() onPressed: { parent.source = "DraggerCurrentTimeOn.png"; indicatorCurrentTime.width = 2; indicatorCurrentTime.color = "red"; parent.canBeSnapped = true } onReleased: { parent.source = "DraggerCurrentTime.png"; indicatorCurrentTime.width = 1; indicatorCurrentTime.color = "orange"; parent.canBeSnapped = false } } QxCursorShapeArea { anchors.fill: parent cursorShape: Qt.ArrowCursor } } } }