~gotwig/gazette/global-service-states

« back to all changes in this revision

Viewing changes to lib/ShadowedLabel.vala

  • Committer: Santiago Ocamica
  • Date: 2013-07-19 22:30:09 UTC
  • Revision ID: santi6982@gmail.com-20130719223009-2t8rkv5ikw84iy2g
Many many changes, introduces some API changes and personalizable widgets, the text size, color and font are now standarized and changeable through dconf (I'll add the options to the plug when I find the time)

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
public class ShadowedLabel : Actor {
25
25
    Granite.Drawing.BufferSurface buffer;
26
26
 
 
27
    string text_color;
 
28
    string shadow_color;
 
29
 
27
30
    string _label = "";
28
31
    public string label {
29
32
        get {
43
46
        }
44
47
    }
45
48
 
46
 
    public ShadowedLabel (string _label) {
 
49
    public ShadowedLabel (string _label, string text_color = "white", string shadow_color = "black") {
 
50
        this.text_color = text_color;
 
51
        this.shadow_color = shadow_color;
47
52
        content = new Canvas ();
48
53
        (content as Canvas).draw.connect (draw);
49
54
 
54
59
    }
55
60
 
56
61
    bool draw (Cairo.Context cr) {
 
62
 
 
63
        Gdk.RGBA _text_color = new Gdk.RGBA();
 
64
        _text_color.parse(text_color);
 
65
        Gdk.RGBA _shadow_color = new Gdk.RGBA();
 
66
        _shadow_color.parse(shadow_color);
 
67
 
57
68
        cr.set_operator (Cairo.Operator.CLEAR);
58
69
        cr.paint ();
59
70
        cr.set_operator (Cairo.Operator.OVER);
63
74
        layout.set_markup (label, -1);
64
75
 
65
76
        buffer.context.move_to (0, 1);
66
 
        buffer.context.set_source_rgba (0, 0, 0, 1);
 
77
        buffer.context.set_source_rgba (_shadow_color.red, _shadow_color.green,
 
78
            _shadow_color.blue, _shadow_color.alpha);
67
79
        Pango.cairo_show_layout (buffer.context, layout);
68
80
        buffer.exponential_blur (3);
69
81
 
70
82
        buffer.context.move_to (0, 0);
71
 
        buffer.context.set_source_rgba (1, 1, 1, 1);
 
83
        buffer.context.set_source_rgba (_text_color.red, _text_color.green,
 
84
            _text_color.blue, _text_color.alpha);
72
85
        Pango.cairo_show_layout (buffer.context, layout);
73
86
 
74
87
        cr.set_source_surface (buffer.surface, 0, 0);
79
92
}
80
93
public class ShadowedLink : ShadowedLabel {
81
94
    string uri;
82
 
    public ShadowedLink (string label, string uri) {
83
 
        base (label);
 
95
    public ShadowedLink (string label, string uri, string text_color = "white", string shadow_color = "black") {
 
96
        base (label, text_color, shadow_color);
84
97
        this.uri = uri;
85
98
        reactive = true;
86
99
        button_release_event.connect (on_click);