summaryrefslogtreecommitdiff
path: root/src/rhlibrary
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhlibrary')
-rw-r--r--src/rhlibrary/player_widget.go53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go
index 7da5a44..4e62839 100644
--- a/src/rhlibrary/player_widget.go
+++ b/src/rhlibrary/player_widget.go
@@ -33,8 +33,10 @@ import (
)
const (
- meterDBFloor float64 = 72 // -72 db is the lowest VU value
- meterSegments float64 = 30 // meter has 30 elements
+ meterDBFloor float64 = 72 // -72 db is the lowest VU value
+ meterSegments float64 = 30 // meter has 30 elements
+ meterOffsetOrange float64 = 25
+ meterOffsetRed float64 = 28
)
func addPlayButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
@@ -89,6 +91,47 @@ func calcMeterLevel(valdb float64) (val float64) {
return
}
+func createMeterBar() (bar *gtk.LevelBar, err error) {
+ if bar, err = gtk.LevelBarNewForInterval(0, meterSegments); err != nil {
+ return
+ }
+ bar.SetMode(gtk.LEVEL_BAR_MODE_DISCRETE)
+ bar.AddOffsetValue(gtk.LEVEL_BAR_OFFSET_LOW, meterOffsetOrange)
+ bar.AddOffsetValue(gtk.LEVEL_BAR_OFFSET_HIGH, meterOffsetRed)
+
+ // bar.RemoveOffsetValue(gtk.LEVEL_BAR_OFFSET_LOW)
+ // bar.RemoveOffsetValue(gtk.LEVEL_BAR_OFFSET_HIGH)
+
+ // var cp *gtk.CssProvider
+ // if cp, err = gtk.CssProviderNew(); err != nil {
+ // return
+ // }
+ // if err = cp.LoadFromData(`
+ // .level-bar.fill-block.level-green {
+ // background-color: green;
+ // }
+ // .level-bar.fill-block.level-orange {
+ // background-color: orange;
+ // }
+ // .level-bar.fill-block.level-red {
+ // background-color: red;
+ // }`); err != nil {
+ // return
+ // }
+
+ // var sc *gtk.StyleContext
+ // if sc, err = bar.GetStyleContext(); err != nil {
+ // return
+ // }
+ // sc.AddProvider(cp, 800) // TOOD: hardcoded value
+
+ // bar.AddOffsetValue("green", 0)
+ // bar.AddOffsetValue("orange", meterOffsetOrange)
+ // bar.AddOffsetValue("red", meterOffsetRed)
+
+ return
+}
+
func addMeter(grid *gtk.Grid, p *player.PlayerChan) (err error) {
var mgrid *gtk.Grid
if mgrid, err = gtk.GridNew(); err != nil {
@@ -98,14 +141,12 @@ func addMeter(grid *gtk.Grid, p *player.PlayerChan) (err error) {
mgrid.SetColumnSpacing(3)
var left, right *gtk.LevelBar
- if left, err = gtk.LevelBarNewForInterval(0, meterSegments); err != nil {
+ if left, err = createMeterBar(); err != nil {
return
}
- if right, err = gtk.LevelBarNewForInterval(0, meterSegments); err != nil {
+ if right, err = createMeterBar(); err != nil {
return
}
- left.SetMode(gtk.LEVEL_BAR_MODE_DISCRETE)
- right.SetMode(gtk.LEVEL_BAR_MODE_DISCRETE)
p.AddUpdateHandler(func(length time.Duration, pos time.Duration, meter player.Meter, userdata interface{}) bool {
glib.IdleAdd(func() {