[gimp] app: add gimp_motion_buffer_pop_event_queue() and use it
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_motion_buffer_pop_event_queue() and use it
- Date: Sun, 17 Apr 2011 18:20:54 +0000 (UTC)
commit bb3eac557d6a52fc1e21c7cd143eaba99f06f7d9
Author: Michael Natterer <mitch gimp org>
Date: Sun Apr 17 20:20:18 2011 +0200
app: add gimp_motion_buffer_pop_event_queue() and use it
instead of accessing and removing the queue's first element menually.
app/display/gimpdisplayshell-tool-events.c | 12 +++++-------
app/display/gimpmotionbuffer.c | 18 +++++++++++++++++-
app/display/gimpmotionbuffer.h | 12 +++++++-----
3 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 9deceb2..58c5426 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -977,17 +977,15 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
FALSE,
time))
{
- /* then update the tool. */
- GimpCoords *buf_coords = &g_array_index (shell->motion_buffer->event_queue,
- GimpCoords, 0);
+ GimpCoords buf_coords;
+
+ gimp_motion_buffer_pop_event_queue (shell->motion_buffer,
+ &buf_coords);
tool_manager_oper_update_active (gimp,
- buf_coords, state,
+ &buf_coords, state,
shell->proximity,
display);
-
- /* remove used event */
- g_array_remove_index (shell->motion_buffer->event_queue, 0);
}
gimp_motion_buffer_push_event_history (shell->motion_buffer,
diff --git a/app/display/gimpmotionbuffer.c b/app/display/gimpmotionbuffer.c
index 8ecb21d..ab137e4 100644
--- a/app/display/gimpmotionbuffer.c
+++ b/app/display/gimpmotionbuffer.c
@@ -385,14 +385,30 @@ gimp_motion_buffer_eval_event (GimpMotionBuffer *buffer,
void
gimp_motion_buffer_push_event_history (GimpMotionBuffer *buffer,
- GimpCoords *coords)
+ const GimpCoords *coords)
{
+ g_return_if_fail (GIMP_IS_MOTION_BUFFER (buffer));
+ g_return_if_fail (coords != NULL);
+
if (buffer->event_history->len == 4)
g_array_remove_index (buffer->event_history, 0);
g_array_append_val (buffer->event_history, *coords);
}
+void
+gimp_motion_buffer_pop_event_queue (GimpMotionBuffer *buffer,
+ GimpCoords *coords)
+{
+ g_return_if_fail (GIMP_IS_MOTION_BUFFER (buffer));
+ g_return_if_fail (coords != NULL);
+ g_return_if_fail (buffer->event_queue->len > 0);
+
+ *coords = g_array_index (buffer->event_queue, GimpCoords, 0);
+
+ g_array_remove_index (buffer->event_queue, 0);
+}
+
/* private functions */
diff --git a/app/display/gimpmotionbuffer.h b/app/display/gimpmotionbuffer.h
index ded8b93..c8c4683 100644
--- a/app/display/gimpmotionbuffer.h
+++ b/app/display/gimpmotionbuffer.h
@@ -68,18 +68,20 @@ struct _GimpMotionBufferClass
};
-GType gimp_motion_buffer_get_type (void) G_GNUC_CONST;
+GType gimp_motion_buffer_get_type (void) G_GNUC_CONST;
-GimpMotionBuffer * gimp_motion_buffer_new (void);
+GimpMotionBuffer * gimp_motion_buffer_new (void);
-gboolean gimp_motion_buffer_eval_event (GimpMotionBuffer *buffer,
+gboolean gimp_motion_buffer_eval_event (GimpMotionBuffer *buffer,
gdouble scale_x,
gdouble scale_y,
GimpCoords *coords,
gboolean event_fill,
guint32 time);
-void gimp_motion_buffer_push_event_history (GimpMotionBuffer *buffer,
- GimpCoords *coords);
+void gimp_motion_buffer_push_event_history (GimpMotionBuffer *buffer,
+ const GimpCoords *coords);
+void gimp_motion_buffer_pop_event_queue (GimpMotionBuffer *buffer,
+ GimpCoords *coords);
#endif /* __GIMP_MOTION_BUFFER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]