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

gEDA-cvs: gaf.git: branch: master updated (1.5.1-20081221-156-g330e6bc)



The branch, master has been updated
       via  330e6bc49a83a176c549644011d186dbc5e1d8b9 (commit)
      from  ef5ab409dc62994ce6aea57586c0698c11291bac (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
=========

 libgeda/include/prototype.h |    2 +-
 libgeda/include/struct.h    |    7 +++++++
 libgeda/src/o_text_basic.c  |   26 ++++++++++++++++++++++++--
 libgeda/src/s_toplevel.c    |    3 +++
 4 files changed, 35 insertions(+), 3 deletions(-)


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

commit 330e6bc49a83a176c549644011d186dbc5e1d8b9
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 7 13:47:27 2009 +0000

    libgeda: Font-renderer-specific text bounds functions.
    
    When using arbitrary fonts, libgeda can't know the world extents of a
    TEXT object without reference to the font renderer.
    
    This patch adds a mechanism for applications (i.e. gschem) to register
    a callback to be used by libgeda for calculating the bounds of a TEXT
    object.

:100644 100644 78408d5... d1d2a8f... M	libgeda/include/prototype.h
:100644 100644 eb5ffb4... b2c0084... M	libgeda/include/struct.h
:100644 100644 6c5864b... 289597e... M	libgeda/src/o_text_basic.c
:100644 100644 e89bc2c... 0b7da2d... M	libgeda/src/s_toplevel.c

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

commit 330e6bc49a83a176c549644011d186dbc5e1d8b9
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date:   Wed Jan 7 13:47:27 2009 +0000

    libgeda: Font-renderer-specific text bounds functions.
    
    When using arbitrary fonts, libgeda can't know the world extents of a
    TEXT object without reference to the font renderer.
    
    This patch adds a mechanism for applications (i.e. gschem) to register
    a callback to be used by libgeda for calculating the bounds of a TEXT
    object.

diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 78408d5..d1d2a8f 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -293,7 +293,7 @@ void o_text_rotate_world(TOPLEVEL *toplevel, int world_centerx, int world_center
 void o_text_mirror_world(TOPLEVEL *toplevel, int world_centerx, int world_centery, OBJECT *object);
 void o_text_set_string(TOPLEVEL *toplevel, OBJECT *obj, const gchar *new_string);
 const gchar *o_text_get_string(TOPLEVEL *toplevel, OBJECT *obj);
-
+void o_text_set_rendered_bounds_func (TOPLEVEL *toplevel, RenderedBoundsFunc func, void *user_data);
 /* s_attrib.c */
 int s_attrib_add_entry(char *new_attrib);
 void s_attrib_print(void);
diff --git a/libgeda/include/struct.h b/libgeda/include/struct.h
index eb5ffb4..b2c0084 100644
--- a/libgeda/include/struct.h
+++ b/libgeda/include/struct.h
@@ -439,6 +439,9 @@ struct st_page {
 /*! \brief different kind of snapping mechanisms used in TOPLEVEL */
 typedef enum {SNAP_OFF, SNAP_GRID, SNAP_RESNAP, SNAP_STATE_COUNT} SNAP_STATE;
 
+/*! \brief Type of callback function for calculating text bounds */
+typedef int(*RenderedBoundsFunc)(void *, OBJECT *, int *, int *, int *, int *);
+
 struct st_toplevel {
 
   /* have to decided on component list stuff */
@@ -572,6 +575,10 @@ struct st_toplevel {
   int hierarchy_netname_order;
   int hierarchy_uref_order;
   char *unnamed_netname;
+
+  /* Callback function for calculating text bounds */
+  RenderedBoundsFunc rendered_text_bounds_func;
+  void *rendered_text_bounds_data;
 };
 
 /* structures below are for gnetlist */
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index 6c5864b..289597e 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -169,8 +169,15 @@ static void update_disp_string(OBJECT *o)
 int world_get_text_bounds(TOPLEVEL *toplevel, OBJECT *o_current, int *left,
                           int *top, int *right, int *bottom)
 {
-  return world_get_object_glist_bounds (toplevel, o_current->text->prim_objs,
-                                        left, top, right, bottom);
+  if (toplevel->rendered_text_bounds_func == NULL) {
+    return world_get_object_glist_bounds (toplevel, o_current->text->prim_objs,
+                                          left, top, right, bottom);
+  } else {
+    return
+      toplevel->rendered_text_bounds_func (toplevel->rendered_text_bounds_data,
+                                           o_current,
+                                           left, top, right, bottom);
+  }
 }
 
 /*! \brief get the position of a text object
@@ -1883,3 +1890,18 @@ const gchar *o_text_get_string (TOPLEVEL *toplevel, OBJECT *obj)
 
   return obj->text->string;
 }
+
+/*! \brief Set the font-renderer-specific bounds function.
+ *  \par Function Description
+ *  Set the function to be used to calculate text bounds for a given
+ *  #TOPLEVEL.
+ *
+ *  \param [in] func      Function to use.
+ *  \param [in] user_data User data to be passed to the function.
+ */
+void o_text_set_rendered_bounds_func (TOPLEVEL *toplevel,
+                                      RenderedBoundsFunc func,
+                                      void *user_data) {
+  toplevel->rendered_text_bounds_func = func;
+  toplevel->rendered_text_bounds_data = user_data;
+}
diff --git a/libgeda/src/s_toplevel.c b/libgeda/src/s_toplevel.c
index e89bc2c..0b7da2d 100644
--- a/libgeda/src/s_toplevel.c
+++ b/libgeda/src/s_toplevel.c
@@ -143,6 +143,9 @@ TOPLEVEL *s_toplevel_new (void)
   toplevel->hierarchy_uref_order = 0;
   toplevel->unnamed_netname = NULL;
 
+  toplevel->rendered_text_bounds_func = NULL;
+  toplevel->rendered_text_bounds_data = NULL;
+
   /* Auto-save interval */
   toplevel->auto_save_interval = 0;
   toplevel->auto_save_timeout = 0;




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