[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: a_pan.nw



  User: werner  
  Date: 06/04/14 07:49:28

  Modified:    .        a_pan.nw a_zoom.nw i_callbacks.nw o_basic.nw
                        x_event.nw x_print.nw
  Log:
  rubberband drawing, motion event dropping, move while drawing improved
  
  
  
  
  Revision  Changes    Path
  1.8       +44 -48    eda/geda/devel/gschem/noweb/a_pan.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: a_pan.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/a_pan.nw,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- a_pan.nw	9 Apr 2006 08:11:36 -0000	1.7
  +++ a_pan.nw	14 Apr 2006 11:49:27 -0000	1.8
  @@ -101,10 +101,13 @@
     /* think it's better that the zoomfactor is defined as pix/mills
        this will be the same as w_current->page_current->to_screen_x/y_constant*/
     int zoom_max = 5;	
  -  double zx,zy,zoom_old,zoom_new,zoom_min;
  +  int start_x, start_y;
  +  double zx, zy, zoom_old, zoom_new, zoom_min;
  +
   #if DEBUG
     printf("a_pan_general(): world_cx=%f, world_cy=%f\n",world_cx, world_cy);
   #endif	
  +
     /* calc minimum zoomfactors and choose the smaller one. They are equal
        if the aspectratio of the world is the same as the screen ratio */
     zx = (double) w_current->width / (w_current->init_right -
  @@ -134,6 +137,14 @@
       }
     }
   
  +  /* check to see if we are inside an action draw net, etc.  If
  +   * yes, convert the start screen coords to world coords */
  +  if (w_current->inside_action) {
  +    SCREENtoWORLD(w_current,
  +		  w_current->start_x, w_current->start_y,
  +		  &start_x, &start_y);
  +  }
  +
     /* calculate the new visible area; adding 0.5 to round */
     w_current->page_current->left = world_cx - (double) w_current->width
       / 2 / zoom_new + 0.5;
  @@ -181,10 +192,13 @@
   #if DEBUG
     printf("zoom_old: %f, zoom_new: %f \n ",zoom_old, zoom_new);
     printf("left: %d, right: %d, top: %d, bottom: %d\n",
  -         w_current->page_current->left, w_current->page_current->right, w_current->page_current->top, w_current->page_current->bottom);
  +         w_current->page_current->left, w_current->page_current->right, 
  +	 w_current->page_current->top, w_current->page_current->bottom);
     printf("aspect: %f\n",
  -         (float) fabs(w_current->page_current->right  - w_current->page_current->left) /
  -         (float) fabs(w_current->page_current->bottom - w_current->page_current->top ));
  +         (float) fabs(w_current->page_current->right  
  +		      - w_current->page_current->left) /
  +         (float) fabs(w_current->page_current->bottom 
  +		      - w_current->page_current->top ));
   #endif
   	
     /* set_window */
  @@ -194,10 +208,26 @@
                w_current->page_current->top   ,
                w_current->page_current->bottom);
   
  +  /* convert world coords back to screen coords */
  +  if (w_current->inside_action) {
  +    WORLDtoSCREEN(w_current,
  +		  start_x, start_y,
  +		  &(w_current->start_x), &(w_current->start_y));
  +    /* set all rubberband points to it's start values:
  +       As we don't draw the rubberbands after zooming/paning this
  +       will lead the a redraw of the rubberbands with the next
  +       motion event */
  +    w_current->last_x = w_current->second_x = w_current->start_x;
  +    w_current->save_x = w_current->loc_x = w_current->start_x;
  +    w_current->last_y = w_current->second_y = w_current->start_y;
  +    w_current->save_y = w_current->loc_y = w_current->start_y;
  +    w_current->distance = 0;
  +  }
  +
     /* redraw */
     if (!(flags & A_PAN_DONT_REDRAW)) {
       x_scrollbars_update(w_current);
  -    o_redraw_all_fast(w_current);
  +    o_redraw_all(w_current);
     }
   }
   
  @@ -215,30 +245,12 @@
   void
   a_pan(TOPLEVEL *w_current, int x, int y)
   {
  -  int sx, sy, lx, ly;
     double world_cx, world_cy;
  +
   #if DEBUG
     printf("a_pan(): x=%d, y=%d\n", x, y);
   #endif	
   
  -  /* check to see if we are inside an action draw net, etc.  If
  -   * yes, convert screen coords to world coords */
  -  if (w_current->inside_action) {
  -    SCREENtoWORLD(w_current,
  -		  w_current->start_x, w_current->start_y,
  -		  &sx, &sy);
  -    SCREENtoWORLD(w_current,
  -		  w_current->last_x, w_current->last_y,
  -		  &lx, &ly);
  -    
  -#if 0
  -    printf("BEGIN: start x %d -> %d \n", w_current->start_x, sx);
  -    printf("BEGIN: start y %d -> %d \n", w_current->start_y, sy);
  -    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , lx);
  -    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , ly);
  -#endif
  -  }
  -
     /* make mouse to the new world-center;
        attention: there are information looses because of type cast in mil_x */
   	
  @@ -247,23 +259,11 @@
   
     a_pan_general(w_current, world_cx, world_cy, 1, 0);
   
  -  /* convert world coords back to screen coords */
  -  if (w_current->inside_action) {
  -    WORLDtoSCREEN(w_current,
  -		  sx, sy,
  -		  &(w_current->start_x), &(w_current->start_y));
  -    WORLDtoSCREEN(w_current,
  -		  lx, ly,
  -		  &(w_current->last_x), &(w_current->last_y));
  -#if 0
  -    printf("END:   start x %d <- %d \n", sx, w_current->start_x);
  -    printf("END:   start y %d <- %d \n", sy, w_current->start_y);
  -    printf("END:   last  x %d <- %d \n", lx, w_current->last_x );
  -    printf("END:   last  y %d <- %d \n", ly, w_current->last_y );
  -#endif
  -  }
  -  /* not needed */
  -  /* o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); */
  +  /* FIXME? This call will trigger a motion event (x_event_motion()), even 
  +     if the user doesn't move the mouse 
  +     Not ready for prime time, maybe there is another way to trigger the 
  +     motion event without changing the cursor position (Werner)*/
  +  /* x_basic_warp_cursor(w_current->drawing_area, x, y, 0); */
   }
   
   
  @@ -279,18 +279,14 @@
   void
   a_pan_mouse(TOPLEVEL *w_current, int diff_x, int diff_y)
   {
  -  int world_dx, world_dy;
     double world_cx, world_cy;
   
   #if DEBUG
     printf("a_pan_mouse(): diff_x=%d, diff_y=%d\n", diff_x, diff_y);
   #endif	
   
  -  world_dx = WORLDabs(w_current, diff_x);
  -  world_dy = WORLDabs(w_current, diff_y);
  -
  -  world_cx=GET_PAGE_CENTER_X(w_current) - world_dx;
  -  world_cy=GET_PAGE_CENTER_Y(w_current) + world_dy;
  +  world_cx=GET_PAGE_CENTER_X(w_current) - WORLDabs(w_current, diff_x);
  +  world_cy=GET_PAGE_CENTER_Y(w_current) + WORLDabs(w_current, diff_y);
   
   #if DEBUG
     printf("  world_cx=%f, world_cy=%f, world_dx=%d, world_dy=%d\n",
  
  
  
  1.10      +19 -56    eda/geda/devel/gschem/noweb/a_zoom.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: a_zoom.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/a_zoom.nw,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- a_zoom.nw	9 Apr 2006 08:11:36 -0000	1.9
  +++ a_zoom.nw	14 Apr 2006 11:49:27 -0000	1.10
  @@ -116,35 +116,7 @@
   a_zoom(TOPLEVEL *w_current, int dir, int selected_from, int pan_flags)
   {
     double world_pan_center_x,world_pan_center_y,relativ_zoom_factor = - 1;
  -  int sx, sy;
  -  int lx, ly;
  -
  -  /* check to see if we are inside an action draw net, etc.  If
  -   * yes, convert screen coords to world coords */
  -  /* some rounding errors occur here because of some type cast
  -   * in the SRCEENtoWORLD and WORLDtoSCREEN function (wh)*/
  -  if (w_current->inside_action) {
  -    SCREENtoWORLD(w_current,
  -                  w_current->start_x,
  -                  w_current->start_y,
  -                  &sx, &sy);
  -    SCREENtoWORLD(w_current,
  -                  w_current->last_x,
  -                  w_current->last_y,
  -                  &lx, &ly);
  -#if DEBUG
  -    printf("a_zoom: Inside an action\n");
  -    printf("BEGIN: start x %d -> %d \n", w_current->start_x, sx);
  -    printf("BEGIN: start y %d -> %d \n", w_current->start_y, sy);
  -    printf("BEGIN: last  x %d -> %d \n", w_current->last_x , lx);
  -    printf("BEGIN: last  y %d -> %d \n", w_current->last_y , ly);
  -#endif
  -    w_current->start_x = sx;
  -    w_current->start_y = sy;
  -    w_current->last_x  = lx;
  -    w_current->last_y  = ly;
  -  }
  -	
  +  int start_x, start_y;
   	
     /*calc center: either "mouse_to_world" or center=center */
     if (w_current->zoom_with_pan == TRUE && selected_from == HOTKEY) {
  @@ -185,38 +157,22 @@
   #endif
   
   
  -  /*calculate new window and draw it */	
  +  /* calculate new window and draw it */
     a_pan_general(w_current, world_pan_center_x, world_pan_center_y,
                   relativ_zoom_factor, pan_flags);
   	
  -  /* convert things back to screen coords*/
  -  if (w_current->inside_action) {
  -    WORLDtoSCREEN(w_current,
  -                  w_current->start_x,
  -                  w_current->start_y,
  -                  &sx, &sy);
  -    WORLDtoSCREEN(w_current,
  -                  w_current->last_x,
  -                  w_current->last_y,
  -                  &lx, &ly);
  -#if DEBUG
  -    printf("END: current factor = %d\n", w_current->page_current
  -           ->zoom_factor);
  -    printf("END:   start x %d <- %d \n", sx, w_current->start_x);
  -    printf("END:   start y %d <- %d \n", sy, w_current->start_y);
  -    printf("END:   last  x %d <- %d \n", lx, w_current->last_x);
  -    printf("END:   last  y %d <- %d \n", ly, w_current->last_y);
  -#endif
  -    w_current->start_x = sx;
  -    w_current->start_y = sy;
  -    w_current->last_x = lx;
  -    w_current->last_y = ly;
  -  }
  -
     /* warp the cursor to the right position */ 
     if (w_current->warp_cursor) {
  -     WORLDtoSCREEN(w_current, world_pan_center_x, world_pan_center_y, &sx, &sy);
  -     x_basic_warp_cursor(w_current->drawing_area, sx, sy, 0);
  +     WORLDtoSCREEN(w_current, world_pan_center_x, world_pan_center_y, 
  +		   &start_x, &start_y);
  +     x_basic_warp_cursor(w_current->drawing_area, start_x, start_y, 0);
  +  }
  +  else {
  +    /* FIXME? trigger a x_event_motion() call without moving the cursor 
  +       this will redraw rubberband lines 
  +       Find a way to trigger the x_event_motion() without moving
  +       the mouse cursor (werner) */
  +    /* x_basic_warp_cursor(w_current->drawing_area, mouse_x, mouse_y, 0); */
     }
   }
   
  @@ -271,6 +227,13 @@
     /* and create the new window*/
     a_pan_general(w_current, world_pan_center_x, world_pan_center_y,
                   relativ_zoom_factor, pan_flags );	
  +
  +  /* FIXME? trigger a x_event_motion() call without moving the cursor 
  +     this will redraw rubberband lines after zooming */
  +  /* removed!, it has side effects in the preview of the part dialog 
  +     need to find another way to trigger x_event_motion() (Werner)*/
  +  /* x_basic_warp_cursor(w_current->drawing_area, mouse_x, mouse_y, 0); */
  +
   }
   
   
  
  
  
  1.48      +3 -2      eda/geda/devel/gschem/noweb/i_callbacks.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: i_callbacks.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/i_callbacks.nw,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -b -r1.47 -r1.48
  --- i_callbacks.nw	9 Apr 2006 08:11:36 -0000	1.47
  +++ i_callbacks.nw	14 Apr 2006 11:49:27 -0000	1.48
  @@ -2012,12 +2012,13 @@
      * don't change the event state, because we want to continue
      * drawing a net. If we are just panning, then continue in
      * select mode.  */
  -  if(!(w_current->event_state == DRAWNET ||
  +  /* removed the limitations of the pan mode (werner) */
  +  /* if(!(w_current->event_state == DRAWNET ||
          w_current->event_state == NETCONT ||
          w_current->event_state == STARTDRAWNET )) {
       i_set_state(w_current, SELECT);
       i_update_toolbar(w_current);
  -  }
  +    } */
     o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY);
   }
   
  
  
  
  1.12      +2 -0      eda/geda/devel/gschem/noweb/o_basic.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_basic.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/o_basic.nw,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- o_basic.nw	19 Feb 2005 23:27:07 -0000	1.11
  +++ o_basic.nw	14 Apr 2006 11:49:27 -0000	1.12
  @@ -126,6 +126,8 @@
     if (w_current->inside_action) {
       switch(w_current->event_state) {
         case(ENDMOVE):
  +	o_erase_selected(w_current);	
  +	/* continue */
         case(ENDCOPY):
           o_drawbounding(w_current, NULL,
                          w_current->page_current->selection2_head->next,
  
  
  
  1.22      +25 -8     eda/geda/devel/gschem/noweb/x_event.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_event.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/x_event.nw,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- x_event.nw	9 Apr 2006 08:11:36 -0000	1.21
  +++ x_event.nw	14 Apr 2006 11:49:27 -0000	1.22
  @@ -881,6 +881,8 @@
   
     int zoom_scale;
     int diff_x;
  +  int skip_event=0;
  +  GdkEvent *test_event;
   
     exit_if_null(w_current);
     global_window_current = w_current;
  @@ -889,13 +891,6 @@
     w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
     w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;
   
  -  mouse_x = (int) event->x;
  -  mouse_y = (int) event->y;
  -
  -  if (w_current->cowindow) {
  -    coord_display_update(w_current, mouse_x, mouse_y);
  -  }
  -
   #if DEBUG
     /* printf("MOTION!\n");*/
   #endif
  @@ -909,6 +904,28 @@
     }
   #endif
   
  +  /* skip the moving event if there are other moving events in the 
  +     gdk event queue (Werner)
  +     Only skip the event if is the same event and no buttons or modifier 
  +     keys changed*/
  +  if ((test_event = gdk_event_get()) != NULL) {
  +    if (test_event->type == GDK_MOTION_NOTIFY
  +	&& ((GdkEventMotion *) test_event)->state == event->state) {
  +      skip_event= 1;
  +    }
  +    gdk_event_put(test_event); /* put it back in front of the queue */
  +    gdk_event_free(test_event);
  +    if (skip_event == 1)
  +      return 0;
  +  }
  +
  +  mouse_x = (int) event->x;
  +  mouse_y = (int) event->y;
  +
  +  if (w_current->cowindow) {
  +    coord_display_update(w_current, mouse_x, mouse_y);
  +  }
  +
     if (w_current->third_button == MOUSEPAN_ENABLED) {
       if((w_current->event_state == MOUSEPAN) &&
          w_current->inside_action) {
  
  
  
  1.15      +2 -2      eda/geda/devel/gschem/noweb/x_print.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_print.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/x_print.nw,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- x_print.nw	3 Apr 2006 18:34:52 -0000	1.14
  +++ x_print.nw	14 Apr 2006 11:49:27 -0000	1.15
  @@ -553,8 +553,8 @@
   
       box = gtk_hbox_new(FALSE, 0);
       gtk_container_border_width(GTK_CONTAINER(box), 0);
  -    gtk_box_pack_start(GTK_CONTAINER(vbox), box, FALSE, TRUE, 5);
  -    gtk_box_set_spacing(box, 10);
  +    gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, TRUE, 5);
  +    gtk_box_set_spacing(GTK_BOX(box), 10);
       gtk_widget_show(box);
   
       label = gtk_label_new (_("Filename"));