diff --git a/src/app/plugins/CMakeLists.txt b/src/app/plugins/CMakeLists.txt index df2e556..715744e 100644 --- a/src/app/plugins/CMakeLists.txt +++ b/src/app/plugins/CMakeLists.txt @@ -1,7 +1,9 @@ set(minuet_PLUGINS PianoView.json + GuitarView.json ) add_subdirectory(PianoView) +add_subdirectory(GuitarView) install(FILES ${minuet_PLUGINS} DESTINATION ${KDE_INSTALL_DATADIR}/minuet/plugins) diff --git a/src/app/plugins/GuitarView.json b/src/app/plugins/GuitarView.json new file mode 100644 index 0000000..9f938e2 --- /dev/null +++ b/src/app/plugins/GuitarView.json @@ -0,0 +1,5 @@ +{ + "menuName": "GuitarView", + "iconName": "group", + "mainPage": "GuitarView.qml" +} diff --git a/src/app/plugins/GuitarView/CMakeLists.txt b/src/app/plugins/GuitarView/CMakeLists.txt new file mode 100644 index 0000000..d276b9e --- /dev/null +++ b/src/app/plugins/GuitarView/CMakeLists.txt @@ -0,0 +1,6 @@ +set(minuet_GUITAR + GuitarView.qml + FretBoard.qml +) + +install(FILES ${minuet_GUITAR} DESTINATION ${KDE_INSTALL_DATADIR}/minuet/plugins/GuitarView) diff --git a/src/app/plugins/GuitarView/FretBoard.qml b/src/app/plugins/GuitarView/FretBoard.qml new file mode 100644 index 0000000..356c722 --- /dev/null +++ b/src/app/plugins/GuitarView/FretBoard.qml @@ -0,0 +1,92 @@ +import QtQuick 2.7 + +Rectangle { + id: fretBoard + height: (string1.height + string1.anchors.topMargin) * 6 + string1.anchors.topMargin + color: "#4b3020" + property double string_size: 3 + property string string_color: "#FFF2E6" + property bool show_fret_marker: false + property bool show_two_markers: false + property bool is_nut: false + property bool is_end: false + + Rectangle { + id: fret_marker1 + height: 6.5 * string_size; width: height + radius: width * 0.5 + visible: show_fret_marker + opacity: 0.7 + anchors { + horizontalCenter: parent.horizontalCenter + horizontalCenterOffset: - string_size / 2 + verticalCenter: parent.verticalCenter + verticalCenterOffset: show_two_markers ? -(parent.height - (string1.y - parent.y)) / 4 : 0 + } + color: "#E2E2E2" + border.width: string_size / 2 + border.color: "#535353" + } + + Rectangle { + id: fret_marker2 + height: fret_marker1.height; width: height + radius: width * 0.5 + visible: show_two_markers + opacity: fret_marker1.opacity + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + verticalCenterOffset: show_two_markers ? (parent.height - (string1.y - parent.y)) / 4 : 0 + } + color: "#E2E2E2" + border.width: string_size / 2 + border.color: "#535353" + } + + Rectangle { + id: string1 + width: parent.width; height: string_size + anchors { left: parent.left; top: parent.top; topMargin: 3 * height} + color: string_color + } + + Rectangle { + id: string2 + width: parent.width; height: string_size + anchors { left: parent.left; top: string1.bottom; topMargin: 3 * height} + color: string_color + } + Rectangle { + id: string3 + width: parent.width; height: string_size + anchors { left: parent.left; top: string2.bottom; topMargin: 3 * height} + color: string_color + } + Rectangle { + id: string4 + width: parent.width; height: string_size + anchors { left: parent.left; top: string3.bottom; topMargin: 3 * height} + color: string_color + } + Rectangle { + id: string5 + width: parent.width; height: string_size + anchors { left: parent.left; top: string4.bottom; topMargin: 3 * height} + color: string_color + } + Rectangle { + id: string6 + width: parent.width; height: string_size + anchors { left: parent.left; top: string5.bottom; topMargin: 3 * height} + color: string_color + } + + Rectangle { + id: rightBar + width: is_nut ? string_size * 4 : string_size; height: parent.height + anchors {right: parent.right; top: parent.top; bottom: parent.bottom} + visible: is_end ? false : true + color: "#D9D9D9" + } +} diff --git a/src/app/plugins/GuitarView/GuitarView.qml b/src/app/plugins/GuitarView/GuitarView.qml new file mode 100644 index 0000000..6374f3d --- /dev/null +++ b/src/app/plugins/GuitarView/GuitarView.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 by Sandro S. Andrade +** +** This program is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License or (at your option) version 3 or any later version +** accepted by the membership of KDE e.V. (or its successor approved +** by the membership of KDE e.V.), which shall act as a proxy +** defined in Section 14 of version 3 of the license. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.0 + +Flickable { + id: flickable + + width: guitar.width + height: 156.4 + contentWidth: guitar.width + boundsBehavior: Flickable.OvershootBounds + clip: true + + function noteOn(chan, pitch, vel) { + } + function noteOff(chan, pitch, vel) { + } + function noteMark(chan, pitch, vel, color) { + } + function noteUnmark(chan, pitch, vel, color) { + } + function clearAllMarks() { + } + function scrollToNote(pitch) { + } + function highlightKey(pitch, color) { + } + function itemForPitch(pitch) { + } + + Rectangle { + id: guitar + + width: board.board_width * 410 + 8.5; height: parent.height + anchors.horizontalCenter: parent.horizontalCenter + radius: 5 + color: "#141414" + + Item { + id: board + width: parent.width + height: fretBoard1.height + anchors.centerIn: parent + + property double board_width: 2.5 + + FretBoard { id: nut; anchors.left: parent.left ; width: board.board_width * 8.5; is_nut: true} + FretBoard { id: fretBoard1; anchors.left: nut.right ; width: board.board_width * 29.466} + FretBoard { id: fretBoard2; anchors.left: fretBoard1.right; width: board.board_width * 27.812} + FretBoard { id: fretBoard3; anchors.left: fretBoard2.right; width: board.board_width * 26.251; show_fret_marker: true} + FretBoard { id: fretBoard4; anchors.left: fretBoard3.right; width: board.board_width * 24.788} + FretBoard { id: fretBoard5; anchors.left: fretBoard4.right; width: board.board_width * 23.387; show_fret_marker: true} + FretBoard { id: fretBoard6; anchors.left: fretBoard5.right; width: board.board_width * 22.075} + FretBoard { id: fretBoard7; anchors.left: fretBoard6.right; width: board.board_width * 20.836; show_fret_marker: true} + FretBoard { id: fretBoard8; anchors.left: fretBoard7.right; width: board.board_width * 19.666} + FretBoard { id: fretBoard9; anchors.left: fretBoard8.right; width: board.board_width * 18.562; show_fret_marker: true} + FretBoard { id: fretBoard10; anchors.left: fretBoard9.right; width: board.board_width * 17.521} + FretBoard { id: fretBoard11; anchors.left: fretBoard10.right; width: board.board_width * 16.537} + FretBoard { id: fretBoard12; anchors.left: fretBoard11.right; width: board.board_width * 15.609; show_fret_marker: true; show_two_markers: true} + FretBoard { id: fretBoard13; anchors.left: fretBoard12.right; width: board.board_width * 14.733} + FretBoard { id: fretBoard14; anchors.left: fretBoard13.right; width: board.board_width * 13.906} + FretBoard { id: fretBoard15; anchors.left: fretBoard14.right; width: board.board_width * 13.126; show_fret_marker: true} + FretBoard { id: fretBoard16; anchors.left: fretBoard15.right; width: board.board_width * 12.289} + FretBoard { id: fretBoard17; anchors.left: fretBoard16.right; width: board.board_width * 11.693; show_fret_marker: true} + FretBoard { id: fretBoard18; anchors.left: fretBoard17.right; width: board.board_width * 11.037} + FretBoard { id: fretBoard19; anchors.left: fretBoard18.right; width: board.board_width * 10.418} + FretBoard { id: fretBoard20; anchors.left: fretBoard19.right; width: board.board_width * 9.833} + FretBoard { id: fretBoard21; anchors.left: fretBoard20.right; width: board.board_width * 9.282} + FretBoard { id: fretBoard22; anchors.left: fretBoard21.right; width: board.board_width * 9.760} + FretBoard { id: chords; anchors.left: fretBoard22.right; width: board.board_width * 30; is_end: true} + } + } + + ScrollIndicator.horizontal: ScrollIndicator { active: true } +} diff --git a/src/app/plugins/PianoView/BlackKey.qml b/src/app/plugins/PianoView/BlackKey.qml index 20f2076..85c3ab5 100644 --- a/src/app/plugins/PianoView/BlackKey.qml +++ b/src/app/plugins/PianoView/BlackKey.qml @@ -1,33 +1,33 @@ /**************************************************************************** ** ** Copyright (C) 2016 by Sandro S. Andrade ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as ** published by the Free Software Foundation; either version 2 of ** the License or (at your option) version 3 or any later version ** accepted by the membership of KDE e.V. (or its successor approved -** by the membership of KDE e.V.), which shall act as a proxy +** by the membership of KDE e.V.), which shall act as a proxy ** defined in Section 14 of version 3 of the license. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . ** ****************************************************************************/ import QtQuick 2.7 Rectangle { property Item anchor width: 0.6 * keyWidth; height: 0.6 * keyHeight anchors { left: anchor.right; leftMargin: -(0.6 * keyWidth) / 2; top: anchor.top } border { width: 1; color: "black" } color: "black" z: 1 } diff --git a/src/app/plugins/PianoView/Octave.qml b/src/app/plugins/PianoView/Octave.qml index df760ec..7cdefdb 100644 --- a/src/app/plugins/PianoView/Octave.qml +++ b/src/app/plugins/PianoView/Octave.qml @@ -1,43 +1,43 @@ /**************************************************************************** ** ** Copyright (C) 2016 by Sandro S. Andrade ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as ** published by the Free Software Foundation; either version 2 of ** the License or (at your option) version 3 or any later version ** accepted by the membership of KDE e.V. (or its successor approved -** by the membership of KDE e.V.), which shall act as a proxy +** by the membership of KDE e.V.), which shall act as a proxy ** defined in Section 14 of version 3 of the license. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . ** ****************************************************************************/ import QtQuick 2.7 Item { property Item initialAnchor width: 7 * keyWidth; height: keyHeight - 10 anchors.left: initialAnchor.right WhiteKey { id: whiteKey1 } BlackKey { anchor: whiteKey1 } WhiteKey { id: whiteKey2; anchor: whiteKey1 } BlackKey { anchor: whiteKey2 } WhiteKey { id: whiteKey3; anchor: whiteKey2 } WhiteKey { id: whiteKey4; anchor: whiteKey3 } BlackKey { anchor: whiteKey4 } WhiteKey { id: whiteKey5; anchor: whiteKey4 } BlackKey { anchor: whiteKey5 } WhiteKey { id: whiteKey6; anchor: whiteKey5 } BlackKey { anchor: whiteKey6 } WhiteKey { anchor: whiteKey6 } } diff --git a/src/app/plugins/PianoView/PianoView.qml b/src/app/plugins/PianoView/PianoView.qml index 90b3218..cdf8433 100644 --- a/src/app/plugins/PianoView/PianoView.qml +++ b/src/app/plugins/PianoView/PianoView.qml @@ -1,147 +1,147 @@ /**************************************************************************** ** ** Copyright (C) 2016 by Sandro S. Andrade ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as ** published by the Free Software Foundation; either version 2 of ** the License or (at your option) version 3 or any later version ** accepted by the membership of KDE e.V. (or its successor approved -** by the membership of KDE e.V.), which shall act as a proxy +** by the membership of KDE e.V.), which shall act as a proxy ** defined in Section 14 of version 3 of the license. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . ** ****************************************************************************/ import QtQuick 2.7 import QtQuick.Controls 2.0 Flickable { id: flickable width: Math.min(parent.width, piano.width) height: keyHeight + 30 contentWidth: piano.width boundsBehavior: Flickable.OvershootBounds clip: true property int keyWidth: Math.max(16, (parent.width - 80) / 52) property int keyHeight: 3.4 * keyWidth function noteOn(chan, pitch, vel) { if (vel > 0) highlightKey(pitch, "#778692") else noteOff(chan, pitch, vel) } function noteOff(chan, pitch, vel) { highlightKey(pitch, ([1,3,6,8,10].indexOf(pitch % 12) > -1) ? "black":"white") } function noteMark(chan, pitch, vel, color) { noteMark.createObject(itemForPitch(pitch), { color: color }) } function noteUnmark(chan, pitch, vel, color) { if(itemForPitch(pitch)!= undefined){ var item = itemForPitch(pitch).children[0] if (item != undefined) item.destroy() } } function clearAllMarks() { for (var index = 21; index <= 108; ++index) { noteOff(0, index, 0) var markItem = itemForPitch(index).children[0] if (markItem != undefined) markItem.destroy() } } function scrollToNote(pitch) { flickable.contentX = flickable.contentWidth/88*(pitch-21) - flickable.width/2 } function highlightKey(pitch, color) { itemForPitch(pitch).color = color } function itemForPitch(pitch) { var noteItem if (pitch < 24) { noteItem = keyboard.children[pitch-21] } else if (pitch == 108) { noteItem = whiteKeyC } else { var note = (pitch - 24) % 12 var octave = (pitch - 24 - note) / 12 noteItem = keyboard.children[3+octave].children[note] } return noteItem } Rectangle { id: piano width: 3 * keyWidth + 7 * (7 * keyWidth); height: parent.height anchors.horizontalCenter: parent.horizontalCenter radius: 5 color: "#141414" Row { id: octaveNumber width: parent.width; height: 18 anchors.left: parent.left anchors.leftMargin: 2 * keyWidth Repeater { model: 7 Label { text: i18nc("technical term, do you have a musician friend?", "Octave") + " " + (1 + modelData) width: 7 * keyWidth color: "white" height: parent.height } } } Item { id: keyboard anchors { top: octaveNumber.bottom; horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 5 } width: 3 * keyWidth + 7 * (7 * keyWidth); height: keyHeight - octaveNumber.height WhiteKey { id: whiteKeyA } BlackKey { anchor: whiteKeyA } WhiteKey { id: whiteKeyB; anchor: whiteKeyA } Octave { id: octave1; initialAnchor: whiteKeyB } Octave { id: octave2; initialAnchor: octave1 } Octave { id: octave3; initialAnchor: octave2 } Octave { id: octave4; initialAnchor: octave3 } Octave { id: octave5; initialAnchor: octave4 } Octave { id: octave6; initialAnchor: octave5 } Octave { id: octave7; initialAnchor: octave6 } WhiteKey { id: whiteKeyC; anchor: octave7 } Rectangle { width: 3 * keyWidth + 7 * (7 * keyWidth); height: 2 anchors { left: whiteKeyA.left; bottom: whiteKeyA.top } color: "#A40E09" } } Component { id: noteMark Rectangle { width: keyWidth - 4; height: keyWidth - 4 radius: (keyWidth - 4) / 2 border.color: "black" anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 2 } } } } ScrollIndicator.horizontal: ScrollIndicator { active: true } } diff --git a/src/app/plugins/PianoView/WhiteKey.qml b/src/app/plugins/PianoView/WhiteKey.qml index 1eac691..edc17b8 100644 --- a/src/app/plugins/PianoView/WhiteKey.qml +++ b/src/app/plugins/PianoView/WhiteKey.qml @@ -1,33 +1,33 @@ /**************************************************************************** ** ** Copyright (C) 2016 by Sandro S. Andrade ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as ** published by the Free Software Foundation; either version 2 of ** the License or (at your option) version 3 or any later version ** accepted by the membership of KDE e.V. (or its successor approved -** by the membership of KDE e.V.), which shall act as a proxy +** by the membership of KDE e.V.), which shall act as a proxy ** defined in Section 14 of version 3 of the license. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . ** ****************************************************************************/ import QtQuick 2.7 Rectangle { property Item anchor width: keyWidth; height: keyHeight border { width: 1; color: "black" } color: "white" Component.onCompleted: if (anchor != null) anchors.left = anchor.right }