giu icon indicating copy to clipboard operation
giu copied to clipboard

[bug] StyleColorPlotLines has no effect on a Plot

Open hirikilabs opened this issue 1 year ago • 3 comments

What happend?

Applying a SetColor with StyleColorPlotLines to a Plot with a Line, results in the line plot drawn in the default color. Any other color change in the same Style() call (border, background...) works normaly.

Code example

main.go
g.SingleWindow().Layout(
		g.Style().
			SetColor(g.StyleColorBorder, color.RGBA{250, 100, 100, 255}).
			SetColor(g.StyleColorPlotLines, color.RGBA{250, 100, 100, 255}).
			To(
				g.Plot("Plot 1").AxisLimits(0, 128, -1.2, 1.2, g.ConditionOnce).Plots(
					g.Line("Kaixo", buffer[:]),
				),
			),
	)

To Reproduce

  1. Run the demo code
  2. Line Plot will be drawn in the default bluish color instead of the red color provided

Version

(latest)

OS

Debian Sid

hirikilabs avatar Aug 29 '24 13:08 hirikilabs

ok, let me take a look just btw, there was some reason why I wrote in #392 that we want the whole main.go.

main.go
package main

import (
	"slices"

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

var buffer = slices.Repeat([]float64{0, 1}, 8)

func loop() {
	giu.SingleWindow().Layout(
		giu.Style().
			SetColor(giu.StyleColorBorder, colornames.Yellow).
			SetColor(giu.StyleColorPlotLines, colornames.Red).
			To(
				giu.Plot("Plot 1").AxisLimits(0, 128, -1.2, 1.2, giu.ConditionOnce).Plots(
					giu.Line("Kaixo", buffer[:]),
				),
			),
	)
}

func main() {
	wnd := giu.NewMasterWindow("Style for PlotLine [debug,issue-847]", 800, 600, 0)
	wnd.Run(loop)
}

gucio321 avatar Sep 17 '24 17:09 gucio321

well, I see: giu.StyleColorPlotLines is a link to cimgui.ColPlotLine which does... IDK what it does but it does not change color of plot lines in implot (that makes sense as it comes from imgui not implot). The correct link should be cimgui.PloColLine

gucio321 avatar Sep 17 '24 17:09 gucio321

I've noticed one more thing: cimgui.PlotCol cannot be used in cimgui.PushStyleColor* but in cimgui.PlotPushStyleCol* this will force giu to implement additional features here.

We need to decide wheather we want to put all styles together (StyleSetter will figure out which method should it use) or make separated StyleSetter's method for Plot styles and add another PlotStyleColor enum. @AllenDang what do you think?

gucio321 avatar Sep 17 '24 17:09 gucio321