Skip to content

Commit

Permalink
Add BgColor setter to RowWidget.
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDang committed Jan 23, 2021
1 parent ce90674 commit 809022c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -1609,16 +1609,23 @@ type RowWidget struct {
flags imgui.TableRowFlags
minRowHeight float64
layout Layout
bgColor *color.RGBA
}

func Row(widgets ...Widget) *RowWidget {
return &RowWidget{
flags: 0,
minRowHeight: 0,
layout: widgets,
bgColor: nil,
}
}

func (r *RowWidget) BgColor(c *color.RGBA) *RowWidget {
r.bgColor = c
return r
}

func (r *RowWidget) Flags(flags imgui.TableRowFlags) *RowWidget {
r.flags = flags
return r
Expand All @@ -1642,6 +1649,10 @@ func (r *RowWidget) Build() {
}
w.Build()
}

if r.bgColor != nil {
imgui.TableSetBgColor(imgui.TableBgTarget_RowBg0, uint32(imgui.GetColorU32(ToVec4Color(*(r.bgColor)))), -1)
}
}

type Rows []*RowWidget
Expand Down
3 changes: 3 additions & 0 deletions examples/hugelist/hugelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"image/color"

g "github.com/AllenDang/giu"
)
Expand All @@ -20,6 +21,8 @@ func buildRows() []*g.RowWidget {
)
}

rows[0].BgColor(&(color.RGBA{200, 100, 100, 255}))

return rows
}

Expand Down

0 comments on commit 809022c

Please sign in to comment.