[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #77 from SecondFlight/feature
Browse files Browse the repository at this point in the history
Add project component
  • Loading branch information
SecondFlight committed Nov 3, 2020
2 parents dea68be + 34ea88a commit 89b68de
Show file tree
Hide file tree
Showing 12 changed files with 511 additions and 365 deletions.
2 changes: 2 additions & 0 deletions Main/BasicComponents/DigitControl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ Item {
// If highBound and lowBound are unset, they will both be 0
property bool hasBound: highBound != lowBound

cursorShape: Qt.SizeVerCursor

onDrag: {
let delta = ((deltaY) * 0.07 * speedMultiplier * _stepsPerIncrement) + remainder;
let roundedDelta = Math.round(Math.round(delta / _stepsPerIncrement) * _stepsPerIncrement);
Expand Down
11 changes: 9 additions & 2 deletions Main/BasicComponents/Icon.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import QtQuick 2.15
import QtGraphicalEffects 1.15
import QtQuick.Window 2.15

Item {
id: icon
Expand All @@ -41,9 +42,15 @@ Item {
anchors.centerIn: parent
sourceSize.width: imageWidth
sourceSize.height: imageHeight
fillMode: Image.PreserveAspectFit
fillMode: Image.Pad
visible: false
sourceClipRect: Qt.rect(-1, -1, imageWidth + 2, imageHeight + 2)
sourceClipRect:
Qt.rect(
-1,
-1,
imageWidth * Screen.devicePixelRatio + 2,
imageHeight * Screen.devicePixelRatio + 2
)
}
ColorOverlay {
anchors.fill: image
Expand Down
200 changes: 125 additions & 75 deletions Main/ControlsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@
<https://www.gnu.org/licenses/>.
*/

import QtQuick 2.14
import QtGraphicalEffects 1.14
import QtQuick 2.15
import QtGraphicalEffects 1.15
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.15

import "BasicComponents"
import "Global"
import "Menus"

Rectangle {
id: controlsPanel
property real spacerMargins: 7

height: 42

function updateAll() {
Expand All @@ -35,36 +39,35 @@ Rectangle {
tempoControl.value = Anthem.getBeatsPerMinute();
}

Connections {
target: mainWindow
function onFlush() {
updateAll();
}
}

radius: 1
color: colors.white_12

Item {
id: controlPanelSpacer
id: paddingItem
anchors {
fill: parent
margins: 7
margins: controlsPanel.spacerMargins
}

Row {
id: groupContainer
property int totalGroupWidths:
property real totalGroupWidths:
group1.width + spacerWidth +
group2.width + spacerWidth +
group3.width + spacerWidth +
group4.width + spacerWidth +
group5.width + spacerWidth +
group6.width
property int spacerWidth: 2
property int groupCount: 6
property real spacerWidth: 2
property real groupCount: 6
property real spacerCount: groupCount * 2 - 2

spacing: (controlPanelSpacer.width - totalGroupWidths) / ((groupCount - 1) * 2)
property real spacingBase:
Math.floor(
(Screen.devicePixelRatio *
(paddingItem.width - totalGroupWidths)) /
((groupCount - 1) * 2)
) / Screen.devicePixelRatio;

Row {
id: group1
Expand Down Expand Up @@ -191,13 +194,22 @@ Rectangle {
}
}

ControlsPanelSpacer {
spacerNumber: 1
}

Rectangle {
height: 16
anchors.verticalCenter: parent.verticalCenter
width: groupContainer.spacerWidth
color: colors.white_12
}

ControlsPanelSpacer {
spacerNumber: 2
}


Row {
id: group2
spacing: 4
Expand Down Expand Up @@ -242,13 +254,21 @@ Rectangle {
}
}

ControlsPanelSpacer {
spacerNumber: 3
}

Rectangle {
height: 16
anchors.verticalCenter: parent.verticalCenter
width: groupContainer.spacerWidth
color: colors.white_12
}

ControlsPanelSpacer {
spacerNumber: 4
}

Row {
id: group3
spacing: 4
Expand Down Expand Up @@ -315,81 +335,98 @@ Rectangle {
}
}

ControlsPanelSpacer {
spacerNumber: 5
}

Rectangle {
height: 16
anchors.verticalCenter: parent.verticalCenter
width: groupContainer.spacerWidth
color: colors.white_12
}

ControlsPanelSpacer {
spacerNumber: 6
}

Row {
id: group4
spacing: 2

DigitControl {
id: tempoControl

Item {
height: 28
width: 70

lowBound: 10
highBound: 999
step: 0.01
smallestIncrement: 0.01
decimalPlaces: 2
value: 140
property int lastSentValue: 140
hoverMessage: qsTr("Tempo")
units: qsTr("BPM")

fontPixelSize: 16

// onValueChanged: {
// Anthem.setBeatsPerMinute(value, false);
// }

onValueChangeCompleted: {
const old = lastSentValue;

const command = {
exec: () => {
lastSentValue = value;
tempoControl.value = value;
Anthem.setBeatsPerMinute(value, true);
},
undo: () => {
lastSentValue = old;
tempoControl.value = old;
Anthem.setBeatsPerMinute(old, true);
},
description: qsTr('set BPM')
DigitControl {
id: tempoControl

anchors {
fill: parent
rightMargin: 6
}

exec(command);
}
lowBound: 10
highBound: 999
step: 0.01
smallestIncrement: 0.01
decimalPlaces: 2
value: 140
property real lastSentValue: 140
hoverMessage: qsTr("Tempo")
units: qsTr("BPM")

fontPixelSize: 16
alignment: Text.AlignRight

// onValueChanged: {
// Anthem.setBeatsPerMinute(value, false);
// }

onValueChangeCompleted: {
const old = lastSentValue;

// This MouseArea changes the step on tempoControl
// depending on which digit is clicked.
MouseArea {
anchors.fill: parent
onPressed: {
mouse.accepted = false;
let distanceFromRight = parent.width - mouseX;
if (distanceFromRight <= 8) {
tempoControl.step = 0.01;
const command = {
exec: () => {
lastSentValue = value;
tempoControl.value = value;
Anthem.setBeatsPerMinute(value, true);
},
undo: () => {
lastSentValue = old;
tempoControl.value = old;
Anthem.setBeatsPerMinute(old, true);
},
description: qsTr('set BPM')
}
else if (distanceFromRight <= 16) {
tempoControl.step = 0.1;

exec(command);
}

// This MouseArea changes the step on tempoControl
// depending on which digit is clicked.
MouseArea {
anchors.fill: parent
onPressed: {
mouse.accepted = false;
let distanceFromRight = parent.width - mouseX;
if (distanceFromRight <= 10) {
tempoControl.step = 0.01;
}
else if (distanceFromRight <= 20) {
tempoControl.step = 0.1;
}
else {
tempoControl.step = 1;
}
}
else {
tempoControl.step = 1;
onReleased: {
mouse.accepted = false;
}
}
onReleased: {
mouse.accepted = false;
}
onPositionChanged: {
mouse.accepted = false;
onPositionChanged: {
mouse.accepted = false;
}
cursorShape: Qt.SizeVerCursor
}
}
}
Expand All @@ -404,7 +441,7 @@ Rectangle {
anchors.bottom: parent.bottom
anchors.right: timeSignatureSlash.left
width: 18
hoverMessage: qsTr("Time signature numerator")
hoverMessage: qsTr("Time signature")

fontPixelSize: 16
alignment: Text.AlignRight
Expand Down Expand Up @@ -441,7 +478,6 @@ Rectangle {
id: timeSignatureSlash
text: "/"
font.family: Fonts.monoMedium.name
font.weight: Font.Bold
font.pixelSize: 16
anchors.centerIn: parent
color: colors.white_70
Expand All @@ -455,7 +491,7 @@ Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
width: 18
hoverMessage: qsTr("Time signature denominator")
hoverMessage: qsTr("Time signature")

fontPixelSize: 16
alignment: Text.AlignLeft
Expand Down Expand Up @@ -496,7 +532,6 @@ Rectangle {
height: 28

font.family: Fonts.monoMedium.name
font.weight: Font.Bold
font.pixelSize: 16

color: colors.white_70
Expand All @@ -511,7 +546,6 @@ Rectangle {
height: 28

font.family: Fonts.monoMedium.name
font.weight: Font.Bold
font.pixelSize: 16

color: colors.white_70
Expand All @@ -520,13 +554,21 @@ Rectangle {
}
}

ControlsPanelSpacer {
spacerNumber: 7
}

Rectangle {
height: 16
anchors.verticalCenter: parent.verticalCenter
width: groupContainer.spacerWidth
color: colors.white_12
}

ControlsPanelSpacer {
spacerNumber: 8
}

Row {
id: group5
spacing: 4
Expand Down Expand Up @@ -571,13 +613,21 @@ Rectangle {
}
}

ControlsPanelSpacer {
spacerNumber: 9
}

Rectangle {
height: 16
anchors.verticalCenter: parent.verticalCenter
width: groupContainer.spacerWidth
color: colors.white_12
}

ControlsPanelSpacer {
spacerNumber: 10
}

Row {
id: group6
spacing: 4
Expand Down
Loading

0 comments on commit 89b68de

Please sign in to comment.