mirror of
https://github.com/overte-org/overte.git
synced 2025-06-21 20:41:52 +02:00
Use ScrollBar from QQC2 which is supports both mouse and touch events
This commit is contained in:
parent
c03772d345
commit
b69b580a68
2 changed files with 47 additions and 63 deletions
|
@ -11,6 +11,7 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
import QtQuick.Controls 2.2 as QQC2
|
||||||
|
|
||||||
import "../styles-uit"
|
import "../styles-uit"
|
||||||
|
|
||||||
|
@ -24,6 +25,51 @@ TableView {
|
||||||
|
|
||||||
model: ListModel { }
|
model: ListModel { }
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
tableView.flickableItem.QQC2.ScrollBar.vertical = scrollbar
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.ScrollBar {
|
||||||
|
id: scrollbar
|
||||||
|
parent: tableView.flickableItem
|
||||||
|
policy: QQC2.ScrollBar.AsNeeded
|
||||||
|
orientation: Qt.Vertical
|
||||||
|
visible: size < 1.0
|
||||||
|
topPadding: tableView.headerVisible ? hifi.dimensions.tableHeaderHeight : 0
|
||||||
|
anchors.top: tableView.flickableItem.top
|
||||||
|
anchors.left: tableView.flickableItem.right
|
||||||
|
anchors.bottom: tableView.flickableItem.bottom
|
||||||
|
|
||||||
|
background: Item {
|
||||||
|
implicitWidth: hifi.dimensions.scrollbarBackgroundWidth
|
||||||
|
Rectangle {
|
||||||
|
anchors {
|
||||||
|
fill: parent;
|
||||||
|
topMargin: hifi.dimensions.tableHeaderHeight
|
||||||
|
}
|
||||||
|
color: isLightColorScheme ? hifi.colors.tableScrollBackgroundLight
|
||||||
|
: hifi.colors.tableScrollBackgroundDark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Item {
|
||||||
|
id: scrollbarHandle
|
||||||
|
|
||||||
|
implicitWidth: hifi.dimensions.scrollbarHandleWidth
|
||||||
|
Rectangle {
|
||||||
|
anchors {
|
||||||
|
fill: parent
|
||||||
|
topMargin: 3
|
||||||
|
bottomMargin: 3 // ""
|
||||||
|
leftMargin: 1 // Move it right
|
||||||
|
rightMargin: -1 // ""
|
||||||
|
}
|
||||||
|
radius: hifi.dimensions.scrollbarHandleWidth/2
|
||||||
|
color: isLightColorScheme ? hifi.colors.tableScrollHandleLight : hifi.colors.tableScrollHandleDark
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
headerVisible: false
|
headerVisible: false
|
||||||
headerDelegate: Rectangle {
|
headerDelegate: Rectangle {
|
||||||
height: hifi.dimensions.tableHeaderHeight
|
height: hifi.dimensions.tableHeaderHeight
|
||||||
|
@ -98,74 +144,13 @@ TableView {
|
||||||
backgroundVisible: true
|
backgroundVisible: true
|
||||||
|
|
||||||
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
||||||
verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
|
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
||||||
|
|
||||||
style: TableViewStyle {
|
style: TableViewStyle {
|
||||||
// Needed in order for rows to keep displaying rows after end of table entries.
|
// Needed in order for rows to keep displaying rows after end of table entries.
|
||||||
backgroundColor: tableView.isLightColorScheme ? hifi.colors.tableBackgroundLight : hifi.colors.tableBackgroundDark
|
backgroundColor: tableView.isLightColorScheme ? hifi.colors.tableBackgroundLight : hifi.colors.tableBackgroundDark
|
||||||
alternateBackgroundColor: tableView.isLightColorScheme ? hifi.colors.tableRowLightOdd : hifi.colors.tableRowDarkOdd
|
alternateBackgroundColor: tableView.isLightColorScheme ? hifi.colors.tableRowLightOdd : hifi.colors.tableRowDarkOdd
|
||||||
|
|
||||||
padding.top: headerVisible ? hifi.dimensions.tableHeaderHeight: 0
|
padding.top: headerVisible ? hifi.dimensions.tableHeaderHeight: 0
|
||||||
|
|
||||||
handle: Item {
|
|
||||||
id: scrollbarHandle
|
|
||||||
implicitWidth: hifi.dimensions.scrollbarHandleWidth
|
|
||||||
Rectangle {
|
|
||||||
anchors {
|
|
||||||
fill: parent
|
|
||||||
topMargin: 3
|
|
||||||
bottomMargin: 3 // ""
|
|
||||||
leftMargin: 1 // Move it right
|
|
||||||
rightMargin: -1 // ""
|
|
||||||
}
|
|
||||||
radius: hifi.dimensions.scrollbarHandleWidth/2
|
|
||||||
color: isLightColorScheme ? hifi.colors.tableScrollHandleLight : hifi.colors.tableScrollHandleDark
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollBarBackground: Item {
|
|
||||||
implicitWidth: hifi.dimensions.scrollbarBackgroundWidth
|
|
||||||
Rectangle {
|
|
||||||
anchors {
|
|
||||||
fill: parent
|
|
||||||
margins: -1 // Expand
|
|
||||||
topMargin: -1
|
|
||||||
}
|
|
||||||
color: isLightColorScheme ? hifi.colors.tableScrollBackgroundLight : hifi.colors.tableScrollBackgroundDark
|
|
||||||
|
|
||||||
// Extend header color above scrollbar background
|
|
||||||
Rectangle {
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
topMargin: -hifi.dimensions.tableHeaderHeight
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
height: hifi.dimensions.tableHeaderHeight
|
|
||||||
color: tableView.isLightColorScheme ? hifi.colors.tableBackgroundLight : hifi.colors.tableBackgroundDark
|
|
||||||
visible: headerVisible
|
|
||||||
}
|
|
||||||
Rectangle {
|
|
||||||
// Extend header bottom border
|
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
height: 1
|
|
||||||
color: isLightColorScheme ? hifi.colors.lightGrayText : hifi.colors.baseGrayHighlight
|
|
||||||
visible: headerVisible
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
incrementControl: Item {
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
|
|
||||||
decrementControl: Item {
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rowDelegate: Rectangle {
|
rowDelegate: Rectangle {
|
||||||
|
|
|
@ -364,7 +364,6 @@ void Web3DOverlay::hoverLeaveOverlay(const PointerEvent& event) {
|
||||||
|
|
||||||
void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
||||||
if (_inputMode == Touch) {
|
if (_inputMode == Touch) {
|
||||||
handlePointerEventAsMouse(event);
|
|
||||||
handlePointerEventAsTouch(event);
|
handlePointerEventAsTouch(event);
|
||||||
} else {
|
} else {
|
||||||
handlePointerEventAsMouse(event);
|
handlePointerEventAsMouse(event);
|
||||||
|
|
Loading…
Reference in a new issue