X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdisplay%2Fsp-canvas.h;h=9c8b199823db70799ded17afa50920ea4b94bc56;hb=0dc33d4ce43e0bb49c63aa53b826ec4a1ff68e28;hp=a9bf2e4c35fe7bb0aceca27622aea3905cbff099;hpb=cae46a08a948c1f6fa3736b5449b8d8c56d92d1f;p=inkscape.git diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index a9bf2e4c3..9c8b19982 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -1,8 +1,8 @@ -#ifndef __SP_CANVAS_H__ -#define __SP_CANVAS_H__ +#ifndef SEEN_SP_CANVAS_H +#define SEEN_SP_CANVAS_H /** \file - * SPCanvas, SPCanvasBuf, and SPCanvasItem. + * SPCanvas, SPCanvasBuf. * * Authors: * Federico Mena @@ -33,11 +33,23 @@ #include #include -#include -#include +#include + +#include <2geom/matrix.h> #include +#include <2geom/rect.h> + +G_BEGIN_DECLS + +#define SP_TYPE_CANVAS sp_canvas_get_type() +#define SP_CANVAS(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CANVAS, SPCanvas)) +#define SP_IS_CANVAS(obj) (GTK_CHECK_TYPE((obj), SP_TYPE_CANVAS)) + +GType sp_canvas_get_type(); + struct SPCanvas; +struct SPCanvasItem; struct SPCanvasGroup; enum { @@ -52,60 +64,15 @@ struct SPCanvasBuf{ guchar *buf; int buf_rowstride; NRRectL rect; + NRRectL visible_rect; /// Background color, given as 0xrrggbb guint32 bg_color; // If empty, ignore contents of buffer and use a solid area of bg_color bool is_empty; + cairo_t *ct; }; -/** - * An SPCanvasItem refers to a SPCanvas and to its parent item; it has - * four coordinates, a bounding rectangle, and a transformation matrix. - */ -struct SPCanvasItem : public GtkObject { - SPCanvas *canvas; - SPCanvasItem *parent; - - double x1, y1, x2, y2; - NR::Rect bounds; - NR::Matrix xform; -}; - -/** - * The vtable of an SPCanvasItem. - */ -struct SPCanvasItemClass : public GtkObjectClass { - void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); - - void (* render) (SPCanvasItem *item, SPCanvasBuf *buf); - double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); - - int (* event) (SPCanvasItem *item, GdkEvent *event); -}; - -SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...); - -#define sp_canvas_item_set gtk_object_set - -void sp_canvas_item_affine_absolute(SPCanvasItem *item, NR::Matrix const &aff); - -void sp_canvas_item_raise(SPCanvasItem *item, int positions); -void sp_canvas_item_lower(SPCanvasItem *item, int positions); -void sp_canvas_item_show(SPCanvasItem *item); -void sp_canvas_item_hide(SPCanvasItem *item); -int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime); -void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime); - -NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item); - -void sp_canvas_item_grab_focus(SPCanvasItem *item); - -void sp_canvas_item_request_update(SPCanvasItem *item); - -/* get item z-order in parent group */ - -gint sp_canvas_item_order(SPCanvasItem * item); - +G_END_DECLS // SPCanvas ------------------------------------------------- /** @@ -113,77 +80,101 @@ gint sp_canvas_item_order(SPCanvasItem * item); */ struct SPCanvas { GtkWidget widget; - + guint idle_id; - + SPCanvasItem *root; - + double dx0, dy0; int x0, y0; - + /* Area that needs redrawing, stored as a microtile array */ int tLeft,tTop,tRight,tBottom; int tileH,tileV; uint8_t *tiles; - + /* Last known modifier state, for deferred repick when a button is down */ int state; - + /* The item containing the mouse pointer, or NULL if none */ SPCanvasItem *current_item; - + /* Item that is about to become current (used to track deletions and such) */ SPCanvasItem *new_current_item; - + /* Item that holds a pointer grab, or NULL if none */ SPCanvasItem *grabbed_item; - + /* Event mask specified when grabbing an item */ guint grabbed_event_mask; - + /* If non-NULL, the currently focused item */ SPCanvasItem *focused_item; - + /* Event on which selection of current item is based */ GdkEvent pick_event; - + int close_enough; - + /* GC for temporary draw pixmap */ GdkGC *pixmap_gc; - + unsigned int need_update : 1; unsigned int need_redraw : 1; unsigned int need_repick : 1; - + + int forced_redraw_count; + int forced_redraw_limit; + /* For use by internal pick_current_item() function */ unsigned int left_grabbed_item : 1; /* For use by internal pick_current_item() function */ unsigned int in_repick : 1; - int rendermode; + // In most tools Inkscape only generates enter and leave events + // on the current item, but no other enter events if a mouse button + // is depressed -- see function pick_current_item(). Some tools + // may wish the canvas to generate to all enter events, (e.g., the + // connector tool). If so, they may temporarily set this flag to + // 'true'. + bool gen_all_enter_events; - NR::Rect getViewbox() const; + /* For scripting, sometimes we want to delay drawing. */ + bool drawing_disabled; + + int rendermode; + +#if ENABLE_LCMS + bool enable_cms_display_adj; + Glib::ustring* cms_key; +#endif // ENABLE_LCMS + + bool is_scrolling; + + Geom::Rect getViewbox() const; + NR::IRect getViewboxIntegers() const; }; GtkWidget *sp_canvas_new_aa(); SPCanvasGroup *sp_canvas_root(SPCanvas *canvas); -void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear); +void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling = false); void sp_canvas_update_now(SPCanvas *canvas); void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2); +void sp_canvas_force_full_redraw_after_interruptions(SPCanvas *canvas, unsigned int count); +void sp_canvas_end_forced_full_redraws(SPCanvas *canvas); + +bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world); void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy); void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy); -NR::Point sp_canvas_window_to_world(SPCanvas const *canvas, NR::Point const win); -NR::Point sp_canvas_world_to_window(SPCanvas const *canvas, NR::Point const world); +Geom::Point sp_canvas_window_to_world(SPCanvas const *canvas, Geom::Point const win); +Geom::Point sp_canvas_world_to_window(SPCanvas const *canvas, Geom::Point const world); -bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, NR::Point const &world); - -#endif +#endif // SEEN_SP_CANVAS_H /* Local Variables: