MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Render

Method Render

Source/ClickButton.cpp:72–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void ClickButton::Render()
73{
74 ofPushStyle();
75
76 float w, h;
77 GetDimensions(w, h);
78
79 ofColor color, textColor;
80 IUIControl::GetColors(color, textColor);
81
82 ofFill();
83 ofSetColor(0, 0, 0, gModuleDrawAlpha * .5f);
84 ofRect(mX + 1, mY + 1, w, h);
85 DrawBeacon(mX + w / 2, mY + h / 2);
86 float press = ofClamp((1 - (gTime - mClickTime) / 200), 0, 1);
87 color.r = ofLerp(color.r, 0, press);
88 color.g = ofLerp(color.g, 0, press);
89 color.b = ofLerp(color.b, 0, press);
90 ofSetColor(color);
91 ofRect(mX, mY, w, h);
92
93 if (mDisplayStyle == ButtonDisplayStyle::kText)
94 {
95 ofSetColor(textColor);
96 DrawTextNormal(GetDisplayName(), mX + 2, mY + 12);
97 }
98 else if (mDisplayStyle == ButtonDisplayStyle::kPlay)
99 {
100 ofSetColor(textColor);
101 ofFill();
102 ofTriangle(mX + 5, mY + 2, mX + 5, mY + 12, mX + 15, mY + 7);
103 }
104 else if (mDisplayStyle == ButtonDisplayStyle::kPause)
105 {
106 ofSetColor(textColor);
107 ofFill();
108 ofRect(mX + 5, mY + 2, 4, 10, 0);
109 ofRect(mX + 11, mY + 2, 4, 10, 0);
110 }
111 else if (mDisplayStyle == ButtonDisplayStyle::kStop)
112 {
113 ofSetColor(textColor);
114 ofFill();
115 ofRect(mX + 5, mY + 2, 10, 10, 0);
116 }
117 else if (mDisplayStyle == ButtonDisplayStyle::kGrabSample)
118 {
119 ofSetColor(textColor);
120 for (int i = 0; i < 5; ++i)
121 {
122 float height = (i % 2 == 0) ? 6 : 10;
123 float x = mX + 4 + i * 3;
124 ofLine(x, mY + 7 - height / 2, x, mY + 7 + height / 2);
125 }
126 }
127 else if (mDisplayStyle == ButtonDisplayStyle::kSampleIcon)
128 {
129 ofSetColor(textColor);

Callers

nothing calls this directly

Calls 11

ofPushStyleFunction · 0.85
ofFillFunction · 0.85
ofSetColorFunction · 0.85
ofRectFunction · 0.85
ofClampFunction · 0.85
ofLerpFunction · 0.85
DrawTextNormalFunction · 0.85
ofTriangleFunction · 0.85
ofLineFunction · 0.85
ofSetLineWidthFunction · 0.85
ofPopStyleFunction · 0.85

Tested by

no test coverage detected