MCPcopy Create free account
hub / github.com/defold/defold / ComputeSafeAreaAdjust

Function ComputeSafeAreaAdjust

engine/gui/src/gui.cpp:336–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334 }
335
336 static void ComputeSafeAreaAdjust(SafeAreaMode mode, uint32_t window_width, uint32_t window_height,
337 int32_t inset_left, int32_t inset_top, int32_t inset_right, int32_t inset_bottom,
338 uint32_t* out_width, uint32_t* out_height, float* out_offset_x, float* out_offset_y)
339 {
340 if (mode == SAFE_AREA_LONG || mode == SAFE_AREA_SHORT)
341 {
342 const bool landscape = window_width >= window_height;
343 const bool apply_long = mode == SAFE_AREA_LONG;
344 const bool apply_lr = landscape ? apply_long : !apply_long;
345
346 if (apply_lr)
347 {
348 inset_top = 0;
349 inset_bottom = 0;
350 }
351 else
352 {
353 inset_left = 0;
354 inset_right = 0;
355 }
356 }
357 else if (mode != SAFE_AREA_BOTH)
358 {
359 inset_left = 0;
360 inset_top = 0;
361 inset_right = 0;
362 inset_bottom = 0;
363 }
364
365 *out_width = (uint32_t) dmMath::Max(0, (int32_t)window_width - inset_left - inset_right);
366 *out_height = (uint32_t) dmMath::Max(0, (int32_t)window_height - inset_top - inset_bottom);
367 *out_offset_x = (float) inset_left;
368 *out_offset_y = (float) inset_bottom;
369 }
370
371 void SetSafeAreaAdjust(HContext context, bool enabled, uint32_t width, uint32_t height, float offset_x, float offset_y)
372 {

Callers 2

UpdateSafeAreaAdjustFunction · 0.85
SetSceneSafeAreaModeFunction · 0.85

Calls 1

MaxFunction · 0.50

Tested by

no test coverage detected