segmented render time display
This commit is contained in:
@@ -30,18 +30,18 @@ func Text(format string, a ...interface{}) {
|
||||
// It also fills the background of the text with half-transparant black, and takes care of the padding.
|
||||
func TextBackground(format string, a ...interface{}) {
|
||||
pad := Vec2f(imgui.CurrentStyle().ItemSpacing())
|
||||
TextBackgroundV(itype.Vec4f{0, 0, 0, 0.5}, pad, format, a...)
|
||||
TextBackgroundV(PackedColor(itype.Vec4f{0, 0, 0, 0.5}), pad, format, a...)
|
||||
}
|
||||
|
||||
// TextBackgroundV wraps imgui.Text to create a shortcut for fmt.Sprintf.
|
||||
//
|
||||
// It also fills the background of the text with the given color.
|
||||
func TextBackgroundV(color itype.Vec4f, padding itype.Vec2f, format string, a ...interface{}) {
|
||||
func TextBackgroundV(color imgui.PackedColor, padding itype.Vec2f, format string, a ...interface{}) {
|
||||
text := fmt.Sprintf(format, a...)
|
||||
orig := imgui.CursorScreenPos()
|
||||
size := imgui.CalcTextSize(text, false, 0)
|
||||
halfpad := padding.Multiply(0.5)
|
||||
imgui.BackgroundDrawList().AddRectFilledV(orig.Minus(Vec2(halfpad)), orig.Plus(size).Plus(Vec2(halfpad)), PackedColor(color), 0, 0)
|
||||
imgui.BackgroundDrawList().AddRectFilledV(orig.Minus(Vec2(halfpad)), orig.Plus(size).Plus(Vec2(halfpad)), color, 0, 0)
|
||||
|
||||
imgui.Text(text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user