giu: [bug] Kind a glitch of desktop background from widgets when the main window has a transparent color

What happend?

Hey there,

i’m not 100% sure if this is a bug, but i want to create a main window with a slight transparent color. I did the following:

  • Created a new main window with the flag g.MasterWindowFlagsTransparent
  • Set the main window background color to something transparent like wnd.SetBgColor(color.RGBA{A: 175})
  • Create a window with some widgets
  • Then, the background behind the actual main window will kinda glitch through the created window (see following image as reference)

grafik

I’ll added the code that i used to take the screenshot to reproduce/test.

Any ideas to fix this issue?

Kind regards

Code example

main.go
package main

import (
	g "github.com/AllenDang/giu"
	"image/color"
)

var (
	foo  string
	foo2 bool
)

func loop() {
	//Render one window
	g.Window("Test window").Layout(
		g.Label("Hello World! I'm a label"),
		g.Selectable("Hello World! I'm a selectable"),
		g.InputText(&foo).Hint("You can enter something here..."),
		g.Checkbox("Check me!", &foo2),
		g.Button("Press me!"),
		g.RadioButton("One lonely radio button!", foo2),

		g.Table().Columns(
			g.TableColumn("Col1"),
			g.TableColumn("Col2"),
			g.TableColumn("Col3"),
		).Rows(
			g.TableRow(
				g.Label("Row1"),
				g.Label("Row1"),
				g.Label("Row1"),
			),
			g.TableRow(
				g.Label("Row2"),
				g.Label("Row2"),
				g.Label("Row2"),
			),
			g.TableRow(
				g.Label("Row3"),
				g.Label("Row3"),
				g.Label("Row3"),
			),
		).Size(400, 200),

		g.Child().Layout(
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
			g.Checkbox("Checkbox inside a child!", &foo2),
		).Size(200, 100),
	)

	//Render another window
	g.Window("I have no focus").Size(200, 100).Layout(
		g.Checkbox("I'm a checkbox!", &foo2),
	)
}

func main() {
	//Main window (set flag transparent, otherwise transparent color will not work)
	wnd := g.NewMasterWindow("Hello World!", 800, 600, g.MasterWindowFlagsTransparent)

	//Set main window slightly transparent
	wnd.SetBgColor(color.RGBA{A: 175})

	wnd.Run(loop)
}

To Reproduce

  1. Run my demo
  2. You should see the same as my screenshot (if ur background is green 😄)

Version

master (v0.6.2)

OS

Windows 11 Go 1.18

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 29 (6 by maintainers)

Most upvoted comments

Thank you now we are sure that there is something wrong with giu/imgui-go. @AllenDang needs to investigate it

Hey @gucio321 , i now found some time to hang on this and I was finally able to rebuild this in the plain c imgui (i used a main window bg-color with rgba: 0 0 0 128): grafik

The mentioned issues above are not occuring in plain imgui, so my guess this is a giu related issue.

Hi, are there any news at this? @AllenDang or @gucio321 ? Or did you already found an solution @SeyRyuu ? I also want to create a transparent main window and facing the same problems.

PS: I am fairly new at github, so i hope it is okay to comment in this thread.