Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mini fx rewrite without merge conflicts #7438

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
7 changes: 0 additions & 7 deletions include/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ class LMMS_EXPORT Effect : public Plugin
return 1.0f - m_wetDryModel.value();
}

inline float gate() const
michaelgregorius marked this conversation as resolved.
Show resolved Hide resolved
{
const float level = m_gateModel.value();
return level*level * m_processors;
}

inline f_cnt_t bufferCount() const
{
return m_bufferCount;
Expand Down Expand Up @@ -227,7 +221,6 @@ class LMMS_EXPORT Effect : public Plugin

BoolModel m_enabledModel;
FloatModel m_wetDryModel;
FloatModel m_gateModel;
TempoSyncKnobModel m_autoQuitModel;

bool m_autoQuitDisabled;
Expand Down
55 changes: 55 additions & 0 deletions include/EffectLabelButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* EffectLabelButton.h - class trackLabelButton
*
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
*
* 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 LMMS_GUI_EFFECT_LABEL_BUTTON_H
#define LMMS_GUI_EFFECT_LABEL_BUTTON_H

#include <QPushButton>

namespace lmms::gui
{

class EffectView;

class EffectLabelButton : public QPushButton
{
Q_OBJECT
public:
EffectLabelButton( EffectView * _tv, QWidget * _parent );
~EffectLabelButton() override = default;

protected:
void paintEvent(QPaintEvent* pe) override;

private:
EffectView * m_effectView;
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
QString m_iconName;
QRect m_buttonRect;
QString elideName( const QString &name );
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
} ;


} // namespace lmms::gui

#endif // LMMS_GUI_EFFECT_LABEL_BUTTON_H
michaelgregorius marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 8 additions & 3 deletions include/EffectView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
#include "AutomatableModel.h"
#include "PluginView.h"
#include "Effect.h"
#include "EffectLabelButton.h"
michaelgregorius marked this conversation as resolved.
Show resolved Hide resolved

class QGraphicsOpacityEffect;
class QGroupBox;
class QLabel;
class QPushButton;
class QMdiSubWindow;
class QHBoxLayout;
class QLabel;
class QToolButton;

namespace lmms::gui
{
Expand Down Expand Up @@ -62,7 +66,7 @@ class EffectView : public PluginView
}

static constexpr int DEFAULT_WIDTH = 215;
static constexpr int DEFAULT_HEIGHT = 60;
static constexpr int DEFAULT_HEIGHT = 35;

void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
Expand All @@ -88,17 +92,18 @@ public slots:


private:
QPixmap m_bg;
QHBoxLayout* m_mainLayout;
LedCheckBox * m_bypass;
EffectLabelButton* m_label;
Knob * m_wetDry;
TempoSyncKnob * m_autoQuit;
Knob * m_gate;
QMdiSubWindow * m_subWindow;
EffectControlDialog * m_controlView;

bool m_dragging;
QGraphicsOpacityEffect* m_opacityEffect;

friend class EffectLabelButton;
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
} ;


Expand Down
5 changes: 1 addition & 4 deletions src/core/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Effect::Effect( const Plugin::Descriptor * _desc,
m_bufferCount( 0 ),
m_enabledModel( true, this, tr( "Effect enabled" ) ),
m_wetDryModel( 1.0f, -1.0f, 1.0f, 0.01f, this, tr( "Wet/Dry mix" ) ),
m_gateModel( 0.0f, 0.0f, 1.0f, 0.01f, this, tr( "Gate" ) ),
m_autoQuitModel( 1.0f, 1.0f, 8000.0f, 100.0f, 1.0f, this, tr( "Decay" ) ),
m_autoQuitDisabled( false )
{
Expand Down Expand Up @@ -91,7 +90,6 @@ void Effect::saveSettings( QDomDocument & _doc, QDomElement & _this )
m_enabledModel.saveSettings( _doc, _this, "on" );
m_wetDryModel.saveSettings( _doc, _this, "wet" );
m_autoQuitModel.saveSettings( _doc, _this, "autoquit" );
m_gateModel.saveSettings( _doc, _this, "gate" );
controls()->saveState( _doc, _this );
}

Expand All @@ -103,7 +101,6 @@ void Effect::loadSettings( const QDomElement & _this )
m_enabledModel.loadSettings( _this, "on" );
m_wetDryModel.loadSettings( _this, "wet" );
m_autoQuitModel.loadSettings( _this, "autoquit" );
m_gateModel.loadSettings( _this, "gate" );

QDomNode node = _this.firstChild();
while( !node.isNull() )
Expand Down Expand Up @@ -155,7 +152,7 @@ void Effect::checkGate( double _out_sum )

// Check whether we need to continue processing input. Restart the
// counter if the threshold has been exceeded.
if (_out_sum - gate() <= F_EPSILON)
if (_out_sum <= F_EPSILON)
{
incrementBufferCount();
if( bufferCount() > timeout() )
Expand Down
1 change: 1 addition & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ SET(LMMS_SRCS
gui/widgets/CaptionMenu.cpp
gui/widgets/ComboBox.cpp
gui/widgets/CustomTextKnob.cpp
gui/widgets/EffectLabelButton.cpp
gui/widgets/Fader.cpp
gui/widgets/FloatModelEditorBase.cpp
gui/widgets/Graph.cpp
Expand Down
116 changes: 56 additions & 60 deletions src/gui/EffectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <QMouseEvent>
#include <QPushButton>
#include <QPainter>
#include <QPainterPath>
#include <QBoxLayout>
#include <QLabel>
#include <QToolButton>

#include "EffectView.h"
#include "DummyEffect.h"
Expand All @@ -45,65 +49,60 @@
namespace lmms::gui
{

EffectView::EffectView( Effect * _model, QWidget * _parent ) :
PluginView( _model, _parent ),
m_bg( embed::getIconPixmap( "effect_plugin" ) ),
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
m_subWindow( nullptr ),
EffectView::EffectView(Effect * _model, QWidget * _parent) :
PluginView(_model, _parent),
m_subWindow(nullptr),
m_controlView(nullptr),
m_dragging(false)
{
setFixedSize(EffectView::DEFAULT_WIDTH, EffectView::DEFAULT_HEIGHT);
setFocusPolicy(Qt::StrongFocus);

m_mainLayout = new QHBoxLayout();
m_mainLayout->setContentsMargins(8, 2, 8, 2);

// Disable effects that are of type "DummyEffect"
bool hasControls = effect()->controls()->controlCount() > 0;
bool isEnabled = !dynamic_cast<DummyEffect *>( effect() );
m_bypass = new LedCheckBox( this, "", isEnabled ? LedCheckBox::LedColor::Green : LedCheckBox::LedColor::Red );
m_bypass->move( 3, 3 );
m_bypass->setEnabled( isEnabled );

enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
m_bypass = new LedCheckBox(this, "", isEnabled ? LedCheckBox::LedColor::Green : LedCheckBox::LedColor::Red);
m_bypass->setEnabled(isEnabled);
m_bypass->setToolTip(tr("On/Off"));
m_mainLayout->addWidget(m_bypass);

QFont labelFont = adjustedToPixelSize(font(), 10);
m_label = new EffectLabelButton(this, this);
m_label->setText(model()->displayName());
m_label->setFont(labelFont);
m_label->setCheckable(true);
m_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
if(hasControls)
{
connect(m_label, SIGNAL(clicked()), this, SLOT(editControls()));
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved
}
m_mainLayout->addWidget(m_label);

m_wetDry = new Knob(KnobType::Small17, this);
m_wetDry->setEnabled(isEnabled);
m_wetDry->setHintText(tr("Wet Level:"), "");
m_mainLayout->addWidget(m_wetDry);

m_wetDry = new Knob( KnobType::Bright26, this );
m_wetDry->setLabel( tr( "W/D" ) );
m_wetDry->move( 40 - m_wetDry->width() / 2, 5 );
m_wetDry->setEnabled( isEnabled );
m_wetDry->setHintText( tr( "Wet Level:" ), "" );


m_autoQuit = new TempoSyncKnob( KnobType::Bright26, this );
m_autoQuit->setLabel( tr( "DECAY" ) );
m_autoQuit->move( 78 - m_autoQuit->width() / 2, 5 );
m_autoQuit->setEnabled( isEnabled && !effect()->m_autoQuitDisabled );
m_autoQuit->setHintText( tr( "Time:" ), "ms" );


m_gate = new Knob( KnobType::Bright26, this );
m_gate->setLabel( tr( "GATE" ) );
m_gate->move( 116 - m_gate->width() / 2, 5 );
m_gate->setEnabled( isEnabled && !effect()->m_autoQuitDisabled );
m_gate->setHintText( tr( "Gate:" ), "" );

m_autoQuit = new TempoSyncKnob(KnobType::Small17, this);
m_autoQuit->setEnabled(isEnabled && !effect()->m_autoQuitDisabled);
m_autoQuit->setVisible(isEnabled && !effect()->m_autoQuitDisabled);
m_autoQuit->setHintText(tr("Stop after:"), "ms");
m_mainLayout->addWidget(m_autoQuit);

setModel( _model );

if( effect()->controls()->controlCount() > 0 )
if(hasControls)
{
auto ctls_btn = new QPushButton(tr("Controls"), this);
QFont f = ctls_btn->font();
ctls_btn->setFont(adjustedToPixelSize(f, 10));
ctls_btn->setGeometry( 150, 14, 50, 20 );
connect( ctls_btn, SIGNAL(clicked()),
this, SLOT(editControls()));

m_controlView = effect()->controls()->createView();
if( m_controlView )
if(m_controlView)
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
{
m_subWindow = getGUI()->mainWindow()->addWindowedWidget( m_controlView );

if ( !m_controlView->isResizable() )
m_subWindow = getGUI()->mainWindow()->addWindowedWidget(m_controlView);
if (!m_controlView->isResizable())
{
m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
m_subWindow->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
if (m_subWindow->layout())
{
m_subWindow->layout()->setSizeConstraint(QLayout::SetFixedSize);
Expand All @@ -112,9 +111,9 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :

Qt::WindowFlags flags = m_subWindow->windowFlags();
flags &= ~Qt::WindowMaximizeButtonHint;
m_subWindow->setWindowFlags( flags );
m_subWindow->setWindowFlags(flags);

connect( m_controlView, SIGNAL(closed()),
connect(m_controlView, SIGNAL(closed()),
this, SLOT(closeEffects()));

m_subWindow->hide();
Expand All @@ -125,8 +124,7 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) :
m_opacityEffect->setOpacity(1);
setGraphicsEffect(m_opacityEffect);

//move above vst effect view creation
//setModel( _model );
setLayout(m_mainLayout);
}


Expand All @@ -148,12 +146,14 @@ void EffectView::editControls()
{
m_subWindow->show();
m_subWindow->raise();
effect()->controls()->setViewVisible( true );
effect()->controls()->setViewVisible(true);
m_label->setChecked(true);
}
else
{
m_subWindow->hide();
effect()->controls()->setViewVisible( false );
effect()->controls()->setViewVisible(false);
m_label->setChecked(false);
}
}
}
Expand Down Expand Up @@ -190,7 +190,8 @@ void EffectView::closeEffects()
{
m_subWindow->hide();
}
effect()->controls()->setViewVisible( false );
effect()->controls()->setViewVisible(false);
m_label->setChecked(false);
}


Expand Down Expand Up @@ -255,19 +256,15 @@ void EffectView::mouseMoveEvent(QMouseEvent* event)

void EffectView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_bg );

QFont f = adjustedToPixelSize(font(), 10);
f.setBold( true );
p.setFont( f );
QPainter p(this);
QPainterPath path;

QString elidedText = p.fontMetrics().elidedText( model()->displayName(), Qt::ElideRight, width() - 22 );
path.addRoundedRect(QRectF(2, 2, EffectView::DEFAULT_WIDTH - 4, EffectView::DEFAULT_HEIGHT - 4), 2, 2);
enp2s0 marked this conversation as resolved.
Show resolved Hide resolved

p.setPen( palette().shadow().color() );
p.drawText( 6, 55, elidedText );
p.setPen( palette().text().color() );
p.drawText( 5, 54, elidedText );
QPen pen(Qt::black, 1);
p.setPen(pen);
p.fillPath(path, QColor(0x3b, 0x42, 0x4a));
p.drawPath(path);
}


Expand All @@ -278,7 +275,6 @@ void EffectView::modelChanged()
m_bypass->setModel( &effect()->m_enabledModel );
m_wetDry->setModel( &effect()->m_wetDryModel );
m_autoQuit->setModel( &effect()->m_autoQuitModel );
m_gate->setModel( &effect()->m_gateModel );
}

} // namespace lmms::gui
Loading
Loading