]> git.cworth.org Git - xoboot/commitdiff
Rename anim_state_t to anim_stage_t to avoid confusion with state_t
authorCarl Worth <cworth@cworth.org>
Tue, 28 Aug 2007 06:54:38 +0000 (23:54 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 28 Aug 2007 06:54:38 +0000 (23:54 -0700)
xoboot.c

index 3259c8253194a03c7dce9f74dc196bbd428210bb..14cfd07bc737ff80a3138996416f216d786abf9e 100644 (file)
--- a/xoboot.c
+++ b/xoboot.c
@@ -13,28 +13,29 @@ typedef enum {
     ANIM_OUTLINE,
     ANIM_FADE,
     ANIM_DONE
-} anim_state_t;
-
-typedef struct _anim_stage {
-    double length;
-    anim_state_t state;
 } anim_stage_t;
 
-anim_stage_t timeline[] = {
-    { 0.5, ANIM_BLANK },
-    { 1.0, ANIM_HEAD },
-    { 2.0, ANIM_BODY },
-    { 6.0, ANIM_SPIN },
-    { 1.0, ANIM_SPIN_DONE },
-    { 1.0, ANIM_OUTLINE },
-    { 1.0, ANIM_FADE },
+typedef struct _timeline {
+    double duration;
+    anim_stage_t state;
+    double transition;
+} timeline_t;
+
+timeline_t timeline[] = {
+    { 0.5, ANIM_BLANK,      0.0},
+    { 1.0, ANIM_HEAD,       0.0},
+    { 2.0, ANIM_BODY,       0.0},
+    { 7.0, ANIM_SPIN,       6.0},
+    { 1.0, ANIM_SPIN_DONE,  0.0},
+    { 1.0, ANIM_OUTLINE,    0.0},
+    { 1.0, ANIM_FADE,       0.5},
     { 0.0, ANIM_DONE }
 };
 
 typedef struct _state {
     GtkWidget *drawing_area;
     double progress;
-    anim_state_t anim_state;
+    anim_stage_t anim_stage;
 } state_t;
 
 typedef struct _color {
@@ -167,24 +168,24 @@ xoboot_expose_event (GtkWidget      *widget,
                      gpointer        closure)
 {
     state_t *state = closure;
-    anim_state_t anim_state = state->anim_state;
+    anim_stage_t anim_stage = state->anim_stage;
     cairo_t *cr;
     double shrink;
 
     cr = gdk_cairo_create (widget->window);
 
-    if (anim_state < ANIM_FADE)
+    if (anim_stage < ANIM_FADE)
        set_color (cr, &background[0]);
     else
        set_color (cr, &background[1]);
 
     cairo_paint (cr);
 
-    if (anim_state == ANIM_BLANK)
+    if (anim_stage == ANIM_BLANK)
        goto DONE;
 
     shrink = 0.0;
-    if (anim_state >= ANIM_OUTLINE) {
+    if (anim_stage >= ANIM_OUTLINE) {
        set_color (cr, &xo_black);
        draw_head (cr, XO_OUTLINE_EXTRA);
        draw_body (cr, XO_OUTLINE_EXTRA);
@@ -194,14 +195,14 @@ xoboot_expose_event (GtkWidget      *widget,
     set_color (cr, &xo_green);
 
     draw_head (cr, shrink);
-    if (anim_state == ANIM_HEAD)
+    if (anim_stage == ANIM_HEAD)
        goto DONE;
 
     draw_body (cr, shrink);
-    if (anim_state == ANIM_BODY)
+    if (anim_stage == ANIM_BODY)
        goto DONE;
 
-    if (anim_state < ANIM_FADE)
+    if (anim_stage < ANIM_FADE)
        draw_dots (cr);
     else
        draw_ring (cr);
@@ -238,15 +239,15 @@ create_window (state_t *state)
 }
 
 static gint
-timeout_callback (gpointer closure)
+timeline_advance (gpointer closure)
 {
     state_t *state = closure;
 
-    state->anim_state++;
-    if (state->anim_state > ANIM_DONE)
-       state->anim_state = ANIM_DONE;
-    else
-       gtk_widget_queue_draw (state->drawing_area);
+    if (state->anim_stage == ANIM_DONE)
+       return FALSE;
+
+    state->anim_stage++;
+    gtk_widget_queue_draw (state->drawing_area);
 
     return TRUE;
 }
@@ -260,11 +261,11 @@ main (int argc, char *argv[])
 
     state.drawing_area = create_window (&state);
     state.progress = 0.0;
-    state.anim_state = 0;
+    state.anim_stage = 0;
 
     gtk_widget_show_all (gtk_widget_get_toplevel (state.drawing_area));
 
-    g_timeout_add (1000, timeout_callback, &state);
+    g_timeout_add (1000, timeline_advance, &state);
 
     gtk_main ();