-
Notifications
You must be signed in to change notification settings - Fork 282
GLFW Plugin example
Pierre Champion edited this page May 10, 2019
·
25 revisions
The dart code cannot control the glfw.Window
size, position, ...
To gain control over the glfw.Window
we need to build your own plugin in order to access the underlying API, please read the plugin wiki in order to learn more about the plugin architecture.
In this example, we answer the issue #126, How to make the window as not resizable.
To make the window not resizable for the entire lifetime of the application, there is no need to use the dart and Golang platform-channels.
Using hover the file to edit is desktop/cmd/options.go
.
By creating a custom GLFW Plugin, we gain access to the glfw.Window
interface. Having access to the glfw.Window interface allows users to customize the window to there needs.
Source code:
package main
import (
"github.com/go-flutter-desktop/go-flutter"
"github.com/go-flutter-desktop/go-flutter/plugin"
"github.com/go-gl/glfw/v3.2/glfw"
)
var options = []flutter.Option{
flutter.WindowInitialDimensions(800, 600),
flutter.AddPlugin(&WindowNotResizable{}),
// ...
}
type WindowNotResizable struct{}
var _ flutter.PluginGLFW = &WindowNotResizable{} // compile-time type check
// WindowNotResizable struct must implement InitPlugin and InitPluginGLFW
func (p *WindowNotResizable) InitPlugin(messenger plugin.BinaryMessenger) error {
// nothing to do
return nil
}
func (p *WindowNotResizable) InitPluginGLFW(window *glfw.Window) error {
window.SetSizeLimits(800, 600, 800, 600)
return nil
}