Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
{
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>
*
* 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just noticed that this class inherits from QPushButton whereas TrackLabelButton inherits from QToolButton. I think the letter is done so that the button can be put into a checked state when for example an instrument window is opened. So I wonder if the same would make sense for opened effects.

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

protected:
void paintEvent(QPaintEvent* pe) override;

private:
EffectView * m_effectView;
QString m_iconName;
QRect m_buttonRect;
QString elideName( const QString &name );
} ;


} // namespace lmms::gui

#endif // LMMS_GUI_EFFECT_LABEL_BUTTON_H
14 changes: 11 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"

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

namespace lmms::gui
{
Expand Down Expand Up @@ -62,12 +66,14 @@ 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;
void mouseReleaseEvent(QMouseEvent* event) override;

void setViewWidth(int px);

public slots:
void editControls();
void moveUp();
Expand All @@ -88,17 +94,19 @@ 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;

int m_viewWidth;
bool m_dragging;
QGraphicsOpacityEffect* m_opacityEffect;

friend class EffectLabelButton;
} ;


Expand Down
11 changes: 4 additions & 7 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 @@ -146,19 +143,19 @@ Effect * Effect::instantiate( const QString& pluginName,



void Effect::checkGate( double _out_sum )
void Effect::checkGate(double _out_sum)
{
if( m_autoQuitDisabled )
if(m_autoQuitDisabled)
{
return;
}

// 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() )
if(bufferCount() > timeout())
{
stopRunning();
resetBufferCount();
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
129 changes: 67 additions & 62 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" ) ),
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);
setViewWidth(EffectView::DEFAULT_WIDTH);

// Disable effects that are of type "DummyEffect"
m_mainLayout = new QHBoxLayout();
m_mainLayout->setContentsMargins(8, 2, 8, 2);

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 );

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()));
}
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 );
setModel(_model);

if( effect()->controls()->controlCount() > 0 )
if(hasControls)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(hasControls)
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)
{
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, m_viewWidth - 4, EffectView::DEFAULT_HEIGHT - 4), 2, 2);

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,15 @@ 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 );
}




void EffectView::setViewWidth(int px)
{
m_viewWidth = px;
setFixedSize(m_viewWidth, EffectView::DEFAULT_HEIGHT);
}

} // namespace lmms::gui
Loading