166
187
clear_screen (void)
168
usplash_clear (0, 0, usplash_xres, usplash_yres, theme->background);
170
usplash_put (left_edge, top_edge, theme->pixmap);
190
if (theme->clear_screen)
191
theme->clear_screen();
193
usplash_clear (0, 0, usplash_xres, usplash_yres, theme->background);
194
usplash_put (left_edge, top_edge, theme->pixmap);
175
201
clear_progressbar (void)
179
x1 = left_edge + theme->progressbar_x;
180
y1 = top_edge + theme->progressbar_y;
182
x2 = x1 + theme->progressbar_width;
183
y2 = y1 + theme->progressbar_height;
185
usplash_clear (x1, y1, x2, y2, theme->progressbar_background);
203
if (theme->clear_progressbar)
204
theme->clear_progressbar();
208
x1 = left_edge + theme->progressbar_x;
209
y1 = top_edge + theme->progressbar_y;
211
x2 = x1 + theme->progressbar_width;
212
y2 = y1 + theme->progressbar_height;
214
usplash_clear (x1, y1, x2, y2, theme->progressbar_background);
189
219
draw_progressbar (int percentage)
191
int x1, y1, x2, y2, xx, bg, fg;
193
if (percentage < 0) {
194
bg = theme->progressbar_foreground;
195
fg = theme->progressbar_background;
196
percentage = -percentage;
198
bg = theme->progressbar_background;
199
fg = theme->progressbar_foreground;
202
if (percentage > 100)
206
x1 = left_edge + theme->progressbar_x;
207
y1 = top_edge + theme->progressbar_y;
209
x2 = x1 + theme->progressbar_width;
210
y2 = y1 + theme->progressbar_height;
212
xx = x1 + ((theme->progressbar_width * percentage) / 100);
214
usplash_clear (x1, y1, xx, y2, fg);
215
usplash_clear (xx, y1, x2, y2, bg);
222
if (percentage > 100 || percentage < -100)
225
if (theme->draw_progressbar)
226
theme->draw_progressbar(percentage);
228
int x1, y1, x2, y2, xx, bg, fg;
230
if (percentage < 0) {
231
bg = theme->progressbar_foreground;
232
fg = theme->progressbar_background;
233
percentage = -percentage;
235
bg = theme->progressbar_background;
236
fg = theme->progressbar_foreground;
239
x1 = left_edge + theme->progressbar_x;
240
y1 = top_edge + theme->progressbar_y;
242
x2 = x1 + theme->progressbar_width;
243
y2 = y1 + theme->progressbar_height;
245
xx = x1 + ((theme->progressbar_width * percentage) / 100);
247
usplash_clear (x1, y1, xx, y2, fg);
248
usplash_clear (xx, y1, x2, y2, bg);
220
255
clear_text (void)
224
x1 = left_edge + theme->text_x;
225
y1 = top_edge + theme->text_y;
227
x2 = x1 + theme->text_width;
228
y2 = y1 + theme->text_height;
230
usplash_clear (x1, y1, x2, y2, theme->text_background);
258
if (theme->clear_text)
263
x1 = left_edge + theme->text_x;
264
y1 = top_edge + theme->text_y;
266
x2 = x1 + theme->text_width;
267
y2 = y1 + theme->text_height;
269
usplash_clear (x1, y1, x2, y2, theme->text_background);
234
275
draw_text (const char *string, size_t len)
278
if (theme->draw_text)
279
theme->draw_text(string, len);
236
281
/* FIXME some kind of better word wrapping here, perhaps? */
238
while (len > theme->line_length) {
239
draw_line (string, theme->line_length);
240
string += theme->line_length;
241
len -= theme->line_length;
283
while (len > theme->line_length) {
284
draw_line (string, theme->line_length);
285
string += theme->line_length;
286
len -= theme->line_length;
245
draw_line (string, len);
290
draw_line (string, len);
268
315
theme->text_foreground, theme->text_background);
318
handle_input (const char *string, const size_t len, const int quiet)
322
int x1, y1, x2, y2, xpos;
325
char inputbuf[PIPE_BUF] = "";
327
/* some variables which we'll need */
328
x1 = left_edge + theme->text_x;
329
x2 = x1 + theme->text_width;
331
y2 = top_edge + theme->text_y + theme->text_height;
332
y1 = y2 - theme->line_height;
334
/* draw the prompt */
335
draw_line (string, len);
337
for (i = 0; i < len; i++)
338
xpos += usplash_getfontwidth (*(string + i));
341
for (i = 0; i < PIPE_BUF - 1; i++) {
343
if (input == '\n' || input == '\r' || input == '\0')
351
/* Make sure the text doesn't overflow */
352
if (xpos + usplash_getfontwidth (input) > x2) {
354
top_edge + theme->text_y +
357
top_edge + theme->text_y,
359
theme->text_height - theme->line_height);
360
usplash_clear (x1, y1, x2, y2, theme->text_background);
364
usplash_text (xpos, y1, &input, 1,
365
theme->text_foreground, theme->text_background);
366
xpos += usplash_getfontwidth (input);
370
/* We wait for timeout seconds for someone to read the user input */
371
for (i = 1; i != timeout + 1; i++) {
372
fifo_outfd = open (USPLASH_OUTFIFO, O_WRONLY|O_NONBLOCK);
382
wlen = write (fifo_outfd, inputbuf, strlen(inputbuf) + 1);
387
memset(inputbuf, 0, PIPE_BUF);
272
392
draw_status (const char *string, size_t len, int mode)
274
int x1, y1, x2, y2, fg;
277
fg = theme->text_failure;
278
} else if (mode > 0) {
279
fg = theme->text_success;
281
fg = theme->text_foreground;
284
x2 = left_edge + theme->text_x + theme->text_width;
285
y2 = top_edge + theme->text_y + theme->text_height;
287
x1 = x2 - theme->status_width;
288
y1 = y2 - theme->line_height;
290
usplash_clear (x1, y1, x2, y2, theme->text_background);
292
usplash_text (x1, y1, string, len, fg, theme->text_background);
395
if (theme->draw_status)
396
theme->draw_status(string, len, mode);
398
int x1, y1, x2, y2, fg;
401
fg = theme->text_failure;
402
} else if (mode > 0) {
403
fg = theme->text_success;
405
fg = theme->text_foreground;
408
x2 = left_edge + theme->text_x + theme->text_width;
409
y2 = top_edge + theme->text_y + theme->text_height;
411
x1 = x2 - theme->status_width;
412
y1 = y2 - theme->line_height;
414
usplash_clear (x1, y1, x2, y2, theme->text_background);
416
usplash_text (x1, y1, string, len, fg, theme->text_background);
422
animate_step(pulsating) {
423
static int pulsate_step = 0;
424
static int num_steps = 37;
426
if (theme->animate_step)
427
theme->animate_step(pulsating);
432
if(pulsate_step < 19)
433
x1 = left_edge + theme->progressbar_x + (theme->progressbar_width/20) * pulsate_step;
435
x1 = left_edge + theme->progressbar_x + (theme->progressbar_width/20) * (36-pulsate_step);
437
y1 = top_edge + theme->progressbar_y;
439
x2 = x1 + (theme->progressbar_width/10);
440
y2 = y1 + theme->progressbar_height;
441
usplash_clear (x1, y1, x2, y2, theme->progressbar_foreground);
443
pulsate_step = (pulsate_step + 1) % num_steps;