ui: Rename ActualScale -> ActualScreenScale

This commit is contained in:
Hajime Hoshi 2016-03-23 01:14:28 +09:00
parent 2beba60530
commit 6efead974f
3 changed files with 18 additions and 18 deletions

View File

@ -101,8 +101,8 @@ func ScreenScale() int {
return currentUI.scale
}
func ActualScale() int {
return currentUI.actualScale()
func ActualScreenScale() int {
return currentUI.actualScreenScale()
}
type userInterface struct {
@ -147,7 +147,7 @@ func (u *userInterface) windowScale() int {
return u.scale * int(u.deviceScale)
}
func (u *userInterface) actualScale() int {
func (u *userInterface) actualScreenScale() int {
return u.windowScale() * u.framebufferScale
}
@ -205,7 +205,7 @@ func (u *userInterface) setScreenSize(width, height, scale int) bool {
// To prevent hanging up, return asap if the width is too small.
// 252 is an arbitrary number and I guess this is small enough.
const minWindowWidth = 252
if width*u.actualScale() < minWindowWidth {
if width*u.actualScreenScale() < minWindowWidth {
u.scale = origScale
return false
}

View File

@ -50,7 +50,7 @@ func SwapBuffers() {
}
func SetScreenSize(width, height int) bool {
scale := canvas.Get("dataset").Get("ebitenScale").Int()
scale := canvas.Get("dataset").Get("ebitenScreenScale").Int()
return currentUI.setScreenSize(width, height, scale)
}
@ -60,11 +60,11 @@ func SetScreenScale(scale int) bool {
}
func ScreenScale() int {
return canvas.Get("dataset").Get("ebitenScale").Int()
return canvas.Get("dataset").Get("ebitenScreenScale").Int()
}
func ActualScale() int {
return canvas.Get("dataset").Get("ebitenActualScale").Int()
func ActualScreenScale() int {
return canvas.Get("dataset").Get("ebitenActualScreenScale").Int()
}
var canvas *js.Object
@ -226,7 +226,7 @@ func Init() *opengl.Context {
}
func setMouseCursorFromEvent(e *js.Object) {
scale := canvas.Get("dataset").Get("ebitenScale").Int()
scale := canvas.Get("dataset").Get("ebitenScreenScale").Int()
rect := canvas.Call("getBoundingClientRect")
x, y := e.Get("clientX").Int(), e.Get("clientY").Int()
x -= rect.Get("left").Int()
@ -252,7 +252,7 @@ func (u *userInterface) start(width, height, scale int, title string) error {
}
func (*userInterface) size() (width, height int) {
a := canvas.Get("dataset").Get("ebitenActualScale").Int()
a := canvas.Get("dataset").Get("ebitenActualScreenScale").Int()
if a == 0 {
// a == 0 only on the initial state.
return
@ -264,16 +264,16 @@ func (*userInterface) size() (width, height int) {
func (u *userInterface) setScreenSize(width, height, scale int) bool {
w, h := u.size()
s := canvas.Get("dataset").Get("ebitenScale").Int()
s := canvas.Get("dataset").Get("ebitenScreenScale").Int()
if w == width && h == height && s == scale {
return false
}
actualScale := scale * devicePixelRatio()
canvas.Set("width", width*actualScale)
canvas.Set("height", height*actualScale)
canvas.Get("dataset").Set("ebitenScale", scale)
canvas.Get("dataset").Set("ebitenActualScale", actualScale)
actualScreenScale := scale * devicePixelRatio()
canvas.Set("width", width*actualScreenScale)
canvas.Set("height", height*actualScreenScale)
canvas.Get("dataset").Set("ebitenScreenScale", scale)
canvas.Get("dataset").Set("ebitenActualScreenScale", actualScreenScale)
canvasStyle := canvas.Get("style")
cssWidth := width * scale

4
run.go
View File

@ -70,7 +70,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
defer ui.Terminate()
glContext.Check()
graphicsContext, err := newGraphicsContext(width, height, ui.ActualScale())
graphicsContext, err := newGraphicsContext(width, height, ui.ActualScreenScale())
if err != nil {
return err
}
@ -93,7 +93,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
}
if changed {
w, h := runContext.newScreenWidth, runContext.newScreenHeight
if err := graphicsContext.setSize(w, h, ui.ActualScale()); err != nil {
if err := graphicsContext.setSize(w, h, ui.ActualScreenScale()); err != nil {
return err
}
}