~ubuntu-branches/ubuntu/karmic/edubuntu-artwork/karmic

« back to all changes in this revision

Viewing changes to art/usplash/usplash-theme-edubuntu.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2006-09-11 15:12:25 UTC
  • Revision ID: james.westby@ubuntu.com-20060911151225-n4q8em8lfd1grqfd
Tags: 0.1.0-34
new usplash artwork (not final yet)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* usplash
 
2
 *
 
3
 * eft-theme.c - definition of eft theme
 
4
 *
 
5
 * Copyright © 2006 Dennis Kaarsemaker <dennis@kaarsemaker.net>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
20
 */
 
21
 
 
22
#include <usplash-theme.h>
 
23
/* Needed for the custom drawing functions */
 
24
#include <usplash_backend.h>
 
25
 
 
26
extern struct usplash_pixmap pixmap_usplash_800_600, pixmap_usplash_1024_768, pixmap_usplash_1365_768_scaled;
 
27
extern struct usplash_pixmap pixmap_throbber_back;
 
28
extern struct usplash_pixmap pixmap_throbber_fore;
 
29
 
 
30
void t_init(struct usplash_theme* theme);
 
31
void t_clear_progressbar(struct usplash_theme* theme);
 
32
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
 
33
void t_animate_step(struct usplash_theme* theme, int pulsating);
 
34
 
 
35
struct usplash_theme usplash_theme_1024_768;
 
36
struct usplash_theme usplash_theme_1365_768_scaled;
 
37
 
 
38
/* Theme definition */
 
39
struct usplash_theme usplash_theme = {
 
40
        .version = THEME_VERSION, /* ALWAYS set this to THEME_VERSION, 
 
41
                                 it's a compatibility check */
 
42
    .next = &usplash_theme_1024_768,
 
43
    .ratio = USPLASH_4_3,
 
44
 
 
45
        /* Background and font */
 
46
        .pixmap = &pixmap_usplash_800_600,
 
47
 
 
48
        /* Palette indexes */
 
49
        .background             = 0x0,
 
50
        .progressbar_background = 0x7,
 
51
        .progressbar_foreground = 0x156,
 
52
        .text_background        = 0x0,
 
53
        .text_foreground        = 0x15,
 
54
        .text_success           = 0x33,
 
55
        .text_failure           = 0x144,
 
56
 
 
57
        /* Progress bar position and size in pixels */
 
58
        .progressbar_x      = 292, /* 800/2-216/2 */
 
59
        .progressbar_y      = 371,
 
60
        .progressbar_width  = 216,
 
61
        .progressbar_height = 8,
 
62
 
 
63
        /* Text box position and size in pixels */
 
64
        .text_x      = 120,
 
65
        .text_y      = 307,
 
66
        .text_width  = 360,
 
67
        .text_height = 100,
 
68
 
 
69
        /* Text details */
 
70
        .line_height  = 15,
 
71
        .line_length  = 32,
 
72
        .status_width = 35,
 
73
 
 
74
    /* Functions */
 
75
    .init = t_init,
 
76
    .clear_progressbar = t_clear_progressbar,
 
77
    .draw_progressbar = t_draw_progressbar,
 
78
    .animate_step = t_animate_step,
 
79
};
 
80
 
 
81
struct usplash_theme usplash_theme_1024_768 = {
 
82
        .version = THEME_VERSION,
 
83
    .next = &usplash_theme_1365_768_scaled,
 
84
    .ratio = USPLASH_4_3,
 
85
 
 
86
        /* Background and font */
 
87
        .pixmap = &pixmap_usplash_1024_768,
 
88
 
 
89
        /* Palette indexes */
 
90
        .background             = 0x0,
 
91
        .progressbar_background = 0x7,
 
92
        .progressbar_foreground = 0x156,
 
93
        .text_background        = 0x0,
 
94
        .text_foreground        = 0x15,
 
95
        .text_success           = 0x33,
 
96
        .text_failure           = 0x144,
 
97
 
 
98
        /* Progress bar position and size in pixels */
 
99
        .progressbar_x      = 404, /* 1024/2 - 216/2 */
 
100
        .progressbar_y      = 475,
 
101
        .progressbar_width  = 216,
 
102
        .progressbar_height = 8,
 
103
 
 
104
        /* Text box position and size in pixels */
 
105
        .text_x      = 322,
 
106
        .text_y      = 525,
 
107
        .text_width  = 380,
 
108
        .text_height = 100,
 
109
 
 
110
        /* Text details */
 
111
        .line_height  = 15,
 
112
        .line_length  = 32,
 
113
        .status_width = 35,
 
114
 
 
115
    /* Functions */
 
116
    .init = t_init,
 
117
    .clear_progressbar = t_clear_progressbar,
 
118
    .draw_progressbar = t_draw_progressbar,
 
119
    .animate_step = t_animate_step,
 
120
};
 
121
 
 
122
struct usplash_theme usplash_theme_1365_768_scaled = {
 
123
        .version = THEME_VERSION,
 
124
    .next = NULL,
 
125
    .ratio = USPLASH_16_9,
 
126
 
 
127
        /* Background and font */
 
128
        .pixmap = &pixmap_usplash_1365_768_scaled,
 
129
 
 
130
        /* Palette indexes */
 
131
        .background             = 0x0,
 
132
        .progressbar_background = 0x7,
 
133
        .progressbar_foreground = 0x156,
 
134
        .text_background        = 0x0,
 
135
        .text_foreground        = 0x15,
 
136
        .text_success           = 0x33,
 
137
        .text_failure           = 0x144,
 
138
 
 
139
        /* Progress bar position and size in pixels */
 
140
        .progressbar_x      = 404, /* 1024/2 - 216/2 */
 
141
        .progressbar_y      = 475,
 
142
        .progressbar_width  = 216,
 
143
        .progressbar_height = 8,
 
144
 
 
145
        /* Text box position and size in pixels */
 
146
        .text_x      = 322,
 
147
        .text_y      = 525,
 
148
        .text_width  = 380,
 
149
        .text_height = 100,
 
150
 
 
151
        /* Text details */
 
152
        .line_height  = 15,
 
153
        .line_length  = 32,
 
154
        .status_width = 35,
 
155
 
 
156
    /* Functions */
 
157
    .init = t_init,
 
158
    .clear_progressbar = t_clear_progressbar,
 
159
    .draw_progressbar = t_draw_progressbar,
 
160
    .animate_step = t_animate_step,
 
161
};
 
162
 
 
163
void t_init(struct usplash_theme *theme) {
 
164
    int x, y;
 
165
    usplash_getdimensions(&x, &y);
 
166
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
 
167
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
 
168
}
 
169
 
 
170
void t_clear_progressbar(struct usplash_theme *theme) {
 
171
    t_draw_progressbar(theme, 0);
 
172
}
 
173
 
 
174
void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
 
175
    int w = (pixmap_throbber_back.width * percentage / 100);
 
176
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);
 
177
    if(percentage == 0)
 
178
        return;
 
179
    if(percentage < 0)
 
180
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
 
181
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
 
182
    else
 
183
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height, 
 
184
                         &pixmap_throbber_fore, 0, 0);
 
185
}
 
186
 
 
187
void t_animate_step(struct usplash_theme* theme, int pulsating) {
 
188
 
 
189
    static int pulsate_step = 0;
 
190
    static int pulse_width = 28;
 
191
    static int step_width = 2;
 
192
    static int num_steps = (216 - 28)/2;
 
193
    int x1;
 
194
 
 
195
    if (pulsating) {
 
196
        t_draw_progressbar(theme, 0);
 
197
    
 
198
        if(pulsate_step < num_steps/2+1)
 
199
                x1 = 2 * step_width * pulsate_step;
 
200
        else
 
201
                x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
 
202
 
 
203
        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
 
204
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);
 
205
 
 
206
        pulsate_step = (pulsate_step + 1) % num_steps;
 
207
    }
 
208
}