1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg: handle Android's own native dpi scaling factor (#8908)

This commit is contained in:
spaceface
2021-02-22 20:24:18 +01:00
committed by GitHub
parent 79edff5c6c
commit b4dc6c83cd
3 changed files with 42 additions and 16 deletions

View File

@ -255,7 +255,7 @@ fn (b Board) hmirror() Board {
// GCC optimization bug; inlining fails when compiled with -prod
[no_inline]
fn (t TileLine) to_left() TileLine {
right_border_idx := 5
right_border_idx := 4
mut res := t
mut zeros := 0
mut nonzeros := 0
@ -729,11 +729,11 @@ fn (mut app App) handle_tap() {
avgx, avgy := avg(s.pos.x, e.pos.x), avg(s.pos.y, e.pos.y)
// TODO: Replace "touch spots" with actual buttons
// bottom left -> change theme
if avgx < 200 && h - avgy < 200 {
if avgx < 50 && h - avgy < 50 {
app.next_theme()
}
// bottom right -> change tile format
if w - avgx < 200 && h - avgy < 200 {
if w - avgx < 50 && h - avgy < 50 {
app.next_tile_format()
}
if app.state == .victory {
@ -767,7 +767,7 @@ fn (mut app App) handle_swipe() {
dmax := if max(adx, ady) > 0 { max(adx, ady) } else { 1 }
tdiff := int(e.time.unix_time_milli() - s.time.unix_time_milli())
// TODO: make this calculation more accurate (don't use arbitrary numbers)
min_swipe_distance := int(math.sqrt(min(w, h) * tdiff / 60)) + 20
min_swipe_distance := int(math.sqrt(min(w, h) * tdiff / 100)) + 20
if dmax < min_swipe_distance {
return
}