2019-04-07 03:42:55 +02:00
|
|
|
// 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
|
|
|
|
|
2019-04-07 03:54:05 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
2019-04-07 03:42:55 +02:00
|
|
|
"image"
|
2019-04-07 03:54:05 +02:00
|
|
|
)
|
|
|
|
|
2019-04-09 05:21:37 +02:00
|
|
|
type UIContext interface {
|
2021-08-04 18:29:45 +02:00
|
|
|
UpdateFrame() error
|
|
|
|
ForceUpdateFrame() error
|
2019-12-09 18:37:10 +01:00
|
|
|
Layout(outsideWidth, outsideHeight float64)
|
2020-10-16 22:16:02 +02:00
|
|
|
|
|
|
|
// AdjustPosition can be called from a different goroutine from Update's or Layout's.
|
|
|
|
AdjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64)
|
2019-04-07 03:42:55 +02:00
|
|
|
}
|
2019-04-07 03:54:05 +02:00
|
|
|
|
|
|
|
// 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")
|
2019-04-07 03:42:55 +02:00
|
|
|
|
|
|
|
type UI interface {
|
2020-01-03 09:32:46 +01:00
|
|
|
Run(context UIContext) error
|
2020-02-11 15:19:43 +01:00
|
|
|
RunWithoutMainLoop(context UIContext)
|
2019-11-30 14:37:53 +01:00
|
|
|
|
2019-04-07 03:42:55 +02:00
|
|
|
DeviceScaleFactor() float64
|
2020-03-20 16:08:40 +01:00
|
|
|
IsFocused() bool
|
2019-04-07 03:42:55 +02:00
|
|
|
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
|
2019-12-14 04:30:03 +01:00
|
|
|
SetCursorMode(mode CursorMode)
|
2020-04-01 14:28:00 +02:00
|
|
|
|
2021-04-11 07:21:38 +02:00
|
|
|
CursorShape() CursorShape
|
|
|
|
SetCursorShape(shape CursorShape)
|
|
|
|
|
2020-04-01 14:28:00 +02:00
|
|
|
IsFullscreen() bool
|
2019-04-07 03:42:55 +02:00
|
|
|
SetFullscreen(fullscreen bool)
|
2020-04-01 14:28:00 +02:00
|
|
|
|
|
|
|
IsRunnableOnUnfocused() bool
|
2020-03-20 16:34:12 +01:00
|
|
|
SetRunnableOnUnfocused(runnableOnUnfocused bool)
|
2020-04-01 14:28:00 +02:00
|
|
|
|
2021-07-22 16:55:26 +02:00
|
|
|
FPSMode() FPSMode
|
|
|
|
SetFPSMode(mode FPSMode)
|
2021-07-22 18:07:28 +02:00
|
|
|
ScheduleFrame()
|
2020-04-01 14:28:00 +02:00
|
|
|
|
|
|
|
IsScreenTransparent() bool
|
2019-11-30 16:07:41 +01:00
|
|
|
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
|
2020-01-03 09:32:46 +01:00
|
|
|
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)
|
2021-04-16 19:27:04 +02:00
|
|
|
SizeLimits() (minw, minh, maxw, maxh int)
|
|
|
|
SetSizeLimits(minw, minh, maxw, maxh int)
|
2019-12-24 16:05:56 +01:00
|
|
|
|
2020-03-20 13:46:23 +01:00
|
|
|
IsFloating() bool
|
|
|
|
SetFloating(floating bool)
|
|
|
|
|
2020-03-21 11:26:28 +01:00
|
|
|
Maximize()
|
|
|
|
IsMaximized() bool
|
|
|
|
|
|
|
|
Minimize()
|
|
|
|
IsMinimized() bool
|
|
|
|
|
2019-12-24 16:05:56 +01:00
|
|
|
SetIcon(iconImages []image.Image)
|
|
|
|
SetTitle(title string)
|
2020-03-21 11:26:28 +01:00
|
|
|
Restore()
|
2021-06-13 13:52:14 +02:00
|
|
|
|
|
|
|
IsBeingClosed() bool
|
|
|
|
SetClosingHandled(handled bool)
|
|
|
|
IsClosingHandled() bool
|
2019-04-07 03:42:55 +02:00
|
|
|
}
|
2021-07-22 16:55:26 +02:00
|
|
|
|
|
|
|
type FPSMode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
FPSModeVsyncOn FPSMode = iota
|
|
|
|
FPSModeVsyncOffMaximum
|
2021-07-22 18:07:28 +02:00
|
|
|
FPSModeVsyncOffMinimum
|
2021-07-22 16:55:26 +02:00
|
|
|
)
|