Skip to content

Commit

Permalink
Remove bottom edge tip
Browse files Browse the repository at this point in the history
Instead, show controls briefly before hiding them.
  • Loading branch information
rschroll committed Feb 18, 2015
1 parent a6d8a60 commit efdbeba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 64 deletions.
1 change: 1 addition & 0 deletions ui/BookPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ PageWithBottomEdge {
function onReady() {
bookWebView.opacity = 1
loadingIndicator.opacity = 0
previewControls()
}

function windowSizeChanged() {
Expand Down
89 changes: 25 additions & 64 deletions ui/components/PageWithBottomEdge.qml
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ Page {

property alias bottomEdgePageComponent: edgeLoader.sourceComponent
property alias bottomEdgePageSource: edgeLoader.source
property alias bottomEdgeTitle: tipLabel.text
property string bottomEdgeTitle
property bool bottomEdgeEnabled: true
property int bottomEdgeExpandThreshold: page.height * 0.2
property int bottomEdgeExposedArea: bottomEdge.state !== "expanded" ? (page.height - bottomEdge.y - bottomEdge.tipHeight) : _areaWhenExpanded
property bool reloadBottomEdgePage: true

property alias bottomEdgeControls: controlLoader.sourceComponent
property int controlPreviewTime: 2000

readonly property alias bottomEdgePage: edgeLoader.item
readonly property bool isReady: ((bottomEdge.y === fakeHeader.height) && bottomEdgePageLoaded)
Expand Down Expand Up @@ -106,6 +107,20 @@ Page {
bottomEdge.state = "collapsed"
}

function previewControls() {
bottomEdge.state = "controls"
previewTimer.restart()
}

Timer {
id: previewTimer
interval: controlPreviewTime
onTriggered: {
if (bottomEdge.state == "controls")
closeBottomEdge()
}
}

function _pushPage()
{
if (edgeLoader.status === Loader.Ready) {
Expand Down Expand Up @@ -147,61 +162,6 @@ Page {
z: 1
}

UbuntuShape {
id: tip
objectName: "bottomEdgeTip"

property bool hidden: (activeFocus === false) ||
((bottomEdge.y - units.gu(1)) < tip.y)

property bool isAnimating: true

enabled: mouseArea.enabled
visible: page.bottomEdgeEnabled
anchors {
bottom: parent.bottom
horizontalCenter: bottomEdge.horizontalCenter
bottomMargin: hidden ? - height + units.gu(1) : -units.gu(1)
Behavior on bottomMargin {
SequentialAnimation {
// wait some msecs in case of the focus change again, to avoid flickering
PauseAnimation {
duration: 300
}
UbuntuNumberAnimation {
duration: UbuntuAnimation.SnapDuration
}
ScriptAction {
script: tip.isAnimating = false
}
}
}
}

z: 1
width: tipLabel.paintedWidth + units.gu(6)
height: bottomEdge.tipHeight + units.gu(1)
color: Theme.palette.normal.overlay
Label {
id: tipLabel

anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: bottomEdge.tipHeight
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
opacity: tip.hidden ? 0.0 : 1.0
Behavior on opacity {
UbuntuNumberAnimation {
duration: UbuntuAnimation.SnapDuration
}
}
}
}

Rectangle {
id: shadow

Expand Down Expand Up @@ -262,7 +222,6 @@ Page {
onPressed: {
page.bottomEdgePressed()
previousY = mouse.y
tip.forceActiveFocus()
}

onMouseYChanged: {
Expand Down Expand Up @@ -478,8 +437,6 @@ Page {
// destroy current bottom page
if (page.reloadBottomEdgePage) {
edgeLoader.active = false
} else {
tip.forceActiveFocus()
}

// notify
Expand Down Expand Up @@ -514,10 +471,15 @@ Page {
Transition {
from: "controls"
to: "collapsed,floating"
SmoothedAnimation {
target: controls
property: "y"
duration: UbuntuAnimation.FastDuration
ParallelAnimation{
SmoothedAnimation {
target: controls
property: "y"
duration: UbuntuAnimation.FastDuration
}
ScriptAction {
script: previewTimer.stop()
}
}
}
]
Expand All @@ -536,7 +498,6 @@ Page {
}

onLoaded: {
tip.forceActiveFocus()
if (page.isReady) {
page._pushPage()
}
Expand Down

0 comments on commit efdbeba

Please sign in to comment.