summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-21 16:30:29 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-21 16:30:29 (GMT)
commit72b2dba087486bf0c2406ad1e7c3b22917bb02e6 (patch)
tree3a56315cf3fb794bb1ac8b8b5f0fe2ee97471a0d /src
parentdcd973603f916c8f47f908c2fb628e4219c42cb2 (diff)
vumeter cont'd
Diffstat (limited to 'src')
-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() {