~tintou/gala/hidpi

« back to all changes in this revision

Viewing changes to plugins/notify/ConfirmationNotification.vala

  • Committer: Corentin Noël
  • Date: 2016-12-18 21:19:40 UTC
  • Revision ID: corentin@elementary.io-20161218211940-w6xr4jehc5a7ja0w
[HiDPI] Notifications are now working

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
                public override void update_allocation (out float content_height, AllocationFlags flags)
57
57
                {
58
 
                        content_height = ICON_SIZE;
 
58
                        content_height = ICON_SIZE * style_context.get_scale ();
59
59
                }
60
60
 
61
61
                public override void draw_content (Cairo.Context cr)
63
63
                        if (!has_progress)
64
64
                                return;
65
65
 
66
 
                        var x = MARGIN + PADDING + ICON_SIZE + SPACING;
67
 
                        var y = MARGIN + PADDING + (ICON_SIZE - PROGRESS_HEIGHT) / 2;
68
 
                        var width = WIDTH - x - MARGIN;
 
66
                        var scale = style_context.get_scale ();
 
67
                        var scaled_width = WIDTH * scale;
 
68
                        var scaled_margin = MARGIN * scale;
 
69
                        var scaled_padding = PADDING * scale;
 
70
                        var scaled_icon_size = ICON_SIZE * scale;
 
71
                        var scaled_spacing = SPACING * scale;
 
72
                        var scaled_progress_height = PROGRESS_HEIGHT * scale;
 
73
                        var x = scaled_margin + scaled_padding + scaled_icon_size + scaled_spacing;
 
74
                        var y = scaled_margin + scaled_padding + (scaled_icon_size - scaled_progress_height) / 2;
 
75
                        var width = scaled_width - x - scaled_margin;
69
76
 
70
77
                        if (!transitioning)
71
78
                                draw_progress_bar (cr, x, y, width, progress);
72
79
                        else {
73
 
                                Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, MARGIN, MARGIN, WIDTH - MARGIN * 2, ICON_SIZE + PADDING * 2, 4);
 
80
                                Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, scaled_margin, scaled_margin, scaled_width - scaled_margin * 2, scaled_icon_size + scaled_padding * 2, 4);
74
81
                                cr.clip ();
75
82
 
76
83
                                draw_progress_bar (cr, x, y + animation_slide_y_offset, width, old_progress);
82
89
 
83
90
                void draw_progress_bar (Cairo.Context cr, int x, float y, int width, int progress)
84
91
                {
 
92
                        var scale = style_context.get_scale ();
85
93
                        var fraction = (int) Math.floor (progress.clamp (0, 100) / 100.0 * width);
86
94
 
 
95
                        var scaled_height = PROGRESS_HEIGHT * scale;
87
96
                        Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, x, y, width,
88
 
                                PROGRESS_HEIGHT, PROGRESS_HEIGHT / 2);
 
97
                                scaled_height, scaled_height / 2);
89
98
                        cr.set_source_rgb (0.8, 0.8, 0.8);
90
99
                        cr.fill ();
91
100
 
92
101
                        if (progress > 0) {
93
102
                                Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, x, y, fraction,
94
 
                                        PROGRESS_HEIGHT, PROGRESS_HEIGHT / 2);
 
103
                                        scaled_height, scaled_height / 2);
95
104
                                cr.set_source_rgb (0.3, 0.3, 0.3);
96
105
                                cr.fill ();
97
106
                        }
111
120
 
112
121
                                old_progress = this.progress;
113
122
 
114
 
                                play_update_transition (ICON_SIZE + PADDING * 2);
 
123
                                play_update_transition ((ICON_SIZE + PADDING * 2) * style_context.get_scale ());
115
124
                        }
116
125
 
117
126
                        if (this.icon_only != icon_only) {