Documentation
¶
Overview ¶
Package frontend provides interface for platform-specific code.
Index ¶
Constants ¶
const ( CallbackContextChange = -100 - iota CallbackMouseDown CallbackKeyDown CallbackMouseUp CallbackAppHide CallbackAppShow CallbackMouseMove CallbackMouseScroll CallbackTouchDown CallbackTouchUp CallbackTouchMove CallbackReady CallbackKeyUp CallbackTextInput CallbackOrientationChange CallbackStop )
const ( MessageExit = iota MessageExec MessageTitle MessageEngineStopped )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Name string `yaml:"name"`
Author string `yaml:"author"`
CompanyDomain string `yaml:"companyDomain"`
PublicUrl string `yaml:"publicUrl"`
Frontend string `yaml:"frontend"`
Debug bool `yaml:"debug"`
MainScene string `yaml:"mainScene"`
LaunchArgs map[string]interface{} `yaml:"launchArgs"`
HostOS string `yaml:"hostOS"`
}
type Context ¶
type Context struct {
DeviceInfo common.DeviceInfo
ScreenInfo common.ScreenInfo
Domain string
Host string
Port string
}
type FeatureDelegate ¶ added in v0.2.0
type FeatureDelegate interface {
OnInvoke(data interface{}) interface{}
}
FeatureDelegate defines interface for a feature, that is provided by the frontend, to be used by the engine. The OnInvoke method is called by the engine. It takes in and returns interface{}, so any types can be used for the specific feature.
type FeatureFunc ¶ added in v0.2.0
type FeatureFunc struct {
// contains filtered or unexported fields
}
FeatureFunc is an implementation of the FeatureDelegate interface that takes in a function that implements the desired feature.
func NewFeatureFunc ¶ added in v0.2.0
func NewFeatureFunc(f func(interface{}) interface{}) *FeatureFunc
NewFeatureFunc Creates a new instance of FeatureFunc with the specified delegate function.
func (*FeatureFunc) OnInvoke ¶ added in v0.2.0
func (f *FeatureFunc) OnInvoke(data interface{}) interface{}
OnInvoke implementation of the interface
type Frontend ¶
type Frontend interface {
//Init is called when the frontend is created.
Init()
//Run is like the main function for the frontend.
Run()
SetEngineDispatcher(disp dispatch.MessageDispatcher)
//GetRenderer should return a fully configured ARenderer. Must be deterministic.
GetRenderer() *rendering.ARenderer
//GetContext should return the Context. It is called by the engine whenever the frontend sends CallbackContextChange.
GetContext() Context
//GetPlatform should return the current Platform.
GetPlatform() common.Platform
//CommencePanic should indicate in a native way, that an error has occurred in either the app or the engine.
CommencePanic(reason, msg string)
GetMessageDispatcher() dispatch.MessageDispatcher
GetWorkDispatcher() dispatch.WorkDispatcher
//GetResourceManager should return an implementation of ResourceManager interface.
GetResourceManager() ResourceManager
//GetApp should return the app data from app.yaml file.
GetApp() *App
//GetLaunchArgs should return arguments.
GetLaunchArgs() a.SiMap
}
Frontend interface defines functions that should be implemented in an Amphion frontend natively. It defines the way engine and frontend will communicate.
type ResourceManager ¶
type ResourceManager interface {
RegisterResource(path string)
IdOf(path string) a.ResId
PathOf(id a.ResId) string
FullPathOf(id a.ResId) string
ReadFile(id a.ResId) ([]byte, error)
}
ResourceManager defines interface, that should be implemented in the frontend to provide functionality of working with files in res folder.
type ResourceManagerImpl ¶ added in v0.2.0
type ResourceManagerImpl struct {
// contains filtered or unexported fields
}
func NewResourceManagerImpl ¶ added in v0.2.0
func NewResourceManagerImpl() *ResourceManagerImpl
func (*ResourceManagerImpl) FullPathOf ¶ added in v0.2.0
func (r *ResourceManagerImpl) FullPathOf(id a.ResId) string
func (*ResourceManagerImpl) IdOf ¶ added in v0.2.0
func (r *ResourceManagerImpl) IdOf(path string) a.ResId
func (*ResourceManagerImpl) PathOf ¶ added in v0.2.0
func (r *ResourceManagerImpl) PathOf(id a.ResId) string
func (*ResourceManagerImpl) RegisterResource ¶ added in v0.2.0
func (r *ResourceManagerImpl) RegisterResource(path string)