Mercurial > MadButterfly
changeset 186:530bb7728546 include_mb_test
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
This is the solution that I dicussed with FourDollars, last night.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 05 Nov 2008 15:24:01 +0800 |
parents | c7e5b8779bb5 |
children | 576fcd1c529a |
files | examples/calculator/main.c examples/svg2code_ex/main.c examples/tank/tank_main.c include/Makefile.am include/mb.h include/mb/X_supp.h include/mb/animate.h include/mb/mb.h include/mb/mb_timer.h include/mb/mb_types.h include/mb/observer.h include/mb/paint.h include/mb/redraw_man.h include/mb/shapes.h include/mb/tools.h include/mb_X_supp.h include/mb_animate.h include/mb_observer.h include/mb_paint.h include/mb_redraw_man.h include/mb_shapes.h include/mb_timer.h include/mb_tools.h include/mb_types.h src/X_main.c src/X_supp.c src/animate.c src/chgcolor.c src/coord.c src/event.c src/geo.c src/observer.c src/paint.c src/redraw_man.c src/rotate.c src/shape_path.c src/shape_rect.c src/shape_text.c src/shift.c src/timer.c src/timertool.c src/tools.c src/visibility.c tools/mb_c_source.m4 |
diffstat | 44 files changed, 976 insertions(+), 977 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/calculator/main.c Tue Nov 04 17:00:26 2008 +0800 +++ b/examples/calculator/main.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,5 +1,5 @@ #include <stdio.h> -#include <mb/mb.h> +#include <mb.h> #include "calculator_scr.h" typedef struct _calc_data calc_data_t;
--- a/examples/svg2code_ex/main.c Tue Nov 04 17:00:26 2008 +0800 +++ b/examples/svg2code_ex/main.c Wed Nov 05 15:24:01 2008 +0800 @@ -5,7 +5,7 @@ * */ #include <stdio.h> -#include <mb/mb.h> +#include <mb.h> #include "svg2code_ex.h" typedef struct _ex_rt ex_rt_t;
--- a/examples/tank/tank_main.c Tue Nov 04 17:00:26 2008 +0800 +++ b/examples/tank/tank_main.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,8 +1,8 @@ #include <math.h> #include <sys/time.h> #include <string.h> -#include <mb/mb.h> -#include <mb/tools.h> +#include <mb.h> +#include <mb_tools.h> #include "svgs.h" enum { MUD, ROC, BRI, BSH };
--- a/include/Makefile.am Tue Nov 04 17:00:26 2008 +0800 +++ b/include/Makefile.am Wed Nov 05 15:24:01 2008 +0800 @@ -1,12 +1,11 @@ -includedir = $(prefix)/include/mb include_HEADERS = \ - mb/animate.h \ - mb/mb.h \ - mb/mb_timer.h \ - mb/mb_types.h \ - mb/observer.h \ - mb/paint.h \ - mb/redraw_man.h \ - mb/shapes.h \ - mb/tools.h \ - mb/X_supp.h + mb_animate.h \ + mb.h \ + mb_timer.h \ + mb_types.h \ + mb_observer.h \ + mb_paint.h \ + mb_redraw_man.h \ + mb_shapes.h \ + mb_tools.h \ + mb_X_supp.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,10 @@ +#ifndef __MB_H_ +#define __MB_H_ + +#include "mb_types.h" +#include "mb_redraw_man.h" +#include "mb_X_supp.h" +#include "mb_animate.h" +#include "mb_shapes.h" + +#endif /* __MB_H_ */
--- a/include/mb/X_supp.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#ifndef __X_SUPP_H_ -#define __X_SUPP_H_ - -#include <X11/Xlib.h> -#include "mb_types.h" -#include "mb_timer.h" -#include "redraw_man.h" - -/*! \ingroup xkb - * @{ - */ -typedef struct _X_kb_info X_kb_info_t; - -struct _X_kb_event { - event_t event; - int keycode; - int sym; -}; -typedef struct _X_kb_event X_kb_event_t; - -/* @} */ - -typedef struct _X_MB_runtime X_MB_runtime_t; - -extern void X_MB_handle_connection(X_MB_runtime_t *rt); -extern X_MB_runtime_t *X_MB_new(const char *display_name, int w, int h); -extern void X_MB_free(X_MB_runtime_t *xmb_rt); - -extern subject_t *X_MB_kbevents(X_MB_runtime_t *xmb_rt); -extern redraw_man_t *X_MB_rdman(X_MB_runtime_t *xmb_rt); -extern mb_tman_t *X_MB_tman(X_MB_runtime_t *xmb_rt); -extern ob_factory_t *X_MB_ob_factory(X_MB_runtime_t *xmb_rt); - -#endif
--- a/include/mb/animate.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -#ifndef __ANIMATE_H_ -#define __ANIMATE_H_ - -#include "mb_types.h" -#include "mb_timer.h" -#include "paint.h" - -/*! \page def_action How to Define An Action? - * - * A action must implement following 4 functions. - * \li start, - * \li step, - * \li stop, - * \li free, - * \li *_new(), and - * \li add *_new() to \ref animate.h . - * - * *_new() must invokes mb_word_add_action() to add new object - * as one of actions in the word specified as an argument of it. - * It also means *_new() must have an argument with type of - * (mb_word_t *). - */ - -/*! \defgroup anim Animation - * \brief Animation is a set of functions to make graph moving. - * @{ - */ -typedef struct _mb_progm mb_progm_t; -typedef struct _mb_word mb_word_t; -typedef struct _mb_action mb_action_t; - -struct _mb_progm_complete { - event_t event; - mb_progm_t *progm; -}; -typedef struct _mb_progm_complete mb_progm_complete_t; - -extern mb_progm_t *mb_progm_new(int max_words, redraw_man_t *rdman); -extern void mb_progm_free(mb_progm_t *progm); -extern mb_word_t *mb_progm_next_word(mb_progm_t *progm, - const mb_timeval_t *start, - const mb_timeval_t *playing); -extern void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman, - mb_timeval_t *now); -extern void mb_progm_abort(mb_progm_t *progm); -extern subject_t *mb_progm_get_complete(mb_progm_t *progm); - -/*! \defgroup ani_actions Animation Actions - * @{ - */ -extern mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord, - mb_word_t *word); -extern mb_action_t *mb_chgcolor_new(co_comp_t r, co_comp_t g, - co_comp_t b, co_comp_t a, - paint_t *paint, mb_word_t *word); -extern mb_action_t *mb_rotate_new(float angle1, float angle2, - coord_t *coord, mb_word_t *word); - -enum { VIS_VISIBLE, VIS_HIDDEN }; -extern mb_action_t *mb_visibility_new(int visib, coord_t *coord, - mb_word_t *word); -/* @} */ - -/*! \defgroup act_support Action Supports. - * @{ - */ -/*! \brief Basic class of animation actions. - * - * \sa \ref def_action - */ -struct _mb_action { - void (*start)(mb_action_t *act, - const mb_timeval_t *now, - const mb_timeval_t *playing_time, - redraw_man_t *rdman); - void (*step)(mb_action_t *act, const mb_timeval_t *now, - redraw_man_t *rdman); - void (*stop)(mb_action_t *act, const mb_timeval_t *now, - redraw_man_t *rdman); - void (*free)(mb_action_t *act); - mb_action_t *next; -}; - -extern void mb_word_add_action(mb_word_t *word, mb_action_t *act); -/* @} */ - -/* @} */ - -#endif /* __ANIMATE_H_ */
--- a/include/mb/mb.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -#ifndef __MB_H_ -#define __MB_H_ - -#include "mb_types.h" -#include "redraw_man.h" -#include "X_supp.h" -#include "animate.h" -#include "shapes.h" - -#endif /* __MB_H_ */
--- a/include/mb/mb_timer.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#ifndef __MB_TIMER_H_ -#define __MB_TIMER_H_ - -#include <sys/time.h> -#include <stdint.h> - -typedef uint32_t mbsec_t; -typedef uint32_t mbusec_t; -typedef struct _mb_timer mb_timer_t; -typedef struct _mb_tman mb_tman_t; -typedef struct timeval mb_timeval_t; - - -typedef void (*mb_tmo_hdlr)(const mb_timeval_t *tmo, - const mb_timeval_t *now, - void *arg); - -extern mb_tman_t *mb_tman_new(void); -extern void mb_tman_free(mb_tman_t *tman); -extern mb_timer_t *mb_tman_timeout(mb_tman_t *tman, - const mb_timeval_t *tmo, - mb_tmo_hdlr hdlr, void *arg); -extern int mb_tman_remove(mb_tman_t *tman, mb_timer_t *timer); -extern int mb_tman_next_timeout(mb_tman_t *tman, - const mb_timeval_t *now, - mb_timeval_t *tmo_after); -extern int mb_tman_handle_timeout(mb_tman_t *tman, mb_timeval_t *now); - -#define MB_TIMEVAL_SET(_tv, _sec, _usec) \ - do { \ - (_tv)->tv_sec = _sec; \ - (_tv)->tv_usec = _usec; \ - } while(0) -#define MB_TIMEVAL_CP(_tv1, _tv2) \ - do { \ - (_tv1)->tv_sec = (_tv2)->tv_sec; \ - (_tv1)->tv_usec = (_tv2)->tv_usec; \ - } while(0) -#define MB_TIMEVAL_SEC(_tv) ((_tv)->tv_sec) -#define MB_TIMEVAL_USEC(_tv) ((_tv)->tv_usec) -#define MB_TIMEVAL_LATER(a, b) \ - ((a)->tv_sec > (b)->tv_sec || \ - ((a)->tv_sec == (b)->tv_sec && \ - (a)->tv_usec > (b)->tv_usec)) -#define MB_TIMEVAL_LATER_INC(a, b) \ - ((a)->tv_sec > (b)->tv_sec || \ - ((a)->tv_sec == (b)->tv_sec && \ - (a)->tv_usec >= (b)->tv_usec)) -#define MB_TIMEVAL_EQ(a, b) \ - ((a)->tv_sec == (b)->tv_sec && \ - (a)->tv_usec == (b)->tv_usec) -#define MB_TIMEVAL_DIFF(a, b) \ - do { \ - (a)->tv_sec -= (b)->tv_sec; \ - if((a)->tv_usec < (b)->tv_usec) { \ - (a)->tv_sec--; \ - (a)->tv_usec += 1000000; \ - } \ - (a)->tv_usec -= (b)->tv_usec; \ - } while(0) -#define MB_TIMEVAL_ADD(a, b) \ - do { \ - (a)->tv_sec += (b)->tv_sec; \ - (a)->tv_usec += (b)->tv_usec; \ - if((a)->tv_usec >= 1000000) { \ - (a)->tv_sec++; \ - (a)->tv_usec -= 1000000; \ - } \ - } while(0) -#define MB_TIMEVAL_DIV(a, b) \ - (((a)->tv_sec * 1000000.0 + (a)->tv_usec) / \ - ((b)->tv_sec * 1000000.0 + (b)->tv_usec)) - - -extern void get_now(mb_timeval_t *tmo); - - -#endif /* __MB_TIMER_H_ */
--- a/include/mb/mb_types.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -#ifndef __MB_TYPES_H_ -#define __MB_TYPES_H_ - -#include <cairo.h> -#include "tools.h" -#include "observer.h" - -typedef float co_aix; -typedef struct _shape shape_t; -typedef struct _geo geo_t; -typedef struct _area area_t; -typedef struct _shnode shnode_t; -typedef struct _paint paint_t; - -struct _redraw_man; - -/*! \brief Base of paint types. - * - * Paints should be freed by users by calling rdman_paint_free() of - * the paint. - * - * \todo move member functions to a seperate structure and setup a - * singleton fro each paint type. - */ -struct _paint { - int flags; - void (*prepare)(paint_t *paint, cairo_t *cr); - void (*free)(struct _redraw_man *rdman, paint_t *paint); - STAILQ(shnode_t) members; - paint_t *pnt_next; /*!< \brief Collect all paints of a rdman. */ -}; - -#define PNTF_FREE 0x1 - -struct _shnode { - shape_t *shape; - shnode_t *next; -}; - -struct _area { - co_aix x, y; - co_aix w, h; -}; - -/*! \brief Geometry data of a shape or a group of shape. - */ -struct _geo { -#ifdef GEO_ORDER - unsigned int order; -#endif - unsigned int flags; - shape_t *shape; - geo_t *coord_next; /*!< \brief Link all member geos together. */ - - area_t *cur_area, *last_area; - area_t areas[2]; - - subject_t *mouse_event; -}; -#define GEF_DIRTY 0x1 -#define GEF_HIDDEN 0x2 /*!< The geo is hidden. */ -#define GEF_FREE 0x4 - -extern int is_overlay(area_t *r1, area_t *r2); -extern void area_init(area_t *area, int n_pos, co_aix pos[][2]); -extern void geo_init(geo_t *g); -extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); -extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, - int *n_overlays, geo_t **overlays); -#define geo_get_shape(g) ((g)->shape) -#define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) -#define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w))) -#define geo_pos_is_in(g, _x, _y) \ - (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \ - _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h)) - - -/*! \brief A coordination system. - * - * It have a transform function defined by matrix to transform - * coordination from source space to target space. - * Source space is where the contained is drawed, and target space - * is where the coordination of parent container of the element - * represented by this coord object. - * - * \dot - * digraph G { - * graph [rankdir=LR]; - * root -> child00 -> child10 -> child20 [label="children" color="blue"]; - * child00 -> child01 -> child02 [label="sibling"]; - * child10 -> child11 [label="sibling"]; - * } - * \enddot - */ -typedef struct _coord { - unsigned int order; - unsigned int flags; - co_aix opacity; - /*! Own one or inherit from an ancestor. - * Setup it when clean coords. - * \sa - * - \ref COF_OWN_CANVAS - * - \ref redraw - */ - cairo_t *canvas; - area_t *cur_area, *last_area; - area_t areas[2]; - - co_aix matrix[6]; - co_aix aggr_matrix[6]; - - struct _coord *parent; - STAILQ(struct _coord) children; - struct _coord *sibling; - unsigned int before_pmem; /*!< \brief The coord is before nth member - * of parent. */ - - int num_members; - STAILQ(geo_t) members; /*!< \brief All geo_t members in this coord. */ - - STAILQ(shape_t) shapes; /*!< \brief All shapes managed by the rdman. */ - - subject_t *mouse_event; -} coord_t; -#define COF_DIRTY 0x1 -#define COF_HIDDEN 0x2 /*!< A coord is hidden. */ -#define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it - * from an ancestor. - */ -#define COF_SKIP_TRIVAL 0x8 /*!< temporary skip descendants - * when trivaling. - */ -#define COF_FREE 0x10 - -extern void coord_init(coord_t *co, coord_t *parent); -extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); -extern co_aix coord_trans_size(coord_t *co, co_aix size); -extern void compute_aggr_of_coord(coord_t *coord); -extern void update_aggr_matrix(coord_t *start); -extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); -extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last); -extern void preorder_coord_skip_subtree(coord_t *subroot); -#define preorder_coord_skip_subtree(sub) \ - do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0) -#define coord_hide(co) \ - do { \ - (co)->flags |= COF_HIDDEN; \ - } while(0) -#define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) -#define coord_get_mouse_event(coord) ((coord)->mouse_event) - - -/*! \brief A grahpic shape. - * - * \dot - * digraph G { - * "shape" -> "coord"; - * "shape" -> "geo"; - * "geo" -> "shape"; - * "coord" -> "shape" [label="members"] - * "shape" -> "shape" [label="sibling"]; - * } - * \enddot - */ -struct _shape { - int sh_type; - geo_t *geo; - coord_t *coord; - paint_t *fill, *stroke; - co_aix stroke_width; - int stroke_linecap:2; - int stroke_linejoin:2; - struct _shape *sh_next; /*!< Link all shapes of a rdman together. */ - void (*free)(shape_t *shape); -}; -enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; - -#define sh_get_mouse_event_subject(sh) ((sh)->geo->mouse_event) -#define sh_hide(sh) \ - do { \ - (sh)->geo->flags |= GEF_HIDDEN; \ - } while(0) -#define sh_show(sh) \ - do { \ - (sh)->geo->flags &= ~GEF_HIDDEN; \ - } while(0) - - -#endif /* __MB_TYPES_H_ */
--- a/include/mb/observer.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -#ifndef __OBSERVER_H_ -#define __OBSERVER_H_ - -#include "tools.h" - -typedef struct _event event_t; -typedef struct _observer observer_t; -typedef struct _subject subject_t; -typedef struct _mouse_event mouse_event_t; -typedef struct _ob_factory ob_factory_t; -typedef void (*evt_handler)(event_t *event, void *arg); - -struct _event { - int type; /*!< event type (a.k.a. EVT_* */ - subject_t *tgt, *cur_tgt; -}; - -/*! \brief Observer of observer pattern. - * - * A target for receiving events. - */ -struct _observer { - evt_handler hdr; - void *arg; - observer_t *next; -}; - -/*! \brief Subject of observer pattern. - * - * Observer is a pattern to decouple caller and callee, - * especial for multiple callee. - * \see http://en.wikipedia.org/wiki/Observer_pattern - */ -struct _subject { - int obj_type; /*!< \brief type of object (a.k.a. OBJT_*). */ - void *obj; /*!< \brief the object this subject for. */ - int flags; - STAILQ(observer_t) observers; -}; -/*! \brief Flag that make a subject to propagate events to parents. */ -#define SUBF_STOP_PROPAGATE 0x1 -#define SUBF_BUSY 0x2 /*!< \brief in subject_notify() */ -#define SUBF_FREE 0x4 /*!< \brief in postponding subject_free() */ - -enum {OBJT_GEO, OBJT_COORD, OBJT_KB, OBJT_PROGM, OBJT_RDMAN}; - -struct _mouse_event { - event_t event; - int x, y; - unsigned int but_state; - unsigned int button; -}; - -#define MOUSE_BUT1 0x1 -#define MOUSE_BUT2 0x2 -#define MOUSE_BUT3 0x4 - -/*! \brief Observer factory. - * - * It provides functions for allocation of subject and observer objects, - * and strategy function for getting the subject of parent coord object. - */ -struct _ob_factory { - subject_t *(*subject_alloc)(ob_factory_t *factory); - void (*subject_free)(ob_factory_t *factory, subject_t *subject); - observer_t *(*observer_alloc)(ob_factory_t *factory); - void (*observer_free)(ob_factory_t *factory, observer_t *observer); - /*! This is a strategy function to get subjects of parents. */ - subject_t *(*get_parent_subject)(ob_factory_t *factory, - subject_t *cur_subject); -}; - -enum {EVT_MOUSE_OVER, EVT_MOUSE_OUT, EVT_MOUSE_MOVE, - EVT_MOUSE_BUT_PRESS, EVT_MOUSE_BUT_RELEASE, - EVT_KB_PRESS, EVT_KB_RELEASE, EVT_PROGM_COMPLETE, - EVT_RDMAN_REDRAW }; - -extern subject_t *subject_new(ob_factory_t *factory, - void *obj, int obj_type); -extern void subject_free(ob_factory_t *factory, subject_t *subject); -extern void subject_notify(ob_factory_t *factory, - subject_t *subject, event_t *evt); -extern observer_t *subject_add_observer(ob_factory_t *factory, - subject_t *subject, - evt_handler hdr, void *arg); -extern void subject_remove_observer(ob_factory_t *factory, - subject_t *subject, - observer_t *observer); - - -#endif /* __OBSERVER_H_ */
--- a/include/mb/paint.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -#ifndef __PAINT_H_ -#define __PAINT_H_ - -#include <cairo.h> -#include "mb_types.h" -#include "redraw_man.h" -#include "tools.h" - -typedef float co_comp_t; - -extern paint_t *rdman_paint_color_new(redraw_man_t *rdman, - co_comp_t r, co_comp_t g, - co_comp_t b, co_comp_t a); -extern void paint_color_set(paint_t *paint, - co_comp_t r, co_comp_t g, - co_comp_t b, co_comp_t a); -extern void paint_color_get(paint_t *paint, - co_comp_t *r, co_comp_t *g, - co_comp_t *b, co_comp_t *a); -#define paint_init(_paint, _prepare, _free) \ - do { \ - (_paint)->flags = 0; \ - (_paint)->prepare = _prepare; \ - (_paint)->free = _free; \ - STAILQ_INIT((_paint)->members); \ - (_paint)->pnt_next = NULL; \ - } while(0) \ - - -typedef struct _grad_stop { - co_aix offset; - co_comp_t r, g, b, a; -} grad_stop_t; - -extern paint_t *rdman_paint_linear_new(redraw_man_t *rdman, - co_aix x1, co_aix y1, - co_aix x2, co_aix y2); -extern grad_stop_t *paint_linear_stops(paint_t *paint, - int n_stops, - grad_stop_t *stops); -extern paint_t *rdman_paint_radial_new(redraw_man_t *rdman, - co_aix cx, co_aix cy, co_aix r); -extern grad_stop_t *paint_radial_stops(paint_t *paint, - int n_stops, - grad_stop_t *stops); - -#define grad_stop_init(stop, _offset, _r, _g, _b, _a) \ - do { \ - (stop)->offset = _offset; \ - (stop)->r = _r; \ - (stop)->g = _g; \ - (stop)->b = _b; \ - (stop)->a = _a; \ - } while(0) - - -#endif /* __PAINT_H_ */
--- a/include/mb/redraw_man.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -#ifndef __REDRAW_MAN_H_ -#define __REDRAW_MAN_H_ - -#include <cairo.h> -#include "tools.h" -#include "mb_types.h" -#include "observer.h" - -typedef struct _redraw_man redraw_man_t; - -typedef void (*free_func_t)(redraw_man_t *rdman, void *obj); -struct _free_obj { - void *obj; - free_func_t free_func; -}; -typedef struct _free_obj free_obj_t; -struct _free_objs { - int num, max; - free_obj_t *objs; -}; -typedef struct _free_objs free_objs_t; - -DARRAY(coords, coord_t *); -DARRAY(geos, geo_t *); -DARRAY(areas, area_t *); - -/*! \brief Manage redrawing of shapes (graphic elements). - * - * Every coord_t and geo_t object is assigned with a unique - * incremental order. The order is a unsigned integer. - * Every time a new coord_t or geo_t object is added, it is - * assigned with a order number that 1 bigger than last one - * until reaching maximum of unsigned integer. - * When a maximum is meet, all coord_t or geo_t objects - * are reasigned with a new order number from 1. It means - * order numbers that have been assigned and then removed - * later are recycled. - * - * Dirty flag is clear when the transformation matrix of a coord - * object been recomputed or when a geo_t objects been redrawed. - */ -struct _redraw_man { - unsigned int next_coord_order; - int n_coords; - coord_t *root_coord; - - elmpool_t *geo_pool; - elmpool_t *coord_pool; - elmpool_t *shnode_pool; - elmpool_t *observer_pool; - elmpool_t *subject_pool; - elmpool_t *paint_color_pool; - - coords_t dirty_coords; - geos_t dirty_geos; - areas_t dirty_areas; - - geos_t gen_geos; - - STAILQ(shape_t) shapes; /*!< \brief All managed shapes. */ - STAILQ(paint_t) paints; /*!< \brief All managed paints. */ - - free_objs_t free_objs; - - cairo_t *cr; - cairo_t *backend; - - ob_factory_t ob_factory; - - subject_t *redraw; /*!< \brief Notified after redrawing. */ -}; - -extern int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, - cairo_t *backend); -extern void redraw_man_destroy(redraw_man_t *rdman); -extern int rdman_find_overlaid_shapes(redraw_man_t *rdman, - geo_t *geo, - geo_t ***overlays); -extern int rdman_add_shape(redraw_man_t *rdman, - shape_t *shape, coord_t *coord); -/*! \brief Make a shape been managed by a redraw manager. */ -#define rdman_shape_man(rdman, shape) \ - STAILQ_INS_TAIL(rdman->shapes, shape_t, sh_next, shape) -extern int rdman_shape_free(redraw_man_t *rdman, shape_t *shape); - -#define rdman_paint_man(rdman, paint) \ - STAILQ_INS_TAIL(rdman->paints, paint_t, pnt_next, shape) -extern int rdman_paint_free(redraw_man_t *rdman, paint_t *paint); - -extern coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent); -extern int rdman_coord_free(redraw_man_t *rdman, coord_t *coord); -extern int rdman_coord_subtree_free(redraw_man_t *rdman, coord_t *subtree); -extern int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord); -extern int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape); -extern int rdman_redraw_changed(redraw_man_t *rdman); -extern int rdman_redraw_all(redraw_man_t *rdman); -extern int rdman_redraw_area(redraw_man_t *rdman, co_aix x, co_aix y, - co_aix w, co_aix h); -extern geo_t *rdman_geos(redraw_man_t *rdman, geo_t *last); -extern int rdman_force_clean(redraw_man_t *rdman); -extern shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape); -#define shnode_free(rdman, node) elmpool_elm_free((rdman)->shnode_pool, node) -#define shnode_list_free(rdman, q) \ - do { \ - shnode_t *__node, *__last; \ - __last = STAILQ_HEAD(q); \ - if(__last == NULL) break; \ - for(__node = STAILQ_NEXT(shnode_t, next, __last); \ - __node != NULL; \ - __node = STAILQ_NEXT(shnode_t, next, __node)) { \ - shnode_free(rdman, __last); \ - __last = __node; \ - } \ - shnode_free(rdman, __last); \ - } while(0) -#define _rdman_paint_child(rdman, paint, shape) \ - do { \ - shnode_t *__node; \ - if((shape)->fill != (paint) && \ - (shape)->stroke != (paint)) { \ - __node = shnode_new(rdman, shape); \ - STAILQ_INS_TAIL((paint)->members, \ - shnode_t, next, __node); \ - } \ - } while(0) -extern void _rdman_paint_real_remove_child(redraw_man_t *rdman, - paint_t *paint, - shape_t *shape); -#define _rdman_paint_remove_child(rdman, paint, shape) \ - do { \ - if((shape)->fill == (shape)->stroke && \ - (shape)->stroke == paint) \ - break; \ - _rdman_paint_real_remove_child(rdman, paint, shape); \ - } while(0) -#define rdman_paint_fill(rdman, paint, shape) \ - do { \ - if((shape)->fill == paint) \ - break; \ - _rdman_paint_remove_child(rdman, paint, shape); \ - _rdman_paint_child(rdman, paint, shape); \ - (shape)->fill = paint; \ - } while(0) -#define rdman_paint_stroke(rdman, paint, shape) \ - do { \ - if((shape)->stroke == paint) \ - break; \ - _rdman_paint_remove_child(rdman, paint, shape); \ - _rdman_paint_child(rdman, paint, shape); \ - (shape)->stroke = paint; \ - } while(0) -extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint); - -extern shape_t *find_shape_at_pos(redraw_man_t *rdman, - co_aix x, co_aix y, int *in_stroke); -#define rdman_get_ob_factory(rdman) (&(rdman)->ob_factory) -#define rdman_get_redraw_subject(rdman) ((rdman)->redraw) - - -#endif /* __REDRAW_MAN_H_ */
--- a/include/mb/shapes.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/*! \file - * \brief Declare interfaces of shapes. - * - * \todo Add ellipse shape. - * \todo Add circle shape. - */ -#ifndef __SHAPES_H_ -#define __SHAPES_H_ - -#include <cairo.h> -#include "mb_types.h" -#include "redraw_man.h" - -/*! \page define_shape How to Define Shapes - * - * A shape implementation must include - * - rdman_shape_*_new() - * - clear memory for shape_t member. - * - assign *_free() to \ref shape_t::free. - * - make new object been managed by a redraw manager. - * - call rdman_shape_man() - * - *_free() - * - assigned to \ref shape_t::free. - * - *_transform() - * - *_draw() - * - first member variable of a shape type must be a shape_t. - * - * Must modify - * - event.c::draw_shape_path() - * - redraw_man.c::clean_shape() - * - redraw_man.c::draw_shape() - */ - -/*! \defgroup shapes Shapes - * @{ - */ - -/*! \defgroup shape_path Shape of Path - * @{ - */ -extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data); -extern void sh_path_transform(shape_t *shape); -extern void sh_path_draw(shape_t *shape, cairo_t *cr); -/* @} */ - -/*! \defgroup shape_text Shape of Text - * @{ - */ -extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, - const char *txt, co_aix x, co_aix y, - co_aix font_size, - cairo_font_face_t *face); -extern void sh_text_set_text(shape_t *shape, const char *txt); -extern void sh_text_transform(shape_t *shape); -extern void sh_text_draw(shape_t *shape, cairo_t *cr); -/* @} */ - -/*! \defgroup shape_rect Shape of Rectangle - * @{ - */ -extern shape_t *rdman_shape_rect_new(redraw_man_t *rdman, - co_aix x, co_aix y, - co_aix w, co_aix h, - co_aix rx, co_aix ry); -extern void sh_rect_transform(shape_t *shape); -extern void sh_rect_draw(shape_t *shape, cairo_t *cr); -extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, - co_aix w, co_aix h, co_aix rx, co_aix ry); -/* @} */ -/* @} */ - -#endif /* __SHAPES_H_ */
--- a/include/mb/tools.h Tue Nov 04 17:00:26 2008 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -#ifndef __TOOLS_H_ -#define __TOOLS_H_ - -typedef struct _elmpool elmpool_t; - -extern elmpool_t *elmpool_new(int elm_sz, int inc_num); -extern void *elmpool_elm_alloc(elmpool_t *pool); -extern void elmpool_elm_free(elmpool_t *pool, void *elm); -extern void elmpool_free(elmpool_t *pool); - - -#define STAILQ(type) \ - struct { \ - type *head; \ - type *tail; \ - } -#define STAILQ_INIT(q) \ - do { \ - (q).head = (q).tail = NULL; \ - } while(0) -#define STAILQ_CLEAN(q) STAILQ_INIT(q) -#define STAILQ_HEAD(q) ((q).head) -#define STAILQ_TAIL(q) ((q).tail) -#define STAILQ_NEXT(type, field, elm) ((elm)->field) -#define STAILQ_INS(q, type, field, elm) \ - do { \ - (elm)->field = (q).head; \ - (q).head = elm; \ - if((q).tail == NULL) \ - (q).tail = elm; \ - } while(0) -#define STAILQ_INS_TAIL(q, type, field, elm) \ - do { \ - (elm)->field = NULL; \ - if((q).tail != NULL) \ - (q).tail->field = elm; \ - (q).tail = elm; \ - if((q).head == NULL) \ - (q).head = elm; \ - } while(0) -#define STAILQ_INS_AFTER(type, field, follow, elm) \ - do { \ - (follow)->field = (elm)->field; \ - (elm)->field = follow; \ - } while(0) -#define STAILQ_REMOVE(q, type, field, elm) \ - do { \ - if((elm) == (q).head) { \ - (q).head = (elm)->field; \ - if((q).head == NULL) \ - (q).tail = NULL; \ - } else { \ - type *_stailq_cur = (q).head; \ - while(_stailq_cur != NULL && \ - _stailq_cur->field != (elm)) \ - _stailq_cur = _stailq_cur->field; \ - if(_stailq_cur != NULL) { \ - _stailq_cur->field = (elm)->field; \ - if((q).tail == (elm)) \ - (q).tail = _stailq_cur; \ - } \ - } \ - } while(0) - -/*! \defgroup darray Dynamic Array - * - * DARRAY is a dynamic sized array/list, it's length is a variable. - * It is extended, automatically, if it is full and more elemnts are - * putted in. - * - * Users of DARRAY must declare a new type to store data. The way to - * declear a new type is to invoke DARRAY() with paramters of name of - * type and type of data to be stored in. The new storage type is named - * with foo_t where foo is the name you pass in. - * - * DARRAY_DEFINE() is inovked to define foo_add() function; foo is name - * of storage type. You can call foo_add() to add a data element - * into a storage object. - * - * Get ith element in a storage object, use - * \code - * obj->ds[i] - * \endcode - * - * To loop over elements in a storage object, us - * \code - * for(i = 0; i < obj->num; i++) { - * v = obj->ds[i]; - * ...... - * } - * \endcode - * @{ - */ -/*! \brief Declare a DARRAY storage type. - * - * \param name is name of storage type. - * \param type is type of data elements that will be stored in. - * - * Type of <name>_t is defined by the macro. It is used to define a - * storage object to contain data elements. - */ -#define DARRAY(name, type) \ - struct _ ## name { \ - int max, num; \ - type *ds; \ - }; \ - typedef struct _ ## name name ## _t -#define DARRAY_DEFINE(name, type) \ - static int name ## _add(name ## _t *da, type v) { \ - type *new_ds; \ - int max; \ - if(da->num >= (da)->max) { \ - max = (da)->max + 32; \ - new_ds = realloc(da->ds, \ - max * sizeof(type)); \ - if(new_ds == NULL) return -1; \ - da->ds = new_ds; \ - da->max = max; \ - } \ - da->ds[da->num++] = v; \ - return 0; \ - } -#define DARRAY_CLEAN(da) do { (da)->num = 0; } while(0) -#define DARRAY_INIT(da) do { (da)->num = (da)->max = 0; (da)->ds = NULL; } -#define DARRAY_DESTROY(da) do { if((da)->ds) free((da)->ds); } while(0) -/* @} */ - -#include <stdlib.h> - -#define O_ALLOC(type) ((type *)malloc(sizeof(type))) - -#define OFFSET(type, mem) (((void *)&((type *)NULL)->mem) - NULL) -#define MEM2OBJ(var, type, mem) ((type *)((void *)var - OFFSET(type, mem))) -#define OFF2TYPE(obj, off, type) (*(type *)((void *)(obj) + (off))) - -#endif /* __TOOLS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_X_supp.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,34 @@ +#ifndef __X_SUPP_H_ +#define __X_SUPP_H_ + +#include <X11/Xlib.h> +#include "mb_types.h" +#include "mb_timer.h" +#include "mb_redraw_man.h" + +/*! \ingroup xkb + * @{ + */ +typedef struct _X_kb_info X_kb_info_t; + +struct _X_kb_event { + event_t event; + int keycode; + int sym; +}; +typedef struct _X_kb_event X_kb_event_t; + +/* @} */ + +typedef struct _X_MB_runtime X_MB_runtime_t; + +extern void X_MB_handle_connection(X_MB_runtime_t *rt); +extern X_MB_runtime_t *X_MB_new(const char *display_name, int w, int h); +extern void X_MB_free(X_MB_runtime_t *xmb_rt); + +extern subject_t *X_MB_kbevents(X_MB_runtime_t *xmb_rt); +extern redraw_man_t *X_MB_rdman(X_MB_runtime_t *xmb_rt); +extern mb_tman_t *X_MB_tman(X_MB_runtime_t *xmb_rt); +extern ob_factory_t *X_MB_ob_factory(X_MB_runtime_t *xmb_rt); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_animate.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,89 @@ +#ifndef __ANIMATE_H_ +#define __ANIMATE_H_ + +#include "mb_types.h" +#include "mb_timer.h" +#include "mb_paint.h" + +/*! \page def_action How to Define An Action? + * + * A action must implement following 4 functions. + * \li start, + * \li step, + * \li stop, + * \li free, + * \li *_new(), and + * \li add *_new() to \ref animate.h . + * + * *_new() must invokes mb_word_add_action() to add new object + * as one of actions in the word specified as an argument of it. + * It also means *_new() must have an argument with type of + * (mb_word_t *). + */ + +/*! \defgroup anim Animation + * \brief Animation is a set of functions to make graph moving. + * @{ + */ +typedef struct _mb_progm mb_progm_t; +typedef struct _mb_word mb_word_t; +typedef struct _mb_action mb_action_t; + +struct _mb_progm_complete { + event_t event; + mb_progm_t *progm; +}; +typedef struct _mb_progm_complete mb_progm_complete_t; + +extern mb_progm_t *mb_progm_new(int max_words, redraw_man_t *rdman); +extern void mb_progm_free(mb_progm_t *progm); +extern mb_word_t *mb_progm_next_word(mb_progm_t *progm, + const mb_timeval_t *start, + const mb_timeval_t *playing); +extern void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman, + mb_timeval_t *now); +extern void mb_progm_abort(mb_progm_t *progm); +extern subject_t *mb_progm_get_complete(mb_progm_t *progm); + +/*! \defgroup ani_actions Animation Actions + * @{ + */ +extern mb_action_t *mb_shift_new(co_aix x, co_aix y, coord_t *coord, + mb_word_t *word); +extern mb_action_t *mb_chgcolor_new(co_comp_t r, co_comp_t g, + co_comp_t b, co_comp_t a, + paint_t *paint, mb_word_t *word); +extern mb_action_t *mb_rotate_new(float angle1, float angle2, + coord_t *coord, mb_word_t *word); + +enum { VIS_VISIBLE, VIS_HIDDEN }; +extern mb_action_t *mb_visibility_new(int visib, coord_t *coord, + mb_word_t *word); +/* @} */ + +/*! \defgroup act_support Action Supports. + * @{ + */ +/*! \brief Basic class of animation actions. + * + * \sa \ref def_action + */ +struct _mb_action { + void (*start)(mb_action_t *act, + const mb_timeval_t *now, + const mb_timeval_t *playing_time, + redraw_man_t *rdman); + void (*step)(mb_action_t *act, const mb_timeval_t *now, + redraw_man_t *rdman); + void (*stop)(mb_action_t *act, const mb_timeval_t *now, + redraw_man_t *rdman); + void (*free)(mb_action_t *act); + mb_action_t *next; +}; + +extern void mb_word_add_action(mb_word_t *word, mb_action_t *act); +/* @} */ + +/* @} */ + +#endif /* __ANIMATE_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_observer.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,91 @@ +#ifndef __OBSERVER_H_ +#define __OBSERVER_H_ + +#include "mb_tools.h" + +typedef struct _event event_t; +typedef struct _observer observer_t; +typedef struct _subject subject_t; +typedef struct _mouse_event mouse_event_t; +typedef struct _ob_factory ob_factory_t; +typedef void (*evt_handler)(event_t *event, void *arg); + +struct _event { + int type; /*!< event type (a.k.a. EVT_* */ + subject_t *tgt, *cur_tgt; +}; + +/*! \brief Observer of observer pattern. + * + * A target for receiving events. + */ +struct _observer { + evt_handler hdr; + void *arg; + observer_t *next; +}; + +/*! \brief Subject of observer pattern. + * + * Observer is a pattern to decouple caller and callee, + * especial for multiple callee. + * \see http://en.wikipedia.org/wiki/Observer_pattern + */ +struct _subject { + int obj_type; /*!< \brief type of object (a.k.a. OBJT_*). */ + void *obj; /*!< \brief the object this subject for. */ + int flags; + STAILQ(observer_t) observers; +}; +/*! \brief Flag that make a subject to propagate events to parents. */ +#define SUBF_STOP_PROPAGATE 0x1 +#define SUBF_BUSY 0x2 /*!< \brief in subject_notify() */ +#define SUBF_FREE 0x4 /*!< \brief in postponding subject_free() */ + +enum {OBJT_GEO, OBJT_COORD, OBJT_KB, OBJT_PROGM, OBJT_RDMAN}; + +struct _mouse_event { + event_t event; + int x, y; + unsigned int but_state; + unsigned int button; +}; + +#define MOUSE_BUT1 0x1 +#define MOUSE_BUT2 0x2 +#define MOUSE_BUT3 0x4 + +/*! \brief Observer factory. + * + * It provides functions for allocation of subject and observer objects, + * and strategy function for getting the subject of parent coord object. + */ +struct _ob_factory { + subject_t *(*subject_alloc)(ob_factory_t *factory); + void (*subject_free)(ob_factory_t *factory, subject_t *subject); + observer_t *(*observer_alloc)(ob_factory_t *factory); + void (*observer_free)(ob_factory_t *factory, observer_t *observer); + /*! This is a strategy function to get subjects of parents. */ + subject_t *(*get_parent_subject)(ob_factory_t *factory, + subject_t *cur_subject); +}; + +enum {EVT_MOUSE_OVER, EVT_MOUSE_OUT, EVT_MOUSE_MOVE, + EVT_MOUSE_BUT_PRESS, EVT_MOUSE_BUT_RELEASE, + EVT_KB_PRESS, EVT_KB_RELEASE, EVT_PROGM_COMPLETE, + EVT_RDMAN_REDRAW }; + +extern subject_t *subject_new(ob_factory_t *factory, + void *obj, int obj_type); +extern void subject_free(ob_factory_t *factory, subject_t *subject); +extern void subject_notify(ob_factory_t *factory, + subject_t *subject, event_t *evt); +extern observer_t *subject_add_observer(ob_factory_t *factory, + subject_t *subject, + evt_handler hdr, void *arg); +extern void subject_remove_observer(ob_factory_t *factory, + subject_t *subject, + observer_t *observer); + + +#endif /* __OBSERVER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_paint.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,57 @@ +#ifndef __PAINT_H_ +#define __PAINT_H_ + +#include <cairo.h> +#include "mb_types.h" +#include "mb_redraw_man.h" +#include "mb_tools.h" + +typedef float co_comp_t; + +extern paint_t *rdman_paint_color_new(redraw_man_t *rdman, + co_comp_t r, co_comp_t g, + co_comp_t b, co_comp_t a); +extern void paint_color_set(paint_t *paint, + co_comp_t r, co_comp_t g, + co_comp_t b, co_comp_t a); +extern void paint_color_get(paint_t *paint, + co_comp_t *r, co_comp_t *g, + co_comp_t *b, co_comp_t *a); +#define paint_init(_paint, _prepare, _free) \ + do { \ + (_paint)->flags = 0; \ + (_paint)->prepare = _prepare; \ + (_paint)->free = _free; \ + STAILQ_INIT((_paint)->members); \ + (_paint)->pnt_next = NULL; \ + } while(0) \ + + +typedef struct _grad_stop { + co_aix offset; + co_comp_t r, g, b, a; +} grad_stop_t; + +extern paint_t *rdman_paint_linear_new(redraw_man_t *rdman, + co_aix x1, co_aix y1, + co_aix x2, co_aix y2); +extern grad_stop_t *paint_linear_stops(paint_t *paint, + int n_stops, + grad_stop_t *stops); +extern paint_t *rdman_paint_radial_new(redraw_man_t *rdman, + co_aix cx, co_aix cy, co_aix r); +extern grad_stop_t *paint_radial_stops(paint_t *paint, + int n_stops, + grad_stop_t *stops); + +#define grad_stop_init(stop, _offset, _r, _g, _b, _a) \ + do { \ + (stop)->offset = _offset; \ + (stop)->r = _r; \ + (stop)->g = _g; \ + (stop)->b = _b; \ + (stop)->a = _a; \ + } while(0) + + +#endif /* __PAINT_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_redraw_man.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,160 @@ +#ifndef __REDRAW_MAN_H_ +#define __REDRAW_MAN_H_ + +#include <cairo.h> +#include "mb_tools.h" +#include "mb_types.h" +#include "mb_observer.h" + +typedef struct _redraw_man redraw_man_t; + +typedef void (*free_func_t)(redraw_man_t *rdman, void *obj); +struct _free_obj { + void *obj; + free_func_t free_func; +}; +typedef struct _free_obj free_obj_t; +struct _free_objs { + int num, max; + free_obj_t *objs; +}; +typedef struct _free_objs free_objs_t; + +DARRAY(coords, coord_t *); +DARRAY(geos, geo_t *); +DARRAY(areas, area_t *); + +/*! \brief Manage redrawing of shapes (graphic elements). + * + * Every coord_t and geo_t object is assigned with a unique + * incremental order. The order is a unsigned integer. + * Every time a new coord_t or geo_t object is added, it is + * assigned with a order number that 1 bigger than last one + * until reaching maximum of unsigned integer. + * When a maximum is meet, all coord_t or geo_t objects + * are reasigned with a new order number from 1. It means + * order numbers that have been assigned and then removed + * later are recycled. + * + * Dirty flag is clear when the transformation matrix of a coord + * object been recomputed or when a geo_t objects been redrawed. + */ +struct _redraw_man { + unsigned int next_coord_order; + int n_coords; + coord_t *root_coord; + + elmpool_t *geo_pool; + elmpool_t *coord_pool; + elmpool_t *shnode_pool; + elmpool_t *observer_pool; + elmpool_t *subject_pool; + elmpool_t *paint_color_pool; + + coords_t dirty_coords; + geos_t dirty_geos; + areas_t dirty_areas; + + geos_t gen_geos; + + STAILQ(shape_t) shapes; /*!< \brief All managed shapes. */ + STAILQ(paint_t) paints; /*!< \brief All managed paints. */ + + free_objs_t free_objs; + + cairo_t *cr; + cairo_t *backend; + + ob_factory_t ob_factory; + + subject_t *redraw; /*!< \brief Notified after redrawing. */ +}; + +extern int redraw_man_init(redraw_man_t *rdman, cairo_t *cr, + cairo_t *backend); +extern void redraw_man_destroy(redraw_man_t *rdman); +extern int rdman_find_overlaid_shapes(redraw_man_t *rdman, + geo_t *geo, + geo_t ***overlays); +extern int rdman_add_shape(redraw_man_t *rdman, + shape_t *shape, coord_t *coord); +/*! \brief Make a shape been managed by a redraw manager. */ +#define rdman_shape_man(rdman, shape) \ + STAILQ_INS_TAIL(rdman->shapes, shape_t, sh_next, shape) +extern int rdman_shape_free(redraw_man_t *rdman, shape_t *shape); + +#define rdman_paint_man(rdman, paint) \ + STAILQ_INS_TAIL(rdman->paints, paint_t, pnt_next, shape) +extern int rdman_paint_free(redraw_man_t *rdman, paint_t *paint); + +extern coord_t *rdman_coord_new(redraw_man_t *rdman, coord_t *parent); +extern int rdman_coord_free(redraw_man_t *rdman, coord_t *coord); +extern int rdman_coord_subtree_free(redraw_man_t *rdman, coord_t *subtree); +extern int rdman_coord_changed(redraw_man_t *rdman, coord_t *coord); +extern int rdman_shape_changed(redraw_man_t *rdman, shape_t *shape); +extern int rdman_redraw_changed(redraw_man_t *rdman); +extern int rdman_redraw_all(redraw_man_t *rdman); +extern int rdman_redraw_area(redraw_man_t *rdman, co_aix x, co_aix y, + co_aix w, co_aix h); +extern geo_t *rdman_geos(redraw_man_t *rdman, geo_t *last); +extern int rdman_force_clean(redraw_man_t *rdman); +extern shnode_t *shnode_new(redraw_man_t *rdman, shape_t *shape); +#define shnode_free(rdman, node) elmpool_elm_free((rdman)->shnode_pool, node) +#define shnode_list_free(rdman, q) \ + do { \ + shnode_t *__node, *__last; \ + __last = STAILQ_HEAD(q); \ + if(__last == NULL) break; \ + for(__node = STAILQ_NEXT(shnode_t, next, __last); \ + __node != NULL; \ + __node = STAILQ_NEXT(shnode_t, next, __node)) { \ + shnode_free(rdman, __last); \ + __last = __node; \ + } \ + shnode_free(rdman, __last); \ + } while(0) +#define _rdman_paint_child(rdman, paint, shape) \ + do { \ + shnode_t *__node; \ + if((shape)->fill != (paint) && \ + (shape)->stroke != (paint)) { \ + __node = shnode_new(rdman, shape); \ + STAILQ_INS_TAIL((paint)->members, \ + shnode_t, next, __node); \ + } \ + } while(0) +extern void _rdman_paint_real_remove_child(redraw_man_t *rdman, + paint_t *paint, + shape_t *shape); +#define _rdman_paint_remove_child(rdman, paint, shape) \ + do { \ + if((shape)->fill == (shape)->stroke && \ + (shape)->stroke == paint) \ + break; \ + _rdman_paint_real_remove_child(rdman, paint, shape); \ + } while(0) +#define rdman_paint_fill(rdman, paint, shape) \ + do { \ + if((shape)->fill == paint) \ + break; \ + _rdman_paint_remove_child(rdman, paint, shape); \ + _rdman_paint_child(rdman, paint, shape); \ + (shape)->fill = paint; \ + } while(0) +#define rdman_paint_stroke(rdman, paint, shape) \ + do { \ + if((shape)->stroke == paint) \ + break; \ + _rdman_paint_remove_child(rdman, paint, shape); \ + _rdman_paint_child(rdman, paint, shape); \ + (shape)->stroke = paint; \ + } while(0) +extern int rdman_paint_changed(redraw_man_t *rdman, paint_t *paint); + +extern shape_t *find_shape_at_pos(redraw_man_t *rdman, + co_aix x, co_aix y, int *in_stroke); +#define rdman_get_ob_factory(rdman) (&(rdman)->ob_factory) +#define rdman_get_redraw_subject(rdman) ((rdman)->redraw) + + +#endif /* __REDRAW_MAN_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_shapes.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,72 @@ +/*! \file + * \brief Declare interfaces of shapes. + * + * \todo Add ellipse shape. + * \todo Add circle shape. + */ +#ifndef __SHAPES_H_ +#define __SHAPES_H_ + +#include <cairo.h> +#include "mb_types.h" +#include "mb_redraw_man.h" + +/*! \page define_shape How to Define Shapes + * + * A shape implementation must include + * - rdman_shape_*_new() + * - clear memory for shape_t member. + * - assign *_free() to \ref shape_t::free. + * - make new object been managed by a redraw manager. + * - call rdman_shape_man() + * - *_free() + * - assigned to \ref shape_t::free. + * - *_transform() + * - *_draw() + * - first member variable of a shape type must be a shape_t. + * + * Must modify + * - event.c::draw_shape_path() + * - redraw_man.c::clean_shape() + * - redraw_man.c::draw_shape() + */ + +/*! \defgroup shapes Shapes + * @{ + */ + +/*! \defgroup shape_path Shape of Path + * @{ + */ +extern shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data); +extern void sh_path_transform(shape_t *shape); +extern void sh_path_draw(shape_t *shape, cairo_t *cr); +/* @} */ + +/*! \defgroup shape_text Shape of Text + * @{ + */ +extern shape_t *rdman_shape_text_new(redraw_man_t *rdman, + const char *txt, co_aix x, co_aix y, + co_aix font_size, + cairo_font_face_t *face); +extern void sh_text_set_text(shape_t *shape, const char *txt); +extern void sh_text_transform(shape_t *shape); +extern void sh_text_draw(shape_t *shape, cairo_t *cr); +/* @} */ + +/*! \defgroup shape_rect Shape of Rectangle + * @{ + */ +extern shape_t *rdman_shape_rect_new(redraw_man_t *rdman, + co_aix x, co_aix y, + co_aix w, co_aix h, + co_aix rx, co_aix ry); +extern void sh_rect_transform(shape_t *shape); +extern void sh_rect_draw(shape_t *shape, cairo_t *cr); +extern void sh_rect_set(shape_t *shape, co_aix x, co_aix y, + co_aix w, co_aix h, co_aix rx, co_aix ry); +/* @} */ +/* @} */ + +#endif /* __SHAPES_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_timer.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,78 @@ +#ifndef __MB_TIMER_H_ +#define __MB_TIMER_H_ + +#include <sys/time.h> +#include <stdint.h> + +typedef uint32_t mbsec_t; +typedef uint32_t mbusec_t; +typedef struct _mb_timer mb_timer_t; +typedef struct _mb_tman mb_tman_t; +typedef struct timeval mb_timeval_t; + + +typedef void (*mb_tmo_hdlr)(const mb_timeval_t *tmo, + const mb_timeval_t *now, + void *arg); + +extern mb_tman_t *mb_tman_new(void); +extern void mb_tman_free(mb_tman_t *tman); +extern mb_timer_t *mb_tman_timeout(mb_tman_t *tman, + const mb_timeval_t *tmo, + mb_tmo_hdlr hdlr, void *arg); +extern int mb_tman_remove(mb_tman_t *tman, mb_timer_t *timer); +extern int mb_tman_next_timeout(mb_tman_t *tman, + const mb_timeval_t *now, + mb_timeval_t *tmo_after); +extern int mb_tman_handle_timeout(mb_tman_t *tman, mb_timeval_t *now); + +#define MB_TIMEVAL_SET(_tv, _sec, _usec) \ + do { \ + (_tv)->tv_sec = _sec; \ + (_tv)->tv_usec = _usec; \ + } while(0) +#define MB_TIMEVAL_CP(_tv1, _tv2) \ + do { \ + (_tv1)->tv_sec = (_tv2)->tv_sec; \ + (_tv1)->tv_usec = (_tv2)->tv_usec; \ + } while(0) +#define MB_TIMEVAL_SEC(_tv) ((_tv)->tv_sec) +#define MB_TIMEVAL_USEC(_tv) ((_tv)->tv_usec) +#define MB_TIMEVAL_LATER(a, b) \ + ((a)->tv_sec > (b)->tv_sec || \ + ((a)->tv_sec == (b)->tv_sec && \ + (a)->tv_usec > (b)->tv_usec)) +#define MB_TIMEVAL_LATER_INC(a, b) \ + ((a)->tv_sec > (b)->tv_sec || \ + ((a)->tv_sec == (b)->tv_sec && \ + (a)->tv_usec >= (b)->tv_usec)) +#define MB_TIMEVAL_EQ(a, b) \ + ((a)->tv_sec == (b)->tv_sec && \ + (a)->tv_usec == (b)->tv_usec) +#define MB_TIMEVAL_DIFF(a, b) \ + do { \ + (a)->tv_sec -= (b)->tv_sec; \ + if((a)->tv_usec < (b)->tv_usec) { \ + (a)->tv_sec--; \ + (a)->tv_usec += 1000000; \ + } \ + (a)->tv_usec -= (b)->tv_usec; \ + } while(0) +#define MB_TIMEVAL_ADD(a, b) \ + do { \ + (a)->tv_sec += (b)->tv_sec; \ + (a)->tv_usec += (b)->tv_usec; \ + if((a)->tv_usec >= 1000000) { \ + (a)->tv_sec++; \ + (a)->tv_usec -= 1000000; \ + } \ + } while(0) +#define MB_TIMEVAL_DIV(a, b) \ + (((a)->tv_sec * 1000000.0 + (a)->tv_usec) / \ + ((b)->tv_sec * 1000000.0 + (b)->tv_usec)) + + +extern void get_now(mb_timeval_t *tmo); + + +#endif /* __MB_TIMER_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_tools.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,136 @@ +#ifndef __TOOLS_H_ +#define __TOOLS_H_ + +typedef struct _elmpool elmpool_t; + +extern elmpool_t *elmpool_new(int elm_sz, int inc_num); +extern void *elmpool_elm_alloc(elmpool_t *pool); +extern void elmpool_elm_free(elmpool_t *pool, void *elm); +extern void elmpool_free(elmpool_t *pool); + + +#define STAILQ(type) \ + struct { \ + type *head; \ + type *tail; \ + } +#define STAILQ_INIT(q) \ + do { \ + (q).head = (q).tail = NULL; \ + } while(0) +#define STAILQ_CLEAN(q) STAILQ_INIT(q) +#define STAILQ_HEAD(q) ((q).head) +#define STAILQ_TAIL(q) ((q).tail) +#define STAILQ_NEXT(type, field, elm) ((elm)->field) +#define STAILQ_INS(q, type, field, elm) \ + do { \ + (elm)->field = (q).head; \ + (q).head = elm; \ + if((q).tail == NULL) \ + (q).tail = elm; \ + } while(0) +#define STAILQ_INS_TAIL(q, type, field, elm) \ + do { \ + (elm)->field = NULL; \ + if((q).tail != NULL) \ + (q).tail->field = elm; \ + (q).tail = elm; \ + if((q).head == NULL) \ + (q).head = elm; \ + } while(0) +#define STAILQ_INS_AFTER(type, field, follow, elm) \ + do { \ + (follow)->field = (elm)->field; \ + (elm)->field = follow; \ + } while(0) +#define STAILQ_REMOVE(q, type, field, elm) \ + do { \ + if((elm) == (q).head) { \ + (q).head = (elm)->field; \ + if((q).head == NULL) \ + (q).tail = NULL; \ + } else { \ + type *_stailq_cur = (q).head; \ + while(_stailq_cur != NULL && \ + _stailq_cur->field != (elm)) \ + _stailq_cur = _stailq_cur->field; \ + if(_stailq_cur != NULL) { \ + _stailq_cur->field = (elm)->field; \ + if((q).tail == (elm)) \ + (q).tail = _stailq_cur; \ + } \ + } \ + } while(0) + +/*! \defgroup darray Dynamic Array + * + * DARRAY is a dynamic sized array/list, it's length is a variable. + * It is extended, automatically, if it is full and more elemnts are + * putted in. + * + * Users of DARRAY must declare a new type to store data. The way to + * declear a new type is to invoke DARRAY() with paramters of name of + * type and type of data to be stored in. The new storage type is named + * with foo_t where foo is the name you pass in. + * + * DARRAY_DEFINE() is inovked to define foo_add() function; foo is name + * of storage type. You can call foo_add() to add a data element + * into a storage object. + * + * Get ith element in a storage object, use + * \code + * obj->ds[i] + * \endcode + * + * To loop over elements in a storage object, us + * \code + * for(i = 0; i < obj->num; i++) { + * v = obj->ds[i]; + * ...... + * } + * \endcode + * @{ + */ +/*! \brief Declare a DARRAY storage type. + * + * \param name is name of storage type. + * \param type is type of data elements that will be stored in. + * + * Type of <name>_t is defined by the macro. It is used to define a + * storage object to contain data elements. + */ +#define DARRAY(name, type) \ + struct _ ## name { \ + int max, num; \ + type *ds; \ + }; \ + typedef struct _ ## name name ## _t +#define DARRAY_DEFINE(name, type) \ + static int name ## _add(name ## _t *da, type v) { \ + type *new_ds; \ + int max; \ + if(da->num >= (da)->max) { \ + max = (da)->max + 32; \ + new_ds = realloc(da->ds, \ + max * sizeof(type)); \ + if(new_ds == NULL) return -1; \ + da->ds = new_ds; \ + da->max = max; \ + } \ + da->ds[da->num++] = v; \ + return 0; \ + } +#define DARRAY_CLEAN(da) do { (da)->num = 0; } while(0) +#define DARRAY_INIT(da) do { (da)->num = (da)->max = 0; (da)->ds = NULL; } +#define DARRAY_DESTROY(da) do { if((da)->ds) free((da)->ds); } while(0) +/* @} */ + +#include <stdlib.h> + +#define O_ALLOC(type) ((type *)malloc(sizeof(type))) + +#define OFFSET(type, mem) (((void *)&((type *)NULL)->mem) - NULL) +#define MEM2OBJ(var, type, mem) ((type *)((void *)var - OFFSET(type, mem))) +#define OFF2TYPE(obj, off, type) (*(type *)((void *)(obj) + (off))) + +#endif /* __TOOLS_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mb_types.h Wed Nov 05 15:24:01 2008 +0800 @@ -0,0 +1,189 @@ +#ifndef __MB_TYPES_H_ +#define __MB_TYPES_H_ + +#include <cairo.h> +#include "mb_tools.h" +#include "mb_observer.h" + +typedef float co_aix; +typedef struct _shape shape_t; +typedef struct _geo geo_t; +typedef struct _area area_t; +typedef struct _shnode shnode_t; +typedef struct _paint paint_t; + +struct _redraw_man; + +/*! \brief Base of paint types. + * + * Paints should be freed by users by calling rdman_paint_free() of + * the paint. + * + * \todo move member functions to a seperate structure and setup a + * singleton fro each paint type. + */ +struct _paint { + int flags; + void (*prepare)(paint_t *paint, cairo_t *cr); + void (*free)(struct _redraw_man *rdman, paint_t *paint); + STAILQ(shnode_t) members; + paint_t *pnt_next; /*!< \brief Collect all paints of a rdman. */ +}; + +#define PNTF_FREE 0x1 + +struct _shnode { + shape_t *shape; + shnode_t *next; +}; + +struct _area { + co_aix x, y; + co_aix w, h; +}; + +/*! \brief Geometry data of a shape or a group of shape. + */ +struct _geo { +#ifdef GEO_ORDER + unsigned int order; +#endif + unsigned int flags; + shape_t *shape; + geo_t *coord_next; /*!< \brief Link all member geos together. */ + + area_t *cur_area, *last_area; + area_t areas[2]; + + subject_t *mouse_event; +}; +#define GEF_DIRTY 0x1 +#define GEF_HIDDEN 0x2 /*!< The geo is hidden. */ +#define GEF_FREE 0x4 + +extern int is_overlay(area_t *r1, area_t *r2); +extern void area_init(area_t *area, int n_pos, co_aix pos[][2]); +extern void geo_init(geo_t *g); +extern void geo_from_positions(geo_t *g, int n_pos, co_aix pos[][2]); +extern void geo_mark_overlay(geo_t *g, int n_others, geo_t **others, + int *n_overlays, geo_t **overlays); +#define geo_get_shape(g) ((g)->shape) +#define geo_set_shape(g, sh) do {(g)->shape = sh;} while(0) +#define _geo_is_in(a, s, w) ((a) >= (s) && (a) < ((s) + (w))) +#define geo_pos_is_in(g, _x, _y) \ + (_geo_is_in(_x, (g)->cur_area->x, (g)->cur_area->w) && \ + _geo_is_in(_y, (g)->cur_area->y, (g)->cur_area->h)) + + +/*! \brief A coordination system. + * + * It have a transform function defined by matrix to transform + * coordination from source space to target space. + * Source space is where the contained is drawed, and target space + * is where the coordination of parent container of the element + * represented by this coord object. + * + * \dot + * digraph G { + * graph [rankdir=LR]; + * root -> child00 -> child10 -> child20 [label="children" color="blue"]; + * child00 -> child01 -> child02 [label="sibling"]; + * child10 -> child11 [label="sibling"]; + * } + * \enddot + */ +typedef struct _coord { + unsigned int order; + unsigned int flags; + co_aix opacity; + /*! Own one or inherit from an ancestor. + * Setup it when clean coords. + * \sa + * - \ref COF_OWN_CANVAS + * - \ref redraw + */ + cairo_t *canvas; + area_t *cur_area, *last_area; + area_t areas[2]; + + co_aix matrix[6]; + co_aix aggr_matrix[6]; + + struct _coord *parent; + STAILQ(struct _coord) children; + struct _coord *sibling; + unsigned int before_pmem; /*!< \brief The coord is before nth member + * of parent. */ + + int num_members; + STAILQ(geo_t) members; /*!< \brief All geo_t members in this coord. */ + + STAILQ(shape_t) shapes; /*!< \brief All shapes managed by the rdman. */ + + subject_t *mouse_event; +} coord_t; +#define COF_DIRTY 0x1 +#define COF_HIDDEN 0x2 /*!< A coord is hidden. */ +#define COF_OWN_CANVAS 0x4 /*!< A coord owns a canvas or inherit it + * from an ancestor. + */ +#define COF_SKIP_TRIVAL 0x8 /*!< temporary skip descendants + * when trivaling. + */ +#define COF_FREE 0x10 + +extern void coord_init(coord_t *co, coord_t *parent); +extern void coord_trans_pos(coord_t *co, co_aix *x, co_aix *y); +extern co_aix coord_trans_size(coord_t *co, co_aix size); +extern void compute_aggr_of_coord(coord_t *coord); +extern void update_aggr_matrix(coord_t *start); +extern coord_t *preorder_coord_subtree(coord_t *root, coord_t *last); +extern coord_t *postorder_coord_subtree(coord_t *root, coord_t *last); +extern void preorder_coord_skip_subtree(coord_t *subroot); +#define preorder_coord_skip_subtree(sub) \ + do { (sub)->flags |= COF_SKIP_TRIVAL; } while(0) +#define coord_hide(co) \ + do { \ + (co)->flags |= COF_HIDDEN; \ + } while(0) +#define coord_show(co) do { co->flags &= ~COF_HIDDEN; } while(0) +#define coord_get_mouse_event(coord) ((coord)->mouse_event) + + +/*! \brief A grahpic shape. + * + * \dot + * digraph G { + * "shape" -> "coord"; + * "shape" -> "geo"; + * "geo" -> "shape"; + * "coord" -> "shape" [label="members"] + * "shape" -> "shape" [label="sibling"]; + * } + * \enddot + */ +struct _shape { + int sh_type; + geo_t *geo; + coord_t *coord; + paint_t *fill, *stroke; + co_aix stroke_width; + int stroke_linecap:2; + int stroke_linejoin:2; + struct _shape *sh_next; /*!< Link all shapes of a rdman together. */ + void (*free)(shape_t *shape); +}; +enum { SHT_UNKNOW, SHT_PATH, SHT_TEXT, SHT_RECT }; + +#define sh_get_mouse_event_subject(sh) ((sh)->geo->mouse_event) +#define sh_hide(sh) \ + do { \ + (sh)->geo->flags |= GEF_HIDDEN; \ + } while(0) +#define sh_show(sh) \ + do { \ + (sh)->geo->flags &= ~GEF_HIDDEN; \ + } while(0) + + +#endif /* __MB_TYPES_H_ */
--- a/src/X_main.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/X_main.c Wed Nov 05 15:24:01 2008 +0800 @@ -8,11 +8,11 @@ #include <cairo-xlib.h> #include <string.h> -#include "mb/shapes.h" -#include "mb/redraw_man.h" -#include "mb/paint.h" -#include "mb/mb_timer.h" -#include "mb/animate.h" +#include "mb_shapes.h" +#include "mb_redraw_man.h" +#include "mb_paint.h" +#include "mb_timer.h" +#include "mb_animate.h" #define OK 0 #define ERR -1
--- a/src/X_supp.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/X_supp.c Wed Nov 05 15:24:01 2008 +0800 @@ -5,9 +5,9 @@ #include <X11/Xutil.h> #include <cairo.h> #include <cairo-xlib.h> -#include "mb/redraw_man.h" -#include "mb/mb_timer.h" -#include "mb/X_supp.h" +#include "mb_redraw_man.h" +#include "mb_timer.h" +#include "mb_X_supp.h" #define ERR -1 #define OK 0
--- a/src/animate.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/animate.c Wed Nov 05 15:24:01 2008 +0800 @@ -68,10 +68,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "mb/mb_types.h" -#include "mb/redraw_man.h" -#include "mb/mb_timer.h" -#include "mb/animate.h" +#include "mb_types.h" +#include "mb_redraw_man.h" +#include "mb_timer.h" +#include "mb_animate.h" #define STEP_INTERVAL 90000
--- a/src/chgcolor.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/chgcolor.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> -#include "mb/animate.h" -#include "mb/paint.h" +#include "mb_animate.h" +#include "mb_paint.h" static float comp_mb_timeval_ratio(const mb_timeval_t *a, const mb_timeval_t *b) {
--- a/src/coord.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/coord.c Wed Nov 05 15:24:01 2008 +0800 @@ -5,7 +5,7 @@ #include <stdio.h> #include <string.h> #include <math.h> -#include "mb/mb_types.h" +#include "mb_types.h" #define ASSERT(x)
--- a/src/event.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/event.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,9 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include <cairo.h> -#include "mb/mb_types.h" -#include "mb/redraw_man.h" -#include "mb/shapes.h" +#include "mb_types.h" +#include "mb_redraw_man.h" +#include "mb_shapes.h" #define OK 0 #define ERR -1
--- a/src/geo.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/geo.c Wed Nov 05 15:24:01 2008 +0800 @@ -6,7 +6,7 @@ */ #include <stdio.h> #include <string.h> -#include "mb/mb_types.h" +#include "mb_types.h" static int is_scale_overlay(co_aix x1, co_aix w1, co_aix x2, co_aix w2) { if(x1 > x2) {
--- a/src/observer.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/observer.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,7 +1,7 @@ #include <stdio.h> -#include "mb/redraw_man.h" -#include "mb/observer.h" -#include "mb/tools.h" +#include "mb_redraw_man.h" +#include "mb_observer.h" +#include "mb_tools.h" #ifndef ASSERT #define ASSERT(x)
--- a/src/paint.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/paint.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <cairo.h> -#include "mb/paint.h" +#include "mb_paint.h" #define ASSERT(x)
--- a/src/redraw_man.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/redraw_man.c Wed Nov 05 15:24:01 2008 +0800 @@ -2,11 +2,11 @@ #include <stdlib.h> #include <string.h> #include <cairo.h> -#include "mb/mb_types.h" -#include "mb/shapes.h" -#include "mb/tools.h" -#include "mb/redraw_man.h" -#include "mb/observer.h" +#include "mb_types.h" +#include "mb_shapes.h" +#include "mb_tools.h" +#include "mb_redraw_man.h" +#include "mb_observer.h" /* NOTE: bounding box should also consider width of stroke. @@ -1402,7 +1402,7 @@ /* Test cases */ #include <CUnit/Basic.h> -#include "mb/paint.h" +#include "mb_paint.h" struct _sh_dummy { shape_t shape;
--- a/src/rotate.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/rotate.c Wed Nov 05 15:24:01 2008 +0800 @@ -2,7 +2,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> -#include "mb/animate.h" +#include "mb_animate.h" static float comp_mb_timeval_ratio(const mb_timeval_t *a, const mb_timeval_t *b) {
--- a/src/shape_path.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/shape_path.c Wed Nov 05 15:24:01 2008 +0800 @@ -3,8 +3,8 @@ #include <ctype.h> #include <string.h> #include <cairo.h> -#include "mb/mb_types.h" -#include "mb/redraw_man.h" +#include "mb_types.h" +#include "mb_redraw_man.h" /*! \brief Implement respective objects for SVG path tag. *
--- a/src/shape_rect.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/shape_rect.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,8 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "mb/mb_types.h" -#include "mb/shapes.h" +#include "mb_types.h" +#include "mb_shapes.h" typedef struct _sh_rect { shape_t shape;
--- a/src/shape_text.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/shape_text.c Wed Nov 05 15:24:01 2008 +0800 @@ -3,8 +3,8 @@ #include <string.h> #include <math.h> #include <cairo.h> -#include "mb/mb_types.h" -#include "mb/shapes.h" +#include "mb_types.h" +#include "mb_shapes.h" #define ASSERT(x) #define OK 0
--- a/src/shift.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/shift.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "mb/animate.h" +#include "mb_animate.h" static float comp_mb_timeval_ratio(const mb_timeval_t *a, const mb_timeval_t *b) {
--- a/src/timer.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/timer.c Wed Nov 05 15:24:01 2008 +0800 @@ -2,8 +2,8 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> -#include "mb/mb_timer.h" -#include "mb/tools.h" +#include "mb_timer.h" +#include "mb_tools.h" #define OK 0
--- a/src/timertool.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/timertool.c Wed Nov 05 15:24:01 2008 +0800 @@ -5,7 +5,7 @@ #include <sys/types.h> #include <sys/sysctl.h> #endif -#include "mb/mb_timer.h" +#include "mb_timer.h" #ifdef __FreeBSD__
--- a/src/tools.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/tools.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,5 +1,5 @@ #include <stdlib.h> -#include "mb/tools.h" +#include "mb_tools.h" /*! \brief Small fixed size data elements management.
--- a/src/visibility.c Tue Nov 04 17:00:26 2008 +0800 +++ b/src/visibility.c Wed Nov 05 15:24:01 2008 +0800 @@ -1,6 +1,6 @@ #include <stdio.h> #include <stdlib.h> -#include "mb/animate.h" +#include "mb_animate.h" typedef struct _mb_visibility mb_visibility_t;
--- a/tools/mb_c_source.m4 Tue Nov 04 17:00:26 2008 +0800 +++ b/tools/mb_c_source.m4 Wed Nov 05 15:24:01 2008 +0800 @@ -298,10 +298,10 @@ [#include <stdio.h> #include <stdlib.h> #include <string.h> -#include "mb/mb_types.h" -#include "mb/redraw_man.h" -#include "mb/shapes.h" -#include "mb/paint.h" +#include <mb_types.h> +#include <mb_redraw_man.h> +#include <mb_shapes.h> +#include <mb_paint.h> #include "$1.h" $1_t *$1_new(redraw_man_t *rdman, coord_t *parent_coord) {