From 69947a624b43a5de257217b3af9e1383312ba305 Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Thu, 1 Nov 2012 21:35:17 +0100 Subject: [PATCH] Track: allow smaller height Here's one way to cram more stuff onto small screens, or otherwise help reducing visual clutter: Allow tracks to be shift-dragged all the way down to 8 px height. Signed-off-by: Tobias Doerffel --- include/track.h | 15 ++++++++++++ src/core/track.cpp | 45 ++++++++++++++++++++++------------ src/tracks/AutomationTrack.cpp | 2 +- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/include/track.h b/include/track.h index 256cf31d1..1011c245d 100644 --- a/include/track.h +++ b/include/track.h @@ -59,6 +59,13 @@ const int TRACK_OP_WIDTH = 78; const int DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT = 96; const int TRACK_OP_WIDTH_COMPACT = 60; +/*! The minimum track height in pixels + * + * Tracks can be resized by shift-dragging anywhere inside the track + * display. This sets the minimum size in pixels for a track. + */ +const Uint16 MINIMAL_TRACK_HEIGHT = 8; +const Uint16 DEFAULT_TRACK_HEIGHT = 32; const int TCO_BORDER_WIDTH = 1; @@ -435,6 +442,13 @@ public: using Model::dataChanged; + inline int getHeight() { + return ( m_height >= MINIMAL_TRACK_HEIGHT ? m_height : DEFAULT_TRACK_HEIGHT ); + } + inline void setHeight( int _height ) { + m_height = _height; + } + public slots: virtual void setName( const QString & _new_name ) @@ -450,6 +464,7 @@ private: trackContainer * m_trackContainer; TrackTypes m_type; QString m_name; + int m_height; BoolModel m_mutedModel; BoolModel m_soloModel; diff --git a/src/core/track.cpp b/src/core/track.cpp index 7f2cc096d..b9b925f34 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -80,13 +80,6 @@ const Sint16 RESIZE_GRIP_WIDTH = 4; const Uint16 TRACK_OP_BTN_WIDTH = 20; const Uint16 TRACK_OP_BTN_HEIGHT = 14; -/*! The minimum track height in pixels - * - * Tracks can be resized by shift-dragging anywhere inside the track - * display. This sets the minimum size in pixels for a track. - */ -const Uint16 MINIMAL_TRACK_HEIGHT = 32; - /*! A pointer for that text bubble used when moving segments, etc. * @@ -1563,6 +1556,7 @@ track::track( TrackTypes _type, trackContainer * _tc ) : m_trackContentObjects() /*!< The track content objects (segments) */ { m_trackContainer->addTrack( this ); + m_height = -1; } @@ -1679,8 +1673,10 @@ void track::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.setAttribute( "type", type() ); _this.setAttribute( "name", name() ); _this.setAttribute( "muted", isMuted() ); -// ### TODO -// _this.setAttribute( "height", m_trackView->height() ); + if( m_height >= MINIMAL_TRACK_HEIGHT ) + { + _this.setAttribute( "height", m_height ); + } QDomElement ts_de = _doc.createElement( nodeName() ); // let actual track (InstrumentTrack, bbTrack, sampleTrack etc.) save @@ -1773,12 +1769,11 @@ void track::loadSettings( const QDomElement & _this ) } node = node.nextSibling(); } -/* + if( _this.attribute( "height" ).toInt() >= MINIMAL_TRACK_HEIGHT ) { - m_trackView->setFixedHeight( - _this.attribute( "height" ).toInt() ); - }*/ + m_height = _this.attribute( "height" ).toInt(); + } } @@ -2122,6 +2117,7 @@ trackView::trackView( track * _track, trackContainerView * _tcv ) : layout->addWidget( &m_trackOperationsWidget ); layout->addWidget( &m_trackSettingsWidget ); layout->addWidget( &m_trackContentWidget, 1 ); + setFixedHeight( m_track->getHeight() ); resizeEvent( NULL ); @@ -2225,7 +2221,8 @@ void trackView::modelChanged() connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) ); m_trackOperationsWidget.m_muteBtn->setModel( &m_track->m_mutedModel ); m_trackOperationsWidget.m_soloBtn->setModel( &m_track->m_soloModel ); - ModelView::modelChanged(); + ModelView::modelChanged(); + setFixedHeight( m_track->getHeight() ); } @@ -2256,6 +2253,10 @@ void trackView::undoStep( JournalEntry & _je ) MINIMAL_TRACK_HEIGHT ) ); m_trackContainerView->realignTracks(); break; + /*case RestoreTrack: + setFixedHeight( DEFAULT_TRACK_HEIGHT ); + m_trackContainerView->realignTracks(); + break; */ } restoreJournallingState(); } @@ -2331,6 +2332,16 @@ void trackView::dropEvent( QDropEvent * _de ) */ void trackView::mousePressEvent( QMouseEvent * _me ) { + // If previously dragged too small, restore on shift-leftclick + if( height() < DEFAULT_TRACK_HEIGHT && + _me->modifiers() & Qt::ShiftModifier && + _me->button() == Qt::LeftButton ) + { + setFixedHeight( DEFAULT_TRACK_HEIGHT ); + m_track->setHeight( DEFAULT_TRACK_HEIGHT ); + } + + if( m_trackContainerView->allowRubberband() == true ) { QWidget::mousePressEvent( _me ); @@ -2385,6 +2396,7 @@ void trackView::mousePressEvent( QMouseEvent * _me ) */ void trackView::mouseMoveEvent( QMouseEvent * _me ) { + if( m_trackContainerView->allowRubberband() == true ) { QWidget::mouseMoveEvent( _me ); @@ -2415,12 +2427,15 @@ void trackView::mouseMoveEvent( QMouseEvent * _me ) { setFixedHeight( qMax( _me->y(), MINIMAL_TRACK_HEIGHT ) ); m_trackContainerView->realignTracks(); + m_track->setHeight( height() ); + } + if( height() < DEFAULT_TRACK_HEIGHT ) { + toolTip::add( this, m_track->m_name ); } } - /*! \brief Handle a mouse release event on this track View. * * \param _me the MouseEvent to handle. diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index 67ca77379..1f92533dd 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -131,7 +131,7 @@ AutomationTrackView::AutomationTrackView( AutomationTrack * _at, trackContainerView * _tcv ) : trackView( _at, _tcv ) { - setFixedHeight( 32 ); + setFixedHeight( 32 ); trackLabelButton * tlb = new trackLabelButton( this, getTrackSettingsWidget() ); tlb->setIcon( embed::getIconPixmap( "automation_track" ) );