Skip to content
Snippets Groups Projects
MainScore.qml 5.62 KiB
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
  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
  scoreObj.meter: GLOB.rhythmsEnabled && !GLOB.singleNoteMode ? Tmeter.Meter_4_4 : Tmeter.NoMeter
  enableDoubleAccids: GLOB.enableDoubleAccids
  scoreObj.showNoteNames: GLOB.namesOnScore
  scoreObj.nameColor: GLOB.nameColor
  scoreObj.nameStyle: GLOB.noteNameStyle
  scoreObj.enableDoubleAccidentals: GLOB.enableDoubleAccids
  scoreObj.enharmNotesEnabled: GLOB.showEnharmNotes
  scoreObj.enableTechnical: GLOB.instrument.bandoneon
    onMelodyGenerate: nootkaWindow.showDialog(Nootka.MelodyGenerator)
    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
  Timer { id: zoomTimer; interval: 500 }
  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
  }

SeeLook's avatar
SeeLook committed
  PinchArea {
    anchors.fill: parent
SeeLook's avatar
SeeLook committed
    pinch.dragAxis: Pinch.XandYAxis
    onPinchFinished: {
      if (pinch.scale > 1.4)
SeeLook's avatar
SeeLook committed
        zoom(true)
      else if (pinch.scale < 0.7)
SeeLook's avatar
SeeLook committed
        zoom(false)
    }
    // HACK: keeping MouseArea inside PinchArea makes it working
    MouseArea {
      anchors.fill: parent
SeeLook's avatar
SeeLook committed
      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
SeeLook's avatar
SeeLook committed
  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
    font { pixelSize: 12 }
    transformOrigin: Item.TopLeft; scale: 1.0 / 6.0
    text: GLOB.showKeyName && enableKeySign ? mainObj.keyNameText : ""
  Connections {
    target: SOUND
    onInitialized: {
      singleNote = Qt.binding(function() { return GLOB.singleNoteMode })
      scoreObj.allowAdding = Qt.binding(function() { return !GLOB.singleNoteMode })
      enableKeySign = Qt.binding(function() { return GLOB.keySignatureEnabled })
      if (!GLOB.singleNoteMode)
        scoreObj.editModeAct.trigger()
      if (NOO.isAndroid() && GLOB.gotIt("howToScore", true))
        Qt.createComponent("qrc:/gotit/FirstTouchScore.qml").createObject(mainScore)
    onClefTypeChanged: score.clef = GLOB.clefType
  Connections {
    target: GLOB.tuning
    onScordatureChanged: updateScord()
  }
    if (scordature)
SeeLook's avatar
SeeLook committed
    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
    if (singleNote)
      notePrompt = Qt.createComponent("qrc:/score/NotePrompt.qml").createObject(scoreObj.note(0))
    else
      notePrompt.destroy()
    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)