GimpMotionBuffer

GimpMotionBuffer

Synopsis

                    GimpMotionBuffer;
struct              GimpMotionBufferClass;
GimpMotionBuffer *  gimp_motion_buffer_new              (void);
void                gimp_motion_buffer_begin_stroke     (GimpMotionBuffer *buffer,
                                                         guint32 time,
                                                         GimpCoords *last_motion);
void                gimp_motion_buffer_end_stroke       (GimpMotionBuffer *buffer);
gboolean            gimp_motion_buffer_motion_event     (GimpMotionBuffer *buffer,
                                                         GimpCoords *coords,
                                                         guint32 time,
                                                         gdouble scale_x,
                                                         gdouble scale_y,
                                                         gboolean event_fill);
guint32             gimp_motion_buffer_get_last_motion_time
                                                        (GimpMotionBuffer *buffer);
void                gimp_motion_buffer_request_stroke   (GimpMotionBuffer *buffer,
                                                         GdkModifierType state,
                                                         guint32 time);
void                gimp_motion_buffer_request_hover    (GimpMotionBuffer *buffer,
                                                         GdkModifierType state,
                                                         gboolean proximity);

Description

Details

GimpMotionBuffer

typedef struct {
  GimpObject  parent_instance;

  guint32     last_read_motion_time;

  guint32     last_motion_time; /*  previous time of a forwarded motion event  */
  gdouble     last_motion_delta_time;
  gdouble     last_motion_delta_x;
  gdouble     last_motion_delta_y;
  gdouble     last_motion_distance;

  GimpCoords  last_coords;      /* last motion event                   */

  GArray     *event_history;
  GArray     *event_queue;
  gboolean    event_delay;      /* TRUE if theres an unsent event in
                                 *  the history buffer
                                 */

  gint               event_delay_timeout;
  GdkModifierType    last_active_state;
} GimpMotionBuffer;


struct GimpMotionBufferClass

struct GimpMotionBufferClass {
  GimpObjectClass  parent_class;

  void (* stroke) (GimpMotionBuffer *buffer,
                   const GimpCoords *coords,
                   guint32           time,
                   GdkModifierType   state);
  void (* hover)  (GimpMotionBuffer *buffer,
                   const GimpCoords *coords,
                   GdkModifierType   state,
                   gboolean          proximity);
};


gimp_motion_buffer_new ()

GimpMotionBuffer *  gimp_motion_buffer_new              (void);


gimp_motion_buffer_begin_stroke ()

void                gimp_motion_buffer_begin_stroke     (GimpMotionBuffer *buffer,
                                                         guint32 time,
                                                         GimpCoords *last_motion);


gimp_motion_buffer_end_stroke ()

void                gimp_motion_buffer_end_stroke       (GimpMotionBuffer *buffer);


gimp_motion_buffer_motion_event ()

gboolean            gimp_motion_buffer_motion_event     (GimpMotionBuffer *buffer,
                                                         GimpCoords *coords,
                                                         guint32 time,
                                                         gdouble scale_x,
                                                         gdouble scale_y,
                                                         gboolean event_fill);

This function evaluates the event to decide if the change is big enough to need handling and returns FALSE, if change is less than set filter level taking a whole lot of load off any draw tools that have no use for these events anyway. If the event is seen fit at first look, it is evaluated for speed and smoothed. Due to lousy time resolution of events pretty strong smoothing is applied to timestamps for sensible speed result. This function is also ideal for other event adjustment like pressure curve or calculating other derived dynamics factors like angular velocity calculation from tilt values, to allow for even more dynamic brushes. Calculated distance to last event is stored in GimpCoords because its a sideproduct of velocity calculation and is currently calculated in each tool. If they were to use this distance, more resouces on recalculating the same value would be saved.

Returns :

TRUE if the motion was significant enough to be processed, FALSE otherwise.

gimp_motion_buffer_get_last_motion_time ()

guint32             gimp_motion_buffer_get_last_motion_time
                                                        (GimpMotionBuffer *buffer);


gimp_motion_buffer_request_stroke ()

void                gimp_motion_buffer_request_stroke   (GimpMotionBuffer *buffer,
                                                         GdkModifierType state,
                                                         guint32 time);


gimp_motion_buffer_request_hover ()

void                gimp_motion_buffer_request_hover    (GimpMotionBuffer *buffer,
                                                         GdkModifierType state,
                                                         gboolean proximity);