MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / OnDraw

Method OnDraw

ui/UIButton.cpp:223–254  ·  view source on GitHub ↗

behavior when gadget is being drawn.

Source from the content-addressed store, hash-verified

221
222// behavior when gadget is being drawn.
223void UIButton::OnDraw() {
224 // do state based drawing
225 // determine colors here.
226 if (IsDisabled())
227 m_State = UI_BTS_DISABLED;
228
229 switch (m_State) {
230 case UI_BTS_ACTIVATED:
231 case UI_BTS_HILITE:
232 ui_DrawLTBox(GR_BLACK, GR_LIGHTGRAY, 0, 0, m_W, m_H);
233 break;
234
235 case UI_BTS_INACTIVE:
236 ui_DrawLTBox(GR_LIGHTGRAY, GR_BLACK, 0, 0, m_W, m_H);
237 break;
238
239 case UI_BTS_DISABLED:
240 ui_DrawLTBox(GR_DARKGRAY, GR_DARKGRAY, 0, 0, m_W, m_H);
241 break;
242
243 default:
244 Int3();
245 }
246
247 ui_DrawRect(m_Colors[m_State], 1, 1, m_W - 1, m_H - 1);
248
249 if (m_Items[m_State]) {
250 int x = (m_W / 2 - m_Items[m_State]->width() / 2);
251 int y = (m_H / 2 - m_Items[m_State]->height() / 2);
252 m_Items[m_State]->draw(x, y, IsDisabled() ? uiDrawFaded : uiDrawNormal);
253 }
254}
255
256// behavior when key is pressed.
257void UIButton::OnKeyDown(int key) {}

Callers

nothing calls this directly

Calls 9

ui_DrawLTBoxFunction · 0.85
ui_DrawRectFunction · 0.85
ui_GetTextWidthFunction · 0.85
ui_DrawSetTextTypeFunction · 0.85
widthMethod · 0.45
heightMethod · 0.45
drawMethod · 0.45
get_colorMethod · 0.45
get_alphaMethod · 0.45

Tested by

no test coverage detected