Port PlaySampleSound to QQC2. Fix crash on press down key in scroll window

This commit is contained in:
vladest 2017-11-19 20:09:07 +01:00
parent 19f9af0576
commit b21f66f666
3 changed files with 30 additions and 37 deletions

View file

@ -56,8 +56,8 @@ ScrollingWindow {
id: toolWindowTabViewItem
height: pane.scrollHeight
width: pane.contentWidth
anchors.left: parent.left
anchors.top: parent.top
anchors.left: parent !== null ? parent.left : undefined
anchors.top: parent !== null ? parent.top : undefined
TabView {
id: tabView

View file

@ -9,9 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "../../styles-uit"
@ -57,31 +56,31 @@ RowLayout {
HifiConstants { id: hifi; }
Button {
style: ButtonStyle {
background: Rectangle {
implicitWidth: 20;
implicitHeight: 20;
radius: hifi.buttons.radius;
gradient: Gradient {
GradientStop {
position: 0.2;
color: isPlaying ? hifi.buttons.colorStart[hifi.buttons.blue] : hifi.buttons.colorStart[hifi.buttons.black];
}
GradientStop {
position: 1.0;
color: isPlaying ? hifi.buttons.colorFinish[hifi.buttons.blue] : hifi.buttons.colorFinish[hifi.buttons.black];
}
id: control
background: Rectangle {
implicitWidth: 20;
implicitHeight: 20;
radius: hifi.buttons.radius;
gradient: Gradient {
GradientStop {
position: 0.2;
color: isPlaying ? hifi.buttons.colorStart[hifi.buttons.blue] : hifi.buttons.colorStart[hifi.buttons.black];
}
GradientStop {
position: 1.0;
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();
}

View file

@ -43,7 +43,9 @@ Window {
// type should only consist of logic sized areas, with nothing drawn (although the
// default value for the frame property does include visual decorations)
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 scrollHeight: scrollView.height
@ -76,7 +78,7 @@ Window {
ScrollView {
id: scrollView
contentItem: content
contentChildren: content
clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
anchors.fill: parent
@ -84,13 +86,7 @@ Window {
anchors.bottomMargin: footerPane.height
ScrollBar.vertical: ScrollBar {
parent: scrollView
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 {
implicitWidth: 8
Rectangle {
@ -118,10 +114,8 @@ Window {
}
}
}
}
function scrollBy(delta) {
scrollView.flickableItem.contentY += delta;
}