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

Tidy up MixerChannelView #7431

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
214 changes: 107 additions & 107 deletions include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@
*
*/

#ifndef MIXER_CHANNEL_VIEW_H
#define MIXER_CHANNEL_VIEW_H
#ifndef LMMS_MIXER_CHANNEL_VIEW_H
#define LMMS_MIXER_CHANNEL_VIEW_H
messmerd marked this conversation as resolved.
Show resolved Hide resolved

#include <QGraphicsView>
#include <QLabel>
#include <QLineEdit>
#include <QPixmap>
#include <QWidget>

#include "EffectRackView.h"
#include "Fader.h"
Expand All @@ -32,113 +38,107 @@
#include "PixmapButton.h"
#include "SendButtonIndicator.h"

#include <QGraphicsView>
#include <QLabel>
#include <QLineEdit>
#include <QPixmap>
#include <QWidget>

namespace lmms
{
class MixerChannel;
namespace lmms {
class MixerChannel;
}

namespace lmms::gui
namespace lmms::gui {
Rossmaxx marked this conversation as resolved.
Show resolved Hide resolved
class PeakIndicator;

constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3;
constexpr int MIXER_CHANNEL_OUTER_BORDER_SIZE = 1;

class MixerChannelView : public QWidget
{
class PeakIndicator;

constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3;
constexpr int MIXER_CHANNEL_OUTER_BORDER_SIZE = 1;

class MixerChannelView : public QWidget
{
Q_OBJECT
Q_PROPERTY(QBrush backgroundActive READ backgroundActive WRITE setBackgroundActive)
Q_PROPERTY(QColor strokeOuterActive READ strokeOuterActive WRITE setStrokeOuterActive)
Q_PROPERTY(QColor strokeOuterInactive READ strokeOuterInactive WRITE setStrokeOuterInactive)
Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive)
Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive)
public:
enum class SendReceiveState
{
None, SendToThis, ReceiveFromThis
};

MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex);
void paintEvent(QPaintEvent* event) override;
void contextMenuEvent(QContextMenuEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
bool eventFilter(QObject* dist, QEvent* event) override;

int channelIndex() const;
void setChannelIndex(int index);

SendReceiveState sendReceiveState() const;
void setSendReceiveState(const SendReceiveState& state);

QBrush backgroundActive() const;
void setBackgroundActive(const QBrush& c);

QColor strokeOuterActive() const;
void setStrokeOuterActive(const QColor& c);

QColor strokeOuterInactive() const;
void setStrokeOuterInactive(const QColor& c);

QColor strokeInnerActive() const;
void setStrokeInnerActive(const QColor& c);

QColor strokeInnerInactive() const;
void setStrokeInnerInactive(const QColor& c);

void reset();

public slots:
void renameChannel();
void resetColor();
void selectColor();
void randomizeColor();

private slots:
void renameFinished();
void removeChannel();
void removeUnusedChannels();
void moveChannelLeft();
void moveChannelRight();

private:
bool confirmRemoval(int index);
QString elideName(const QString& name);
MixerChannel* mixerChannel() const;
auto isMasterChannel() const -> bool { return m_channelIndex == 0; }

private:
SendButtonIndicator* m_sendButton;
Knob* m_sendKnob;
LcdWidget* m_channelNumberLcd;
QLineEdit* m_renameLineEdit;
QGraphicsView* m_renameLineEditView;
QLabel* m_sendArrow;
QLabel* m_receiveArrow;
PixmapButton* m_muteButton;
PixmapButton* m_soloButton;
PeakIndicator* m_peakIndicator = nullptr;
Fader* m_fader;
EffectRackView* m_effectRackView;
MixerView* m_mixerView;
SendReceiveState m_sendReceiveState = SendReceiveState::None;
int m_channelIndex = 0;
bool m_inRename = false;

QBrush m_backgroundActive;
QColor m_strokeOuterActive;
QColor m_strokeOuterInactive;
QColor m_strokeInnerActive;
QColor m_strokeInnerInactive;

friend class MixerView;
};
Q_OBJECT
Q_PROPERTY(QBrush backgroundActive READ backgroundActive WRITE setBackgroundActive)
Q_PROPERTY(QColor strokeOuterActive READ strokeOuterActive WRITE setStrokeOuterActive)
Q_PROPERTY(QColor strokeOuterInactive READ strokeOuterInactive WRITE setStrokeOuterInactive)
Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive)
Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive)
public:
enum class SendReceiveState
{
None,
SendToThis,
ReceiveFromThis
};

MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex);
void paintEvent(QPaintEvent* event) override;
void contextMenuEvent(QContextMenuEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
bool eventFilter(QObject* dist, QEvent* event) override;

int channelIndex() const;
void setChannelIndex(int index);

SendReceiveState sendReceiveState() const;
void setSendReceiveState(const SendReceiveState& state);

QBrush backgroundActive() const;
void setBackgroundActive(const QBrush& c);

QColor strokeOuterActive() const;
void setStrokeOuterActive(const QColor& c);

QColor strokeOuterInactive() const;
void setStrokeOuterInactive(const QColor& c);

QColor strokeInnerActive() const;
void setStrokeInnerActive(const QColor& c);

QColor strokeInnerInactive() const;
void setStrokeInnerInactive(const QColor& c);

void reset();

public slots:
void renameChannel();
void resetColor();
void selectColor();
void randomizeColor();

private slots:
void renameFinished();
void removeChannel();
void removeUnusedChannels();
void moveChannelLeft();
void moveChannelRight();

private:
bool confirmRemoval(int index);
QString elideName(const QString& name);
MixerChannel* mixerChannel() const;
auto isMasterChannel() const -> bool { return m_channelIndex == 0; }

private:
SendButtonIndicator* m_sendButton;
Knob* m_sendKnob;
LcdWidget* m_channelNumberLcd;
QLineEdit* m_renameLineEdit;
QGraphicsView* m_renameLineEditView;
QLabel* m_sendArrow;
QLabel* m_receiveArrow;
PixmapButton* m_muteButton;
PixmapButton* m_soloButton;
PeakIndicator* m_peakIndicator = nullptr;
Fader* m_fader;
EffectRackView* m_effectRackView;
MixerView* m_mixerView;
SendReceiveState m_sendReceiveState = SendReceiveState::None;
int m_channelIndex = 0;
bool m_inRename = false;

QBrush m_backgroundActive;
QColor m_strokeOuterActive;
QColor m_strokeOuterInactive;
QColor m_strokeInnerActive;
QColor m_strokeInnerInactive;

friend class MixerView;
};
} // namespace lmms::gui

#endif
#endif // LMMS_MIXER_CHANNEL_VIEW_H
Loading
Loading