AllenDang / giu

Cross platform rapid GUI framework for golang based on Dear ImGui.
MIT License
2.16k stars 128 forks source link

[bug] g.StyleColorWindowBg doesnt work? #736

Closed JunkMeal closed 6 months ago

JunkMeal commented 7 months ago

What happend?

I used setColor to g.StyleColorWindowBg and it didnt change

Code example

main.go ```golang package main import ( "image/color" g "github.com/AllenDang/giu" "golang.org/x/image/colornames" ) func loop() { g.SingleWindow().Layout( g.Style(). SetColor(g.StyleColorButton, color.RGBA{40, 40, 40, 255}). SetColor(g.StyleColorWindowBg, colornames.Deeppink). To( g.Button("Send").Size(g.Auto, 0), )) } func main() { wnd := g.NewMasterWindow("window", 1000, 600, 0) wnd.Run(loop) } ```

To Reproduce

  1. Run my demo
  2. no pink background

Version

master

OS

Arch Linux

gucio321 commented 6 months ago

in fact you are applying your style to a button, not a window. In this case you should either

giu.Style().SetColor(windowbg...).To(
   giu.Custom(func() {
      giu.WIndow().Layout(....)
   ),
)

or

giu.PushStyle(...)
/* add your window*/
giu.PopStyle()

Let me know if you didn't get it working!

gucio321 commented 6 months ago

Here is modified example

package main

import (
    g "github.com/AllenDang/giu"
    "golang.org/x/image/colornames"
)

var content string

func loop() {
    g.PushStyleColor(g.StyleColorWindowBg, colornames.Red)
    g.SingleWindow().Layout(
        g.Label("Hello world from giu"),
        g.InputTextMultiline(&content).Size(g.Auto, g.Auto),
    )
    g.PopStyleColor()
}

func main() {
    wnd := g.NewMasterWindow("Hello world", 400, 200, 0)
    wnd.Run(loop)
}