Skip to content

Commit

Permalink
Extract drawing of info text into method
Browse files Browse the repository at this point in the history
Extract the drawing of the info text into its own private method `drawInfoText`.
  • Loading branch information
michaelgregorius committed Apr 12, 2024
1 parent 1027bc7 commit 49868d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/LfoGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class LfoGraph : public QWidget, public ModelView
void paintEvent(QPaintEvent* pe) override;

private:
void drawInfoText(const EnvelopeAndLfoParameters&);
void toggleAmountModel();

private:
Expand Down
11 changes: 10 additions & 1 deletion src/gui/instrument/LfoGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ void LfoGraph::paintEvent(QPaintEvent*)

p.drawPolyline(polyLine);

// Draw the info text
drawInfoText(*params);
}

void LfoGraph::drawInfoText(const EnvelopeAndLfoParameters& params)
{
QPainter p(this);

const float lfoSpeed = params.getLfoSpeedModel().value();
const bool x100 = params.getX100Model().value();

const float hertz = 1. / (SECS_PER_LFO_OSCILLATION * lfoSpeed) * (x100 ? 100. : 1.);
const auto infoText = tr("%1 Hz").arg(hertz, 0, 'f', 3);

Expand Down

0 comments on commit 49868d4

Please sign in to comment.