mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-08-25 16:35:07 +03:00
Merge pull request #31 from RiV-chain/go-webview-selector
Go webview selector
This commit is contained in:
commit
ea969b4792
7 changed files with 90 additions and 15 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/RiV-chain/RiV-mesh/src/defaults"
|
||||
"github.com/jchv/go-webview-selector"
|
||||
|
||||
"github.com/docopt/docopt-go"
|
||||
)
|
||||
|
@ -37,10 +36,10 @@ func main() {
|
|||
Console(false)
|
||||
}
|
||||
debug := true
|
||||
w := webview.New(debug)
|
||||
w := New(debug)
|
||||
defer w.Destroy()
|
||||
w.SetTitle("RiV-mesh")
|
||||
w.SetSize(690, 920, webview.HintFixed)
|
||||
w.SetSize(690, 920, HintFixed)
|
||||
|
||||
if confui.IndexHtml == "" {
|
||||
confui.IndexHtml = defaults.GetHttpEndpoint("http://localhost:19019")
|
||||
|
|
|
@ -3,5 +3,39 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/webview/webview"
|
||||
)
|
||||
|
||||
func Console(show bool) {
|
||||
}
|
||||
|
||||
type WebView = webview.WebView
|
||||
|
||||
type Hint = webview.Hint
|
||||
|
||||
const (
|
||||
// HintNone specifies that width and height are default size
|
||||
HintNone Hint = iota
|
||||
|
||||
// HintFixed specifies that window size can not be changed by a user
|
||||
HintFixed
|
||||
|
||||
// HintMin specifies that width and height are minimum bounds
|
||||
HintMin
|
||||
|
||||
// HintMax specifies that width and height are maximum bounds
|
||||
HintMax
|
||||
)
|
||||
|
||||
// New creates a new webview in a new window.
|
||||
func New(debug bool) WebView {
|
||||
return webview.New(debug)
|
||||
}
|
||||
|
||||
// NewWindow creates a new webview using an existing window.
|
||||
func NewWindow(debug bool, window unsafe.Pointer) WebView {
|
||||
return webview.NewWindow(debug, window)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ package main
|
|||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/jchv/go-webview2"
|
||||
)
|
||||
|
||||
func Console(show bool) {
|
||||
|
@ -22,3 +25,40 @@ func Console(show bool) {
|
|||
showWin.Call(hwnd, SW_HIDE)
|
||||
}
|
||||
}
|
||||
|
||||
type WebView = webview2.WebView
|
||||
|
||||
type Hint = webview2.Hint
|
||||
|
||||
const (
|
||||
// HintNone specifies that width and height are default size
|
||||
HintNone Hint = iota
|
||||
|
||||
// HintFixed specifies that window size can not be changed by a user
|
||||
HintFixed
|
||||
|
||||
// HintMin specifies that width and height are minimum bounds
|
||||
HintMin
|
||||
|
||||
// HintMax specifies that width and height are maximum bounds
|
||||
HintMax
|
||||
)
|
||||
|
||||
// New creates a new webview in a new window.
|
||||
func New(debug bool) WebView {
|
||||
//return webview2.New(debug)
|
||||
return webview2.NewWithOptions(webview2.WebViewOptions{
|
||||
Debug: debug,
|
||||
WindowOptions: webview2.WindowOptions{
|
||||
IconId: 101,
|
||||
Title: "RiV-mesh",
|
||||
Width: 706,
|
||||
Height: 960,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// NewWindow creates a new webview using an existing window.
|
||||
func NewWindow(debug bool, window unsafe.Pointer) WebView {
|
||||
return webview2.NewWindow(debug, window)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue