mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 03:09:17 +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,
|
||||
// DisableFramelessWindowDecorations: false,
|
||||
WebviewUserDataPath: "",
|
||||
ZoomFactor: 1.0,
|
||||
},
|
||||
// Mac platform specific options
|
||||
Mac: &mac.Options{
|
||||
|
@ -56,6 +56,8 @@ func main() {
|
||||
DisableWindowIcon: false,
|
||||
// DisableFramelessWindowDecorations: false,
|
||||
WebviewUserDataPath: "",
|
||||
IsZoomControlEnabled: false,
|
||||
ZoomFactor: float64,
|
||||
},
|
||||
Mac: &mac.Options{
|
||||
TitleBar: &mac.TitleBar{
|
||||
|
@ -434,10 +434,19 @@ func (f *Frontend) setupChromium() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = settings.PutIsZoomControlEnabled(false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
|
||||
if opts := f.frontendOptions.Windows; opts != nil {
|
||||
if opts.ZoomFactor > 0.0 {
|
||||
chromium.PutZoomFactor(opts.ZoomFactor)
|
||||
}
|
||||
err = settings.PutIsZoomControlEnabled(opts.IsZoomControlEnabled)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
err = settings.PutIsStatusBarEnabled(false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package edge
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2/internal/w32"
|
||||
"golang.org/x/sys/windows"
|
||||
"math"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type _ICoreWebView2ControllerVtbl struct {
|
||||
@ -130,3 +130,28 @@ func (i *ICoreWebView2Controller) NotifyParentWindowPositionChanged() error {
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
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.
|
||||
// "Rounded Corners" are only available on Windows 11.
|
||||
DisableFramelessWindowDecorations bool
|
||||
|
@ -42,6 +42,8 @@ func main() {
|
||||
WindowStartState: options.Maximised,
|
||||
CSSDragProperty: "--wails-draggable",
|
||||
CSSDragValue: "drag",
|
||||
ZoomFactor: 1.0,
|
||||
IsZoomControlEnabled: false,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
@ -361,6 +363,21 @@ Indicates what value the `CSSDragProperty` style should have to drag the window.
|
||||
Name: CSSDragValue<br/>
|
||||
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
|
||||
|
||||
A slice of struct instances defining methods that need to be bound to the frontend.
|
||||
|
Loading…
Reference in New Issue
Block a user