add method Window.Hide, minor formatting and doc fixes

This commit is contained in:
mlange-42 2023-04-14 11:33:38 +02:00
parent d899a6bbed
commit a36cfb17b4
2 changed files with 15 additions and 7 deletions

View File

@ -46,10 +46,10 @@ var defaultCanvasVertexFormat = glhf.AttrFormat{
canvasColor: glhf.Attr{Name: "aColor", Type: glhf.Vec4},
canvasTexCoords: glhf.Attr{Name: "aTexCoords", Type: glhf.Vec2},
canvasIntensity: glhf.Attr{Name: "aIntensity", Type: glhf.Float},
canvasClip: glhf.Attr{Name: "aClipRect", Type: glhf.Vec4},
canvasClip: glhf.Attr{Name: "aClipRect", Type: glhf.Vec4},
}
// Sets up a base shader with everything needed for a Pixel
// NewGLShader sets up a base shader with everything needed for a Pixel
// canvas to render correctly. The defaults can be overridden
// by simply using the SetUniform function.
func NewGLShader(fragmentShader string) *GLShader {
@ -109,10 +109,10 @@ func (gs *GLShader) getUniform(Name string) int {
// SetUniform appends a custom uniform name and value to the shader.
// if the uniform already exists, it will simply be overwritten.
//
// example:
// Example:
//
// utime := float32(time.Since(starttime)).Seconds())
// mycanvas.shader.AddUniform("u_time", &utime)
// utime := float32(time.Since(starttime)).Seconds())
// mycanvas.shader.AddUniform("u_time", &utime)
func (gs *GLShader) SetUniform(name string, value interface{}) {
t, p := getAttrType(value)
if loc := gs.getUniform(name); loc > -1 {

View File

@ -232,7 +232,7 @@ func (w *Window) ClipboardText() string {
}
// SetClipboardText passes the given string to the underlying glfw window to set the
// systems clipboard.
// systems clipboard.
func (w *Window) SetClipboardText(text string) {
w.window.SetClipboardString(text)
}
@ -527,6 +527,14 @@ func (w *Window) Show() {
})
}
// Hide hides the window, if it was previously visible. If the window is already
// hidden or is in full screen mode, this function does nothing.
func (w *Window) Hide() {
mainthread.Call(func() {
w.window.Hide()
})
}
// Clipboard returns the contents of the system clipboard.
func (w *Window) Clipboard() string {
var clipboard string
@ -536,7 +544,7 @@ func (w *Window) Clipboard() string {
return clipboard
}
// SetClipboardString sets the system clipboard to the specified UTF-8 encoded string.
// SetClipboard sets the system clipboard to the specified UTF-8 encoded string.
func (w *Window) SetClipboard(str string) {
mainthread.Call(func() {
w.window.SetClipboardString(str)