aboutsummaryrefslogtreecommitdiff
path: root/ScrollBar.qml
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-06-21 20:21:50 +0200
committerAdrian Kummerlaender2015-06-21 20:21:50 +0200
commit97e3cfada0d599fe6121d92d52e4782fc02aed08 (patch)
treea351ca7412489152af3f127bcfe6f0180d17a928 /ScrollBar.qml
downloadMetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar.gz
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar.bz2
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar.lz
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar.xz
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.tar.zst
MetaTerm-97e3cfada0d599fe6121d92d52e4782fc02aed08.zip
Initial commit of _MetaTerm_ UI prototype
MetaTerm is a meta terminal in the sense that it allows launching multiple terminal shells and applications in a unified interface that is in itself reminiscent of a terminal shell.
Diffstat (limited to 'ScrollBar.qml')
-rw-r--r--ScrollBar.qml78
1 files changed, 78 insertions, 0 deletions
diff --git a/ScrollBar.qml b/ScrollBar.qml
new file mode 100644
index 0000000..18f149c
--- /dev/null
+++ b/ScrollBar.qml
@@ -0,0 +1,78 @@
+import QtQuick 2.0;
+
+Item {
+ id: scrollbar
+ width: (handleSize + 2)
+ visible: (flickable.visibleArea.heightRatio < 1.0)
+
+ anchors {
+ top: flickable.top
+ right: flickable.right
+ bottom: flickable.bottom
+ }
+
+ property Flickable flickable
+ property int handleSize
+
+ Item {
+ id: bar
+
+ anchors.fill: parent
+
+ Rectangle {
+ anchors.fill: parent
+ color: "black"
+ opacity: 0.5
+ }
+
+ MouseArea {
+ id: control
+ anchors.fill: parent
+
+ drag {
+ target: handle
+ minimumY: 0
+ maximumY: (bar.height - handle.height)
+ axis: Drag.YAxis
+ }
+
+ onClicked: {
+ flickable.contentY = (mouse.y / bar.height * (flickable.contentHeight - flickable.height));
+ }
+ }
+
+ Item {
+ id: handle;
+ height: Math.max(20, (flickable.visibleArea.heightRatio * bar.height))
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ Rectangle {
+ id: backHandle
+ anchors {
+ fill: parent
+ margins: 1
+ }
+
+ color: (control.pressed ? "gray" : "white")
+ }
+ }
+ }
+
+ Binding {
+ target: handle
+ property: "y"
+ value: (flickable.contentY * control.drag.maximumY / (flickable.contentHeight - flickable.height))
+ when: (!control.drag.active)
+ }
+
+ Binding {
+ target: flickable
+ property: "contentY"
+ value: (handle.y * (flickable.contentHeight - flickable.height) / control.drag.maximumY)
+ when: (control.drag.active || control.pressed)
+ }
+}