mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 13:49:23 +02:00
Port PlaySampleSound to QQC2. Fix crash on press down key in scroll window
This commit is contained in:
parent
19f9af0576
commit
b21f66f666
3 changed files with 30 additions and 37 deletions
|
@ -56,8 +56,8 @@ ScrollingWindow {
|
||||||
id: toolWindowTabViewItem
|
id: toolWindowTabViewItem
|
||||||
height: pane.scrollHeight
|
height: pane.scrollHeight
|
||||||
width: pane.contentWidth
|
width: pane.contentWidth
|
||||||
anchors.left: parent.left
|
anchors.left: parent !== null ? parent.left : undefined
|
||||||
anchors.top: parent.top
|
anchors.top: parent !== null ? parent.top : undefined
|
||||||
|
|
||||||
TabView {
|
TabView {
|
||||||
id: tabView
|
id: tabView
|
||||||
|
|
|
@ -9,9 +9,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Controls.Styles 1.4
|
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
import "../../styles-uit"
|
import "../../styles-uit"
|
||||||
|
@ -57,31 +56,31 @@ RowLayout {
|
||||||
HifiConstants { id: hifi; }
|
HifiConstants { id: hifi; }
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
style: ButtonStyle {
|
id: control
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 20;
|
implicitWidth: 20;
|
||||||
implicitHeight: 20;
|
implicitHeight: 20;
|
||||||
radius: hifi.buttons.radius;
|
radius: hifi.buttons.radius;
|
||||||
gradient: Gradient {
|
gradient: Gradient {
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 0.2;
|
position: 0.2;
|
||||||
color: isPlaying ? hifi.buttons.colorStart[hifi.buttons.blue] : hifi.buttons.colorStart[hifi.buttons.black];
|
color: isPlaying ? hifi.buttons.colorStart[hifi.buttons.blue] : hifi.buttons.colorStart[hifi.buttons.black];
|
||||||
}
|
}
|
||||||
GradientStop {
|
GradientStop {
|
||||||
position: 1.0;
|
position: 1.0;
|
||||||
color: isPlaying ? hifi.buttons.colorFinish[hifi.buttons.blue] : hifi.buttons.colorFinish[hifi.buttons.black];
|
color: isPlaying ? hifi.buttons.colorFinish[hifi.buttons.blue] : hifi.buttons.colorFinish[hifi.buttons.black];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
label: HiFiGlyphs {
|
|
||||||
// absolutely position due to asymmetry in glyph
|
|
||||||
x: isPlaying ? 0 : 1;
|
|
||||||
y: 1;
|
|
||||||
size: 14;
|
|
||||||
color: (control.pressed || control.hovered) ? (isPlaying ? "black" : hifi.colors.primaryHighlight) : "white";
|
|
||||||
text: isPlaying ? hifi.glyphs.stop_square : hifi.glyphs.playback_play;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
contentItem: HiFiGlyphs {
|
||||||
|
// absolutely position due to asymmetry in glyph
|
||||||
|
// x: isPlaying ? 0 : 1;
|
||||||
|
// y: 1;
|
||||||
|
size: 14;
|
||||||
|
color: (control.pressed || control.hovered) ? (isPlaying ? "black" : hifi.colors.primaryHighlight) : "white";
|
||||||
|
text: isPlaying ? hifi.glyphs.stop_square : hifi.glyphs.playback_play;
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: isPlaying ? stopSound() : playSound();
|
onClicked: isPlaying ? stopSound() : playSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ Window {
|
||||||
// type should only consist of logic sized areas, with nothing drawn (although the
|
// type should only consist of logic sized areas, with nothing drawn (although the
|
||||||
// default value for the frame property does include visual decorations)
|
// default value for the frame property does include visual decorations)
|
||||||
property var pane: Item {
|
property var pane: Item {
|
||||||
property bool isScrolling: scrollView.height < scrollView.contentItem.height
|
property bool isScrolling: scrollView.contentChildren.length > 0 ?
|
||||||
|
(scrollView.height < scrollView.contentChildren[0].height) :
|
||||||
|
false
|
||||||
property int contentWidth: scrollView.width - (isScrolling ? 10 : 0)
|
property int contentWidth: scrollView.width - (isScrolling ? 10 : 0)
|
||||||
property int scrollHeight: scrollView.height
|
property int scrollHeight: scrollView.height
|
||||||
|
|
||||||
|
@ -76,7 +78,7 @@ Window {
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
id: scrollView
|
id: scrollView
|
||||||
contentItem: content
|
contentChildren: content
|
||||||
clip: true
|
clip: true
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
@ -84,13 +86,7 @@ Window {
|
||||||
anchors.bottomMargin: footerPane.height
|
anchors.bottomMargin: footerPane.height
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
parent: scrollView
|
|
||||||
policy: ScrollBar.AsNeeded
|
policy: ScrollBar.AsNeeded
|
||||||
orientation: Qt.Vertical
|
|
||||||
x: scrollView.mirrored ? 0 : scrollView.width - width
|
|
||||||
y: scrollView.topPadding
|
|
||||||
height: scrollView.availableHeight
|
|
||||||
active: scrollView.ScrollBar.horizontal.active
|
|
||||||
contentItem: Item {
|
contentItem: Item {
|
||||||
implicitWidth: 8
|
implicitWidth: 8
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -118,10 +114,8 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function scrollBy(delta) {
|
function scrollBy(delta) {
|
||||||
scrollView.flickableItem.contentY += delta;
|
scrollView.flickableItem.contentY += delta;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue