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

Method Render

Source/TextEntry.cpp:105–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void TextEntry::Render()
106{
107 ofPushStyle();
108
109 ofSetLineWidth(.5f);
110
111 float xOffset = 0;
112 if (mDrawLabel)
113 {
114 DrawTextNormal(Name(), mX, mY + 12);
115 xOffset = mLabelSize;
116 }
117
118 bool isCurrent = IKeyboardFocusListener::GetActiveKeyboardFocus() == this;
119
120 ofColor color(255, 255, 255);
121 if (!isCurrent && mInErrorMode)
122 color.set(200, 100, 100);
123
124 if (!isCurrent)
125 UpdateDisplayString();
126
127 float w, h;
128 GetDimensions(w, h);
129 if (isCurrent)
130 {
131 ofSetColor(color, gModuleDrawAlpha * .1f);
132 ofFill();
133 ofRect(mX + xOffset, mY, w - xOffset, h);
134 }
135 ofSetColor(color, gModuleDrawAlpha);
136 ofNoFill();
137 ofRect(mX + xOffset, mY, w - xOffset, h);
138
139 gFontFixedWidth.DrawString(mString, 12, mX + 2 + xOffset, mY + 12);
140
141 if (IKeyboardFocusListener::GetActiveKeyboardFocus() == this)
142 {
143 if (mCaretBlink)
144 {
145 int caretX = mX + 2 + xOffset;
146 int caretY = mY + 1;
147 if (mCaretPosition > 0)
148 {
149 char beforeCaret[MAX_TEXTENTRY_LENGTH];
150 strncpy(beforeCaret, mString, mCaretPosition);
151 beforeCaret[mCaretPosition] = 0;
152 caretX += gFontFixedWidth.GetStringWidth(beforeCaret, 12);
153 }
154 ofFill();
155 ofRect(caretX, caretY, 1, 12, L(corner, 1));
156 }
157 mCaretBlinkTimer += ofGetLastFrameTime();
158 if (mCaretBlinkTimer > .3f)
159 {
160 mCaretBlinkTimer -= .3f;
161 mCaretBlink = !mCaretBlink;
162 }

Callers

nothing calls this directly

Calls 12

ofPushStyleFunction · 0.85
ofSetLineWidthFunction · 0.85
DrawTextNormalFunction · 0.85
ofSetColorFunction · 0.85
ofFillFunction · 0.85
ofRectFunction · 0.85
ofNoFillFunction · 0.85
ofGetLastFrameTimeFunction · 0.85
ofPopStyleFunction · 0.85
DrawStringMethod · 0.80
GetStringWidthMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected