ui: Add AdjustedTouches for consistency

This commit is contained in:
Hajime Hoshi 2018-04-02 01:53:10 +09:00
parent e44a930bbb
commit c540d0fc0d
4 changed files with 16 additions and 1 deletions

View File

@ -119,7 +119,7 @@ type Touch interface {
// //
// Touches always returns nil on desktops. // Touches always returns nil on desktops.
func Touches() []Touch { func Touches() []Touch {
t := input.Get().Touches() t := ui.AdjustedTouches()
tt := make([]Touch, len(t)) tt := make([]Touch, len(t))
for i := 0; i < len(tt); i++ { for i := 0; i < len(tt); i++ {
tt[i] = t[i] tt[i] = t[i]

View File

@ -366,6 +366,11 @@ func adjustCursorPosition(x, y int) (int, int) {
return x - int(ox/s), y - int(oy/s) return x - int(ox/s), y - int(oy/s)
} }
func AdjustedTouches() []*input.Touch {
// TODO: Apply adjustCursorPosition
return input.Get().Touches()
}
func IsCursorVisible() bool { func IsCursorVisible() bool {
u := currentUI u := currentUI
if !u.isRunning() { if !u.isRunning() {

View File

@ -86,6 +86,11 @@ func AdjustedCursorPosition() (x, y int) {
return int(float64(x) / scale), int(float64(y) / scale) return int(float64(x) / scale), int(float64(y) / scale)
} }
func AdjustedTouches() []*input.Touch {
// TODO: Apply adjustment here
return input.Get().Touches()
}
func IsCursorVisible() bool { func IsCursorVisible() bool {
// The initial value is an empty string, so don't compare with "auto" here. // The initial value is an empty string, so don't compare with "auto" here.
return canvas.Get("style").Get("cursor").String() != "none" return canvas.Get("style").Get("cursor").String() != "none"

View File

@ -242,6 +242,11 @@ func AdjustedCursorPosition() (x, y int) {
return currentUI.adjustCursorPosition(input.Get().CursorPosition()) return currentUI.adjustCursorPosition(input.Get().CursorPosition())
} }
func AdjustedTouches() []*input.Touch {
// TODO: Apply adjustment here
return input.Get().Touches()
}
func (u *userInterface) adjustCursorPosition(x, y int) (int, int) { func (u *userInterface) adjustCursorPosition(x, y int) (int, int) {
u.m.Lock() u.m.Lock()
ox, oy, _, _ := u.screenPaddingImpl() ox, oy, _, _ := u.screenPaddingImpl()