GUI-improvements, zooming-selectboxes in piano-roll and song-editor and more

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@12 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2005-09-29 07:18:55 +00:00
parent f64b25ba44
commit b3754454cd
16 changed files with 297 additions and 110 deletions

View File

@@ -29,6 +29,7 @@
#include <QPainter>
#include <QPixmap>
#include <QMouseEvent>
#include <QWheelEvent>
#else
@@ -45,7 +46,10 @@
tabWidget::tabWidget( const QString & _caption, QWidget * _parent ) :
QWidget( _parent ),
m_curWidget( 0 ),
#ifndef QT4
specialBgHandlingWidget( QColor( 96, 96, 96 ) ),
#endif
m_activeTab( 0 ),
m_caption( _caption )
{
setFont( pointSize<7>( font() ) );
@@ -55,7 +59,7 @@ tabWidget::tabWidget( const QString & _caption, QWidget * _parent ) :
setPalette( pal );
#else
setPaletteBackgroundColor( QColor( 96, 96, 96 ) );
//setBackgroundMode( Qt::NoBackground );
setBackgroundMode( Qt::NoBackground );
#endif
}
@@ -68,14 +72,25 @@ tabWidget::~tabWidget()
void tabWidget::addTab( QWidget * _w, const QString & _name )
void tabWidget::addTab( QWidget * _w, const QString & _name, int _idx )
{
widgetDesc d = { _w, _name, fontMetrics().width( _name ) + 10 } ;
m_widgets.push_back( d );
// make sure new tab doesn't overlap current widget
m_widgets[m_curWidget].w->raise();
widgetDesc d = { _w, _name, fontMetrics().width( _name ) + 10 } ;
if( _idx < 0 || m_widgets.contains( _idx ) == TRUE )
{
while( m_widgets.contains( ++_idx ) == TRUE )
{
}
}
m_widgets[_idx] = d;
_w->setFixedSize( width() - 4, height() - 14 );
_w->move( 2, 12 );
if( m_widgets.contains( m_activeTab ) )
{
// make sure new tab doesn't overlap current widget
m_widgets[m_activeTab].w->raise();
}
}
@@ -85,18 +100,20 @@ void tabWidget::mousePressEvent( QMouseEvent * _me )
{
if( _me->y() > 1 && _me->y() < 13 )
{
int cx = 14 + fontMetrics().width( m_caption );
int cx = ( ( m_caption == "" ) ? 4 : 14 ) +
fontMetrics().width( m_caption );
for( widgetStack::iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
{
if( _me->x() >= cx && _me->x() <= cx + it->nwidth )
if( _me->x() >= cx &&
_me->x() <= cx + ( *it ).nwidth )
{
it->w->raise();
m_curWidget = it - m_widgets.begin();
( *it ).w->raise();
m_activeTab = it.key();
update();
return;
}
cx += it->nwidth;
cx += ( *it ).nwidth;
}
}
}
@@ -109,7 +126,7 @@ void tabWidget::resizeEvent( QResizeEvent * )
for( widgetStack::iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
{
it->w->setFixedSize( width() - 4, height() - 14 );
( *it ).w->setFixedSize( width() - 4, height() - 14 );
}
}
@@ -127,6 +144,8 @@ void tabWidget::paintEvent( QPaintEvent * _pe )
QPainter p( &pm );
#endif
bool big_tab_captions = ( m_caption == "" );
int add = big_tab_captions ? 1 : 0;
p.setPen( QColor( 64, 64, 64 ) );
p.drawRect( 0, 0, width(), height() );
@@ -138,31 +157,43 @@ void tabWidget::paintEvent( QPaintEvent * _pe )
p.setPen( QColor( 0, 0, 0 ) );
p.drawRect( 1, 1, width() - 2, height() - 2 );
p.fillRect( 2, 2, width() - 4, 9, QColor( 30, 45, 60 ) );
p.drawLine( 2, 11, width() - 3, 11 );
p.fillRect( 2, 2, width() - 4, 9 + add, QColor( 30, 45, 60 ) );
p.drawLine( 2, 11 + add, width() - 3, 11 + add );
p.setPen( QColor( 255, 255, 255 ) );
p.setFont( font() );
p.drawText( 5, 10, m_caption );
if( !big_tab_captions )
{
p.setPen( QColor( 255, 255, 255 ) );
p.setFont( font() );
p.drawText( 5, 10, m_caption );
}
int cx = 14 + fontMetrics().width( m_caption );
int cx = ( big_tab_captions ? 4 : 14 ) +
fontMetrics().width( m_caption );
p.setFont( pointSize<6>( p.font() ) );
QColor cap_col( 160, 160, 160 );
if( big_tab_captions )
{
p.setFont( pointSize<7>( p.font() ) );
cap_col = QColor( 224, 224, 224 );
}
else
{
p.setFont( pointSize<6>( p.font() ) );
}
p.setPen( cap_col );
p.setPen( QColor( 160, 160, 160 ) );
for( widgetStack::iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
{
if( it - m_widgets.begin() == m_curWidget )
if( it.key() == m_activeTab )
{
p.setPen( QColor( 32, 48, 64 ) );
p.fillRect( cx, 2, it->nwidth - 6, 9,
QColor( 160, 160, 160 ) );
p.fillRect( cx, 2, ( *it ).nwidth - 6, 9, cap_col );
}
p.drawText( cx + 3, 9, it->name );
p.setPen( QColor( 160, 160, 160 ) );
cx += it->nwidth;
p.drawText( cx + 3, 9 + add, ( *it ).name );
p.setPen( cap_col );
cx += ( *it ).nwidth;
}
#ifndef QT4
@@ -173,5 +204,23 @@ void tabWidget::paintEvent( QPaintEvent * _pe )
void tabWidget::wheelEvent( QWheelEvent * _we )
{
int dir = ( _we->delta() > 0 ) ? 1 : -1;
int tab = m_activeTab;
while( tab > -1 && static_cast<csize>( tab ) < m_widgets.count() )
{
tab += dir;
if( m_widgets.contains( tab ) )
{
break;
}
}
setActiveTab( tab );
}
#include "tab_widget.moc"