From 27c5295388421640619d951c862236d457d3bc50 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Mon, 27 Jul 2015 13:16:41 +0200 Subject: [PATCH 1/6] Get rid of too small fonts in all file browsers Removes one of the several calls to pointSizeF. This method seems to return a font which has the same height in pixels on all displays (regardless of the display's actual DPI value). In the long run these calls will all have to be removed to make LMMS usable on high DPI displays. --- src/gui/FileBrowser.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index ecb640277..ef05c6465 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -372,8 +372,6 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) : headerItem()->setHidden( true ); setSortingEnabled( false ); - setFont( pointSizeF( font(), 7.5f ) ); - connect( this, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), SLOT( activateListItem( QTreeWidgetItem *, int ) ) ); connect( this, SIGNAL( itemCollapsed( QTreeWidgetItem * ) ), From cd0176b5afe18eef71bc45c66ec2017a109a0602 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 29 Jul 2015 22:35:06 +0200 Subject: [PATCH 2/6] Controllers are rendered more dynamically ControllerRackView now uses a layout to organize the ControllerViews. The ControllerViews in turn use layouts to organize their widgets (labels and push button). ControllerView now inherits from QFrame instead of QWidget. The (static) background image for controllers was deleted because the ControllerView can now be resized dynamically. Song: Added specific signals for added and removed controllers. Also removed a TODO by putting the functionality to remove all controllers in a method (removeAllControllers). Deleted Controllers now don't unregister from Song during deletion. This has to be done by the client (Hollywood principle - "Don't call us, we call you."). TODO: For some strange reason I cannot programmatically resize the controller rack to make it fit the controllers on my screen. --- data/themes/default/controller_bg.png | Bin 5240 -> 0 bytes include/ControllerRackView.h | 9 +- include/ControllerView.h | 7 +- include/Song.h | 4 + src/core/Controller.cpp | 5 -- src/core/Song.cpp | 38 ++++++--- src/gui/widgets/ControllerRackView.cpp | 113 +++++++++++++------------ src/gui/widgets/ControllerView.cpp | 56 +++++------- 8 files changed, 120 insertions(+), 112 deletions(-) delete mode 100644 data/themes/default/controller_bg.png diff --git a/data/themes/default/controller_bg.png b/data/themes/default/controller_bg.png deleted file mode 100644 index 6d7830fffc51792f273d452d67921378d180dcd0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5240 zcmV-;6o>1HP)Y3(34n{4GJ=az=d55?gTo~d62qH+bpfJ(n>PWh}=bY~SWzc)?{`RZ;TyQ3dxi789{LtS)eBN*n(}%dz$ixMrANgynU9a@L^je%7s38Bk z)aRl&2aGN^+;8m*^#5h!V*F3(^wal39AIJn%<^FCIdNTPx5?~-`d%ctU8)o5?~;TS zi`&cFxODMDS+tAWPygVVXFmD(KW={byWigPH^i5I`pVD#{Q2kq{`6yyfh6|#SJ=C^ zhkN(#q1$v=Z`N3^*I2Dq*x%oWh`{zethMN^9URD7Sg{}o5vk7%(@B=(#rf5c$U~+- zmA)yNhZSBgf26q1GW*{45v1mj@pMV?YUGTi6@w9{e6sw$9}n}J=R_e(qXO7*&xqUlJ{MBn6dr$w})k~lKe6v~q2EeuU z$dRLGNW;sQui(~l39%NYF<5W`Yu#$ohetyEJTf&8Gu(g(U>KPfnNR$7i!1f0?QFP+ zVyK807O8)Py&zA2j9fOFQ^AZ-Rz@n0$&*Q8d=SbNh za|hFhNjz+r=<$@Luxab_m1QO~4e<*WB{P^IOTJmg8z5cZb;Fzhc<|5zc=+K*@m1f+ z-ksZj(RG_o0bB=gr)?X<^?HTnayd8wiJisH0NDVD*ukN!gtX2CoKoS*I8AaMI&kZ9 zXR>aR>N&jYOToZJB`2xi=`kxYPiDD`Cz&qPjbe+~MG9GWGIMU>7qf-vOu^|Lz^|uR zfMyaHg#cAu3>Czxuv}cw&SJ>89xR@l!PjIiJW~&mFu~g;T*tZq*>@ZCB#a@9F)(d| zqsNZn`n3fB9szI$z-a&%TLG}yY|!-sxXNx_Omsuftl2~5=+rfLZ(m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*^hu_G(|_$*12$O`4uQ`D2`9R=2|c*7)V%_an34IRG^|WT?LD zyRSaK^4XUF?g97`!()qA1YnLFJ@zMe@7#VKz)t`?gW*|S?H_Sn?;rP%{|kqAw> m_controllerViews; QScrollArea * m_scrollArea; + QVBoxLayout * m_scrollAreaLayout; QPushButton * m_addButton; + // Stores the index of where to insert the next ControllerView. + // Needed so that the StretchItem always stays at the last position. + int m_nextIndex; } ; #endif diff --git a/include/ControllerView.h b/include/ControllerView.h index f1d73c400..8903c0e3c 100644 --- a/include/ControllerView.h +++ b/include/ControllerView.h @@ -25,7 +25,7 @@ #ifndef CONTROLLER_VIEW_H #define CONTROLLER_VIEW_H -#include +#include #include "AutomatableModel.h" #include "Controller.h" @@ -39,7 +39,7 @@ class QMdiSubWindow; class LedCheckBox; -class ControllerView : public QWidget, public ModelView +class ControllerView : public QFrame, public ModelView { Q_OBJECT public: @@ -70,15 +70,14 @@ signals: protected: virtual void contextMenuEvent( QContextMenuEvent * _me ); - virtual void paintEvent( QPaintEvent * _pe ); virtual void modelChanged(); virtual void mouseDoubleClickEvent( QMouseEvent * event ); private: - QPixmap m_bg; QMdiSubWindow * m_subWindow; ControllerDialog * m_controllerDlg; + QLabel * m_nameLabel; bool m_show; } ; diff --git a/include/Song.h b/include/Song.h index 8f33a208b..8c7d6d899 100644 --- a/include/Song.h +++ b/include/Song.h @@ -323,6 +323,8 @@ private: void saveControllerStates( QDomDocument & doc, QDomElement & element ); void restoreControllerStates( const QDomElement & element ); + void removeAllControllers(); + AutomationTrack * m_globalAutomationTrack; @@ -376,6 +378,8 @@ signals: void lengthChanged( int tacts ); void tempoChanged( bpm_t newBPM ); void timeSignatureChanged( int oldTicksPerTact, int ticksPerTact ); + void controllerAdded( Controller * ); + void controllerRemoved( Controller * ); } ; diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index 325399e0b..bb9ecef4f 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -95,11 +95,6 @@ Controller::~Controller() s_controllers.remove( idx ); } - if( Engine::getSong() ) - { - Engine::getSong()->removeController( this ); - } - m_valueBuffer.clear(); // Remove connections by destroyed signal } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 21ab0ed49..fe9a124b3 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -828,11 +828,7 @@ void Song::clearProject() gui->getProjectNotes()->clear(); } - // Move to function - while( !m_controllers.empty() ) - { - delete m_controllers.last(); - } + removeAllControllers(); emit dataChanged(); @@ -1215,6 +1211,19 @@ void Song::restoreControllerStates( const QDomElement & element ) } + +void Song::removeAllControllers() +{ + for (int i = 0; i < m_controllers.size(); ++i) + { + delete m_controllers.at(i); + } + + m_controllers.clear(); +} + + + void Song::exportProjectTracks() { exportProject( true ); @@ -1383,12 +1392,14 @@ void Song::setModified() -void Song::addController( Controller * c ) +void Song::addController( Controller * controller ) { - if( c != NULL && m_controllers.contains( c ) == false ) + if( controller && !m_controllers.contains( controller ) ) { - m_controllers.append( c ); - emit dataChanged(); + m_controllers.append( controller ); + emit controllerAdded( controller ); + + this->setModified(); } } @@ -1402,11 +1413,10 @@ void Song::removeController( Controller * controller ) { m_controllers.remove( index ); - if( Engine::getSong() ) - { - Engine::getSong()->setModified(); - } - emit dataChanged(); + emit controllerRemoved( controller ); + delete controller; + + this->setModified(); } } diff --git a/src/gui/widgets/ControllerRackView.cpp b/src/gui/widgets/ControllerRackView.cpp index 182571093..b727869af 100644 --- a/src/gui/widgets/ControllerRackView.cpp +++ b/src/gui/widgets/ControllerRackView.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "Song.h" #include "embed.h" @@ -43,32 +44,32 @@ ControllerRackView::ControllerRackView( ) : - QWidget() + QWidget(), + m_nextIndex(0) { - setMinimumWidth( 250 ); - setMaximumWidth( 250 ); - resize( 250, 160 ); - setWindowIcon( embed::getIconPixmap( "controller" ) ); setWindowTitle( tr( "Controller Rack" ) ); m_scrollArea = new QScrollArea( this ); - m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); - m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) ); - m_scrollArea->setMinimumHeight( 64 ); + + QWidget * scrollAreaWidget = new QWidget( m_scrollArea ); + m_scrollAreaLayout = new QVBoxLayout( scrollAreaWidget ); + m_scrollAreaLayout->addStretch(); + scrollAreaWidget->setLayout( m_scrollAreaLayout ); + + m_scrollArea->setWidget( scrollAreaWidget ); + m_scrollArea->setWidgetResizable( true ); m_addButton = new QPushButton( this ); m_addButton->setText( tr( "Add" ) ); - QWidget * w = new QWidget(); - m_scrollArea->setWidget( w ); - connect( m_addButton, SIGNAL( clicked() ), this, SLOT( addController() ) ); - connect( Engine::getSong(), SIGNAL( dataChanged() ), - this, SLOT( update() ) ); + Song * song = Engine::getSong(); + connect( song, SIGNAL( controllerAdded( Controller* ) ), SLOT( onControllerAdded( Controller* ) ) ); + connect( song, SIGNAL( controllerRemoved( Controller* ) ), SLOT( onControllerRemoved( Controller* ) ) ); QVBoxLayout * layout = new QVBoxLayout(); layout->addWidget( m_scrollArea ); @@ -82,8 +83,10 @@ ControllerRackView::ControllerRackView( ) : flags &= ~Qt::WindowMaximizeButtonHint; subWin->setWindowFlags( flags ); - parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); - parentWidget()->move( 880, 310 ); + subWin->setAttribute( Qt::WA_DeleteOnClose, false ); + subWin->move( 880, 310 ); + + resize( 600, 400 ); } @@ -91,8 +94,6 @@ ControllerRackView::ControllerRackView( ) : ControllerRackView::~ControllerRackView() { - // delete scroll-area with all children - delete m_scrollArea; } @@ -119,8 +120,7 @@ void ControllerRackView::deleteController( ControllerView * _view ) { Controller * c = _view->getController(); - int connectionCount = c->connectionCount(); - if( connectionCount > 0 ) + if( c->connectionCount() > 0 ) { QMessageBox msgBox; msgBox.setIcon( QMessageBox::Question ); @@ -134,58 +134,63 @@ void ControllerRackView::deleteController( ControllerView * _view ) } } - - m_controllerViews.erase( qFind( m_controllerViews.begin(), - m_controllerViews.end(), _view ) ); - delete _view; - delete c; - update(); + Song * song = Engine::getSong(); + song->removeController( c ); } -void ControllerRackView::update() +void ControllerRackView::onControllerAdded( Controller * controller ) { - QWidget * w = m_scrollArea->widget(); - Song * s = Engine::getSong(); + QWidget * scrollAreaWidget = m_scrollArea->widget(); - setUpdatesEnabled( false ); + ControllerView * controllerView = new ControllerView( controller, scrollAreaWidget ); - int i = 0; - for( i = 0; i < m_controllerViews.size(); ++i ) - { - delete m_controllerViews[i]; - } + connect( controllerView, SIGNAL( deleteController( ControllerView * ) ), + this, SLOT( deleteController( ControllerView * ) ), Qt::QueuedConnection ); - m_controllerViews.clear(); - - for( i = 0; i < s->m_controllers.size(); ++i ) - { - ControllerView * v = new ControllerView( s->m_controllers[i], w ); - - connect( v, SIGNAL( deleteController( ControllerView * ) ), - this, SLOT( deleteController( ControllerView * ) ), - Qt::QueuedConnection ); - - m_controllerViews.append( v ); - v->move( 0, i*32 ); - v->show(); - } - - w->setFixedSize( 210, i*32 ); - - setUpdatesEnabled( true ); - QWidget::update(); + m_controllerViews.append( controllerView ); + m_scrollAreaLayout->insertWidget( m_nextIndex, controllerView ); + ++m_nextIndex; } + + +void ControllerRackView::onControllerRemoved( Controller * removedController ) +{ + ControllerView * viewOfRemovedController = 0; + + QVector::const_iterator end = m_controllerViews.end(); + for ( QVector::const_iterator it = m_controllerViews.begin(); it != end; ++it) + { + ControllerView *currentControllerView = *it; + if ( currentControllerView->getController() == removedController ) + { + viewOfRemovedController = currentControllerView; + break; + } + } + + if (viewOfRemovedController ) + { + m_controllerViews.erase( qFind( m_controllerViews.begin(), + m_controllerViews.end(), viewOfRemovedController ) ); + + delete viewOfRemovedController; + --m_nextIndex; + } +} + + + + void ControllerRackView::addController() { // TODO: Eventually let the user pick from available controller types Engine::getSong()->addController( new LfoController( Engine::getSong() ) ); - update(); // fix bug which always made ControllerRackView loose focus when adding // new controller diff --git a/src/gui/widgets/ControllerView.cpp b/src/gui/widgets/ControllerView.cpp index b6ed84333..54cf8c8b7 100644 --- a/src/gui/widgets/ControllerView.cpp +++ b/src/gui/widgets/ControllerView.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "ControllerView.h" @@ -46,22 +47,32 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : - QWidget( _parent ), + QFrame( _parent ), ModelView( _model, this ), - m_bg( embed::getIconPixmap( "controller_bg" ) ), m_subWindow( NULL ), m_controllerDlg( NULL ), m_show( true ) { - setFixedSize( 210, 32 ); + this->setFrameStyle( QFrame::StyledPanel ); + this->setFrameShadow( QFrame::Raised ); + + QVBoxLayout *vBoxLayout = new QVBoxLayout(this); + + QHBoxLayout *hBox = new QHBoxLayout(); + vBoxLayout->addLayout(hBox); + + QLabel *label = new QLabel( "" + _model->displayName() + "", this); + + hBox->addWidget(label); + + QPushButton * controlsButton = new QPushButton( tr( "Controls" ), this ); + connect( controlsButton, SIGNAL( clicked() ), SLOT( editControls() ) ); + + hBox->addWidget(controlsButton); + + m_nameLabel = new QLabel(_model->name(), this); + vBoxLayout->addWidget(m_nameLabel); - QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), this ); - - QFont f = ctls_btn->font(); - ctls_btn->setFont( pointSize<8>( f ) ); - ctls_btn->setGeometry( 140, 2, 50, 14 ); - connect( ctls_btn, SIGNAL( clicked() ), - this, SLOT( editControls() ) ); m_controllerDlg = getController()->createDialog( gui->mainWindow()->workspace() ); @@ -90,7 +101,6 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : ControllerView::~ControllerView() { - delete m_subWindow; } @@ -128,28 +138,6 @@ void ControllerView::deleteController() -void ControllerView::paintEvent( QPaintEvent * ) -{ - QPainter p( this ); - p.drawPixmap( 0, 0, m_bg ); - - QFont f = pointSizeF( font(), 7.5f ); - f.setBold( true ); - p.setFont( f ); - - Controller * c = castModel(); - - p.setPen( QColor( 64, 64, 64 ) ); - p.drawText( 7, 13, c->displayName() ); - p.setPen( Qt::white ); - p.drawText( 6, 12, c->displayName() ); - - f.setBold( false ); - p.setFont( f ); - p.drawText( 8, 26, c->name() ); -} - - void ControllerView::mouseDoubleClickEvent( QMouseEvent * event ) { @@ -162,7 +150,7 @@ void ControllerView::mouseDoubleClickEvent( QMouseEvent * event ) if( ok && !new_name.isEmpty() ) { c->setName( new_name ); - update(); + m_nameLabel->setText( new_name ); } } From 76e4859ef085500d961fe8af7cc6e082813e06d1 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Thu, 30 Jul 2015 21:08:35 +0200 Subject: [PATCH 3/6] Get rid of hardcoded pixel sizes in the plugin browser and side bar The PluginDescWidget doesn't use calls to pointSize anymore. Also the name of the plugin is only painted bold when hovered over with the mouse. The animation speed was increased a bit as well. Hope it is not too fast for displays with smaller resolutions. The problem with the current implementation is that it increases the height by incremental steps of 1 pixel (triggered by a QTimer) which gives a slower speed on high DPI displays. In the future this implementation might be improved, e.g. by using the animation classes provided by Qt. The SideBarWidget also does not use calls to pointSize anymore. Instead the standard font is increased by 2 (typographical) points and then rendered at the right place using information from QFontMetrics. In the long run the header of the SideBarWidget should be organized using a layout, e.g. a layout with one QLabel to render the icon and one QLabel to render the header text. This would ensure that the black background would always be large enough and that the fonts do not protude into the actual content. --- src/gui/PluginBrowser.cpp | 13 ++++++++----- src/gui/widgets/SideBarWidget.cpp | 11 ++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 6e7174168..6e7b9a619 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -68,7 +68,6 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : "Beat+Bassline Editor or into an " "existing instrument track." ), m_view ); - hint->setFont( pointSize<8>( hint->font() ) ); hint->setWordWrap( true ); QScrollArea* scrollarea = new QScrollArea( m_view ); @@ -153,8 +152,12 @@ void PluginDescWidget::paintEvent( QPaintEvent * ) p.drawRect( 0, 0, rect().right(), rect().bottom() ); p.drawPixmap( 4, 4, logo ); - QFont f = pointSize<8>( p.font() ); - f.setBold( true ); + QFont f = p.font(); + if ( m_mouseOver ) + { + f.setBold( true ); + } + p.setFont( f ); p.drawText( 10 + logo_size.width(), 15, m_pluginDescriptor.displayName ); @@ -162,7 +165,7 @@ void PluginDescWidget::paintEvent( QPaintEvent * ) if( height() > 24 || m_mouseOver ) { f.setBold( false ); - p.setFont( pointSize<8>( f ) ); + p.setFont( f ); QRect br; p.drawText( 10 + logo_size.width(), 20, width() - 58 - 5, 999, Qt::TextWordWrap, @@ -231,7 +234,7 @@ void PluginDescWidget::updateHeight() if( !m_updateTimer.isActive() ) { - m_updateTimer.start( 15 ); + m_updateTimer.start( 10 ); } } diff --git a/src/gui/widgets/SideBarWidget.cpp b/src/gui/widgets/SideBarWidget.cpp index 2da0c9a45..c1559f909 100644 --- a/src/gui/widgets/SideBarWidget.cpp +++ b/src/gui/widgets/SideBarWidget.cpp @@ -55,21 +55,22 @@ SideBarWidget::~SideBarWidget() void SideBarWidget::paintEvent( QPaintEvent * ) { - const int TITLE_FONT_HEIGHT = 13; - QPainter p( this ); p.fillRect( 0, 0, width(), 27, palette().highlight().color() ); QFont f = p.font(); f.setBold( true ); - p.setFont( pointSize( f ) ); + f.setUnderline( true ); + f.setPointSize( f.pointSize() + 2 ); + p.setFont( f ); p.setPen( palette().highlightedText().color() ); const int tx = m_icon.width()+4; - const int ty = 2+TITLE_FONT_HEIGHT; + + QFontMetrics metrics( f ); + const int ty = metrics.ascent(); p.drawText( tx, ty, m_title ); - p.drawLine( tx, ty+4, width()-4, ty+4 ); p.drawPixmap( 2, 2, m_icon.transformed( QTransform().rotate( -90 ) ) ); } From fa5c0c1569f2c1c08319a3b2982b650a2e55cfba Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Thu, 30 Jul 2015 22:32:38 +0200 Subject: [PATCH 4/6] Fixes the rendering of the tact numbers in the timeline Fixed the rendering of the tact numbers in the timeline widget. Before this fix they were not readable because they were too big. Interestingly in this case the fix is to use a font size in pixels (half the height of the widget). The numbers are now also rendered a bit darker than the lines. Also removed the pixmap for the timeline from the code and from the filesystem. It was only used to determine the fixed height of the widget but not rendered. Therefore it was removed and the height is now directly set to 18 pixels which was the height of the pixmap. --- data/themes/default/timeline.png | Bin 212 -> 0 bytes include/TimeLineWidget.h | 1 - src/gui/TimeLineWidget.cpp | 21 ++++++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) delete mode 100644 data/themes/default/timeline.png diff --git a/data/themes/default/timeline.png b/data/themes/default/timeline.png deleted file mode 100644 index b942d72d16b4e8f4f23b086b70577b5af0f97cdd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Ex0VEjY7dQ6-DW)WEcNc~RchdzzKwht>i(`m{ zWbMJ*o-B+Et{dm9dwYQG%2(EZH=mVG6BRk)xhr1zvv+phuQ|^yY>CLun`JlW_1cq( zhLMvM!}4_|Z(X+VslgXJlm9QT?u_$^$X?s}H0^8FldQFwDH$)0hJNm!_jlu;7nh16 zrgbU`U)#J;v2EJLn9{;^>Zi{}b*Jj;*jin8K3z0pM#R3g*3b7bB<>Aaek#sH0OVXx LS3j3^P6height() ); + setFixedHeight( 18 ); m_xOffset -= s_posMarkerPixmap->width() / 2; @@ -250,10 +244,18 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) int x = m_xOffset + s_posMarkerPixmap->width() / 2 - ( ( static_cast( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast( m_ppt ) ); - p.setPen( QColor( 192, 192, 192 ) ); + QColor lineColor( 192, 192, 192 ); + QColor tactColor( lineColor.darker( 120 ) ); + + // Set font to half of the widgets size (in pixels) + QFont font = p.font(); + font.setPixelSize( this->height() * 0.5 ); + p.setFont( font ); + for( int i = 0; x + i * m_ppt < width(); ++i ) { const int cx = x + qRound( i * m_ppt ); + p.setPen( lineColor ); p.drawLine( cx, 5, cx, height() - 6 ); ++tact_num; if( ( tact_num - 1 ) % @@ -261,9 +263,10 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) MidiTime::ticksPerTact() / m_ppt ) ) == 0 ) { const QString s = QString::number( tact_num ); + p.setPen( tactColor ); p.drawText( cx + qRound( ( m_ppt - p.fontMetrics(). width( s ) ) / 2 ), - height() - p.fontMetrics().height() / 2, s ); + height() - p.fontMetrics().ascent() / 2, s ); } } From ef449f5baebb0f5d449e14a50aed25c1da90ef7b Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 16 Aug 2015 09:39:00 +0200 Subject: [PATCH 5/6] Remove the horizontal scrollbar from controller rack view Removes the potential horizontal scrollbar from the controller rack view. Also sets the MDI window of the controller rack to a bigger size in the constructor and moves it towards the other windows. This code is active in the case where there is no default template from which the window states are loaded. --- src/gui/widgets/ControllerRackView.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/ControllerRackView.cpp b/src/gui/widgets/ControllerRackView.cpp index b727869af..2bf7054a8 100644 --- a/src/gui/widgets/ControllerRackView.cpp +++ b/src/gui/widgets/ControllerRackView.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ ControllerRackView::ControllerRackView( ) : m_scrollArea = new QScrollArea( this ); m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) ); + m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); QWidget * scrollAreaWidget = new QWidget( m_scrollArea ); m_scrollAreaLayout = new QVBoxLayout( scrollAreaWidget ); @@ -84,9 +86,8 @@ ControllerRackView::ControllerRackView( ) : subWin->setWindowFlags( flags ); subWin->setAttribute( Qt::WA_DeleteOnClose, false ); - subWin->move( 880, 310 ); - - resize( 600, 400 ); + subWin->move( 680, 310 ); + subWin->resize(400, 200); } @@ -152,6 +153,7 @@ void ControllerRackView::onControllerAdded( Controller * controller ) m_controllerViews.append( controllerView ); m_scrollAreaLayout->insertWidget( m_nextIndex, controllerView ); + ++m_nextIndex; } From 4571d1402921c94f1e6b4b6b004702d761131eb2 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Tue, 18 Aug 2015 18:23:40 +0200 Subject: [PATCH 6/6] Prevent resizing of the "Controls" button The "Controls" button will now keep its minimal size when the ControllerView is resized. --- src/gui/widgets/ControllerView.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/widgets/ControllerView.cpp b/src/gui/widgets/ControllerView.cpp index 54cf8c8b7..641f27e78 100644 --- a/src/gui/widgets/ControllerView.cpp +++ b/src/gui/widgets/ControllerView.cpp @@ -62,6 +62,9 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : vBoxLayout->addLayout(hBox); QLabel *label = new QLabel( "" + _model->displayName() + "", this); + QSizePolicy sizePolicy = label->sizePolicy(); + sizePolicy.setHorizontalStretch(1); + label->setSizePolicy(sizePolicy); hBox->addWidget(label);