Changeset 59 for branches

Show
Ignore:
Timestamp:
10/23/09 17:58:55 (2 years ago)
Author:
mirko
Message:

Keybindings core.

Location:
branches/clutter-experiments
Files:
3 modified

Legend:

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

    r57 r59  
    6161  gfloat x, y; 
    6262  clutter_event_get_coords (event, &x, &y); 
    63   g_print ("Stage clicked at (%d, %d)\n", x, y); 
     63  g_print ("Stage clicked at (%f, %f)\n", x, y); 
    6464  // clutter cluttered my first draw, so redraw on click to allow testing. 
    65   clutter_actor_queue_redraw(CLUTTER_ACTOR(stage)); 
     65  // clutter_actor_queue_redraw(CLUTTER_ACTOR(stage)); 
    6666  return TRUE; /* Stop further handling of this event. */ 
    6767} 
     
    169169 
    170170  /* 
    171   // ---------------------------------------------- 
    172   // render low res version of all pages 
    173   // TODO: show fancy progress bar in the meantime. 
    174   // ---------------------------------------------- 
    175   for(int ii(0); ii != doc.n_pages(); ++ii) 
    176     doc.page(ii).render(pdfcube::page::LOW_RES); 
    177  
    178  
    179171  // -------------------------- 
    180172  // arrange pages in an index 
  • branches/clutter-experiments/page.hh

    r56 r59  
    2121   * Usually, on start, all the pages will be rendered in a low res 
    2222   * version, while higher res versions will be rendered on demand by 
    23    * the animations. We need to program the animations in advance so 
    24    * that we can pre-render hi-res versions of the pages before the 
    25    * animations begins. One way can be to read animations from the 
    26    * PDF. 
     23   * the animations.  
     24   * 
     25   * While displaying one page the following page is rendered in high 
     26   * resolution. No forward animation is possible until the rendering 
     27   * finishes. 
    2728   * 
    2829   */ 
     
    105106          { 
    106107            int w, h; 
    107             // we assume 4/3 aspect monitor can be done better 
     108            // FIXME: we assume 4/3 aspect monitor.  
    108109            double box_w = 1600; 
    109110            double box_h = 1200; 
  • branches/clutter-experiments/pdfcube.hh

    r57 r59  
    11#pragma once 
     2 
     3#include <cassert> 
    24 
    35namespace pdfcube { 
     
    9597      g_thread_create(render_thread, this, FALSE, NULL); 
    9698       
     99      clutter_actor_set_reactive(the_stage_m, TRUE); 
     100      g_signal_connect(the_stage_m,  
     101                       "key-press-event", 
     102                       G_CALLBACK (pdfcube::app::keypress_event),  
     103                       NULL); 
    97104      clutter_threads_enter(); 
    98105      clutter_main(); 
     
    174181      clutter_actor_set_size(me->current_page_m, w, h); 
    175182      clutter_container_add_actor(CLUTTER_CONTAINER(me->the_stage_m),  
    176                             me->current_page_m); 
     183                                  me->current_page_m); 
     184 
     185      ClutterBindingPool *binding_pool; 
     186      std::cerr << G_OBJECT_TYPE_NAME(me->the_stage_m) << std::endl; 
     187      binding_pool = clutter_binding_pool_new(G_OBJECT_TYPE_NAME(me->the_stage_m)); 
     188 
     189      clutter_binding_pool_install_action(binding_pool,  
     190                                          "move-up", 
     191                                          CLUTTER_Up, (ClutterModifierType)0, 
     192                                          G_CALLBACK(pdfcube::app::action_move_up), 
     193                                          me,  
     194                                          NULL); 
     195 
     196      clutter_binding_pool_install_action(binding_pool,  
     197                                          "move-up", 
     198                                          CLUTTER_KP_Up, (ClutterModifierType)0, 
     199                                          G_CALLBACK(pdfcube::app::action_move_up), 
     200                                          me,  
     201                                          NULL); 
     202 
    177203      return FALSE; 
    178204    } 
     
    211237    } 
    212238 
     239    ////////////////////////////////////////////////////////////////////// 
     240    // 
     241    // Callbacks 
     242    // 
     243    static gboolean keypress_event(ClutterActor* actor, 
     244                                   ClutterEvent* evt, 
     245                                   gpointer data) 
     246    { 
     247      pdfcube::app* self = (pdfcube::app*)data; 
     248      ClutterKeyEvent* key_evt = (ClutterKeyEvent*)evt; 
     249      ClutterBindingPool *pool = NULL; 
     250       
     251      std::cerr << " * " << G_OBJECT_TYPE_NAME(actor) << std::endl; 
     252      /* retrieve the binding pool for the type of the actor */ 
     253      pool = clutter_binding_pool_find(G_OBJECT_TYPE_NAME(actor)); 
     254       
     255      assert(pool); 
     256      /* activate any callback matching the key symbol and modifiers 
     257       * mask of the key event. the returned value can be directly 
     258       * used to signal that the actor has handled the event. 
     259       */ 
     260      return clutter_binding_pool_activate (pool,  
     261                                            (guint)key_evt->keyval, 
     262                                            (ClutterModifierType)key_evt->modifier_state, 
     263                                            G_OBJECT(actor)); 
     264       
     265    } 
     266 
     267    static gboolean action_move_up(GObject             *instance, 
     268                                   const gchar         *action_name, 
     269                                   guint                key_val, 
     270                                   ClutterModifierType  modifiers, 
     271                                   gpointer             user_data) 
     272    { 
     273      std::cerr << "move-up" << std::endl; 
     274    } 
     275 
     276 
     277 
    213278  }; 
    214279}