mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
ebiten: add IsWindowAspectRatioFixed
This also updates examples/windowsize. Closes #1804
This commit is contained in:
parent
7482cae978
commit
891ca2a08d
@ -60,7 +60,7 @@ func init() {
|
||||
|
||||
const (
|
||||
initScreenWidth = 480
|
||||
initScreenHeight = 360
|
||||
initScreenHeight = 480
|
||||
initScreenScale = 1
|
||||
)
|
||||
|
||||
@ -291,6 +291,10 @@ func (g *game) Update() error {
|
||||
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
|
||||
}
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyA) {
|
||||
ebiten.SetWindowAspectRatioFixed(!ebiten.IsWindowAspectRatioFixed())
|
||||
}
|
||||
|
||||
g.count++
|
||||
return nil
|
||||
}
|
||||
@ -344,6 +348,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
||||
[D] Switch the window decoration (only for desktops)
|
||||
[L] Switch the window floating state (only for desktops)
|
||||
[W] Switch whether to skip clearing the screen
|
||||
[A] Switch whether to fix window aspect ratio (only for desktops)
|
||||
%s
|
||||
IsFocused?: %s
|
||||
Window Position: (%d, %d)
|
||||
|
@ -231,6 +231,10 @@ func (w *Window) SetAspectRatioFixed(fixed bool) {
|
||||
w.ui.setWindowAspectRatioFixed(fixed)
|
||||
}
|
||||
|
||||
func (w *Window) IsAspectRatioFixed() bool {
|
||||
return w.ui.isWindowAspectRatioFixed()
|
||||
}
|
||||
|
||||
func (w *Window) SetIcon(iconImages []image.Image) {
|
||||
// The icons are actually set at (*UserInterface).loop.
|
||||
w.ui.setIconImages(iconImages)
|
||||
|
@ -82,6 +82,10 @@ func (*Window) IsMinimized() bool {
|
||||
func (*Window) SetAspectRatioFixed(fixed bool) {
|
||||
}
|
||||
|
||||
func (*Window) IsAspectRatioFixed() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (*Window) SetIcon(iconImages []image.Image) {
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,19 @@ func SetWindowResizable(resizable bool) {
|
||||
}
|
||||
|
||||
// SetWindowAspectRatioFixed sets whether the window should keep its aspect ratio while resizing.
|
||||
//
|
||||
// SetWindowAspectRatioFixed is concurrent-safe.
|
||||
func SetWindowAspectRatioFixed(fixed bool) {
|
||||
ui.Get().Window().SetAspectRatioFixed(fixed)
|
||||
}
|
||||
|
||||
// IsWindowAspectRatioFixed reports whether the window should keep its aspect ratio while resizing.
|
||||
//
|
||||
// IsWindowAspectRatioFixed is concurrent-safe.
|
||||
func IsWindowAspectRatioFixed() bool {
|
||||
return ui.Get().Window().IsAspectRatioFixed()
|
||||
}
|
||||
|
||||
// SetWindowTitle sets the title of the window.
|
||||
//
|
||||
// SetWindowTitle does nothing on browsers or mobiles.
|
||||
|
Loading…
Reference in New Issue
Block a user