diff --git a/data/themes/classic/effect_plugin.png b/data/themes/classic/effect_plugin.png deleted file mode 100644 index 6a759672ff5..00000000000 Binary files a/data/themes/classic/effect_plugin.png and /dev/null differ diff --git a/data/themes/default/effect_plugin.png b/data/themes/default/effect_plugin.png deleted file mode 100644 index 4c312037984..00000000000 Binary files a/data/themes/default/effect_plugin.png and /dev/null differ diff --git a/include/Effect.h b/include/Effect.h index 7eb911701a0..f081731ca1f 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -124,12 +124,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; @@ -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; diff --git a/include/EffectLabelButton.h b/include/EffectLabelButton.h new file mode 100644 index 00000000000..0bd076eaf74 --- /dev/null +++ b/include/EffectLabelButton.h @@ -0,0 +1,49 @@ +/* + * EffectLabelButton.h - class trackLabelButton + * + * Copyright (c) 2024 Noah Brecht + * + * 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 + +namespace lmms::gui +{ + +class EffectView; + +class EffectLabelButton : public QPushButton +{ + 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 diff --git a/include/EffectView.h b/include/EffectView.h index 805e4a4279c..b964bbd018c 100644 --- a/include/EffectView.h +++ b/include/EffectView.h @@ -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 { @@ -43,6 +45,7 @@ class EffectControlDialog; class Knob; class LedCheckBox; class TempoSyncKnob; +class EffectLabelButton; class EffectView : public PluginView @@ -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; void mouseMoveEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override; @@ -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; - } ; diff --git a/src/core/Effect.cpp b/src/core/Effect.cpp index 1fb0b71b5c1..7b11494d0a0 100644 --- a/src/core/Effect.cpp +++ b/src/core/Effect.cpp @@ -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 ) { @@ -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 ); } @@ -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() ) @@ -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() ) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 4195ec58c1a..d4a5a4446b9 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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 diff --git a/src/gui/EffectView.cpp b/src/gui/EffectView.cpp index a5095ee6d13..9129d7dee29 100644 --- a/src/gui/EffectView.cpp +++ b/src/gui/EffectView.cpp @@ -28,10 +28,16 @@ #include #include #include +#include +#include +#include +#include +#include "Effect.h" #include "EffectView.h" #include "DummyEffect.h" #include "CaptionMenu.h" +#include "EffectLabelButton.h" #include "embed.h" #include "GuiApplication.h" #include "FontHelper.h" @@ -45,62 +51,57 @@ 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); + + 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( 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); - - 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) { - 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 ); @@ -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); } @@ -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); } } } @@ -191,6 +193,7 @@ void EffectView::closeEffects() m_subWindow->hide(); } effect()->controls()->setViewVisible( false ); + m_label->setChecked(false); } @@ -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); } @@ -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 diff --git a/src/gui/widgets/EffectLabelButton.cpp b/src/gui/widgets/EffectLabelButton.cpp new file mode 100644 index 00000000000..63ee2a80a36 --- /dev/null +++ b/src/gui/widgets/EffectLabelButton.cpp @@ -0,0 +1,53 @@ +/* + * EffectLabelButton.cpp - implementation of class trackLabelButton, a label + * which is renamable by double-clicking it + * + * Copyright (c) 2024 Noah Brecht + * + * 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. + * + */ + + +#include "EffectLabelButton.h" + +#include +#include + +#include "ConfigManager.h" +#include "embed.h" +#include "EffectView.h" +#include "Effect.h" + +namespace lmms::gui +{ + +EffectLabelButton::EffectLabelButton(EffectView* _tv, QWidget* _parent) : + QPushButton(_parent), + m_effectView(_tv) +{ + setAttribute(Qt::WA_OpaquePaintEvent, true); + setAcceptDrops(false); + + setCursor(QCursor(embed::getIconPixmap("hand"), 3, 3)); + setStyleSheet("text-align:left;padding:2px;"); + setCheckable(true); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); +} + +} // namespace lmms::gui