mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 14:34:26 +01:00
internal/ui: rename functions
This commit is contained in:
parent
41a68bf17b
commit
5e7ec81f5c
@ -243,7 +243,7 @@ func (c *context) layoutGame(outsideWidth, outsideHeight float64, deviceScaleFac
|
||||
return ow, oh
|
||||
}
|
||||
|
||||
func (c *context) adjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64) {
|
||||
func (c *context) clientPositionToLogicalPosition(x, y float64, deviceScaleFactor float64) (float64, float64) {
|
||||
s, ox, oy := c.screenScaleAndOffsets()
|
||||
// The scale 0 indicates that the screen is not initialized yet.
|
||||
// As any cursor values don't make sense, just return NaN.
|
||||
|
@ -64,7 +64,7 @@ func (u *userInterfaceImpl) updateInputState() error {
|
||||
s := u.deviceScaleFactor(m)
|
||||
cx = u.dipFromGLFWPixel(cx, m)
|
||||
cy = u.dipFromGLFWPixel(cy, m)
|
||||
cx, cy = u.context.adjustPosition(cx, cy, s)
|
||||
cx, cy = u.context.clientPositionToLogicalPosition(cx, cy, s)
|
||||
|
||||
// AdjustPosition can return NaN at the initialization.
|
||||
if !math.IsNaN(cx) && !math.IsNaN(cy) {
|
||||
|
@ -107,13 +107,13 @@ func (u *userInterfaceImpl) setMouseCursorFromEvent(e js.Value) {
|
||||
if u.cursorMode == CursorModeCaptured {
|
||||
x, y := e.Get("clientX").Int(), e.Get("clientY").Int()
|
||||
u.origCursorX, u.origCursorY = x, y
|
||||
dx, dy := u.context.adjustPosition(e.Get("movementX").Float(), e.Get("movementY").Float(), u.DeviceScaleFactor())
|
||||
dx, dy := u.context.clientPositionToLogicalPosition(e.Get("movementX").Float(), e.Get("movementY").Float(), u.DeviceScaleFactor())
|
||||
u.inputState.CursorX += int(dx)
|
||||
u.inputState.CursorY += int(dy)
|
||||
return
|
||||
}
|
||||
|
||||
x, y := u.context.adjustPosition(e.Get("clientX").Float(), e.Get("clientY").Float(), u.DeviceScaleFactor())
|
||||
x, y := u.context.clientPositionToLogicalPosition(e.Get("clientX").Float(), e.Get("clientY").Float(), u.DeviceScaleFactor())
|
||||
u.inputState.CursorX, u.inputState.CursorY = int(x), int(y)
|
||||
u.origCursorX, u.origCursorY = int(x), int(y)
|
||||
}
|
||||
@ -130,7 +130,7 @@ func (u *userInterfaceImpl) updateTouchesFromEvent(e js.Value) {
|
||||
touches := e.Get("targetTouches")
|
||||
for i := 0; i < touches.Length(); i++ {
|
||||
t := touches.Call("item", i)
|
||||
x, y := u.context.adjustPosition(t.Get("clientX").Float(), t.Get("clientY").Float(), u.DeviceScaleFactor())
|
||||
x, y := u.context.clientPositionToLogicalPosition(t.Get("clientX").Float(), t.Get("clientY").Float(), u.DeviceScaleFactor())
|
||||
u.inputState.Touches[i] = Touch{
|
||||
Valid: true,
|
||||
ID: TouchID(t.Get("identifier").Int()),
|
||||
|
@ -42,7 +42,7 @@ func (u *userInterfaceImpl) updateInputState(keys map[Key]struct{}, runes []rune
|
||||
u.inputState.Touches[i].Valid = false
|
||||
}
|
||||
for i, t := range touches {
|
||||
x, y := u.context.adjustPosition(t.X, t.Y, u.DeviceScaleFactor())
|
||||
x, y := u.context.clientPositionToLogicalPosition(t.X, t.Y, u.DeviceScaleFactor())
|
||||
u.inputState.Touches[i] = Touch{
|
||||
Valid: true,
|
||||
ID: t.ID,
|
||||
|
@ -28,7 +28,7 @@ func (u *userInterfaceImpl) updateInputState() {
|
||||
u.inputState.Touches[i].Valid = false
|
||||
}
|
||||
for i, t := range u.nativeTouches {
|
||||
x, y := u.context.adjustPosition(float64(t.X), float64(t.Y), deviceScaleFactor)
|
||||
x, y := u.context.clientPositionToLogicalPosition(float64(t.X), float64(t.Y), deviceScaleFactor)
|
||||
u.inputState.Touches[i] = Touch{
|
||||
Valid: true,
|
||||
ID: TouchID(t.ID),
|
||||
|
@ -361,11 +361,6 @@ func (u *userInterfaceImpl) setGBuildSize(widthPx, heightPx int) {
|
||||
})
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) adjustPosition(x, y int) (int, int) {
|
||||
xf, yf := u.context.adjustPosition(float64(x), float64(y), deviceScale())
|
||||
return int(xf), int(yf)
|
||||
}
|
||||
|
||||
func (u *userInterfaceImpl) CursorMode() CursorMode {
|
||||
return CursorModeHidden
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user