libs/core/src/eu/core/ui.cc
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "eu/core/ui.h" | ||
| 2 | |||
| 3 | |||
| 4 | namespace eu::core | ||
| 5 | { | ||
| 6 | |||
| 7 | |||
| 8 | 1 | v2 calculate_region(const v2& mouse_pos, const v2& pos, const v2& my_tex, const v2& widget_size, float region_sz) | |
| 9 | { | ||
| 10 | 1 | float region_x = (mouse_pos.x - pos.x) * (my_tex.x / widget_size.x) - region_sz * 0.5f; | |
| 11 | 1 | float region_y = (mouse_pos.y - pos.y) * (my_tex.y / widget_size.y) - region_sz * 0.5f; | |
| 12 | 1 | if (region_x < 0.0f) | |
| 13 | { | ||
| 14 | 1 | region_x = 0.0f; | |
| 15 | } | ||
| 16 | ✗ | else if (region_x > my_tex.x - region_sz) | |
| 17 | { | ||
| 18 | ✗ | region_x = my_tex.x - region_sz; | |
| 19 | } | ||
| 20 | 1 | if (region_y < 0.0f) | |
| 21 | { | ||
| 22 | 1 | region_y = 0.0f; | |
| 23 | } | ||
| 24 | ✗ | else if (region_y > my_tex.y - region_sz) | |
| 25 | { | ||
| 26 | ✗ | region_y = my_tex.y - region_sz; | |
| 27 | } | ||
| 28 | |||
| 29 | 1 | return {region_x, region_y}; | |
| 30 | } | ||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 |