ebiten/internal/driver/ui.go

110 lines
2.4 KiB
Go
Raw Normal View History

// Copyright 2019 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package driver
import (
"errors"
"image"
)
type UIContext interface {
2020-04-02 17:06:42 +02:00
Update() error
ForceUpdate() error
Layout(outsideWidth, outsideHeight float64)
// AdjustPosition can be called from a different goroutine from Update's or Layout's.
AdjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64)
}
// RegularTermination represents a regular termination.
// Run can return this error, and if this error is received,
// the game loop should be terminated as soon as possible.
var RegularTermination = errors.New("regular termination")
type UI interface {
Run(context UIContext) error
RunWithoutMainLoop(context UIContext)
2019-11-30 14:37:53 +01:00
DeviceScaleFactor() float64
IsFocused() bool
ScreenSizeInFullscreen() (int, int)
2020-04-02 17:06:42 +02:00
ResetForFrame()
2019-11-30 14:37:53 +01:00
2020-04-01 14:28:00 +02:00
CursorMode() CursorMode
SetCursorMode(mode CursorMode)
2020-04-01 14:28:00 +02:00
CursorShape() CursorShape
SetCursorShape(shape CursorShape)
2020-04-01 14:28:00 +02:00
IsFullscreen() bool
SetFullscreen(fullscreen bool)
2020-04-01 14:28:00 +02:00
IsRunnableOnUnfocused() bool
SetRunnableOnUnfocused(runnableOnUnfocused bool)
2020-04-01 14:28:00 +02:00
FPSMode() FPSMode
SetFPSMode(mode FPSMode)
ScheduleFrame()
2020-04-01 14:28:00 +02:00
IsScreenTransparent() bool
SetScreenTransparent(transparent bool)
2020-02-09 15:03:03 +01:00
SetInitFocused(focused bool)
2019-11-30 14:37:53 +01:00
2019-04-07 11:28:50 +02:00
Input() Input
2019-12-24 16:05:56 +01:00
Window() Window
Graphics() Graphics
2019-12-24 16:05:56 +01:00
}
type Window interface {
IsDecorated() bool
SetDecorated(decorated bool)
IsResizable() bool
SetResizable(resizable bool)
Position() (int, int)
SetPosition(x, y int)
Size() (int, int)
SetSize(width, height int)
SizeLimits() (minw, minh, maxw, maxh int)
SetSizeLimits(minw, minh, maxw, maxh int)
2019-12-24 16:05:56 +01:00
IsFloating() bool
SetFloating(floating bool)
Maximize()
IsMaximized() bool
Minimize()
IsMinimized() bool
2019-12-24 16:05:56 +01:00
SetIcon(iconImages []image.Image)
SetTitle(title string)
Restore()
IsBeingClosed() bool
SetClosingHandled(handled bool)
IsClosingHandled() bool
}
type FPSMode int
const (
FPSModeVsyncOn FPSMode = iota
FPSModeVsyncOffMaximum
FPSModeVsyncOffMinimum
)