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

gEDA-cvs: branch: master updated (1.1.1.20070708-18-g7f54d6e)



The branch, master has been updated
       via  7f54d6e4996f15d14781a49b3400ce89a39a60dd (commit)
       via  50a6da87868ce9d0f3cc788a8a9918fd9210a536 (commit)
       via  8ad905e0d55b7ed60b3f5c63cf6056ddccee7a8b (commit)
      from  e4f7225254cb5168131d31347a8de277181f41ea (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/a_zoom.c       |   17 ++++++++-----
 gschem/src/x_compselect.c |   14 ++++++----
 gschem/src/x_preview.c    |   57 ++++++++++++++++++++++++++++++++++++++------
 3 files changed, 67 insertions(+), 21 deletions(-)


=================
 Commit Messages
=================

commit 7f54d6e4996f15d14781a49b3400ce89a39a60dd
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 05:10:27 2007 +0100

    Make the preview widget resizable
    
    Added handler for the configure event to resize the backing store and
    re-zoom the preview. Added the A_PAN_IGNORE_BORDERS flag to the zoom
    extents calls - giving a nice centered preview.
    
    Altered component selector dialog's alignment widget to allow the preview
    widget to expand to fill the available space.

:100644 100644 f8c2e0b... e890e7f... M	gschem/src/x_compselect.c
:100644 100644 2653563... 692703e... M	gschem/src/x_preview.c

commit 50a6da87868ce9d0f3cc788a8a9918fd9210a536
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 04:52:23 2007 +0100

    Fix mouse initiated zoom / panning operations on the preview widget
    
    The preview widget isn't called with a filename for previewing component
    sources, so the test for filename != NULL in the mouse event handlers
    stopped those callbacks working.
    
    Also added a scroll event handler to allow zooming with the mouse wheel.

:100644 100644 25636d0... 2653563... M	gschem/src/x_preview.c

commit 8ad905e0d55b7ed60b3f5c63cf6056ddccee7a8b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 04:49:35 2007 +0100

    Fix zoom extents to work correctly first time. Closes bug #1699959.
    
    A page's visible area is intialised to be the same size as the canvas
    extents. The zoom extents code scales based on this visible area, however
    this initialisation isn't correct, since the aspect ratio of the screen
    doesn't always match the canvas extents. The first call to zoom extents
    would fix this by correctly setting the visible area.
    
    By making the zoom extents code work from the screen aspect ratio (scaled
    to world coordinates), we can zoom to the visible extents in one shot.
    
    Also fixed some /2 operations, which for doubles should be /2.0

:100644 100644 8f431f3... 44b5683... M	gschem/src/a_zoom.c

=========
 Changes
=========

commit 7f54d6e4996f15d14781a49b3400ce89a39a60dd
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 05:10:27 2007 +0100

    Make the preview widget resizable
    
    Added handler for the configure event to resize the backing store and
    re-zoom the preview. Added the A_PAN_IGNORE_BORDERS flag to the zoom
    extents calls - giving a nice centered preview.
    
    Altered component selector dialog's alignment widget to allow the preview
    widget to expand to fill the available space.

diff --git a/gschem/src/x_compselect.c b/gschem/src/x_compselect.c
index f8c2e0b..e890e7f 100644
--- a/gschem/src/x_compselect.c
+++ b/gschem/src/x_compselect.c
@@ -1095,12 +1095,14 @@ compselect_init (Compselect *compselect)
                                     NULL));
   alignment = GTK_WIDGET (g_object_new (GTK_TYPE_ALIGNMENT,
                                         /* GtkAlignment */
-                                        "right-padding", 5,
-                                        "left-padding",  5,
-                                        "xscale",        0.0,
-                                        "yscale",        0.0,
-                                        "xalign",        0.5,
-                                        "yalign",        0.5,
+                                        "left-padding",   5,
+                                        "right-padding",  5,
+                                        "top-padding",    5,
+                                        "bottom-padding", 5,
+                                        "xscale",         1.0,
+                                        "yscale",         1.0,
+                                        "xalign",         0.5,
+                                        "yalign",         0.5,
                                         NULL));
   preview = GTK_WIDGET (g_object_new (TYPE_PREVIEW,
                                       /* Preview */
diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index 2653563..692703e 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -88,6 +88,11 @@ preview_callback_realize (GtkWidget *widget,
   preview_toplevel->window = preview_toplevel->drawing_area->window;
   gtk_widget_grab_focus (preview_toplevel->drawing_area);
 
+  preview_toplevel->width  = preview_toplevel->drawing_area->allocation.width;
+  preview_toplevel->height = preview_toplevel->drawing_area->allocation.height;
+  preview_toplevel->win_width  = preview_toplevel->width;
+  preview_toplevel->win_height = preview_toplevel->height;
+
   preview_toplevel->backingstore = gdk_pixmap_new (
     preview_toplevel->window,
     preview_toplevel->drawing_area->allocation.width,
@@ -118,7 +123,7 @@ preview_callback_realize (GtkWidget *widget,
 
   a_zoom_extents(preview_toplevel,
                  preview_page->object_head,
-                 A_PAN_DONT_REDRAW);
+                 A_PAN_DONT_REDRAW | A_PAN_IGNORE_BORDERS);
 
   o_redraw_all(preview_toplevel);
 
@@ -271,7 +276,7 @@ preview_update (Preview *preview)
   /* display current page (possibly empty) */
   a_zoom_extents (preview_toplevel,
                   preview_toplevel->page_current->object_head,
-                  A_PAN_DONT_REDRAW);
+                  A_PAN_DONT_REDRAW | A_PAN_IGNORE_BORDERS);
   o_redraw_all (preview_toplevel);
   
 }
@@ -338,6 +343,30 @@ preview_class_init (PreviewClass *klass)
         
 }
 
+static gboolean
+preview_event_configure (GtkWidget         *widget,
+                         GdkEventConfigure *event,
+                         gpointer           user_data)
+{
+  gboolean retval;
+  int save_redraw;
+  TOPLEVEL *preview_toplevel = PREVIEW (widget)->preview_toplevel;
+  PAGE     *preview_page = preview_toplevel->page_current;
+
+  save_redraw = preview_toplevel->DONT_REDRAW;
+  preview_toplevel->DONT_REDRAW = 1;
+  retval = x_event_configure (widget, event, preview_toplevel);
+  preview_toplevel->DONT_REDRAW = save_redraw;
+  if (preview_page != NULL) {
+    a_zoom_extents(preview_toplevel,
+                   preview_page->object_head,
+                   A_PAN_DONT_REDRAW | A_PAN_IGNORE_BORDERS);
+    o_redraw_all_fast(preview_toplevel);
+  }
+  return retval;
+}
+
+
 static gint
 preview_event_scroll (GtkWidget *widget,
                       GdkEventScroll *event,
@@ -357,6 +386,7 @@ preview_init (Preview *preview)
     { "expose_event",         G_CALLBACK (preview_callback_expose)        },
     { "button_press_event",   G_CALLBACK (preview_callback_button_press)  },
     { "motion_notify_event",  G_CALLBACK (preview_callback_motion_notify) },
+    { "configure_event",      G_CALLBACK (preview_event_configure)        },
     { "scroll_event",         G_CALLBACK (preview_event_scroll)           },
     { NULL,                   NULL                                        }
   }, *tmp;
@@ -368,6 +398,7 @@ preview_init (Preview *preview)
   preview_toplevel->init_top    = 0;
   preview_toplevel->init_right  = WIDTH_C;
   preview_toplevel->init_bottom = HEIGHT_C;
+
   preview_toplevel->width  = 160;
   preview_toplevel->height = 120;
   preview_toplevel->win_width  = preview_toplevel->width;

commit 50a6da87868ce9d0f3cc788a8a9918fd9210a536
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 04:52:23 2007 +0100

    Fix mouse initiated zoom / panning operations on the preview widget
    
    The preview widget isn't called with a filename for previewing component
    sources, so the test for filename != NULL in the mouse event handlers
    stopped those callbacks working.
    
    Also added a scroll event handler to allow zooming with the mouse wheel.

diff --git a/gschem/src/x_preview.c b/gschem/src/x_preview.c
index 25636d0..2653563 100644
--- a/gschem/src/x_preview.c
+++ b/gschem/src/x_preview.c
@@ -100,6 +100,9 @@ preview_callback_realize (GtkWidget *widget,
 
   i_vars_set (preview_toplevel);
 
+  /* be sure to turn off scrollbars */
+  preview_toplevel->scrollbars_flag = FALSE;
+
   /* be sure to turn off the grid */
   preview_toplevel->grid = FALSE;
 
@@ -166,11 +169,11 @@ preview_callback_button_press (GtkWidget *widget,
 {
   Preview *preview = PREVIEW (widget);
   TOPLEVEL *preview_toplevel = preview->preview_toplevel;
-  
-  if (!preview->active || preview->filename == NULL) {
+
+  if (!preview->active) {
     return TRUE;
   }
-  
+
   switch (event->button) {
       case 1: /* left mouse button: zoom in */
         a_zoom (preview_toplevel, ZOOM_IN, HOTKEY, 0);
@@ -208,7 +211,7 @@ preview_callback_motion_notify (GtkWidget *widget,
 {
   Preview *preview = PREVIEW (widget);
   
-  if (!preview->active || preview->filename == NULL) {
+  if (!preview->active) {
     return TRUE;
   }
   
@@ -335,6 +338,14 @@ preview_class_init (PreviewClass *klass)
         
 }
 
+static gint
+preview_event_scroll (GtkWidget *widget,
+                      GdkEventScroll *event,
+                      TOPLEVEL *w_current)
+{
+  return x_event_scroll (widget, event, PREVIEW (widget)->preview_toplevel);
+}
+
 static void
 preview_init (Preview *preview)
 {
@@ -346,6 +357,7 @@ preview_init (Preview *preview)
     { "expose_event",         G_CALLBACK (preview_callback_expose)        },
     { "button_press_event",   G_CALLBACK (preview_callback_button_press)  },
     { "motion_notify_event",  G_CALLBACK (preview_callback_motion_notify) },
+    { "scroll_event",         G_CALLBACK (preview_event_scroll)           },
     { NULL,                   NULL                                        }
   }, *tmp;
   TOPLEVEL *preview_toplevel;
@@ -360,8 +372,6 @@ preview_init (Preview *preview)
   preview_toplevel->height = 120;
   preview_toplevel->win_width  = preview_toplevel->width;
   preview_toplevel->win_height = preview_toplevel->height;
-  /* be sure to turn off scrollbars */
-  preview_toplevel->scrollbars_flag = FALSE;
 
   preview_toplevel->drawing_area = GTK_WIDGET (preview);
   preview->preview_toplevel = preview_toplevel;

commit 8ad905e0d55b7ed60b3f5c63cf6056ddccee7a8b
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Sun Jul 22 04:49:35 2007 +0100

    Fix zoom extents to work correctly first time. Closes bug #1699959.
    
    A page's visible area is intialised to be the same size as the canvas
    extents. The zoom extents code scales based on this visible area, however
    this initialisation isn't correct, since the aspect ratio of the screen
    doesn't always match the canvas extents. The first call to zoom extents
    would fix this by correctly setting the visible area.
    
    By making the zoom extents code work from the screen aspect ratio (scaled
    to world coordinates), we can zoom to the visible extents in one shot.
    
    Also fixed some /2 operations, which for doubles should be /2.0

diff --git a/gschem/src/a_zoom.c b/gschem/src/a_zoom.c
index 8f431f3..44b5683 100644
--- a/gschem/src/a_zoom.c
+++ b/gschem/src/a_zoom.c
@@ -200,16 +200,19 @@ void a_zoom_extents(TOPLEVEL *w_current, OBJECT *o_current, int pan_flags)
          lleft, lright, ltop, lbottom);
 #endif
 
-  /*calc the necessary zoomfactor to show everything
-    taking the fabs makes only sense if they're not sorted*/
-  zx = (double) GET_PAGE_WIDTH(w_current) / fabs(lright-lleft);
-  zy = (double) GET_PAGE_HEIGHT(w_current) / fabs(lbottom-ltop);
+  /* Calc the necessary zoomfactor to show everything
+   * Start with the windows width and height, then scale back to world
+   * coordinates with the to_screen_y_constant as the initial page data
+   * may not have the correct aspect ratio. */
+  zx = (double)w_current->width / (lright-lleft);
+  zy = (double)w_current->height / (lbottom-ltop);
   /* choose the smaller one, 0.9 for paddings on all side*/
-  relativ_zoom_factor = (zx < zy ? zx : zy) * 0.9;
+  relativ_zoom_factor = (zx < zy ? zx : zy) * 0.9
+    / w_current->page_current->to_screen_y_constant;
 	
   /*get the center of the objects*/
-  world_pan_center_x = (double) (lright + lleft) /2;
-  world_pan_center_y = (double) (lbottom + ltop) /2;
+  world_pan_center_x = (double) (lright + lleft) /2.0;
+  world_pan_center_y = (double) (lbottom + ltop) /2.0;
 	
   /* and create the new window*/
   a_pan_general(w_current, world_pan_center_x, world_pan_center_y,




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs