From e109f3e55012dadd9a2baf027421f4c0cba27aa3 Mon Sep 17 00:00:00 2001 From: Paul Giblock Date: Fri, 7 Aug 2009 16:26:07 -0400 Subject: [PATCH] Make Controller-Rack resizable Per request, make the Controller-rack vertically sizable. This is also part of our effort to slowly deprecate old fixed-positioning code in favor of layouts. (cherry picked from commit bb76ba51213affb9e41c97b7665814595a556625) --- include/controller_rack_view.h | 2 +- src/gui/widgets/controller_rack_view.cpp | 52 ++++++++++++------------ 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/include/controller_rack_view.h b/include/controller_rack_view.h index 7e9701c40..3275a2ac9 100644 --- a/include/controller_rack_view.h +++ b/include/controller_rack_view.h @@ -1,7 +1,7 @@ /* * controller_rack_view.h - view for song's controllers * - * Copyright (c) 2008 Paul Giblock + * Copyright (c) 2008-2009 Paul Giblock * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * diff --git a/src/gui/widgets/controller_rack_view.cpp b/src/gui/widgets/controller_rack_view.cpp index e074fbc9a..6f63a6092 100644 --- a/src/gui/widgets/controller_rack_view.cpp +++ b/src/gui/widgets/controller_rack_view.cpp @@ -1,7 +1,7 @@ /* * controller_rack_view.cpp - view for song's controllers * - * Copyright (c) 2008 Paul Giblock + * Copyright (c) 2008-2009 Paul Giblock * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -41,41 +41,49 @@ controllerRackView::controllerRackView( ) : - QWidget() + QWidget(), + m_lastY( 0 ) { - setFixedSize( 250, 250 ); + setMinimumWidth( 250 ); + setMaximumWidth( 250 ); + setWindowIcon( embed::getIconPixmap( "controller" ) ); setWindowTitle( tr( "Controller Rack" ) ); m_scrollArea = new QScrollArea( this ); - m_scrollArea->setFixedSize( 230, 184 ); m_scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) ); - m_scrollArea->move( 6, 22 ); + m_scrollArea->setMinimumHeight( 64 ); + m_scrollArea->setHeight( 128 ); - m_addButton = new QPushButton( this/*, "Add Effect"*/ ); + m_addButton = new QPushButton( this ); m_addButton->setText( tr( "Add" ) ); - m_addButton->move( 75, 210 ); - connect( m_addButton, SIGNAL( clicked( void ) ), + + QWidget * w = new QWidget(); + m_scrollArea->setWidget( w ); + + connect( m_addButton, SIGNAL( clicked( void ) ), this, SLOT( addController( void ) ) ); connect( engine::getSong(), SIGNAL( dataChanged( void ) ), this, SLOT( update( void ) ) ); - QWidget * w = new QWidget(); - m_scrollArea->setWidget( w ); + QVBoxLayout * layout = new QVBoxLayout(); + layout->addWidget( m_scrollArea ); + layout->addWidget( m_addButton ); + this->setLayout( layout ); - m_lastY = 0; + QMdiSubWindow * subWin = + engine::getMainWindow()->workspace()->addSubWindow( this ); - QMdiSubWindow * subWin = - engine::getMainWindow()->workspace()->addSubWindow( this ); + // No maximize button Qt::WindowFlags flags = subWin->windowFlags(); - flags |= Qt::MSWindowsFixedSizeDialogHint; flags &= ~Qt::WindowMaximizeButtonHint; subWin->setWindowFlags( flags ); - setWindowFlags( flags ); - subWin->layout()->setSizeConstraint( QLayout::SetFixedSize ); + + + subWin->layout()->setSizeConstraint( QLayout::SetMaximumSize ); parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE ); parentWidget()->move( 880, 310 ); @@ -114,7 +122,7 @@ void controllerRackView::deleteController( controllerView * _view ) { controller * c = _view->getController(); - m_controllerViews.erase( qFind( m_controllerViews.begin(), + m_controllerViews.erase( qFind( m_controllerViews.begin(), m_controllerViews.end(), _view ) ); delete _view; delete c; @@ -128,7 +136,6 @@ void controllerRackView::update( void ) { QWidget * w = m_scrollArea->widget(); song * s = engine::getSong(); -// QVector view_map( fxChain()->m_effects.size(), FALSE ); setUpdatesEnabled( false ); @@ -163,15 +170,6 @@ void controllerRackView::update( void ) void controllerRackView::addController( void ) { // TODO: Eventually let the user pick from available controller types - /* - effectSelectDialog esd( this ); - esd.exec(); - - if( esd.result() == QDialog::Rejected ) - { - return; - } - */ engine::getSong()->addController( new lfoController( engine::getSong() ) ); update();