Skip to content
Snippets Groups Projects
Commit 4c1e4818 authored by SeeLook's avatar SeeLook :musical_note:
Browse files

[Ukulele] Graphical component - similar to guitar so far

parent 36cc183d
No related branches found
No related tags found
No related merge requests found
Pipeline #3466 passed
......@@ -152,7 +152,7 @@ void TguitarBg::paint(QPainter* painter) {
paintTimer.restart();
// FINGERBOARD
painter->setPen(Qt::NoPen);
if (GLOB->instrument().type() == Tinstrument::ClassicalGuitar)
if (GLOB->instrument().clasicGuitar() || GLOB->instrument().ukulele())
painter->setBrush(QBrush(Qt::black, Qt::SolidPattern));
else {
QColor fbEdgeColor(175, 160, 114, 220);
......@@ -161,7 +161,7 @@ void TguitarBg::paint(QPainter* painter) {
QPolygon a;
int fbThick = ((m_strGap * GLOB->Gtune()->stringNr()) / 6) / 3; // thickness of fretboard
painter->drawRect(m_fbRect.x() + m_strGap / 3 - 8, m_fbRect.y() - fbThick, m_fbRect.width() + fbThick, m_fbRect.height() + fbThick);
if (GLOB->instrument().type() == Tinstrument::ClassicalGuitar)
if (GLOB->instrument().clasicGuitar() || GLOB->instrument().ukulele())
painter->setBrush(QBrush(QPixmap(Tpath::img("fingbg"))));
else
painter->setBrush(QBrush(QPixmap(Tpath::img("fingbg-el"))));
......@@ -169,7 +169,7 @@ void TguitarBg::paint(QPainter* painter) {
// FRETS
// zero fret (upper bridge or HUESO)
int huesoW = qRound(m_fbRect.width() * 0.01);
if (GLOB->instrument().type() == Tinstrument::ClassicalGuitar) {
if (GLOB->instrument().clasicGuitar() || GLOB->instrument().ukulele()) {
painter->setPen(Qt::NoPen);
painter->setBrush(QBrush(QColor(255, 251, 240), Qt::SolidPattern)); // #FFFBF0 cream color for hueso
painter->drawRect(m_fbRect.x() - 8, m_fbRect.y() + 4, huesoW, m_fbRect.height());
......@@ -271,7 +271,7 @@ void TguitarBg::paint(QPainter* painter) {
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine)); //on upper bridge
painter->drawLine(m_fbRect.x() - 8, lineYpos - 2, m_fbRect.x() - 8 + huesoW , lineYpos - 2);
painter->drawLine(m_fbRect.x() - 8, lineYpos + m_strWidth[i] - 1, m_fbRect.x() - 8 + huesoW, lineYpos + m_strWidth[i] - 1);
if (GLOB->instrument().type() != Tinstrument::ClassicalGuitar) { // shadow on the pickup if exist (bass or electric guitar)
if (GLOB->instrument().clasicGuitar() || GLOB->instrument().ukulele()) { // shadow on the pickup if exist (bass or electric guitar)
int pickX = width() * 0.88;
// if (!GLOB->GisRightHanded)
// pickX = width() - (BG_PIX->pickUpRect().x() + BG_PIX->pickUpRect().width());
......
......@@ -87,6 +87,7 @@
<file alias="instruments/PianoKeyWhite.qml">qml/instruments/PianoKeyWhite.qml</file>
<file alias="instruments/Bandoneon.qml">qml/instruments/Bandoneon.qml</file>
<file alias="instruments/Sax.qml">qml/instruments/Sax.qml</file>
<file alias="instruments/Ukulele.qml">qml/instruments/Ukulele.qml</file>
<file alias="instruments/OutScaleTip.qml">qml/instruments/OutScaleTip.qml</file>
<file alias="instruments/SaxFlap.qml">qml/instruments/SaxFlap.qml</file>
<file alias="instruments/InstrumentZoom.qml">qml/instruments/InstrumentZoom.qml</file>
......
/** This file is part of Nootka (http://nootka.sf.net) *
* Copyright (C) 2021 by Tomasz Bojczuk (seelook@gmail.com) *
* on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */
import QtQuick 2.9
import QtGraphicalEffects 1.0
import Nootka 1.0
TguitarBg {
id: instrItem
// private
property var correctAnim: null
property var guitarZoom: null
width: Math.max(nootkaWindow.width, GLOB.instrument.getItemHeight(nootkaWindow.height) * 5.4)
height: GLOB.instrument.getItemHeight(nootkaWindow.height)
transformOrigin: Item.TopLeft
Behavior on scale {
enabled: GLOB.useAnimations
NumberAnimation {
duration: 150
onRunningChanged: {
if (guitarZoom && !running && scale > 1)
instrFlick.contentX = guitarZoom.flickX
}
}
}
onCorrectInstrument: {
if (!correctAnim)
correctAnim = Qt.createComponent("qrc:/exam/CorrectInstrAnim.qml").createObject(instrItem)
correctAnim.doCross = wrongItem === null
correctAnim.start()
}
Rectangle {
id: finger
color: GLOB.fingerColor
width: fretWidth / 1.6
height: width * 0.65
radius: width * 0.5
x: fingerPos.x
y: fingerPos.y
visible: false
}
DropShadow {
id: fingerShadow
z: 5
anchors.fill: finger
horizontalOffset: finger.height / 6
verticalOffset: finger.height / 6
color: "black"
radius: NOO.factor() / 3
source: finger
visible: fingerPos.x > 0
scale: !pressed && active && fingerPos.x > 0 ? 1 : 0
Behavior on scale { enabled: GLOB.useAnimations; NumberAnimation { duration: 150 }}
}
Rectangle {
z: 5
color: finger.color
width: parent.width - stringsGap - 2
height: string < 6 ? strWidth(string) * 1.5 : 0
x: 1
y: string < 6 ? fbRect.y + stringsGap / 2 + string * stringsGap - height / 3 : 0
visible: !pressed && active && string < 6 && fingerPos.x == 0
}
Component.onCompleted: {
if (NOO.isAndroid() && NOO.fingerPixels() * 4 > height)
guitarZoom = Qt.createComponent("qrc:/instruments/InstrumentZoom.qml").createObject(instrItem)
}
MouseArea {
property point startPos: Qt.point(0, 0)
enabled: (NOO.fingerPixels() * 4 <= height) || (guitarZoom && instrItem.scale > 1)
width: parent.width; height: parent.height
onPressed: startPos = Qt.point(mouseX, mouseY)
onReleased: {
var dx = mouseX - startPos.x
var dy = mouseY - startPos.y
if (Math.sqrt(dx * dx + dy * dy) < fretWidth / 2)
pressedAt(mouse.x, mouse.y)
}
}
OutScaleTip { show: !active && outOfScale }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment