* First GUI prototype
[jackpanel.git] / jackpanel / Jackpanel.vala
blobcd2932e36d1ffa746411c78191f89eebe13f9e82
1 using Gtk;
2 using Gdk;
3 using Prolooks;
5 namespace Jackpanel {
7 public class Display : DisplayBase {
8 private string _time;
9 public string time { get { return _time; } set { _time = value; queue_draw (); } }
11 private int inner_height;
13 Display () {
14 width = 182;
15 height = 49;
16 inner_height = height - 13;
17 _time = "00:00:00";
18 set_size_request (width, height);
21 protected override bool draw_contents (Cairo.Context cr, Gdk.EventExpose event) {
22 double x = 32;
23 double y = 16;
24 text(cr, _time, x, y, 16);
25 Cairo.TextExtents ext = Cairo.TextExtents();
26 cr.text_extents (_time, ref ext);
28 Color line_color;
29 Color.parse (text_color_default, out line_color);
30 set_source_from_color (cr, line_color, 0.5);
33 cr.move_to (x, y + ext.y_bearing);
34 cr.rel_line_to (0, ext.height);
35 cr.stroke();
37 cr.move_to (x + ext.x_advance + ext.x_bearing, y + ext.y_bearing);
38 cr.rel_line_to (0, ext.height);
39 cr.stroke();
42 cr.move_to (3, inner_height - 13);
43 cr.rel_line_to (width - 20, 0);
44 cr.stroke();
45 return false;
49 public class Jackpanel : Alignment {
51 Jackpanel () {
52 var table = new Table (5, 2, false);
53 var display = new Display ();
54 var to_start = new TransportButton (TransportButton.IconType.TO_START);
55 to_start.height = 20;
56 to_start.width = 31;
58 var fast_backward = new TransportButton (TransportButton.IconType.FAST_BACKWARD);
59 fast_backward.height = 20;
60 fast_backward.width = 31;
62 var play = new TransportButton (TransportButton.IconType.PLAY);
63 play.height = 20;
64 play.width = 31;
66 var stop = new TransportButton (TransportButton.IconType.STOP);
67 stop.height = 20;
68 stop.width = 31;
70 var fast_forward = new TransportButton (TransportButton.IconType.FAST_FORWARD);
71 fast_forward.height = 20;
72 fast_forward.width = 31;
74 table.attach_defaults (display, 0, 5, 0, 1);
76 table.attach_defaults (to_start, 0, 1, 1, 2);
77 table.attach_defaults (fast_backward, 1, 2, 1, 2);
78 table.attach_defaults (fast_forward, 2, 3, 1, 2);
79 table.attach_defaults (stop, 3, 4, 1, 2);
80 table.attach_defaults (play, 4, 5, 1, 2);
82 table.set_col_spacing (0, 4);
83 table.set_col_spacing (1, 4);
84 table.set_col_spacing (2, 10);
85 table.set_col_spacing (3, 4);
87 add (table);
90 static int main (string[] args) {
91 Gtk.init (ref args);
92 var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
93 var panel = new Jackpanel ();
94 window.add (panel);
95 window.destroy += Gtk.main_quit;
96 window.show_all ();
97 Gtk.main ();
98 return 0;
102 } //namespace Jackpanel