Initial commit
[fillmore] / src / marina / StatusBar.vala
1 /* Copyright 2009 Yorba Foundation
2  *
3  * This software is licensed under the GNU Lesser General Public License
4  * (version 2.1 or later).  See the COPYING file in this distribution. 
5  */
6
7 using Logging;
8
9 namespace View {
10 public class StatusBar : Gtk.DrawingArea {
11     Model.TimeSystem provider;
12     int64 current_position = 0;
13     
14     public StatusBar(Model.Project p, Model.TimeSystem provider, int height) {
15         set_flags(Gtk.WidgetFlags.NO_WINDOW);
16         modify_bg(Gtk.StateType.NORMAL, parse_color("#666"));
17         set_size_request(0, height);
18         
19         p.media_engine.position_changed.connect(on_position_changed);
20         this.provider = provider;
21     }
22     
23     public void on_position_changed(int64 new_position) {
24         emit(this, Facility.SIGNAL_HANDLERS, Level.INFO, "on_position_changed");
25         current_position = new_position;
26         queue_draw();
27     }
28     
29     public override bool expose_event(Gdk.EventExpose e) {
30         window.draw_rectangle(style.bg_gc[(int) Gtk.StateType.NORMAL], true, 
31                               allocation.x, allocation.y, allocation.width, allocation.height);  
32
33         string time = provider.get_time_string(current_position);
34
35         Pango.Layout layout = create_pango_layout(time);         
36         Gdk.draw_layout(window, style.white_gc, allocation.x + 4, allocation.y + 2, layout);
37                                 
38         return true;
39     }
40 }
41 }