Skip to content

Commit

Permalink
Move inner border size and outer border size into paintEvent function
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Nov 1, 2024
1 parent 3a6f1f3 commit 6b556fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 0 additions & 3 deletions include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class MixerChannelView : public QWidget
Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive)
Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive)
public:
static constexpr auto InnerBorderSize = 3;
static constexpr auto OuterBorderSize = 1;

MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex);
void paintEvent(QPaintEvent* event) override;
void contextMenuEvent(QContextMenuEvent*) override;
Expand Down
7 changes: 5 additions & 2 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ void MixerChannelView::contextMenuEvent(QContextMenuEvent*)

void MixerChannelView::paintEvent(QPaintEvent*)
{
static constexpr auto innerBorderSize = 3;
static constexpr auto outerBorderSize = 1;

const auto channel = mixerChannel();
const auto isActive = m_mixerView->currentMixerChannel() == this;
const auto width = rect().width();
Expand All @@ -202,11 +205,11 @@ void MixerChannelView::paintEvent(QPaintEvent*)

// inner border
painter.setPen(isActive ? strokeInnerActive() : strokeInnerInactive());
painter.drawRect(1, 1, width - InnerBorderSize, height - InnerBorderSize);
painter.drawRect(1, 1, width - innerBorderSize, height - innerBorderSize);

// outer border
painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive());
painter.drawRect(0, 0, width - OuterBorderSize, height - OuterBorderSize);
painter.drawRect(0, 0, width - outerBorderSize, height - outerBorderSize);
}

void MixerChannelView::mousePressEvent(QMouseEvent*)
Expand Down

0 comments on commit 6b556fa

Please sign in to comment.