summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rhlibrary/player_widget.go85
1 files changed, 49 insertions, 36 deletions
diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go
index 4e62839..d88bbf6 100644
--- a/src/rhlibrary/player_widget.go
+++ b/src/rhlibrary/player_widget.go
@@ -33,12 +33,45 @@ import (
)
const (
- meterDBFloor float64 = 72 // -72 db is the lowest VU value
- meterSegments float64 = 30 // meter has 30 elements
- meterOffsetOrange float64 = 25
- meterOffsetRed float64 = 28
+ meterDBFloor float64 = 72 // -72 db is the lowest VU value
+ meterSegments float64 = 30 // meter has 30 elements
+
+ meterOffsetGreen float64 = meterSegments - 4
+ meterOffsetOrange float64 = meterSegments - 2
+ meterOffsetRed float64 = meterSegments - 1
+)
+
+var (
+ levelBarCss *gtk.CssProvider
)
+func init() {
+ var err error
+ if levelBarCss, err = gtk.CssProviderNew(); err != nil {
+ panic(err.Error())
+ }
+ err = levelBarCss.LoadFromData(`
+.level-bar {
+ -GtkLevelBar-min-block-width: 13;
+ -GtkLevelBar-min-block-height: 8;
+}
+.level-bar.fill-block.level-green {
+ border-color: #00AE00;
+ background-image: linear-gradient(to bottom, #36FF36, #00AE00);
+}
+.level-bar.fill-block.level-orange {
+ border-color: #AE6600;
+ background-image: linear-gradient(to bottom, #FFAC36, #AE6600);
+}
+.level-bar.fill-block.level-red {
+ border-color: #AE0000;
+ background-image: linear-gradient(to bottom, #FF3636, #AE0000);
+}`)
+ if err != nil {
+ panic(err.Error())
+ }
+}
+
func addPlayButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
var btn *gtk.Button
if btn, err = gtk.ButtonNewFromIconName("media-playback-start", gtk.ICON_SIZE_DIALOG); err != nil {
@@ -96,38 +129,18 @@ func createMeterBar() (bar *gtk.LevelBar, err error) {
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)
+ bar.RemoveOffsetValue(gtk.LEVEL_BAR_OFFSET_LOW)
+ bar.RemoveOffsetValue(gtk.LEVEL_BAR_OFFSET_HIGH)
+
+ var sc *gtk.StyleContext
+ if sc, err = bar.GetStyleContext(); err != nil {
+ return
+ }
+ sc.AddProvider(levelBarCss, 600) // TOOD: hardcoded value
+
+ bar.AddOffsetValue("green", meterOffsetGreen)
+ bar.AddOffsetValue("orange", meterOffsetOrange)
+ bar.AddOffsetValue("red", meterOffsetRed)
return
}