Added support for label align in gauges.
This commit is contained in:
parent
3968b02432
commit
137d2a7eb2
@ -1,4 +1,4 @@
|
|||||||
# termui [](https://travis-ci.org/gizak/termui) [](https://godoc.org/github.com/gizak/termui)
|
# termui [](https://travis-ci.org/gizak/termui) [](https://godoc.org/github.com/gizak/termui)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -54,6 +54,7 @@ func main() {
|
|||||||
g3.Y = 11
|
g3.Y = 11
|
||||||
g3.Border.Label = "Gauge with custom label"
|
g3.Border.Label = "Gauge with custom label"
|
||||||
g3.Label = "{{percent}}% (100MBs free)"
|
g3.Label = "{{percent}}% (100MBs free)"
|
||||||
|
g3.Align = termui.AlignRight
|
||||||
|
|
||||||
termui.Render(g0, g1, g2, g3)
|
termui.Render(g0, g1, g2, g3)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 32 KiB |
30
gauge.go
30
gauge.go
@ -20,12 +20,24 @@ import (
|
|||||||
g.BarColor = termui.ColorRed
|
g.BarColor = termui.ColorRed
|
||||||
g.PercentColor = termui.ColorBlue
|
g.PercentColor = termui.ColorBlue
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Align is the position of the gauge's label.
|
||||||
|
type Align int
|
||||||
|
|
||||||
|
// All supported positions.
|
||||||
|
const (
|
||||||
|
AlignLeft Align = iota
|
||||||
|
AlignCenter
|
||||||
|
AlignRight
|
||||||
|
)
|
||||||
|
|
||||||
type Gauge struct {
|
type Gauge struct {
|
||||||
Block
|
Block
|
||||||
Percent int
|
Percent int
|
||||||
BarColor Attribute
|
BarColor Attribute
|
||||||
PercentColor Attribute
|
PercentColor Attribute
|
||||||
Label string
|
Label string
|
||||||
|
Align Align
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGauge return a new gauge with current theme.
|
// NewGauge return a new gauge with current theme.
|
||||||