| 1 |
/* |
| 2 |
* Audacity: A Digital Audio Editor |
| 3 |
*/ |
| 4 |
import QtQuick 2.15 |
| 5 |
import QtQuick.Controls 2.15 |
| 6 |
|
| 7 |
import Muse.Ui 1.0 |
| 8 |
import Muse.UiComponents 1.0 |
| 9 |
|
| 10 |
StyledPopupView { |
| 11 |
id: root |
| 12 |
|
| 13 |
padding: 8 |
| 14 |
margins: 8 |
| 15 |
contentWidth: contentRect.width |
| 16 |
contentHeight: contentRect.height |
| 17 |
placement: PopupView.PreferAbove |
| 18 |
openPolicies: PopupView.NoActivateFocus |
| 19 |
|
| 20 |
property rect contentRect: fontMetrics.boundingRect(qsTrc("projectscene", "Pan: 100R")) |
| 21 |
property double value: 0 |
| 22 |
|
| 23 |
Item { |
| 24 |
id: content |
| 25 |
|
| 26 |
anchors.fill: parent |
| 27 |
|
| 28 |
StyledTextLabel { |
| 29 |
id: label |
| 30 |
|
| 31 |
anchors.left: parent.left |
| 32 |
|
| 33 |
text: qsTrc("projectscene", "Pan:") |
| 34 |
} |
| 35 |
|
| 36 |
StyledTextLabel { |
| 37 |
anchors.right: parent.right |
| 38 |
|
| 39 |
text: { |
| 40 |
let value = Math.round(root.value); |
| 41 |
let direction = value < 0 ? 'L' : value > 0 ? 'R' : ''; |
| 42 |
return `${Math.abs(value)}${direction}`; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
FontMetrics { |
| 48 |
id: fontMetrics |
| 49 |
|
| 50 |
font: label.font |
| 51 |
} |
| 52 |
|
| 53 |
Timer { |
| 54 |
id: openTimer |
| 55 |
|
| 56 |
interval: ui.theme.tooltipDelay |
| 57 |
repeat: false |
| 58 |
|
| 59 |
onTriggered: { |
| 60 |
open() |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
Timer { |
| 65 |
id: closeTimer |
| 66 |
|
| 67 |
interval: ui.theme.tooltipDelay |
| 68 |
repeat: false |
| 69 |
|
| 70 |
onTriggered: { |
| 71 |
close() |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
function show() { |
| 76 |
openTimer.restart() |
| 77 |
closeTimer.stop() |
| 78 |
} |
| 79 |
|
| 80 |
function hide() { |
| 81 |
closeTimer.restart() |
| 82 |
openTimer.stop() |
| 83 |
} |
| 84 |
} |