mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
exp/textinput: use native pixels for a candidate window position
This commit is contained in:
parent
3e4c47eb70
commit
c0d9954b3e
@ -47,7 +47,7 @@ type State struct {
|
|||||||
//
|
//
|
||||||
// Start returns nil and nil if the current environment doesn't support this package.
|
// Start returns nil and nil if the current environment doesn't support this package.
|
||||||
func Start(x, y int) (states chan State, close func()) {
|
func Start(x, y int) (states chan State, close func()) {
|
||||||
cx, cy := ui.Get().LogicalPositionToClientPosition(float64(x), float64(y))
|
cx, cy := ui.Get().LogicalPositionToClientPositionInNativePixels(float64(x), float64(y))
|
||||||
return theTextInput.Start(int(cx), int(cy))
|
return theTextInput.Start(int(cx), int(cy))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,6 +285,10 @@ func (c *context) screenScaleAndOffsets() (scale, offsetX, offsetY float64) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserInterface) LogicalPositionToClientPosition(x, y float64) (float64, float64) {
|
func (u *UserInterface) LogicalPositionToClientPositionInNativePixels(x, y float64) (float64, float64) {
|
||||||
return u.context.logicalPositionToClientPosition(x, y, u.Monitor().DeviceScaleFactor())
|
s := u.Monitor().DeviceScaleFactor()
|
||||||
|
x, y = u.context.logicalPositionToClientPosition(x, y, s)
|
||||||
|
x = dipToNativePixels(x, s)
|
||||||
|
y = dipToNativePixels(y, s)
|
||||||
|
return x, y
|
||||||
}
|
}
|
||||||
|
@ -129,3 +129,7 @@ func deviceScaleFactorImpl() float64 {
|
|||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return x * scale
|
||||||
|
}
|
||||||
|
@ -2131,3 +2131,7 @@ func IsScreenTransparentAvailable() bool {
|
|||||||
func (u *UserInterface) RunOnMainThread(f func()) {
|
func (u *UserInterface) RunOnMainThread(f func()) {
|
||||||
u.mainThread.Call(f)
|
u.mainThread.Call(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return dipToGLFWPixel(x, scale)
|
||||||
|
}
|
||||||
|
@ -92,3 +92,7 @@ func deviceScaleFactorImpl() float64 {
|
|||||||
// TODO: Can this be called from non-main threads?
|
// TODO: Can this be called from non-main threads?
|
||||||
return float64(C.devicePixelRatio())
|
return float64(C.devicePixelRatio())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
@ -811,3 +811,7 @@ func (u *UserInterface) updateIconIfNeeded() error {
|
|||||||
func IsScreenTransparentAvailable() bool {
|
func IsScreenTransparentAvailable() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
@ -181,3 +181,7 @@ func (u *UserInterface) Monitor() *Monitor {
|
|||||||
func IsScreenTransparentAvailable() bool {
|
func IsScreenTransparentAvailable() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
@ -174,3 +174,7 @@ func (u *UserInterface) Monitor() *Monitor {
|
|||||||
func IsScreenTransparentAvailable() bool {
|
func IsScreenTransparentAvailable() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dipToNativePixels(x float64, scale float64) float64 {
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user