Newer
Older
/** This file is part of Nootka (http://nootka.sf.net) *
* Copyright (C) 2017-2021 by Tomasz Bojczuk (seelook@gmail.com) *
* on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */
import QtQuick 2.12
import QtQuick.Controls 2.12
import Score 1.0
import Nootka 1.0
import Nootka.Main 1.0
Score {
id: mainScore
property alias showNamesAct: mainObj.showNamesAct
property alias extraAccidsAct: mainObj.extraAccidsAct
property alias zoomInAct: mainObj.zoomInAct
property alias zoomOutAct: mainObj.zoomOutAct
property alias transposeAct: mainObj.transposeAct
property alias openXmlAct: mainObj.openXmlAct
property alias saveXmlAct: mainObj.saveXmlAct
property alias playAct: mainObj.playAct
property alias scoreActions: mainObj.scoreActions
property alias melodyActions: mainObj.melodyActions
property alias noteActions: mainObj.noteActions
property alias notesMenuAct: mainObj.notesMenuAct
property alias randMelodyAct: mainObj.randMelodyAct
property alias keyName: keyName
SeeLook
committed
scoreObj.meter: GLOB.rhythmsEnabled && !GLOB.singleNoteMode ? Tmeter.Meter_4_4 : Tmeter.NoMeter
focus: true
clef: GLOB.clefType
enableDoubleAccids: GLOB.enableDoubleAccids
scoreObj.showNoteNames: GLOB.namesOnScore
SeeLook
committed
scoreObj.nameColor: GLOB.nameColor
scoreObj.nameStyle: GLOB.noteNameStyle
scoreObj.enableDoubleAccidentals: GLOB.enableDoubleAccids
scoreObj.enharmNotesEnabled: GLOB.showEnharmNotes
scoreObj.bgColor: activPal.base
scoreObj.enableTechnical: GLOB.instrument.bandoneon
TmainScoreObject {
id: mainObj
onMelodyGenerate: nootkaWindow.showDialog(Nootka.MelodyGenerator)
mainScoreItem: mainScore
onMelodyNameDialog: Qt.createComponent("qrc:/score/MelodyNameDialog.qml").createObject(nootkaWindow)
onWantSelectGotIt: Qt.createComponent("qrc:/gotit/NoteSelected.qml").createObject(nootkaWindow.contentItem.parent, { "remaindChecked": true })
notesMenuAct.enabled: mainScore.meter !== Tmeter.NoMeter
}
Text {
text: mainObj.title
visible: !singleNote
y: NOO.factor() / 2; x: parent.width * 0.125; z: -1
color: activPal.dimText
width: parent.width * 0.75
horizontalAlignment: Text.AlignHCenter
font { pixelSize: NOO.factor() * 2; bold: true }
}
Text {
text: mainObj.composer
visible: !singleNote
y: NOO.factor() * 1.5; x: parent.width * 0.875; z: -1
color: activPal.dimText
width: parent.width * 0.125
horizontalAlignment: Text.AlignHCenter
font.bold: true
}
pinch.dragAxis: Pinch.XandYAxis
onPinchFinished: {
zoom(false)
}
// HACK: keeping MouseArea inside PinchArea makes it working
MouseArea {
anchors.fill: parent
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y > 0)
zoom(true)
else if (wheel.angleDelta.y < 0)
zoom(false)
} else
wheel.accepted = false
}
// reset note selection when score is clicked
onClicked: currentNote = null
function zoom(zoomIn) {
if (!zoomTimer.running) {
if (zoomIn)
zoomInAct.trigger()
else
zoomOutAct.trigger()
zoomTimer.running = true
Text {
id: keyName
parent: firstStaff
visible: GLOB.showKeyName && enableKeySign
x: clef === Tclef.PianoStaffClefs ? 7.5 : 5.5
y: clef === Tclef.PianoStaffClefs ? 4.2 : 7
color: activPal.text
font { pixelSize: 12 }
transformOrigin: Item.TopLeft; scale: 1.0 / 6.0
text: GLOB.showKeyName && enableKeySign ? mainObj.keyNameText : ""
}
SeeLook
committed
// private
property var scordature: null
property var notePrompt: null
SeeLook
committed
Connections {
target: SOUND
onInitialized: {
mainObj.scoreObject = scoreObj
singleNote = Qt.binding(function() { return GLOB.singleNoteMode })
scoreObj.allowAdding = Qt.binding(function() { return !GLOB.singleNoteMode })
enableKeySign = Qt.binding(function() { return GLOB.keySignatureEnabled })
updateScord()
if (!GLOB.singleNoteMode)
scoreObj.editModeAct.trigger()
if (NOO.isAndroid() && GLOB.gotIt("howToScore", true))
Qt.createComponent("qrc:/gotit/FirstTouchScore.qml").createObject(mainScore)
SeeLook
committed
}
SeeLook
committed
Connections {
target: GLOB
onClefTypeChanged: score.clef = GLOB.clefType
SeeLook
committed
}
SeeLook
committed
Connections {
target: GLOB.tuning
onScordatureChanged: updateScord()
}
SeeLook
committed
function updateScord() {
SeeLook
committed
scordature.destroy()
if (GLOB.tuning.scordature && GLOB.instrument.isGuitar && !GLOB.instrument.bassGuitar && !GLOB.instrument.ukulele) {
scordature = Qt.createComponent("qrc:/score/Scordature.qml").createObject(firstStaff)
firstStaff.scordSpace = scordature.realHeight
SeeLook
committed
} else
firstStaff.scordSpace = 0
}
onSingleNoteChanged: {
if (singleNote)
notePrompt = Qt.createComponent("qrc:/score/NotePrompt.qml").createObject(scoreObj.note(0))
else
notePrompt.destroy()
}
Rectangle { // note highlight
id: noteHighlight
parent: currentNote
visible: currentNote != null && !singleNote
width: currentNote ? (currentNote.width - currentNote.alterWidth) * 1.5 : 0
height: currentNote ? Math.min(12.0, currentNote.notePosY + 6.0) : 0
x: currentNote ? -width * 0.25 : 0
y: currentNote ? Math.min(currentNote.height - height, Math.max(0.0, currentNote.notePosY - height / 2.0)) : 0
color: NOO.alpha(activPal.highlight, 75)
z: -1
radius: width / 3.0
}