MCPcopy Create free account
hub / github.com/TheWaveWarden/odin2 / paint

Method paint

Source/gui/ModAmountComponentExtended.cpp:35–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void ModAmountComponentExtended::paint(Graphics &g) {
36
37 SET_INTERPOLATION_QUALITY(g)
38
39 auto bounds = getLocalBounds().toFloat();
40 const auto corner = float(getHeight()) * 0.1f;
41
42 const auto scaleCompensation = float(ConfigFileManager::getInstance().getOptionGuiScale()) / float(GuiScale::Z200);
43 juce::BorderSize<float> border_size(3.0f * scaleCompensation, 3.0f * scaleCompensation, 1.0f * scaleCompensation, 2.0f * scaleCompensation);
44 border_size.subtractFrom(bounds);
45
46 if (m_value > 0 && m_value <= 1) {
47 g.setColour(m_cols_pos[0].withAlpha(0.3f));
48 bounds = bounds.removeFromLeft(bounds.proportionOfWidth(m_value));
49 g.fillRoundedRectangle(bounds, corner);
50 } else if (m_value > 1 && m_value <= 2) {
51 g.setColour(m_cols_pos[0].withAlpha(0.3f));
52 const auto bounds2 = bounds.removeFromLeft(bounds.proportionOfWidth(m_value - 1.0f));
53 g.fillRoundedRectangle(bounds, corner);
54
55 g.setColour(m_cols_pos[1].withAlpha(0.3f));
56 g.fillRoundedRectangle(bounds2, corner);
57 } else if (m_value > 2 && m_value <= 3) {
58 g.setColour(m_cols_pos[1].withAlpha(0.3f));
59 const auto bounds2 = bounds.removeFromLeft(bounds.proportionOfWidth(m_value - 2.0f));
60 g.fillRoundedRectangle(bounds, corner);
61
62 g.setColour(m_cols_pos[2].withAlpha(0.3f));
63 g.fillRoundedRectangle(bounds2, corner);
64 }
65
66 else if (m_value < 0 && m_value >= -1) {
67 g.setColour(m_cols_neg[0].withAlpha(0.3f));
68 bounds = bounds.removeFromRight(bounds.proportionOfWidth(-m_value));
69 g.fillRoundedRectangle(bounds, corner);
70 } else if (m_value < -1 && m_value >= -2) {
71 g.setColour(m_cols_neg[1].withAlpha(0.3f));
72 const auto bounds2 = bounds.removeFromLeft(bounds.proportionOfWidth(2.0f + m_value));
73 g.fillRoundedRectangle(bounds, corner);
74 g.setColour(m_cols_neg[0].withAlpha(0.3f));
75 g.fillRoundedRectangle(bounds2, corner);
76 } else if (m_value < -2 && m_value >= -3) {
77 g.setColour(m_cols_neg[2].withAlpha(0.3f));
78 const auto bounds2 = bounds.removeFromLeft(bounds.proportionOfWidth(3.0f + m_value));
79 g.fillRoundedRectangle(bounds, corner);
80
81 g.setColour(m_cols_neg[1].withAlpha(0.3f));
82 g.fillRoundedRectangle(bounds2, corner);
83 }
84
85 g.setFont(Helpers::getAldrichFont(H / 1.8f));
86 g.setColour(COL_TEXT_BLUE);
87 g.drawText(juce::String(juce::roundToInt(m_value * 100.0f)), getLocalBounds(), Justification::centred, true);
88}

Callers

nothing calls this directly

Calls 1

getOptionGuiScaleMethod · 0.80

Tested by

no test coverage detected