Give pixmap buttons feedback on click

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@976 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-05-17 15:27:52 +00:00
parent dd28a28745
commit 47f1a985b7
4 changed files with 30 additions and 3 deletions

View File

@@ -3,6 +3,13 @@
* plugins/stereo_matrix/stereomatrix_controls.cpp:
Allow knobs to invert phase as well
* include/pixmap_button.h:
* src/gui/widgets/pixmap_button.cpp:
Make button pixmap "activate" on click
* src/gui/widgets/automatable_button.cpp:
Noted bug in automatable button
2008-05-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* include/project_renderer.h:

View File

@@ -50,12 +50,14 @@ signals:
protected:
virtual void paintEvent( QPaintEvent * _pe );
virtual void mousePressEvent( QMouseEvent * _me );
virtual void mouseReleaseEvent( QMouseEvent * _me );
virtual void mouseDoubleClickEvent( QMouseEvent * _me );
private:
QPixmap m_activePixmap;
QPixmap m_inactivePixmap;
bool m_pressed;
} ;

View File

@@ -146,6 +146,8 @@ void automatableButton::mousePressEvent( QMouseEvent * _me )
void automatableButton::mouseReleaseEvent( QMouseEvent * _me )
{
// TODO: Fix this. for example: LeftDown, RightDown, Both Released causes two events
// or - pressing down then releasing outside of the bbox causes click event.
emit clicked();
}

View File

@@ -38,7 +38,8 @@
pixmapButton::pixmapButton( QWidget * _parent, const QString & _name ) :
automatableButton( _parent, _name ),
m_activePixmap(),
m_inactivePixmap()
m_inactivePixmap(),
m_pressed( FALSE )
{
setActiveGraphic( embed::getIconPixmap( "led_yellow" ) );
setInactiveGraphic( embed::getIconPixmap( "led_off" ), FALSE );
@@ -58,7 +59,7 @@ void pixmapButton::paintEvent( QPaintEvent * )
{
QPainter p( this );
if( model()->value() )
if( model()->value() || m_pressed )
{
if( !m_activePixmap.isNull() )
{
@@ -85,12 +86,27 @@ void pixmapButton::mousePressEvent( QMouseEvent * _me )
}
else
{
// Show pressing graphics if this isn't checkable
if( !isCheckable() )
{
m_pressed = TRUE;
update();
}
automatableButton::mousePressEvent( _me );
}
}
void pixmapButton::mouseReleaseEvent( QMouseEvent * _me )
{
automatableButton::mouseReleaseEvent( _me );
if( !isCheckable() )
{
m_pressed = FALSE;
update();
}
}
void pixmapButton::mouseDoubleClickEvent( QMouseEvent * _me )
{