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

Method OnDraw

ui/UIGroup.cpp:81–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void UIGroup::OnDraw() {
82 ui_DrawSetAlpha(255);
83
84 int text_height = 0;
85 int text_width = 0;
86
87 if (m_Label) {
88 text_height = ui_GetTextHeight("X") / 2;
89 text_width = ui_GetTextWidth(m_Label);
90 }
91
92 ui_DrawLine(m_BoxColor, 0, text_height, 0, m_H - 1); // left side
93 ui_DrawLine(m_BoxColor, 0, m_H - 1, m_W - 1, m_H - 1); // bottom
94 ui_DrawLine(m_BoxColor, m_W - 1, m_H - 1, m_W - 1, text_height); // right side
95
96 int top_edge_length = 0;
97
98 top_edge_length = (m_W - text_width) / 2;
99 if (m_Label)
100 top_edge_length -= 3;
101
102 if (top_edge_length < 0)
103 top_edge_length = 0;
104
105 ui_DrawLine(m_BoxColor, 0, text_height, top_edge_length, text_height);
106 ui_DrawLine(m_BoxColor, m_W, text_height, m_W - top_edge_length, text_height);
107
108 if (!m_bTextCreated) {
109 m_bTextCreated = true;
110 UITextItem item{(m_Label) ? m_Label : "", m_LabelColor};
111 m_tLabel.Create(m_Wnd, &item, m_X + top_edge_length + 3, m_Y);
112 }
113}
114
115void UIGroup::OnDestroy() {
116 if (m_Label)

Callers

nothing calls this directly

Calls 5

ui_DrawSetAlphaFunction · 0.85
ui_GetTextHeightFunction · 0.85
ui_GetTextWidthFunction · 0.85
ui_DrawLineFunction · 0.85
CreateMethod · 0.45

Tested by

no test coverage detected