Simplify FadeButton update (#5311)
This commit is contained in:
@@ -50,7 +50,6 @@ public slots:
|
||||
|
||||
|
||||
protected:
|
||||
void customEvent( QEvent * ) override;
|
||||
void paintEvent( QPaintEvent * _pe ) override;
|
||||
|
||||
|
||||
@@ -66,7 +65,6 @@ private:
|
||||
QColor m_holdColor;
|
||||
int activeNotes;
|
||||
|
||||
void signalUpdate();
|
||||
QColor fadeToColor(QColor, QColor, QTime, float);
|
||||
|
||||
} ;
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* custom_events.h - custom event types list
|
||||
*
|
||||
* Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CUSTOM_EVENTS_H
|
||||
#define CUSTOM_EVENTS_H
|
||||
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
|
||||
|
||||
namespace customEvents
|
||||
{
|
||||
|
||||
enum Type
|
||||
{
|
||||
GUI_UPDATE = QEvent::User
|
||||
} ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* update_event.h - signal GUI updates
|
||||
*
|
||||
* Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef UPDATE_EVENT_H
|
||||
#define UPDATE_EVENT_H
|
||||
|
||||
#include "custom_events.h"
|
||||
|
||||
|
||||
|
||||
class updateEvent : public QEvent
|
||||
{
|
||||
public:
|
||||
updateEvent() :
|
||||
QEvent( (QEvent::Type)customEvents::GUI_UPDATE )
|
||||
{
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -24,12 +24,10 @@
|
||||
|
||||
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
|
||||
#include "embed.h"
|
||||
#include "FadeButton.h"
|
||||
#include "update_event.h"
|
||||
|
||||
|
||||
const float FadeDuration = 300;
|
||||
@@ -71,7 +69,7 @@ void FadeButton::activate()
|
||||
{
|
||||
m_stateTimer.restart();
|
||||
activeNotes++;
|
||||
signalUpdate();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,14 +92,6 @@ void FadeButton::noteEnd()
|
||||
m_releaseTimer.restart();
|
||||
}
|
||||
|
||||
signalUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FadeButton::customEvent(QEvent *)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -165,9 +155,3 @@ QColor FadeButton::fadeToColor(QColor startCol, QColor endCol, QTime timer, floa
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
void FadeButton::signalUpdate()
|
||||
{
|
||||
QApplication::postEvent(this, new updateEvent());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user