mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 03:40:45 +08:00
* #1057 expose ZoomFactor get/set and add the respective windows only options * Remove debug log, use IsZoomControlEnabled as well * use math.float to/from 64bits functions instead * Add new windows options ZoomFactor and IsZoomControlEnabled doc * Grammar * Update options.mdx Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
parent
7effede62b
commit
f4adff1cb3
@ -55,6 +55,7 @@ func main() {
|
|||||||
DisableWindowIcon: false,
|
DisableWindowIcon: false,
|
||||||
// DisableFramelessWindowDecorations: false,
|
// DisableFramelessWindowDecorations: false,
|
||||||
WebviewUserDataPath: "",
|
WebviewUserDataPath: "",
|
||||||
|
ZoomFactor: 1.0,
|
||||||
},
|
},
|
||||||
// Mac platform specific options
|
// Mac platform specific options
|
||||||
Mac: &mac.Options{
|
Mac: &mac.Options{
|
||||||
|
@ -56,6 +56,8 @@ func main() {
|
|||||||
DisableWindowIcon: false,
|
DisableWindowIcon: false,
|
||||||
// DisableFramelessWindowDecorations: false,
|
// DisableFramelessWindowDecorations: false,
|
||||||
WebviewUserDataPath: "",
|
WebviewUserDataPath: "",
|
||||||
|
IsZoomControlEnabled: false,
|
||||||
|
ZoomFactor: float64,
|
||||||
},
|
},
|
||||||
Mac: &mac.Options{
|
Mac: &mac.Options{
|
||||||
TitleBar: &mac.TitleBar{
|
TitleBar: &mac.TitleBar{
|
||||||
|
@ -434,10 +434,19 @@ func (f *Frontend) setupChromium() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
err = settings.PutIsZoomControlEnabled(false)
|
|
||||||
|
|
||||||
|
if opts := f.frontendOptions.Windows; opts != nil {
|
||||||
|
if opts.ZoomFactor > 0.0 {
|
||||||
|
chromium.PutZoomFactor(opts.ZoomFactor)
|
||||||
|
}
|
||||||
|
err = settings.PutIsZoomControlEnabled(opts.IsZoomControlEnabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
err = settings.PutIsStatusBarEnabled(false)
|
err = settings.PutIsStatusBarEnabled(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package edge
|
package edge
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2/internal/w32"
|
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2/internal/w32"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
|
"math"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type _ICoreWebView2ControllerVtbl struct {
|
type _ICoreWebView2ControllerVtbl struct {
|
||||||
@ -130,3 +130,28 @@ func (i *ICoreWebView2Controller) NotifyParentWindowPositionChanged() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (i *ICoreWebView2Controller) PutZoomFactor(zoomFactor float64) error {
|
||||||
|
var err error
|
||||||
|
_, _, err = i.vtbl.PutZoomFactor.Call(
|
||||||
|
uintptr(unsafe.Pointer(i)),
|
||||||
|
uintptr(math.Float64bits(zoomFactor)),
|
||||||
|
)
|
||||||
|
if err != windows.ERROR_SUCCESS {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *ICoreWebView2Controller) GetZoomFactor() (float64, error) {
|
||||||
|
var err error
|
||||||
|
var zoomFactorUint64 uint64
|
||||||
|
_, _, err = i.vtbl.GetZoomFactor.Call(
|
||||||
|
uintptr(unsafe.Pointer(i)),
|
||||||
|
uintptr(unsafe.Pointer(&zoomFactorUint64)),
|
||||||
|
)
|
||||||
|
if err != windows.ERROR_SUCCESS {
|
||||||
|
return 0.0, err
|
||||||
|
}
|
||||||
|
return math.Float64frombits(zoomFactorUint64), nil
|
||||||
|
}
|
||||||
|
@ -372,3 +372,10 @@ func (e *Chromium) Focus() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Chromium) PutZoomFactor(zoomFactor float64) {
|
||||||
|
err := e.controller.PutZoomFactor(zoomFactor)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
@ -64,6 +64,9 @@ type Options struct {
|
|||||||
WindowIsTranslucent bool
|
WindowIsTranslucent bool
|
||||||
DisableWindowIcon bool
|
DisableWindowIcon bool
|
||||||
|
|
||||||
|
IsZoomControlEnabled bool
|
||||||
|
ZoomFactor float64
|
||||||
|
|
||||||
// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
|
// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
|
||||||
// "Rounded Corners" are only available on Windows 11.
|
// "Rounded Corners" are only available on Windows 11.
|
||||||
DisableFramelessWindowDecorations bool
|
DisableFramelessWindowDecorations bool
|
||||||
|
@ -42,6 +42,8 @@ func main() {
|
|||||||
WindowStartState: options.Maximised,
|
WindowStartState: options.Maximised,
|
||||||
CSSDragProperty: "--wails-draggable",
|
CSSDragProperty: "--wails-draggable",
|
||||||
CSSDragValue: "drag",
|
CSSDragValue: "drag",
|
||||||
|
ZoomFactor: 1.0,
|
||||||
|
IsZoomControlEnabled: false,
|
||||||
Bind: []interface{}{
|
Bind: []interface{}{
|
||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
@ -361,6 +363,21 @@ Indicates what value the `CSSDragProperty` style should have to drag the window.
|
|||||||
Name: CSSDragValue<br/>
|
Name: CSSDragValue<br/>
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|
||||||
|
### ZoomFactor
|
||||||
|
|
||||||
|
Name: ZoomFactor<br/>
|
||||||
|
Type: `float64`
|
||||||
|
|
||||||
|
This defines the zoom factor for the WebView2. This is the option matching the Edge user activated zoom in or out.
|
||||||
|
|
||||||
|
### IsZoomControlEnabled
|
||||||
|
|
||||||
|
Name: IsZoomControlEnabled<br/>
|
||||||
|
Type: `bool`
|
||||||
|
|
||||||
|
This enables the zoom factor to be changed by the user. Please note that the zoom factor can be set in the options while
|
||||||
|
disallowing the user to change it at runtime (f.e. for a kiosk application or similar).
|
||||||
|
|
||||||
### Bind
|
### Bind
|
||||||
|
|
||||||
A slice of struct instances defining methods that need to be bound to the frontend.
|
A slice of struct instances defining methods that need to be bound to the frontend.
|
||||||
|
Loading…
Reference in New Issue
Block a user