-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Effects UI rewrite #7438
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
base: master
Are you sure you want to change the base?
Effects UI rewrite #7438
Changes from 15 commits
34daf03
124a894
9d01945
efd8cfe
eaf94e4
889818a
5b3ce79
af9ed03
34a48d8
7f541f5
5127544
89cb23f
809a152
e6aa0ea
b09286e
a7d7597
f059a2b
082e068
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have just noticed that this class inherits from |
||
| { | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 "gui_templates.h" | ||||||
|
|
@@ -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) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| { | ||||||
| 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 ) | ||||||
| { | ||||||
| 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(), 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(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 | ||||||
Uh oh!
There was an error while loading. Please reload this page.