From 512b407dbd89cd180ae4e722fb7b571153caebc5 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 6 Apr 2006 08:16:07 +0000 Subject: [PATCH] improved plugin-browser git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@119 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 11 +++ TODO | 5 +- configure.in | 4 +- include/plugin_browser.h | 16 +++- src/core/plugin_browser.cpp | 153 +++++++++++++++++------------------- 5 files changed, 101 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab24e44f0..8d7396581 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-04-05 Tobias Doerffel + + * include/plugin_browser.h: + * src/core/plugin_browser.cpp: + - per default show small items for plugins in plugin-browser and show + details on mouse-over (nice animations!! ;-) - avoids problems with + hidden plugin-items because of too low screen-resolution and missing + scrollbars + - draw plugin-details-text using QPainter::drawText (not with old own + (buggy) algorithm for text-drawing with word-break-support) + 2006-04-04 Tobias Doerffel * plugins/flp_import/unrtf/*: diff --git a/TODO b/TODO index 8f64ba7d8..dc47e7a49 100644 --- a/TODO +++ b/TODO @@ -14,13 +14,13 @@ - bristol-bindings - resample sample-track-tcos when using hq-mode - add support for panes-interface (like blender) (instead of MDI etc.) -- message when importing unsupported MIDI-file (track-count = 0) +- message to user when importing unsupported MIDI-file (track-count = 0) - volume-knobs for each sample-track - AMS/OMS-bindings - remove binary-embed-system - recording-functionality - show loading-vst-hint when cloning vestige-track -- do not hang when saving while loading VST-plugin +- do not hang when saving while loading VST-plugin (because then we call dispatcher while the load-process is still going on) - tempo-recogn. and sync of beat-samples - do not quantize when importing from MIDI-file - separate GUI and data/sound-processing-code @@ -31,7 +31,6 @@ - do not skip samples because of rounding-errors when resampling in src/lib/sample_buffer.cpp - MIDI-program/MIDI-mapping/process program-/channel-change-events from MIDI-files - DSSI-support -- somehow avoid hidden plugin-descriptor-widgets plugin-browser if height of window is too small -> add scrollbar - use drawLineF() for drawing notes in pattern::paintEvent() in qt4-version - only redraw region given by paint-event in pattern, bbTCO, sampleTCO etc. - pre-listen when opening sample with QFileDialog diff --git a/configure.in b/configure.in index 789e16668..d37b1cfb6 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.4-cvs20060404, tobydox/at/users/dot/sourceforge/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060404) +AC_INIT(lmms, 0.1.4-cvs20060405, tobydox/at/users/dot/sourceforge/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060405) AM_CONFIG_HEADER(config.h) diff --git a/include/plugin_browser.h b/include/plugin_browser.h index f09c93631..55ce7ba2a 100644 --- a/include/plugin_browser.h +++ b/include/plugin_browser.h @@ -37,11 +37,13 @@ #include #include +#include #else #include #include +#include #endif @@ -73,6 +75,7 @@ private: class pluginDescWidget : public QWidget, public engineObject { + Q_OBJECT public: pluginDescWidget( const plugin::descriptor & _pd, QWidget * _parent, engine * _engine ); @@ -80,17 +83,24 @@ public: protected: - virtual void paintEvent( QPaintEvent * _pe ); + virtual void enterEvent( QEvent * _e ); + virtual void leaveEvent( QEvent * _e ); virtual void mousePressEvent( QMouseEvent * _me ); - virtual void mouseMoveEvent( QMouseEvent * _me ); - virtual void mouseReleaseEvent( QMouseEvent * _me ); + virtual void paintEvent( QPaintEvent * _pe ); + + +private slots: + void updateHeight( void ); private: + QTimer m_updateTimer; + const plugin::descriptor & m_pluginDescriptor; QPixmap m_logo; bool m_mouseOver; + int m_targetHeight; } ; diff --git a/src/core/plugin_browser.cpp b/src/core/plugin_browser.cpp index c8ee5db50..14860379c 100644 --- a/src/core/plugin_browser.cpp +++ b/src/core/plugin_browser.cpp @@ -46,6 +46,7 @@ #include "plugin_browser.h" #include "embed.h" #include "debug.h" +#include "templates.h" #include "gui_templates.h" #include "string_pair_drag.h" @@ -116,13 +117,16 @@ pluginDescWidget::pluginDescWidget( const plugin::descriptor & _pd, QWidget * _parent, engine * _engine ) : QWidget( _parent ), engineObject( _engine ), + m_updateTimer( this ), m_pluginDescriptor( _pd ), m_logo( *_pd.logo ), - m_mouseOver( FALSE ) + m_mouseOver( FALSE ), + m_targetHeight( 24 ) { - setFixedHeight( 60 ); + connect( &m_updateTimer, SIGNAL( timeout() ), SLOT( updateHeight() ) ); + setFixedHeight( m_targetHeight ); setMouseTracking( TRUE ); -#ifndef QT4 +#ifdef QT3 setBackgroundMode( Qt::NoBackground ); #endif setCursor( Qt::PointingHandCursor ); @@ -140,11 +144,8 @@ pluginDescWidget::~pluginDescWidget() void pluginDescWidget::paintEvent( QPaintEvent * ) { - QColor fill_color( 192, 192, 192 ); - if( m_mouseOver ) - { - fill_color = QColor( 224, 224, 224 ); - } + const QColor fill_color = m_mouseOver ? QColor( 224, 224, 224 ) : + QColor( 192, 192, 192 ); #ifdef QT4 QPainter p( this ); @@ -157,76 +158,43 @@ void pluginDescWidget::paintEvent( QPaintEvent * ) // and a painter for it QPainter p( &pm ); #endif + + const int s = 16 + ( 32 * ( tLimit( height(), 24, 60 ) - 24 ) ) / + ( 60 - 24 ); + const QSize logo_size( s, s ); +#ifndef QT3 + QPixmap logo = m_logo.scaled( logo_size, Qt::KeepAspectRatio, + Qt::SmoothTransformation ); +#else + QPixmap logo; + logo.convertFromImage( m_logo.convertToImage().smoothScale( logo_size, + QImage::ScaleMin ) ); +#endif p.setPen( QColor( 64, 64, 64 ) ); p.drawRect( rect() ); - p.drawPixmap( 4, 4, m_logo ); + p.drawPixmap( 4, 4, logo ); QFont f = pointSize<8>( p.font() ); f.setBold( TRUE ); p.setFont( f ); - p.drawText( 58, 14, m_pluginDescriptor.public_name ); + p.drawText( 10 + logo_size.width(), 15, + m_pluginDescriptor.public_name ); - f.setBold( FALSE ); - p.setFont( pointSize<7>( f ) ); -#ifdef QT4 - QStringList words = pluginBrowser::tr( - m_pluginDescriptor.description ).split( ' ' ); -#else - QStringList words = QStringList::split( ' ', - pluginBrowser::tr( m_pluginDescriptor.description ) ); -#endif - for( QStringList::iterator it = words.begin(); it != words.end(); ++it ) + if( height() > 24 || m_mouseOver ) { - if( ( *it ).contains( '-' ) ) + f.setBold( FALSE ); + p.setFont( pointSize<7>( f ) ); + QRect br; + p.drawText( 10 + logo_size.width(), 20, width() - 58 - 5, 999, + Qt::WordBreak, + pluginBrowser::tr( m_pluginDescriptor.description ), + -1, &br ); + if( m_mouseOver ) { -#ifdef QT4 - QStringList splitted_word = it->split( '-' ); -#else - QStringList splitted_word = QStringList::split( '-', - *it ); -#endif - QStringList::iterator orig_it = it; - for( QStringList::iterator it2 = splitted_word.begin(); - it2 != splitted_word.end(); ++it2 ) - { -#ifdef QT4 - if( it2 == --splitted_word.end() ) -#else - if( it2 == splitted_word.fromLast() ) -#endif - { - words.insert( it, *it2 ); - } - else - { - words.insert( it, *it2 + "-" ); - ++it; - } - } - words.erase( orig_it ); - --it; + m_targetHeight = tMax( 60, 25 + br.height() ); } } - int y = 26; - int avail_width = width() - 58 - 5; - QString s; - for( QStringList::iterator it = words.begin(); it != words.end(); ++it ) - { - if( p.fontMetrics().width( s + *it + " " ) >= avail_width ) - { - p.drawText( 58, y, s ); - y += 10; - s = ""; - } - s += *it; - if( ( *it ).right( 1 ) != "-" ) - { - s += " "; - } - } - p.drawText( 58, y, s ); - #ifndef QT4 // blit drawn pixmap to actual widget bitBlt( this, rect().topLeft(), &pm ); @@ -236,40 +204,65 @@ void pluginDescWidget::paintEvent( QPaintEvent * ) +void pluginDescWidget::enterEvent( QEvent * _e ) +{ + m_mouseOver = TRUE; + m_targetHeight = height() + 1; + updateHeight(); + QWidget::enterEvent( _e ); +} + + + + +void pluginDescWidget::leaveEvent( QEvent * _e ) +{ + m_mouseOver = FALSE; + m_targetHeight = 24; + updateHeight(); + QWidget::leaveEvent( _e ); +} + + + + void pluginDescWidget::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton ) { new stringPairDrag( "instrument", m_pluginDescriptor.name, m_logo, this, eng() ); - m_mouseOver = FALSE; - update(); + leaveEvent( _me ); } } -void pluginDescWidget::mouseMoveEvent( QMouseEvent * _me ) +void pluginDescWidget::updateHeight( void ) { - bool new_mouse_over = rect().contains( _me->pos() ); - if( new_mouse_over != m_mouseOver ) + if( m_targetHeight > height() ) { - m_mouseOver = new_mouse_over; - update(); + setFixedHeight( height() + 1 ); + } + else if( m_targetHeight < height() ) + { + setFixedHeight( height() - 1 ); + } + else + { + m_updateTimer.stop(); + return; + } + if( !m_updateTimer.isActive() ) + { + m_updateTimer.start( 15 ); } } -void pluginDescWidget::mouseReleaseEvent( QMouseEvent * _me ) -{ - mouseMoveEvent( _me ); -} - - - #include "plugin_browser.moc"