Changeset 51

Show
Ignore:
Timestamp:
01/25/09 19:46:01 (3 years ago)
Author:
mirko
Message:

few minutes working on the index feature.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/clutter-experiments/main.cc

    r50 r51  
    2222} 
    2323 
     24 
     25static gboolean 
     26on_page_enter(ClutterActor* actor, ClutterEvent *event, gpointer data) 
     27{ 
     28  // Code snippet for a static member of the index class, 
     29  // data should point to the index instance, so one can  
     30  // also click on a page and have its number. 
     31  // FIXME: cancel previous animation before starting a new one. 
     32  ClutterTimeline *timeline = clutter_timeline_new(20, 60); 
     33  clutter_timeline_set_loop(timeline, TRUE); 
     34  clutter_timeline_start(timeline); 
     35  ClutterEffectTemplate *effect_template =  
     36    clutter_effect_template_new(timeline, 
     37                                CLUTTER_ALPHA_SINE_HALF); 
     38  gint x, y; 
     39  clutter_actor_get_position(actor, &x, &y); 
     40  clutter_effect_scale(effect_template, actor, 1.12, 1.12, NULL, NULL); 
     41  g_object_unref(effect_template); 
     42  g_object_unref(timeline); 
     43  return TRUE; 
     44} 
     45 
     46static gboolean 
     47on_page_leave(ClutterActor* actor, ClutterEvent *event, gpointer data) 
     48{ 
     49  return TRUE; 
     50} 
     51 
    2452static gboolean 
    2553on_stage_button_press (ClutterStage *stage, ClutterEvent *event, gpointer data) 
    2654{ 
    27   gint x = 0; 
    28   gint y = 0; 
     55  gint x, y; 
    2956  clutter_event_get_coords (event, &x, &y); 
    3057  g_print ("Stage clicked at (%d, %d)\n", x, y); 
     
    4471{ 
    4572  // ... 
     73  // 1. animate to index when tab is pressed 
     74  // 2. navigate with the keyboard and/or mouse (see on_page_enter) 
     75  // 3. animate to the single page choosen (clicked or previous on esc) 
     76  // 
    4677} 
    4778/** 
     
    200231        } 
    201232       
    202       double padding_x = (box_w - w)/2; 
    203       double padding_y = (box_h - h)/2; 
    204  
    205       cerr << w << ", " << h << ", " << aspect << endl; 
     233 
     234      //cerr << w << ", " << h << ", " << aspect << endl; 
    206235 
    207236      ClutterActor* page =  
    208237        CLUTTER_ACTOR(doc.page(ii).actor(pdfcube::page::LOW_RES)); 
    209       guint sx, sy; 
    210       clutter_actor_get_size(page, &sx, &sy); 
    211       cerr << sx << ", " << sy << endl; 
    212  
     238      clutter_actor_set_size(page, (int)w, (int)h); 
    213239      clutter_actor_set_position(page,  
    214                                  (int)(box_x + padding_x), 
    215                                  (int)(box_y + padding_y)); 
    216       clutter_actor_set_size(page, (int)w, (int)h); 
     240                                 (int)(box_x + box_w/2), 
     241                                 (int)(box_y + box_h/2)); 
     242      // THIS IS NOT RELATIVE TO ACTOR REAL SIZE, BUT TO ACTOR PERCEIVED SIZE 
     243      clutter_actor_set_anchor_point_from_gravity(page, CLUTTER_GRAVITY_CENTER); 
    217244      clutter_group_add_many(CLUTTER_GROUP(stage), page, NULL); 
     245      // Make actor reactive 
     246      clutter_actor_set_reactive(page, TRUE); 
     247      g_signal_connect (page, "enter-event", 
     248                        G_CALLBACK (on_page_enter), NULL); 
     249      g_signal_connect (page, "leave-event", 
     250                        G_CALLBACK (on_page_leave), NULL); 
    218251    } 
    219252 
     
    225258                    G_CALLBACK (on_stage_button_press), NULL); 
    226259 
     260 
    227261  //clutter_stage_hide_cursor (CLUTTER_STAGE (stage)); 
    228262  clutter_actor_show (stage);