MCPcopy Create free account
hub / github.com/StrangeLoopsAudio/gRainbow / paint

Method paint

Source/Components/ArcSpectrogram.cpp:70–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void ArcSpectrogram::paint(juce::Graphics& g) {
71 // Set gradient
72 g.setColour(Utils::Colour::BACKGROUND);
73 g.fillAll();
74
75 // Panel outline
76 g.setColour(Utils::Colour::PANEL.darker(0.2f));
77 g.fillRoundedRectangle(getLocalBounds().toFloat(), 10);
78
79 // If nothing has been loaded skip image, progress bar will fill in void space
80 if (mParameters.ui.specComplete) {
81 int imageIndex = mSpecType.getSelectedId() - 1;
82 // When loading up a plugin a second time, need to set the ComboBox state,
83 // but can't in the constructor so there is the first spot we can enforce
84 // it. Without this, the logo will appear when reopening the plugin
85 if (imageIndex == -1) {
86 mSpecType.setSelectedId(mParameters.ui.specType + 1, juce::dontSendNotification);
87 imageIndex = (int)mParameters.ui.specType;
88 }
89 g.drawImage(mParameters.ui.specImages[imageIndex], mRainbowRect.toFloat(),
90 juce::RectanglePlacement(juce::RectanglePlacement::fillDestination), false);
91 }
92
93 mSpecType.setVisible(mParameters.ui.specComplete);
94
95 // Note and Candidate can be null while loading new values
96 if (!mParameters.ui.specComplete) return;
97
98 // Draw border arcs under clouds
99 ParamNote* note = nullptr;
100 int genIdx = -1; // Currently selected generator. If >= 0, darken generator's line
101 switch (mParameters.getSelectedParams()->type) {
102 case ParamType::NOTE: note = dynamic_cast<ParamNote*>(mParameters.getSelectedParams()); break;
103 case ParamType::GENERATOR: {
104 auto gen = dynamic_cast<ParamGenerator*>(mParameters.getSelectedParams());
105 note = mParameters.note.notes[gen->noteIdx].get();
106 genIdx = gen->genIdx;
107 }
108 case ParamType::GLOBAL: break; // Do nothing, leave note as nullptr
109 default: break; // do nothing
110 }
111
112 // Draw clouds
113 g.drawImage(mCloudLeft.getImage(), mCloudLeft.rect, juce::RectanglePlacement::fillDestination);
114 g.drawImage(mCloudRight.getImage(), mCloudRight.rect, juce::RectanglePlacement::fillDestination);
115
116 // Draw position lines from active note
117 if (note != nullptr) {
118 float startRadians = (1.5f * juce::MathConstants<float>::pi);
119
120 juce::Colour noteColour = mParameters.getSelectedParamColour();
121 // Draw generator position lines
122 for (int i = 0; i < NUM_GENERATORS; ++i) {
123 if (genIdx > -1 && genIdx != i) continue;
124 ParamCandidate* candidate = note->getCandidate(i);
125 if (candidate) {
126 // Draw position line where the gen's candidate is
127 float endRadians = startRadians + candidate->posRatio * juce::MathConstants<float>::pi;

Callers

nothing calls this directly

Calls 3

getSelectedParamsMethod · 0.80
getCandidateMethod · 0.80

Tested by

no test coverage detected