MCPcopy Create free account
hub / github.com/axmolengine/axmol / createMediaControlTexture

Function createMediaControlTexture

core/ui/UIMediaPlayer.cpp:207–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205std::map<MediaControlButtonId, Rect> g_mediaControlTextureRegions;
206
207void createMediaControlTexture()
208{
209 if (g_mediaControlsTexture)
210 return;
211
212 constexpr auto panelW = 64.f;
213 constexpr auto panelH = 64.f;
214 constexpr auto iconW = 32.f;
215 constexpr auto iconH = 32.f;
216 constexpr auto gap = 10.f;
217 constexpr auto border = 2;
218
219 auto* drawNode = DrawNode::create();
220
221 auto DrawStop = [&](const Vec2& middle) -> void {
222 auto s = Vec2(middle.x - iconW / 2.f, middle.y + iconH / 2.f);
223 drawNode->drawSolidRect(s, s + Vec2(iconW, -iconH), Color4F::WHITE);
224 };
225
226 auto DrawPlay = [&](const Vec2& middle) -> void {
227 auto p1 = Vec2(middle.x - iconW / 2.f, middle.y + iconH / 2.f);
228 auto p2 = Vec2(middle.x + iconW / 2.f, middle.y);
229 auto p3 = Vec2(middle.x - iconW / 2.f, middle.y - iconH / 2.f);
230
231 drawNode->drawTriangle(p1, p2, p3, Color4F::WHITE);
232 };
233
234 auto DrawPause = [&](const Vec2& middle) -> void {
235 auto start = Vec2(middle.x - 3, middle.y + iconH / 2.f);
236 drawNode->drawSolidRect(start, start + Vec2(-6, -iconH), Color4F::WHITE);
237
238 start = Vec2(middle.x + 3, middle.y + iconH / 2.f);
239 drawNode->drawSolidRect(start, start + Vec2(6, -iconH), Color4F::WHITE);
240 };
241
242 auto DrawEnterFullscreen = [&](const Vec2& middle) -> void {
243 auto topLeft = Vec2(middle.x - panelW / 2.f + 6, middle.y + panelH / 2.f - 6);
244 auto topRight = Vec2(middle.x + panelW / 2.f - 6, middle.y + panelH / 2.f - 6);
245 auto bottomLeft = Vec2(middle.x - panelW / 2.f + 6, middle.y - panelH / 2.f + 6);
246 auto bottomRight = Vec2(middle.x + panelW / 2.f - 6, middle.y - panelH / 2.f + 6);
247
248 // Top left
249 drawNode->drawSolidRect(topLeft, topLeft + Vec2(20, -6), Color4F::WHITE);
250 drawNode->drawSolidRect(topLeft, topLeft + Vec2(6, -20), Color4F::WHITE);
251
252 // Top right
253 drawNode->drawSolidRect(topRight, topRight + Vec2(-20, -6), Color4F::WHITE);
254 drawNode->drawSolidRect(topRight, topRight + Vec2(-6, -20), Color4F::WHITE);
255
256 // Bottom left
257 drawNode->drawSolidRect(bottomLeft, bottomLeft + Vec2(20, 6), Color4F::WHITE);
258 drawNode->drawSolidRect(bottomLeft, bottomLeft + Vec2(6, 20), Color4F::WHITE);
259
260 // Bottom right
261 drawNode->drawSolidRect(bottomRight, bottomRight + Vec2(-20, 6), Color4F::WHITE);
262 drawNode->drawSolidRect(bottomRight, bottomRight + Vec2(-6, 20), Color4F::WHITE);
263 };
264

Callers 1

createControlsMethod · 0.85

Calls 15

createFunction · 0.85
nextPOTFunction · 0.85
getInstanceFunction · 0.85
drawSolidRectMethod · 0.80
drawSolidCircleMethod · 0.80
beginWithClearMethod · 0.80
secondMethod · 0.80
getRendererMethod · 0.80
Vec2Function · 0.50
SizeFunction · 0.50
RectFunction · 0.50
drawTriangleMethod · 0.45

Tested by

no test coverage detected