rewrote timing of fading animation for not postponing updates of hidden fadeButton until it becomes visible (stable backport)
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms/stable-0.4@2058 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,5 +1,16 @@
|
||||
2009-02-19 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/fade_button.h:
|
||||
* src/gui/widgets/fade_button.cpp:
|
||||
rewrote timing of fading animation for not postponing updates of
|
||||
hidden fadeButton until it becomes visible
|
||||
|
||||
* src/gui/widgets/automatable_button.cpp:
|
||||
* src/core/track.cpp:
|
||||
make sure all buttons in trackOperationsWidget have focus-policy
|
||||
set to Qt::NoFocus in order to make space play song even if you clicked
|
||||
e.g. a mute-button (closes #2486211)
|
||||
|
||||
* include/note.h:
|
||||
* src/core/note.cpp:
|
||||
- coding style fixes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* fade_button.h - declaration of class fadeButton
|
||||
*
|
||||
* Copyright (c) 2005-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -26,6 +26,7 @@
|
||||
#ifndef _FADE_BUTTON_H
|
||||
#define _FADE_BUTTON_H
|
||||
|
||||
#include <QtCore/QTime>
|
||||
#include <QtGui/QAbstractButton>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
@@ -42,7 +43,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void activate( void );
|
||||
void reset( void );
|
||||
|
||||
|
||||
protected:
|
||||
@@ -51,7 +51,7 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
float m_state;
|
||||
QTime m_stateTimer;
|
||||
QColor m_normalColor;
|
||||
QColor m_activatedColor;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* fade_button.cpp - implementation of fade-button
|
||||
*
|
||||
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -35,15 +35,19 @@
|
||||
#include "update_event.h"
|
||||
|
||||
|
||||
const float FadeDuration = 300;
|
||||
|
||||
|
||||
fadeButton::fadeButton( const QColor & _normal_color,
|
||||
const QColor & _activated_color, QWidget * _parent ) :
|
||||
QAbstractButton( _parent ),
|
||||
m_state( 0.0f ),
|
||||
m_stateTimer(),
|
||||
m_normalColor( _normal_color ),
|
||||
m_activatedColor( _activated_color )
|
||||
{
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
setCursor( QCursor( embed::getIconPixmap( "hand" ), 0, 0 ) );
|
||||
setFocusPolicy( Qt::NoFocus );
|
||||
}
|
||||
|
||||
|
||||
@@ -58,21 +62,12 @@ fadeButton::~fadeButton()
|
||||
|
||||
void fadeButton::activate( void )
|
||||
{
|
||||
m_state = 1.00f;
|
||||
m_stateTimer.restart();
|
||||
signalUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void fadeButton::reset( void )
|
||||
{
|
||||
m_state = 0.0f;
|
||||
signalUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void fadeButton::customEvent( QEvent * )
|
||||
{
|
||||
@@ -85,20 +80,19 @@ void fadeButton::customEvent( QEvent * )
|
||||
void fadeButton::paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
QColor col = m_normalColor;
|
||||
if( m_state > 0.0f )
|
||||
if( m_stateTimer.elapsed() < FadeDuration )
|
||||
{
|
||||
const float state = 1 - m_stateTimer.elapsed() / FadeDuration;
|
||||
const int r = (int)( m_normalColor.red() *
|
||||
( 1.0f - m_state ) +
|
||||
m_activatedColor.red() * m_state );
|
||||
( 1.0f - state ) +
|
||||
m_activatedColor.red() * state );
|
||||
const int g = (int)( m_normalColor.green() *
|
||||
( 1.0f - m_state ) +
|
||||
m_activatedColor.green() * m_state );
|
||||
( 1.0f - state ) +
|
||||
m_activatedColor.green() * state );
|
||||
const int b = (int)( m_normalColor.blue() *
|
||||
( 1.0f - m_state ) +
|
||||
m_activatedColor.blue() * m_state );
|
||||
( 1.0f - state ) +
|
||||
m_activatedColor.blue() * state );
|
||||
col.setRgb( r, g, b );
|
||||
|
||||
m_state -= 0.1f;
|
||||
QTimer::singleShot( 20, this, SLOT( update() ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user