From 14f41fe7b3a929a3fe783149a551083a79dd8d8d Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Sun, 29 Jan 2012 23:48:13 +0100 Subject: [PATCH] TrackViews: added compact mode Added an option to shrink the track buttons horizontally, mainly by moving the track name into a tooltip. Closes #3459241. Signed-off-by: Tobias Doerffel --- include/setup_dialog.h | 2 ++ include/track.h | 8 ++++-- src/core/track.cpp | 36 +++++++++++++++++++++----- src/gui/bb_editor.cpp | 14 ++++++++-- src/gui/setup_dialog.cpp | 25 ++++++++++++++++-- src/gui/song_editor.cpp | 26 +++++++++++++++---- src/gui/widgets/track_label_button.cpp | 24 ++++++++++++++--- src/tracks/InstrumentTrack.cpp | 18 ++++++++++--- src/tracks/sample_track.cpp | 12 +++++++-- 9 files changed, 138 insertions(+), 27 deletions(-) diff --git a/include/setup_dialog.h b/include/setup_dialog.h index fb1c58e87..83ca075f2 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -106,6 +106,7 @@ private slots: void toggleManualChPiano( bool _enabled ); void toggleSmoothScroll( bool _enabled ); void toggleOneInstrumentTrackWindow( bool _enabled ); + void toggleCompactTrackButtons( bool _enabled ); private: @@ -152,6 +153,7 @@ private: bool m_manualChPiano; bool m_smoothScroll; bool m_oneInstrumentTrackWindow; + bool m_compactTrackButtons; typedef QMap AswMap; typedef QMap MswMap; diff --git a/include/track.h b/include/track.h index 5d0ea6059..256cf31d1 100644 --- a/include/track.h +++ b/include/track.h @@ -52,10 +52,14 @@ class trackView; typedef QWidget trackSettingsWidget; - - const int DEFAULT_SETTINGS_WIDGET_WIDTH = 224; const int TRACK_OP_WIDTH = 78; +// This shaves 150-ish pixels off track buttons, +// ruled from config: ui.compacttrackbuttons +const int DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT = 96; +const int TRACK_OP_WIDTH_COMPACT = 60; + + const int TCO_BORDER_WIDTH = 1; diff --git a/src/core/track.cpp b/src/core/track.cpp index 38370f5a4..7f2cc096d 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -52,6 +52,7 @@ #include "bb_editor.h" #include "bb_track.h" #include "bb_track_container.h" +#include "config_mgr.h" #include "Clipboard.h" #include "embed.h" #include "engine.h" @@ -1372,15 +1373,28 @@ trackOperationsWidget::trackOperationsWidget( trackView * _parent ) : m_muteBtn->setActiveGraphic( embed::getIconPixmap( "led_off" ) ); m_muteBtn->setInactiveGraphic( embed::getIconPixmap( "led_green" ) ); m_muteBtn->setCheckable( true ); - m_muteBtn->move( 46, 8 ); - m_muteBtn->show(); - toolTip::add( m_muteBtn, tr( "Mute this track" ) ); m_soloBtn = new pixmapButton( this, tr( "Solo" ) ); m_soloBtn->setActiveGraphic( embed::getIconPixmap( "led_red" ) ); m_soloBtn->setInactiveGraphic( embed::getIconPixmap( "led_off" ) ); m_soloBtn->setCheckable( true ); - m_soloBtn->move( 62, 8 ); + + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + m_muteBtn->move( 46, 0 ); + m_soloBtn->move( 46, 16 ); + } + else + { + m_muteBtn->move( 46, 8 ); + m_soloBtn->move( 62, 8 ); + } + + m_muteBtn->show(); + toolTip::add( m_muteBtn, tr( "Mute this track" ) ); + + m_soloBtn->show(); toolTip::add( m_soloBtn, tr( "Solo" ) ); connect( this, SIGNAL( trackRemovalScheduled( trackView * ) ), @@ -2156,9 +2170,17 @@ trackView::~trackView() */ void trackView::resizeEvent( QResizeEvent * _re ) { - m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 ); - m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH, - height() - 1 ); + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH_COMPACT, height() - 1 ); + m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT, height() - 1 ); + } + else + { + m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 ); + m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH, height() - 1 ); + } m_trackContentWidget.setFixedHeight( height() ); } diff --git a/src/gui/bb_editor.cpp b/src/gui/bb_editor.cpp index 66ee5281a..8c127606a 100644 --- a/src/gui/bb_editor.cpp +++ b/src/gui/bb_editor.cpp @@ -34,6 +34,7 @@ #include "MainWindow.h" #include "song.h" #include "tool_button.h" +#include "config_mgr.h" @@ -60,8 +61,17 @@ bbEditor::bbEditor( bbTrackContainer * _tc ) : setWindowIcon( embed::getIconPixmap( "bb_track" ) ); setWindowTitle( tr( "Beat+Bassline Editor" ) ); // TODO: Use style sheet - setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH - + 2 * TCO_BORDER_WIDTH + 192 ); + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + setMinimumWidth( TRACK_OP_WIDTH_COMPACT + DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + + 2 * TCO_BORDER_WIDTH + 192 ); + } + else + { + setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH + + 2 * TCO_BORDER_WIDTH + 192 ); + } m_playButton = new toolButton( embed::getIconPixmap( "play" ), diff --git a/src/gui/setup_dialog.cpp b/src/gui/setup_dialog.cpp index b2d36873e..108b3a5e3 100644 --- a/src/gui/setup_dialog.cpp +++ b/src/gui/setup_dialog.cpp @@ -114,7 +114,9 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : "manualchannelpiano" ).toInt() ), m_smoothScroll( configManager::inst()->value( "ui", "smoothscroll" ).toInt() ), m_oneInstrumentTrackWindow( configManager::inst()->value( "ui", - "oneinstrumenttrackwindow" ).toInt() ) + "oneinstrumenttrackwindow" ).toInt() ), + m_compactTrackButtons( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) { setWindowIcon( embed::getIconPixmap( "setup_general" ) ); setWindowTitle( tr( "Setup LMMS" ) ); @@ -183,7 +185,7 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : tabWidget * misc_tw = new tabWidget( tr( "MISC" ), general ); - misc_tw->setFixedHeight( 138 ); + misc_tw->setFixedHeight( 156 ); ledCheckBox * enable_tooltips = new ledCheckBox( tr( "Enable tooltips" ), @@ -235,6 +237,14 @@ setupDialog::setupDialog( ConfigTabs _tab_to_open ) : connect( hqaudio, SIGNAL( toggled( bool ) ), this, SLOT( toggleHQAudioDev( bool ) ) ); + ledCheckBox * compacttracks = new ledCheckBox( + tr( "Compact track buttons" ), + misc_tw ); + compacttracks->move( 10, 126 ); + compacttracks->setChecked( m_compactTrackButtons ); + connect( compacttracks, SIGNAL( toggled( bool ) ), + this, SLOT( toggleCompactTrackButtons( bool ) ) ); + gen_layout->addWidget( bufsize_tw ); @@ -751,6 +761,8 @@ void setupDialog::accept() QString::number( m_smoothScroll ) ); configManager::inst()->setValue( "ui", "oneinstrumenttrackwindow", QString::number( m_oneInstrumentTrackWindow ) ); + configManager::inst()->setValue( "ui", "compacttrackbuttons", + QString::number( m_compactTrackButtons ) ); configManager::inst()->setWorkingDir( m_workingDir ); configManager::inst()->setVSTDir( m_vstDir ); @@ -916,6 +928,15 @@ void setupDialog::toggleSmoothScroll( bool _enabled ) +void setupDialog::toggleCompactTrackButtons( bool _enabled ) +{ + m_compactTrackButtons = _enabled; +} + + + + + void setupDialog::toggleOneInstrumentTrackWindow( bool _enabled ) { m_oneInstrumentTrackWindow = _enabled; diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index 615b25161..cd1bba8cc 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -52,6 +52,7 @@ #include "visualization_widget.h" #include "AudioDevice.h" #include "piano_roll.h" +#include "config_mgr.h" @@ -89,8 +90,11 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : setFocus(); // create time-line - m_timeLine = new timeLine( TRACK_OP_WIDTH + - DEFAULT_SETTINGS_WIDGET_WIDTH, 32, + int widgetTotal = configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt()==1 ? + DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT : + DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH; + m_timeLine = new timeLine( widgetTotal, 32, pixelsPerTact(), m_s->m_playPos[song::Mode_PlaySong], m_currentPosition, this ); @@ -683,12 +687,24 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth void songEditor::updatePosition( const midiTime & _t ) { + int widgetWidth, trackOpWidth; + if( configManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() ) + { + widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT; + trackOpWidth = TRACK_OP_WIDTH_COMPACT; + } + else + { + widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH; + trackOpWidth = TRACK_OP_WIDTH; + } + if( ( m_s->isPlaying() && m_s->m_playMode == song::Mode_PlaySong && m_timeLine->autoScroll() == timeLine::AutoScrollEnabled) || m_scrollBack == true ) { - const int w = width() - DEFAULT_SETTINGS_WIDGET_WIDTH - - TRACK_OP_WIDTH + const int w = width() - widgetWidth + - trackOpWidth - 32; // rough estimation for width of right scrollbar if( _t > m_currentPosition + w * midiTime::ticksPerTact() / pixelsPerTact() ) @@ -708,7 +724,7 @@ void songEditor::updatePosition( const midiTime & _t ) const int x = m_s->m_playPos[song::Mode_PlaySong].m_timeLine-> markerX( _t ) + 8; - if( x >= TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH-1 ) + if( x >= trackOpWidth + widgetWidth -1 ) { m_positionLine->show(); m_positionLine->move( x, 50 ); diff --git a/src/gui/widgets/track_label_button.cpp b/src/gui/widgets/track_label_button.cpp index 1d264ebd7..0080c090c 100644 --- a/src/gui/widgets/track_label_button.cpp +++ b/src/gui/widgets/track_label_button.cpp @@ -47,7 +47,17 @@ trackLabelButton::trackLabelButton( trackView * _tv, QWidget * _parent ) : setAcceptDrops( true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 0, 0 ) ); setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); - setFixedSize( 160, 29 ); + + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + setFixedSize( 32, 29 ); + } + else + { + setFixedSize( 160, 29 ); + } + setIconSize( QSize( 32, 32 ) ); setText( " " ); @@ -138,8 +148,16 @@ void trackLabelButton::paintEvent( QPaintEvent * _pe ) } } } - - setText( m_trackView->getTrack()->displayName() ); + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + setText(""); + setToolTip( m_trackView->getTrack()->displayName() ); + } + else + { + setText( m_trackView->getTrack()->displayName() ); + } QToolButton::paintEvent( _pe ); } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index bfbad257e..74980c103 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -894,12 +894,23 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, m_tlb, SLOT( update() ) ); // creation of widgets for track-settings-widget + int widgetWidth; + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT; + } + else + { + widgetWidth = DEFAULT_SETTINGS_WIDGET_WIDTH; + } + m_volumeKnob = new knob( knobSmall_17, getTrackSettingsWidget(), tr( "Volume" ) ); m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_it->m_volumeModel ); m_volumeKnob->setHintText( tr( "Volume:" ) + " ", "%" ); - m_volumeKnob->move( DEFAULT_SETTINGS_WIDGET_WIDTH-24*2, 4 ); + m_volumeKnob->move( widgetWidth-2*24, 4 ); m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show(); m_volumeKnob->setWhatsThis( tr( volume_help ) ); @@ -908,11 +919,10 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, tr( "Panning" ) ); m_panningKnob->setModel( &_it->m_panningModel ); m_panningKnob->setHintText( tr( "Panning:" ) + " ", "%" ); - m_panningKnob->move( DEFAULT_SETTINGS_WIDGET_WIDTH-24, 4 ); + m_panningKnob->move( widgetWidth-24, 4 ); m_panningKnob->setLabel( tr( "PAN" ) ); m_panningKnob->show(); - m_midiMenu = new QMenu( tr( "MIDI" ), this ); // sequenced MIDI? @@ -952,7 +962,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, QColor( 64, 255, 16 ), getTrackSettingsWidget() ); m_activityIndicator->setGeometry( - DEFAULT_SETTINGS_WIDGET_WIDTH-2*24-11, 2, 8, 28 ); + widgetWidth-2*24-11, 2, 8, 28 ); m_activityIndicator->show(); connect( m_activityIndicator, SIGNAL( pressed() ), this, SLOT( activityIndicatorPressed() ) ); diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index df8bbf706..0ced90e1e 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -46,7 +46,7 @@ #include "MainWindow.h" #include "EffectRackView.h" #include "track_label_button.h" - +#include "config_mgr.h" sampleTCO::sampleTCO( track * _track ) : @@ -523,7 +523,15 @@ sampleTrackView::sampleTrackView( sampleTrack * _t, trackContainerView * _tcv ) m_volumeKnob->setVolumeKnob( true ); m_volumeKnob->setModel( &_t->m_volumeModel ); m_volumeKnob->setHintText( tr( "Channel volume:" ) + " ", "%" ); - m_volumeKnob->move( DEFAULT_SETTINGS_WIDGET_WIDTH-2*24, 4 ); + if( configManager::inst()->value( "ui", + "compacttrackbuttons" ).toInt() ) + { + m_volumeKnob->move( DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT-2*24, 4 ); + } + else + { + m_volumeKnob->move( DEFAULT_SETTINGS_WIDGET_WIDTH-2*24, 4 ); + } m_volumeKnob->setLabel( tr( "VOL" ) ); m_volumeKnob->show();