mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Feature/align api (#1161)
* Fix WindowSetRGBA API * Change WindowUnFullscreen -> WindowUnfullscreen for consistency RGBA bugfix
This commit is contained in:
@@ -106,8 +106,8 @@ func (b BridgeClient) WindowFullscreen() {
|
||||
b.session.log.Info("WindowFullscreen unsupported in Bridge mode")
|
||||
}
|
||||
|
||||
func (b BridgeClient) WindowUnFullscreen() {
|
||||
b.session.log.Info("WindowUnFullscreen unsupported in Bridge mode")
|
||||
func (b BridgeClient) WindowUnfullscreen() {
|
||||
b.session.log.Info("WindowUnfullscreen unsupported in Bridge mode")
|
||||
}
|
||||
|
||||
func (b BridgeClient) WindowSetColour(colour int) {
|
||||
|
||||
@@ -2,11 +2,12 @@ package bridge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/messagedispatcher"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
@@ -126,7 +127,7 @@ func (d *DialogClient) WindowSetMaxSize(width int, height int) {
|
||||
func (d *DialogClient) WindowFullscreen() {
|
||||
}
|
||||
|
||||
func (d *DialogClient) WindowUnFullscreen() {
|
||||
func (d *DialogClient) WindowUnfullscreen() {
|
||||
}
|
||||
|
||||
func (d *DialogClient) WindowSetColour(colour int) {
|
||||
|
||||
@@ -61,8 +61,8 @@ func (c *Client) WindowFullscreen() {
|
||||
C.Fullscreen(c.app.app)
|
||||
}
|
||||
|
||||
// WindowUnFullscreen will unfullscreen the window
|
||||
func (c *Client) WindowUnFullscreen() {
|
||||
// WindowUnfullscreen will unfullscreen the window
|
||||
func (c *Client) WindowUnfullscreen() {
|
||||
C.UnFullscreen(c.app.app)
|
||||
}
|
||||
|
||||
@@ -141,8 +141,6 @@ func (c *Client) OpenFileDialog(dialogOptions runtime.OpenDialogOptions, callbac
|
||||
c.app.string2CString(strings.Join(filters, ";")),
|
||||
c.app.string2CString(dialogOptions.DefaultFilename),
|
||||
c.app.string2CString(dialogOptions.DefaultDirectory),
|
||||
c.app.bool2Cint(dialogOptions.AllowFiles),
|
||||
c.app.bool2Cint(dialogOptions.AllowDirectories),
|
||||
c.app.bool2Cint(false),
|
||||
c.app.bool2Cint(dialogOptions.ShowHiddenFiles),
|
||||
c.app.bool2Cint(dialogOptions.CanCreateDirectories),
|
||||
@@ -189,8 +187,6 @@ func (c *Client) OpenMultipleFilesDialog(dialogOptions runtime.OpenDialogOptions
|
||||
c.app.string2CString(strings.Join(filters, ";")),
|
||||
c.app.string2CString(dialogOptions.DefaultFilename),
|
||||
c.app.string2CString(dialogOptions.DefaultDirectory),
|
||||
c.app.bool2Cint(dialogOptions.AllowFiles),
|
||||
c.app.bool2Cint(dialogOptions.AllowDirectories),
|
||||
c.app.bool2Cint(true),
|
||||
c.app.bool2Cint(dialogOptions.ShowHiddenFiles),
|
||||
c.app.bool2Cint(dialogOptions.CanCreateDirectories),
|
||||
@@ -239,7 +235,6 @@ func (c *Client) MessageDialog(dialogOptions runtime.MessageDialogOptions, callb
|
||||
c.app.string2CString(string(dialogOptions.Type)),
|
||||
c.app.string2CString(dialogOptions.Title),
|
||||
c.app.string2CString(dialogOptions.Message),
|
||||
c.app.string2CString(dialogOptions.Icon),
|
||||
c.app.string2CString(buttons[0]),
|
||||
c.app.string2CString(buttons[1]),
|
||||
c.app.string2CString(buttons[2]),
|
||||
|
||||
@@ -10,13 +10,14 @@ import "C"
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/leaanthony/go-common-file-dialog/cfd"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"golang.org/x/sys/windows"
|
||||
"log"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/leaanthony/go-common-file-dialog/cfd"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"golang.org/x/sys/windows"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
)
|
||||
|
||||
@@ -63,8 +64,8 @@ func (c *Client) WindowFullscreen() {
|
||||
C.Fullscreen(c.app.app)
|
||||
}
|
||||
|
||||
// WindowUnFullscreen will unfullscreen the window
|
||||
func (c *Client) WindowUnFullscreen() {
|
||||
// WindowUnfullscreen will unfullscreen the window
|
||||
func (c *Client) WindowUnfullscreen() {
|
||||
C.UnFullscreen(c.app.app)
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ func (f *Frontend) WindowFullscreen() {
|
||||
f.mainWindow.Fullscreen()
|
||||
}
|
||||
|
||||
func (f *Frontend) WindowUnFullscreen() {
|
||||
func (f *Frontend) WindowUnfullscreen() {
|
||||
f.mainWindow.UnFullscreen()
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ func (f *Frontend) WindowFullscreen() {
|
||||
f.mainWindow.Fullscreen()
|
||||
}
|
||||
|
||||
func (f *Frontend) WindowUnFullscreen() {
|
||||
func (f *Frontend) WindowUnfullscreen() {
|
||||
f.mainWindow.UnFullscreen()
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ func (f *Frontend) WindowFullscreen() {
|
||||
f.mainWindow.Fullscreen()
|
||||
}
|
||||
|
||||
func (f *Frontend) WindowUnFullscreen() {
|
||||
func (f *Frontend) WindowUnfullscreen() {
|
||||
runtime.LockOSThread()
|
||||
if f.frontendOptions.Frameless && f.frontendOptions.DisableResize == false {
|
||||
f.ExecJS("window.wails.flags.enableResize = true;")
|
||||
|
||||
@@ -231,8 +231,8 @@ func (d *DevWebServer) WindowFullscreen() {
|
||||
d.desktopFrontend.WindowFullscreen()
|
||||
}
|
||||
|
||||
func (d *DevWebServer) WindowUnFullscreen() {
|
||||
d.desktopFrontend.WindowUnFullscreen()
|
||||
func (d *DevWebServer) WindowUnfullscreen() {
|
||||
d.desktopFrontend.WindowUnfullscreen()
|
||||
}
|
||||
|
||||
func (d *DevWebServer) WindowSetRGBA(col *options.RGBA) {
|
||||
@@ -308,7 +308,7 @@ func (d *DevWebServer) broadcast(message string) {
|
||||
d.socketMutex.Lock()
|
||||
defer d.socketMutex.Unlock()
|
||||
for client, locker := range d.websocketClients {
|
||||
go func() {
|
||||
go func(client *websocket.Conn, locker *sync.Mutex) {
|
||||
if client == nil {
|
||||
d.logger.Error("Lost connection to websocket server")
|
||||
return
|
||||
@@ -321,7 +321,7 @@ func (d *DevWebServer) broadcast(message string) {
|
||||
return
|
||||
}
|
||||
locker.Unlock()
|
||||
}()
|
||||
}(client, locker)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ func (d *DevWebServer) broadcastExcludingSender(message string, sender *websocke
|
||||
d.socketMutex.Lock()
|
||||
defer d.socketMutex.Unlock()
|
||||
for client, locker := range d.websocketClients {
|
||||
go func() {
|
||||
go func(client *websocket.Conn, locker *sync.Mutex) {
|
||||
if client == sender {
|
||||
return
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func (d *DevWebServer) broadcastExcludingSender(message string, sender *websocke
|
||||
return
|
||||
}
|
||||
locker.Unlock()
|
||||
}()
|
||||
}(client, locker)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@ package dispatcher
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
func (d *Dispatcher) mustAtoI(input string) int {
|
||||
@@ -31,7 +32,7 @@ func (d *Dispatcher) processWindowMessage(message string, sender frontend.Fronte
|
||||
case 'F':
|
||||
go sender.WindowFullscreen()
|
||||
case 'f':
|
||||
go sender.WindowUnFullscreen()
|
||||
go sender.WindowUnfullscreen()
|
||||
case 's':
|
||||
parts := strings.Split(message[3:], ":")
|
||||
w := d.mustAtoI(parts[0])
|
||||
|
||||
@@ -84,7 +84,7 @@ type Frontend interface {
|
||||
WindowSetMinSize(width int, height int)
|
||||
WindowSetMaxSize(width int, height int)
|
||||
WindowFullscreen()
|
||||
WindowUnFullscreen()
|
||||
WindowUnfullscreen()
|
||||
WindowSetRGBA(col *options.RGBA)
|
||||
WindowReload()
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export function WindowFullscreen() {
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export function WindowUnFullscreen() {
|
||||
export function WindowUnfullscreen() {
|
||||
window.WailsInvoke('Wf');
|
||||
}
|
||||
|
||||
@@ -187,10 +187,13 @@ export function WindowUnminimise() {
|
||||
* Sets the background colour of the window
|
||||
*
|
||||
* @export
|
||||
* @param {RGBA} RGBA background colour
|
||||
* @param {number} R Red
|
||||
* @param {number} G Green
|
||||
* @param {number} B Blue
|
||||
* @param {number} A Alpha
|
||||
*/
|
||||
export function WindowSetRGBA(RGBA) {
|
||||
let rgba = JSON.stringify(RGBA);
|
||||
export function WindowSetRGBA(R, G, B, A) {
|
||||
let rgba = JSON.stringify({r:R || 0, g:G || 0, b:B || 0, a:A || 255});
|
||||
window.WailsInvoke('Wr:' + rgba);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-10
@@ -8,14 +8,6 @@ export interface Size {
|
||||
h: number;
|
||||
}
|
||||
|
||||
export interface RGBA {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: number;
|
||||
}
|
||||
|
||||
|
||||
export interface runtime {
|
||||
EventsEmit(eventName: string, data?: any): void;
|
||||
|
||||
@@ -45,7 +37,7 @@ export interface runtime {
|
||||
|
||||
WindowFullscreen(): void;
|
||||
|
||||
WindowUnFullscreen(): void;
|
||||
WindowUnfullscreen(): void;
|
||||
|
||||
WindowSetSize(width: number, height: number): Promise<Size>;
|
||||
|
||||
@@ -73,7 +65,7 @@ export interface runtime {
|
||||
|
||||
WindowUnminimise(): void;
|
||||
|
||||
WindowSetRGBA(rgba: RGBA): void;
|
||||
WindowSetRGBA(R: number, G: number, B: number, A: number): void;
|
||||
|
||||
BrowserOpenURL(url: string): void;
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -52,8 +52,8 @@ export function WindowFullscreen() {
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export function WindowUnFullscreen() {
|
||||
window.runtime.WindowUnFullscreen();
|
||||
export function WindowUnfullscreen() {
|
||||
window.runtime.WindowUnfullscreen();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package messagedispatcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
@@ -32,7 +33,7 @@ type Client interface {
|
||||
WindowSetMinSize(width int, height int)
|
||||
WindowSetMaxSize(width int, height int)
|
||||
WindowFullscreen()
|
||||
WindowUnFullscreen()
|
||||
WindowUnfullscreen()
|
||||
WindowSetColour(colour int)
|
||||
DarkModeEnabled(callbackID string)
|
||||
SetApplicationMenu(menuJSON string)
|
||||
|
||||
@@ -3,11 +3,12 @@ package messagedispatcher
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/crypto"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
"github.com/wailsapp/wails/v2/internal/messagedispatcher/message"
|
||||
@@ -278,7 +279,7 @@ func (d *Dispatcher) processWindowMessage(result *servicebus.Message) {
|
||||
case "unfullscreen":
|
||||
// Notify clients
|
||||
for _, client := range d.clients {
|
||||
client.frontend.WindowUnFullscreen()
|
||||
client.frontend.WindowUnfullscreen()
|
||||
}
|
||||
case "setcolour":
|
||||
colour, ok := result.Data().(int)
|
||||
|
||||
@@ -2,11 +2,12 @@ package webserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
ws "nhooyr.io/websocket"
|
||||
"nhooyr.io/websocket/wsjson"
|
||||
@@ -150,8 +151,8 @@ func (wc *WebClient) WindowSetTitle(title string) {}
|
||||
// WindowFullscreen is a noop in the webclient
|
||||
func (wc *WebClient) WindowFullscreen() {}
|
||||
|
||||
// WindowUnFullscreen is a noop in the webclient
|
||||
func (wc *WebClient) WindowUnFullscreen() {}
|
||||
// WindowUnfullscreen is a noop in the webclient
|
||||
func (wc *WebClient) WindowUnfullscreen() {}
|
||||
|
||||
// WindowSetColour is a noop in the webclient
|
||||
func (wc *WebClient) WindowSetColour(colour int) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user