summaryrefslogtreecommitdiff
path: root/retrace/daemon/bargraph
diff options
context:
space:
mode:
Diffstat (limited to 'retrace/daemon/bargraph')
-rw-r--r--retrace/daemon/bargraph/glframe_qbargraph.cpp17
-rw-r--r--retrace/daemon/bargraph/glframe_qbargraph.hpp17
-rw-r--r--retrace/daemon/bargraph/ui/qml/mainwin.qml163
3 files changed, 169 insertions, 28 deletions
diff --git a/retrace/daemon/bargraph/glframe_qbargraph.cpp b/retrace/daemon/bargraph/glframe_qbargraph.cpp
index f44bc066..ea410126 100644
--- a/retrace/daemon/bargraph/glframe_qbargraph.cpp
+++ b/retrace/daemon/bargraph/glframe_qbargraph.cpp
@@ -225,6 +225,8 @@ BarGraphView::mouseWheel(int degrees, float zoom_point_x) {
m_translate = new_translate;
m_zoom = new_zoom;
+ emit zoomChanged();
+ emit translateChanged();
update();
}
@@ -233,3 +235,18 @@ BarGraphView::zoom(float *zoom, float *translate) const {
*zoom = m_zoom;
*translate = m_translate;
}
+
+void
+BarGraphView::setZoom(float z) {
+ m_zoom = z;
+ emit zoomChanged();
+ update();
+}
+
+void
+BarGraphView::setTranslate(float z) {
+ m_translate = z;
+ emit translateChanged();
+ update();
+}
+
diff --git a/retrace/daemon/bargraph/glframe_qbargraph.hpp b/retrace/daemon/bargraph/glframe_qbargraph.hpp
index a28d467f..7b3d7962 100644
--- a/retrace/daemon/bargraph/glframe_qbargraph.hpp
+++ b/retrace/daemon/bargraph/glframe_qbargraph.hpp
@@ -77,6 +77,15 @@ class BarGraphView : public QQuickFramebufferObject,
READ randomBarCount
WRITE setRandomBarCount
NOTIFY onRandomBarCount)
+ Q_PROPERTY(float zoom
+ READ getZoom
+ WRITE setZoom
+ NOTIFY zoomChanged)
+ Q_PROPERTY(float translate
+ READ getTranslate
+ WRITE setTranslate
+ NOTIFY translateChanged)
+
public:
BarGraphView();
QQuickFramebufferObject::Renderer *createRenderer() const;
@@ -95,6 +104,12 @@ class BarGraphView : public QQuickFramebufferObject,
int randomBarCount() const {return m_randomBars;}
void setRandomBarCount(int count);
+ float getZoom() const { return m_zoom; }
+ void setZoom(float z);
+
+ float getTranslate() const { return m_translate; }
+ void setTranslate(float z);
+
void zoom(float *zoom, float *translate) const;
std::vector<float> mouse_area;
@@ -102,6 +117,8 @@ class BarGraphView : public QQuickFramebufferObject,
signals:
void onModel();
void onRandomBarCount();
+ void zoomChanged();
+ void translateChanged();
private:
mutable std::mutex m_protect;
diff --git a/retrace/daemon/bargraph/ui/qml/mainwin.qml b/retrace/daemon/bargraph/ui/qml/mainwin.qml
index a9348a83..1e5f1754 100644
--- a/retrace/daemon/bargraph/ui/qml/mainwin.qml
+++ b/retrace/daemon/bargraph/ui/qml/mainwin.qml
@@ -25,11 +25,10 @@
// * Mark Janes <mark.a.janes@intel.com>
// **********************************************************************/
-import QtQuick 2.2
-import QtQuick.Controls 1.1
-import QtQuick.Layouts 1.1
-import QtQuick.Dialogs 1.1
+import QtQuick 2.6
import ApiTrace 1.0
+import QtQuick.Controls 1.5
+import QtQuick.Layouts 1.3
ApplicationWindow {
width: 600
@@ -41,35 +40,143 @@ ApplicationWindow {
id: selection
}
- BarGraph {
- id: barGraph
- selection: selection
- visible: true
+ ColumnLayout {
anchors.fill: parent
- randomBarCount: 1000
- MouseArea {
- property var startx : -1.0;
- property var starty : -1.0;
- anchors.fill: parent
- onPressed : {
- startx = mouse.x / barGraph.width;
- starty = (barGraph.height - mouse.y) / barGraph.height;
- barGraph.mouseDrag(startx, starty, startx, starty);
+
+ BarGraph {
+ id: barGraph
+ width: mainWindow.width
+ height: mainWindow.height - scrollBar.height
+ selection: selection
+ visible: true
+ randomBarCount: 1000
+ MouseArea {
+ property var startx : -1.0;
+ property var starty : -1.0;
+ anchors.fill: parent
+ onPressed : {
+ startx = mouse.x / barGraph.width;
+ starty = (barGraph.height - mouse.y) / barGraph.height;
+ barGraph.mouseDrag(startx, starty, startx, starty);
+ }
+ onPositionChanged : {
+ if (mouse.buttons & Qt.LeftButton) {
+ var endx = mouse.x / barGraph.width;
+ var endy = (barGraph.height - mouse.y) / barGraph.height;
+ barGraph.mouseDrag(startx, starty, endx, endy)
+ }
+ }
+ onWheel : {
+ var wheelx = 1.0;
+ wheelx = wheel.x / barGraph.width;
+ barGraph.mouseWheel(wheel.angleDelta.y / 2, wheelx);
+ }
+ onReleased : {
+ barGraph.mouseRelease();
+ }
+ }
+ onZoomChanged: {
+ scrollBar.positionHandle()
+ }
+ onTranslateChanged: {
+ scrollBar.positionHandle()
}
- onPositionChanged : {
- if (mouse.buttons & Qt.LeftButton) {
- var endx = mouse.x / barGraph.width;
- var endy = (barGraph.height - mouse.y) / barGraph.height;
- barGraph.mouseDrag(startx, starty, endx, endy)
+ }
+ Item {
+ id: scrollBar
+ height: 20
+ width: mainWindow.width
+ anchors {
+ left: mainWindow.left;
+ margins: 1;
+ }
+ function zoomIn () {
+ barGraph.mouseWheel(45, 0.5);
+ }
+ function zoomOut () {
+ barGraph.mouseWheel(-45, 0.5);
+ }
+ function positionHandle() {
+ handle.width = (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom
+ var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width;
+ var fullTranslation = 1.0 - barGraph.zoom;
+ if (fullTranslation == 0) {
+ handle.x = backScrollbar.height;
+ } else {
+ handle.x = backScrollbar.height + barGraph.translate * maxXOffset / fullTranslation;
}
}
- onWheel : {
- var wheelx = 1.0;
- wheelx = wheel.x / barGraph.width;
- barGraph.mouseWheel(wheel.angleDelta.y / 5, wheelx);
+ Rectangle {
+ id: backScrollbar;
+ radius: 2;
+ color: Qt.rgba(0.5, 0.5, 0.5, 0.85);
+ anchors { fill: parent; }
}
- onReleased : {
- barGraph.mouseRelease();
+ MouseArea {
+ width: height;
+ anchors {
+ top: parent.top;
+ left: parent.left;
+ bottom: parent.bottom;
+ margins: (backScrollbar.border.width +1);
+ }
+ onClicked: { scrollBar.zoomOut(); }
+
+ Text {
+ text: "-";
+ anchors.centerIn: parent;
+ }
+ }
+ MouseArea {
+ width: height;
+ anchors {
+ top: parent.top;
+ right: parent.right;
+ bottom: parent.bottom;
+ margins: (backScrollbar.border.width +1);
+ }
+ onClicked: { scrollBar.zoomIn(); }
+
+ Text {
+ text: "+";
+ anchors.centerIn: parent;
+ }
+ }
+
+ Item {
+ id: handle;
+ width: (backScrollbar.width - 2 * backScrollbar.height) / barGraph.zoom
+ x: backScrollbar.height
+ onXChanged: {
+ if (barGraph.zoom == 1.0) {
+ barGraph.translate = 0.0;
+ } else {
+ var fullTranslation = 1.0 - barGraph.zoom;
+ var xOffset = handle.x - backScrollbar.height;
+ var maxXOffset = backScrollbar.width - 2 * backScrollbar.height - handle.width;
+ barGraph.translate = fullTranslation * xOffset / maxXOffset;
+ }
+ }
+
+ anchors {
+ top: parent.top;
+ bottom: parent.bottom;
+ }
+ Rectangle {
+ id: backHandle;
+ color: Qt.rgba(0.2, 0.2, 0.2, 1.0)
+ anchors { fill: parent; }
+ }
+ MouseArea {
+ id: clicker;
+ drag {
+ target: handle;
+ minimumX: backScrollbar.height;
+ maximumX: (backScrollbar.width - backScrollbar.height - handle.width);
+ axis: Drag.XAxis;
+ }
+ anchors { fill: parent; }
+ }
}
}
}