mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 20:03:01 +08:00
Support RGBA, fix compilation error
This commit is contained in:
parent
c5fb2b6143
commit
ac3808f9c3
@ -18,7 +18,6 @@ static inline void processDispatchID(gpointer id) {
|
||||
static void gtkDispatch(int id) {
|
||||
g_idle_add((GSourceFunc)processDispatchID, GINT_TO_POINTER(id));
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@ -205,6 +204,7 @@ func (f *Frontend) WindowSetRGBA(col *options.RGBA) {
|
||||
if col == nil {
|
||||
return
|
||||
}
|
||||
f.mainWindow.SetRGBA(col.R, col.G, col.B, col.A)
|
||||
}
|
||||
|
||||
func (f *Frontend) Quit() {
|
||||
@ -365,8 +365,11 @@ func (f *Frontend) processRequest(request unsafe.Pointer) {
|
||||
defer C.free(unsafe.Pointer(cContent))
|
||||
cMimeType := C.CString(mimeType)
|
||||
defer C.free(unsafe.Pointer(cMimeType))
|
||||
cLen := C.long(len(content))
|
||||
stream := C.g_memory_input_stream_new_from_data(unsafe.Pointer(C.g_strdup(cContent)), cLen, C.g_free)
|
||||
cLen := C.long(C.strlen(cContent))
|
||||
stream := C.g_memory_input_stream_new_from_data(
|
||||
unsafe.Pointer(C.g_strdup(cContent)),
|
||||
cLen,
|
||||
(*[0]byte)(C.g_free))
|
||||
C.webkit_uri_scheme_request_finish(req, stream, cLen, cMimeType)
|
||||
C.g_object_unref(C.gpointer(stream))
|
||||
}
|
||||
|
@ -380,6 +380,19 @@ GtkFileFilter* newFileFilter() {
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct RGBAOptions {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
void *webview;
|
||||
} RGBAOptions;
|
||||
|
||||
void setRGBA(gpointer* data) {
|
||||
RGBAOptions* options = (RGBAOptions*)data;
|
||||
GdkRGBA colour = {options->r / 255.0, options->g / 255.0, options->b / 255.0, options->a / 255.0};
|
||||
webkit_web_view_set_background_color(WEBKIT_WEB_VIEW(options->webview), &colour);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@ -446,6 +459,10 @@ func NewWindow(appoptions *options.App, debug bool) *Window {
|
||||
C.devtoolsEnabled(unsafe.Pointer(webview), C.int(1))
|
||||
}
|
||||
|
||||
// Set background colour
|
||||
RGBA := appoptions.RGBA
|
||||
result.SetRGBA(RGBA.R, RGBA.G, RGBA.B, RGBA.A)
|
||||
|
||||
// Setup window
|
||||
result.SetKeepAbove(appoptions.AlwaysOnTop)
|
||||
result.SetResizable(!appoptions.DisableResize)
|
||||
@ -557,17 +574,15 @@ func (w *Window) IsFullScreen() bool {
|
||||
}
|
||||
|
||||
func (w *Window) SetRGBA(r uint8, g uint8, b uint8, a uint8) {
|
||||
//C.SetRGBA(w.context, C.int(r), C.int(g), C.int(b), C.int(a))
|
||||
data := C.RGBAOptions{
|
||||
r: C.uchar(r),
|
||||
g: C.uchar(g),
|
||||
b: C.uchar(b),
|
||||
a: C.uchar(a),
|
||||
webview: w.webview,
|
||||
}
|
||||
C.ExecuteOnMainThread(C.setRGBA, C.gpointer(&data))
|
||||
|
||||
//func (w *Window) SetApplicationMenu(inMenu *menu.Menu) {
|
||||
// //mainMenu := NewNSMenu(w.context, "")
|
||||
// //processMenu(mainMenu, inMenu)
|
||||
// //C.SetAsApplicationMenu(w.context, mainMenu.nsmenu)
|
||||
//}
|
||||
|
||||
func (w *Window) UpdateApplicationMenu() {
|
||||
//C.UpdateApplicationMenu(w.context)
|
||||
}
|
||||
|
||||
func (w *Window) Run() {
|
||||
|
Loading…
Reference in New Issue
Block a user