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 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Binary file removed data/themes/classic/effect_plugin.png
Binary file not shown.
Binary file removed data/themes/default/effect_plugin.png
Binary file not shown.
7 changes: 0 additions & 7 deletions include/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,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 @@ -249,7 +243,6 @@ class LMMS_EXPORT Effect : public Plugin

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

bool m_autoQuitDisabled;
Expand Down
49 changes: 49 additions & 0 deletions include/EffectLabelButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* EffectLabelButton.h - class trackLabelButton
*
* Copyright (c) 2024 Noah Brecht <noahb2713/at/gmail/dot/com>
*
* 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;

private:
EffectView* m_effectView;
};


} // namespace lmms::gui

#endif // LMMS_GUI_EFFECT_LABEL_BUTTON_H
20 changes: 11 additions & 9 deletions include/EffectView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
#ifndef LMMS_GUI_EFFECT_VIEW_H
#define LMMS_GUI_EFFECT_VIEW_H

#include "AutomatableModel.h"
#include "PluginView.h"
#include "Effect.h"

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

namespace lmms
{
class Effect;
}

namespace lmms::gui
{
Expand All @@ -43,6 +45,7 @@ class EffectControlDialog;
class Knob;
class LedCheckBox;
class TempoSyncKnob;
class EffectLabelButton;


class EffectView : public PluginView
Expand All @@ -62,7 +65,7 @@ class EffectView : public PluginView
}

static constexpr int DEFAULT_WIDTH = 215;
static constexpr int DEFAULT_HEIGHT = 60;
static constexpr int DEFAULT_HEIGHT = 47;
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved

void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
Expand All @@ -88,17 +91,16 @@ 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;

} ;


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 @@ -190,7 +187,7 @@ void Effect::checkGate(double outSum)

// Check whether we need to continue processing input. Restart the
// counter if the threshold has been exceeded.
if (outSum - gate() <= F_EPSILON)
if (outSum <= 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
102 changes: 50 additions & 52 deletions src/gui/EffectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@
#include <QMouseEvent>
#include <QPushButton>
#include <QPainter>
#include <QPainterPath>
#include <QBoxLayout>
#include <QLabel>
#include <QToolButton>

#include "Effect.h"
#include "EffectView.h"
#include "DummyEffect.h"
#include "CaptionMenu.h"
#include "EffectLabelButton.h"
#include "embed.h"
#include "GuiApplication.h"
#include "FontHelper.h"
Expand All @@ -45,62 +51,57 @@
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, 0, 8, 0);

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


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:" ), "" );

QFont labelFont = adjustedToPixelSize(font(), 10);
m_label = new EffectLabelButton(this, this);
m_label->setText(model()->displayName());
if(hasControls)
{
connect(m_label, &EffectLabelButton::clicked, this, &EffectView::editControls);
}
m_mainLayout->addWidget(m_label);

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

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_autoQuit->setLabel("STOP");
m_autoQuit->setFont(labelFont);
m_mainLayout->addWidget(m_autoQuit);

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, DEFAULT_FONT_SIZE));
ctls_btn->setGeometry( 150, 14, 50, 20 );
connect( ctls_btn, SIGNAL(clicked()),
this, SLOT(editControls()));

m_controlView = effect()->controls()->createView();
if( m_controlView )
{
m_subWindow = getGUI()->mainWindow()->addWindowedWidget( m_controlView );

if ( !m_controlView->isResizable() )
{
m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
Expand All @@ -125,8 +126,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 @@ -149,11 +149,13 @@ void EffectView::editControls()
m_subWindow->show();
m_subWindow->raise();
effect()->controls()->setViewVisible( true );
m_label->setChecked(true);
}
else
{
m_subWindow->hide();
effect()->controls()->setViewVisible( false );
m_label->setChecked(false);
}
}
}
Expand Down Expand Up @@ -191,6 +193,7 @@ void EffectView::closeEffects()
m_subWindow->hide();
}
effect()->controls()->setViewVisible( false );
m_label->setChecked(false);
}


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

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

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

QString elidedText = p.fontMetrics().elidedText( model()->displayName(), Qt::ElideRight, width() - 22 );
path.addRoundedRect(rect().marginsRemoved(QMargins(2, 2, 2, 2)), 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 +277,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