From f63600b3fe53308517df127470a2983082a999f3 Mon Sep 17 00:00:00 2001 From: Ruediger Ranft <_rdi_@web.de> Date: Tue, 15 Oct 2013 20:43:29 +0200 Subject: [PATCH 1/3] Added the drawing of the note names. --- src/gui/piano_roll.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index 8cccc6687..f9b8110c6 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -2629,7 +2629,66 @@ void pianoRoll::dragNotes( int x, int y, bool alt, bool shift ) engine::getSong()->setModified(); } +static QString calculateNoteLabel(QString note, int octave) +{ + if(note.isEmpty()) + return ""; + return note + QString::number(octave); +} +static void printNoteHeights(QPainter& p, int bottom, int width, int startKey) +{ + assert(Key_C == 0); + assert(Key_H == 11); + + struct KeyLabel + { + QString key, minor, major; + }; + const KeyLabel labels[12] = { + {QObject::tr("C", "Note name")}, + {"", QObject::tr("Db", "Note name"), QObject::tr("C#", "Note name")}, + {QObject::tr("D", "Note name")}, + {"", QObject::tr("Eb", "Note name"), QObject::tr("D#", "Note name")}, + {QObject::tr("E", "Note name"), QObject::tr("Fb", "Note name")}, + {"F"}, + {"", QObject::tr("Gb", "Note name"), QObject::tr("F#", "Note name")}, + {QObject::tr("G", "Note name")}, + {"", QObject::tr("Ab", "Note name"),QObject::tr( "G#", "Note name")}, + {QObject::tr("A", "Note name")}, + {"", QObject::tr("Bb", "Note name"),QObject::tr( "A#", "Note name")}, + {QObject::tr("B", "Note name")} + }; + + p.setFont( pointSize( p.font() ) ); + p.setPen( QColor( 255, 255, 0 ) ); + for( int y = bottom, key = startKey; y > PR_TOP_MARGIN; + y -= KEY_LINE_HEIGHT, key++) + { + const unsigned note = key % KeysPerOctave; + assert( note < ( sizeof( labels ) / sizeof( *labels) )); + const KeyLabel& noteLabel( labels[note] ); + const int octave = key / KeysPerOctave; + const KeyLabel notes = { + calculateNoteLabel(noteLabel.key, octave), + calculateNoteLabel(noteLabel.minor, octave), + calculateNoteLabel(noteLabel.major, octave), + }; + + + const int drawWidth( width - WHITE_KEY_WIDTH ); + const int hspace = 300; + const int columnCount = drawWidth/hspace + 1; + for(int col = 0; col < columnCount; col++) + { + const int subOffset = 42; + const int x = subOffset + hspace/2 + hspace * col; + p.drawText( WHITE_KEY_WIDTH + x, y, notes.key); + p.drawText( WHITE_KEY_WIDTH + x - subOffset, y, notes.minor); + p.drawText( WHITE_KEY_WIDTH + x + subOffset, y, notes.major); + } + } +} void pianoRoll::paintEvent( QPaintEvent * _pe ) { @@ -3103,6 +3162,8 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) p.drawPixmap( mapFromGlobal( QCursor::pos() ) + QPoint( 8, 8 ), *cursor ); } + + printNoteHeights(p, keyAreaBottom(), width(), m_startKey); } From 11402b49b7524555d7394f38d56ec178994f8525 Mon Sep 17 00:00:00 2001 From: Ruediger Ranft <_rdi_@web.de> Date: Sun, 27 Oct 2013 16:41:18 +0100 Subject: [PATCH 2/3] Refactoring: Calculate the size of the tab widget based on the number of items. --- src/gui/setup_dialog.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/gui/setup_dialog.cpp b/src/gui/setup_dialog.cpp index 7780f2bae..14b955e0e 100644 --- a/src/gui/setup_dialog.cpp +++ b/src/gui/setup_dialog.cpp @@ -190,12 +190,17 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : tabWidget * misc_tw = new tabWidget( tr( "MISC" ), general ); - misc_tw->setFixedHeight( 174 ); + const int XDelta = 10; + const int YDelta = 18; + const int HeaderSize = 30; + int labelNumber = 0; + ledCheckBox * enable_tooltips = new ledCheckBox( tr( "Enable tooltips" ), misc_tw ); - enable_tooltips->move( 10, 18 ); + labelNumber++; + enable_tooltips->move( XDelta, YDelta*labelNumber ); enable_tooltips->setChecked( m_toolTips ); connect( enable_tooltips, SIGNAL( toggled( bool ) ), this, SLOT( toggleToolTips( bool ) ) ); @@ -204,7 +209,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * restart_msg = new ledCheckBox( tr( "Show restart warning after changing settings" ), misc_tw ); - restart_msg->move( 10, 36 ); + labelNumber++; + restart_msg->move( XDelta, YDelta*labelNumber ); restart_msg->setChecked( m_warnAfterSetup ); connect( restart_msg, SIGNAL( toggled( bool ) ), this, SLOT( toggleWarnAfterSetup( bool ) ) ); @@ -212,7 +218,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * dbv = new ledCheckBox( tr( "Display volume as dBV " ), misc_tw ); - dbv->move( 10, 54 ); + labelNumber++; + dbv->move( XDelta, YDelta*labelNumber ); dbv->setChecked( m_displaydBV ); connect( dbv, SIGNAL( toggled( bool ) ), this, SLOT( toggleDisplaydBV( bool ) ) ); @@ -221,7 +228,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * mmpz = new ledCheckBox( tr( "Compress project files per default" ), misc_tw ); - mmpz->move( 10, 72 ); + labelNumber++; + mmpz->move( XDelta, YDelta*labelNumber ); mmpz->setChecked( m_MMPZ ); connect( mmpz, SIGNAL( toggled( bool ) ), this, SLOT( toggleMMPZ( bool ) ) ); @@ -229,7 +237,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * oneitw = new ledCheckBox( tr( "One instrument track window mode" ), misc_tw ); - oneitw->move( 10, 90 ); + labelNumber++; + oneitw->move( XDelta, YDelta*labelNumber ); oneitw->setChecked( m_oneInstrumentTrackWindow ); connect( oneitw, SIGNAL( toggled( bool ) ), this, SLOT( toggleOneInstrumentTrackWindow( bool ) ) ); @@ -237,7 +246,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * hqaudio = new ledCheckBox( tr( "HQ-mode for output audio-device" ), misc_tw ); - hqaudio->move( 10, 108 ); + labelNumber++; + hqaudio->move( XDelta, YDelta*labelNumber ); hqaudio->setChecked( m_hqAudioDev ); connect( hqaudio, SIGNAL( toggled( bool ) ), this, SLOT( toggleHQAudioDev( bool ) ) ); @@ -245,7 +255,8 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * compacttracks = new ledCheckBox( tr( "Compact track buttons" ), misc_tw ); - compacttracks->move( 10, 126 ); + labelNumber++; + compacttracks->move( XDelta, YDelta*labelNumber ); compacttracks->setChecked( m_compactTrackButtons ); connect( compacttracks, SIGNAL( toggled( bool ) ), this, SLOT( toggleCompactTrackButtons( bool ) ) ); @@ -254,11 +265,13 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : ledCheckBox * syncVST = new ledCheckBox( tr( "Sync VST plugins to host playback" ), misc_tw ); - syncVST->move( 10, 144 ); + labelNumber++; + syncVST->move( XDelta, YDelta*labelNumber ); syncVST->setChecked( m_syncVSTPlugins ); connect( syncVST, SIGNAL( toggled( bool ) ), this, SLOT( toggleSyncVSTPlugins( bool ) ) ); + misc_tw->setFixedHeight( YDelta*labelNumber + HeaderSize ); gen_layout->addWidget( bufsize_tw ); From dc86474589d93128e0d2542953d48fac40619eff Mon Sep 17 00:00:00 2001 From: Ruediger Ranft <_rdi_@web.de> Date: Sun, 27 Oct 2013 17:05:18 +0100 Subject: [PATCH 3/3] Added an option do en/disable the note labels. --- include/setup_dialog.h | 2 ++ src/gui/piano_roll.cpp | 6 +++++- src/gui/setup_dialog.cpp | 20 ++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 4bac5e0fe..82f66eae8 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -110,6 +110,7 @@ private slots: void toggleCompactTrackButtons( bool _enabled ); void toggleSyncVSTPlugins( bool _enabled ); void toggleAnimateAFP( bool _enabled ); + void toggleNoteLabels( bool en ); private: @@ -160,6 +161,7 @@ private: bool m_compactTrackButtons; bool m_syncVSTPlugins; bool m_animateAFP; + bool m_printNoteLabels; typedef QMap AswMap; typedef QMap MswMap; diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index f9b8110c6..62c003a31 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -45,6 +45,7 @@ #include #include +#include "config_mgr.h" #include "piano_roll.h" #include "bb_track_container.h" #include "Clipboard.h" @@ -3163,7 +3164,10 @@ void pianoRoll::paintEvent( QPaintEvent * _pe ) *cursor ); } - printNoteHeights(p, keyAreaBottom(), width(), m_startKey); + if( configManager::inst()->value( "ui", "printnotelabels").toInt() ) + { + printNoteHeights(p, keyAreaBottom(), width(), m_startKey); + } } diff --git a/src/gui/setup_dialog.cpp b/src/gui/setup_dialog.cpp index 14b955e0e..3d60175cf 100644 --- a/src/gui/setup_dialog.cpp +++ b/src/gui/setup_dialog.cpp @@ -121,7 +121,9 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : m_syncVSTPlugins( configManager::inst()->value( "ui", "syncvstplugins" ).toInt() ), m_animateAFP(configManager::inst()->value( "ui", - "animateafp").toInt() ) + "animateafp").toInt() ), + m_printNoteLabels(configManager::inst()->value( "ui", + "printnotelabels").toInt() ) { setWindowIcon( embed::getIconPixmap( "setup_general" ) ); setWindowTitle( tr( "Setup LMMS" ) ); @@ -271,6 +273,15 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : connect( syncVST, SIGNAL( toggled( bool ) ), this, SLOT( toggleSyncVSTPlugins( bool ) ) ); + ledCheckBox * noteLabels = new ledCheckBox( + tr( "Enable note labels in piano roll" ), + misc_tw ); + labelNumber++; + noteLabels->move( XDelta, YDelta*labelNumber ); + noteLabels->setChecked( m_printNoteLabels ); + connect( noteLabels, SIGNAL( toggled( bool ) ), + this, SLOT( toggleNoteLabels( bool ) ) ); + misc_tw->setFixedHeight( YDelta*labelNumber + HeaderSize ); @@ -813,6 +824,8 @@ void setupDialog::accept() QString::number( m_syncVSTPlugins ) ); configManager::inst()->setValue( "ui", "animateafp", QString::number( m_animateAFP ) ); + configManager::inst()->setValue( "ui", "printnotelabels", + QString::number( m_printNoteLabels ) ); configManager::inst()->setWorkingDir( m_workingDir ); @@ -1007,7 +1020,10 @@ void setupDialog::toggleAnimateAFP( bool _enabled ) } - +void setupDialog::toggleNoteLabels( bool en ) +{ + m_printNoteLabels = en; +} void setupDialog::toggleOneInstrumentTrackWindow( bool _enabled )