summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rhlibrary/app_window.go25
-rw-r--r--src/rhlibrary/player_widget.go66
-rw-r--r--src/rhlibrary/selector_widget.go2
-rw-r--r--src/rhlibrary/vumeter_widget.go6
4 files changed, 83 insertions, 16 deletions
diff --git a/src/rhlibrary/app_window.go b/src/rhlibrary/app_window.go
index fe4dda8..cf1a97a 100644
--- a/src/rhlibrary/app_window.go
+++ b/src/rhlibrary/app_window.go
@@ -81,13 +81,32 @@ func NewAppWindow(player *player.PlayerChan, width, height int) (aw *AppWindow,
}
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
- if err = aw.drawSelector(grid); err != nil {
+ if err = aw.drawPlayer(grid); err != nil {
return
}
- if err = aw.drawPlayer(grid); err != nil {
+ if err = aw.drawSelector(grid); err != nil {
return
}
- aw.win.Add(grid)
+
+ var frame *gtk.Frame
+ if frame, err = gtk.FrameNew(""); err != nil {
+ return nil, err
+ }
+ var cp *gtk.CssProvider
+ if cp, err = gtk.CssProviderNew(); err != nil {
+ return nil, err
+ }
+ if err = cp.LoadFromData(".frame { border: 0px; padding: 15px; }"); err != nil {
+ return nil, err
+ }
+ var sc *gtk.StyleContext
+ if sc, err = frame.GetStyleContext(); err != nil {
+ return nil, err
+ }
+ sc.AddProvider(cp, 600) // TOOD: hardcoded value
+
+ frame.Add(grid)
+ aw.win.Add(frame)
aw.win.SetDefaultSize(width, height)
return
diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go
index 5440582..032d1b2 100644
--- a/src/rhlibrary/player_widget.go
+++ b/src/rhlibrary/player_widget.go
@@ -25,7 +25,10 @@
package main
import (
+ "time"
+
"code.helsinki.at/rhrd-go/player"
+ "github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
)
@@ -39,7 +42,7 @@ func addPlayButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
rhdl.Println(err) // TODO: feedback at GUI?
}
})
- grid.Add(btn)
+ grid.Attach(btn, 1, 1, 1, 2)
return
}
@@ -53,7 +56,7 @@ func addPauseButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
rhdl.Println(err) // TODO: feedback at GUI?
}
})
- grid.Add(btn)
+ grid.Attach(btn, 2, 1, 1, 2)
return
}
@@ -67,16 +70,55 @@ func addStopButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
rhdl.Println(err) // TODO: feedback at GUI?
}
})
- grid.Add(btn)
+ grid.Attach(btn, 3, 1, 1, 2)
return
}
func addMeter(grid *gtk.Grid, p *player.PlayerChan) error {
widget, err := getVUMeterWidget(p)
- if err == nil {
- grid.Add(widget)
+ if err != nil {
+ return err
+ }
+ grid.Attach(widget, 4, 1, 1, 1)
+ return nil
+}
+
+func addScrubber(grid *gtk.Grid, p *player.PlayerChan) (err error) {
+ var scale *gtk.Scale
+ if scale, err = gtk.ScaleNew(gtk.ORIENTATION_HORIZONTAL, nil); err != nil {
+ return
}
- return err
+ if err = scale.SetProperty("draw-value", false); err != nil {
+ return
+ }
+ scale.SetRange(0, 1)
+ scale.SetValue(0)
+
+ p.AddUpdateHandler(func(length time.Duration, pos time.Duration, meter player.Meter, userdata interface{}) bool {
+ glib.IdleAdd(func() { scale.SetValue(float64(pos) / float64(length)) })
+ return true
+ }, nil)
+
+ grid.Attach(scale, 4, 2, 2, 1)
+ return
+}
+
+func addPlayTime(grid *gtk.Grid, p *player.PlayerChan) (err error) {
+ var label *gtk.Label
+ if label, err = gtk.LabelNew("00:00:00.0"); err != nil {
+ return err
+ }
+
+ p.AddUpdateHandler(func(length time.Duration, pos time.Duration, meter player.Meter, userdata interface{}) bool {
+ glib.IdleAdd(func() {
+ t := time.Unix(0, 0).UTC().Add(pos)
+ label.SetText(t.Format("15:04:05.0"))
+ })
+ return true
+ }, nil)
+
+ grid.Attach(label, 5, 1, 1, 1)
+ return nil
}
func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) {
@@ -100,11 +142,13 @@ func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) {
if err = addMeter(grid, p); err != nil {
return nil, err
}
-
- var frame *gtk.Frame
- if frame, err = gtk.FrameNew("player"); err != nil {
+ if err = addScrubber(grid, p); err != nil {
+ return nil, err
+ }
+ if err = addPlayTime(grid, p); err != nil {
return nil, err
}
- frame.Add(grid)
- return frame, nil
+
+ grid.SetHAlign(gtk.ALIGN_CENTER)
+ return grid, nil
}
diff --git a/src/rhlibrary/selector_widget.go b/src/rhlibrary/selector_widget.go
index 939551a..d571e3d 100644
--- a/src/rhlibrary/selector_widget.go
+++ b/src/rhlibrary/selector_widget.go
@@ -73,5 +73,7 @@ func getSelectorWidget(p *player.PlayerChan) (gtk.IWidget, error) {
grid.SetHExpand(true)
grid.SetVExpand(true)
+ grid.SetHAlign(gtk.ALIGN_CENTER)
+ grid.SetVAlign(gtk.ALIGN_CENTER)
return grid, nil
}
diff --git a/src/rhlibrary/vumeter_widget.go b/src/rhlibrary/vumeter_widget.go
index 35586fa..afffbf5 100644
--- a/src/rhlibrary/vumeter_widget.go
+++ b/src/rhlibrary/vumeter_widget.go
@@ -55,8 +55,8 @@ func getMeterBarCSS() (*gtk.CssProvider, error) {
}
err = meterBarCSS.LoadFromData(`
.level-bar {
- -GtkLevelBar-min-block-width: 13;
- -GtkLevelBar-min-block-height: 8;
+ -GtkLevelBar-min-block-width: 17;
+ -GtkLevelBar-min-block-height: 10;
}
.level-bar.trough {
border: 0;
@@ -202,6 +202,8 @@ func addVUMeterGrid(frame *gtk.Frame, p *player.PlayerChan) (err error) {
grid.Attach(right.orange, 2, 2, 1, 1)
grid.Attach(right.red, 3, 2, 1, 1)
+ grid.SetRowHomogeneous(true)
+
frame.Add(grid)
return
}