Skip to content

Commit

Permalink
Track: allow smaller height
Browse files Browse the repository at this point in the history
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 <tobias.doerffel@gmail.com>
  • Loading branch information
softrabbit authored and tobydox committed Nov 1, 2012
1 parent e7605ea commit 69947a6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
15 changes: 15 additions & 0 deletions include/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -435,6 +442,13 @@ class EXPORT track : public Model, public JournallingObject

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 )
Expand All @@ -450,6 +464,7 @@ public slots:
trackContainer * m_trackContainer;
TrackTypes m_type;
QString m_name;
int m_height;

BoolModel m_mutedModel;
BoolModel m_soloModel;
Expand Down
45 changes: 30 additions & 15 deletions src/core/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -1563,6 +1556,7 @@ track::track( TrackTypes _type, trackContainer * _tc ) :
m_trackContentObjects() /*!< The track content objects (segments) */
{
m_trackContainer->addTrack( this );
m_height = -1;
}


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}


Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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() );
}


Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -2385,6 +2396,7 @@ void trackView::mousePressEvent( QMouseEvent * _me )
*/
void trackView::mouseMoveEvent( QMouseEvent * _me )
{

if( m_trackContainerView->allowRubberband() == true )
{
QWidget::mouseMoveEvent( _me );
Expand Down Expand Up @@ -2415,12 +2427,15 @@ void trackView::mouseMoveEvent( QMouseEvent * _me )
{
setFixedHeight( qMax<int>( _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.
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/AutomationTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ) );
Expand Down

0 comments on commit 69947a6

Please sign in to comment.