applied patch from Paul Seidel with further improvements to the playback
2007-06-20 Sven Neumann <sven@gimp.org> * plug-ins/common/animationplay.c: applied patch from Paul Seidel with further improvements to the playback speed control (bug #338380). svn path=/trunk/; revision=22809
This commit is contained in:

committed by
Sven Neumann

parent
3f747cf0e3
commit
33429e9fe2
@ -1,3 +1,8 @@
|
|||||||
|
2007-06-20 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/common/animationplay.c: applied patch from Paul Seidel
|
||||||
|
with further improvements to the playback speed control (bug #338380).
|
||||||
|
|
||||||
2007-06-20 Sven Neumann <sven@gimp.org>
|
2007-06-20 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/base/tile-pyramid.c (tile_pyramid_write_quarter): added missing
|
* app/base/tile-pyramid.c (tile_pyramid_write_quarter): added missing
|
||||||
|
@ -71,6 +71,8 @@ static void rewind_callback (GtkAction *action);
|
|||||||
static void speed_up_callback (GtkAction *action);
|
static void speed_up_callback (GtkAction *action);
|
||||||
static void speed_down_callback (GtkAction *action);
|
static void speed_down_callback (GtkAction *action);
|
||||||
static void speed_reset_callback (GtkAction *action);
|
static void speed_reset_callback (GtkAction *action);
|
||||||
|
static void speedcombo_changed (GtkWidget *scombo,
|
||||||
|
gpointer data);
|
||||||
static gboolean repaint_sda (GtkWidget *darea,
|
static gboolean repaint_sda (GtkWidget *darea,
|
||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
@ -82,7 +84,8 @@ static void render_frame (gint32 whichframe);
|
|||||||
static void show_frame (void);
|
static void show_frame (void);
|
||||||
static void total_alpha_preview (guchar *ptr);
|
static void total_alpha_preview (guchar *ptr);
|
||||||
static void init_preview (void);
|
static void init_preview (void);
|
||||||
static void update_statusbar (void);
|
static void update_combobox (void);
|
||||||
|
static gdouble get_duration_factor (gint index);
|
||||||
|
|
||||||
|
|
||||||
/* tag util functions*/
|
/* tag util functions*/
|
||||||
@ -129,7 +132,7 @@ static guint timer = 0;
|
|||||||
static GimpImageBaseType imagetype;
|
static GimpImageBaseType imagetype;
|
||||||
static guchar *palette;
|
static guchar *palette;
|
||||||
static gint ncolours;
|
static gint ncolours;
|
||||||
static gdouble duration_factor = 1.0;
|
static gint duration_index = 3;
|
||||||
|
|
||||||
|
|
||||||
/* for shaping */
|
/* for shaping */
|
||||||
@ -142,9 +145,7 @@ static gchar *shape_preview_mask = NULL;
|
|||||||
static GtkWidget *shape_window = NULL;
|
static GtkWidget *shape_window = NULL;
|
||||||
static GdkWindow *root_win = NULL;
|
static GdkWindow *root_win = NULL;
|
||||||
static gboolean detached = FALSE;
|
static gboolean detached = FALSE;
|
||||||
static GtkWidget *statusbar = NULL;
|
static GtkWidget *speedcombo = NULL;
|
||||||
static guint message_context_id = 0;
|
|
||||||
|
|
||||||
|
|
||||||
MAIN ()
|
MAIN ()
|
||||||
|
|
||||||
@ -564,12 +565,16 @@ build_dialog (GimpImageBaseType basetype,
|
|||||||
{
|
{
|
||||||
GtkWidget *toolbar;
|
GtkWidget *toolbar;
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
|
GtkWidget *main_vbox;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
|
GtkWidget *hbox;
|
||||||
GtkWidget *abox;
|
GtkWidget *abox;
|
||||||
|
GtkWidget *ebox;
|
||||||
GtkToolItem *item;
|
GtkToolItem *item;
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
GdkCursor *cursor;
|
GdkCursor *cursor;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
gint index;
|
||||||
|
|
||||||
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
||||||
|
|
||||||
@ -592,12 +597,12 @@ build_dialog (GimpImageBaseType basetype,
|
|||||||
|
|
||||||
ui_manager = ui_manager_new (window);
|
ui_manager = ui_manager_new (window);
|
||||||
|
|
||||||
vbox = gtk_vbox_new (FALSE, 0);
|
main_vbox = gtk_vbox_new (FALSE, 0);
|
||||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (main_vbox);
|
||||||
|
|
||||||
toolbar = gtk_ui_manager_get_widget (ui_manager, "/anim-play-toolbar");
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/anim-play-toolbar");
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (toolbar);
|
gtk_widget_show (toolbar);
|
||||||
|
|
||||||
item =
|
item =
|
||||||
@ -606,6 +611,10 @@ build_dialog (GimpImageBaseType basetype,
|
|||||||
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
|
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
|
||||||
gtk_tool_item_set_expand (item, TRUE);
|
gtk_tool_item_set_expand (item, TRUE);
|
||||||
|
|
||||||
|
vbox = gtk_vbox_new (FALSE, 2);
|
||||||
|
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (abox);
|
gtk_widget_show (abox);
|
||||||
@ -625,14 +634,38 @@ build_dialog (GimpImageBaseType basetype,
|
|||||||
G_CALLBACK (button_press),
|
G_CALLBACK (button_press),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
progress = gtk_progress_bar_new ();
|
hbox = gtk_hbox_new (FALSE, 2);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (progress);
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
statusbar = gtk_statusbar_new ();
|
ebox = gtk_event_box_new ();
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), ebox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (statusbar);
|
gtk_widget_show (ebox);
|
||||||
update_statusbar ();
|
|
||||||
|
speedcombo = gtk_combo_box_new_text ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (ebox), speedcombo);
|
||||||
|
gtk_widget_show (speedcombo);
|
||||||
|
|
||||||
|
for (index = 0; index < 7; index++)
|
||||||
|
{
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
|
text = g_strdup_printf ("%g %%", 100.0 / get_duration_factor (index));
|
||||||
|
gtk_combo_box_append_text (GTK_COMBO_BOX (speedcombo), text);
|
||||||
|
g_free (text);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (speedcombo), 3);
|
||||||
|
|
||||||
|
g_signal_connect (speedcombo, "changed",
|
||||||
|
G_CALLBACK (speedcombo_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gimp_help_set_help_data (ebox, _("Playback speed"), NULL);
|
||||||
|
|
||||||
|
progress = gtk_progress_bar_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), progress, TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show (progress);
|
||||||
|
|
||||||
if (total_frames < 2)
|
if (total_frames < 2)
|
||||||
{
|
{
|
||||||
@ -1379,9 +1412,13 @@ window_destroy (GtkWidget *widget)
|
|||||||
static gint
|
static gint
|
||||||
advance_frame_callback (gpointer data)
|
advance_frame_callback (gpointer data)
|
||||||
{
|
{
|
||||||
|
gdouble duration;
|
||||||
|
|
||||||
remove_timer();
|
remove_timer();
|
||||||
|
|
||||||
timer = g_timeout_add (get_frame_duration ((frame_number + 1) % total_frames) * duration_factor,
|
duration = get_frame_duration ((frame_number + 1) % total_frames);
|
||||||
|
|
||||||
|
timer = g_timeout_add (duration * get_duration_factor (duration_index),
|
||||||
advance_frame_callback, NULL);
|
advance_frame_callback, NULL);
|
||||||
|
|
||||||
do_step ();
|
do_step ();
|
||||||
@ -1400,7 +1437,8 @@ play_callback (GtkToggleAction *action)
|
|||||||
playing = gtk_toggle_action_get_active (action);
|
playing = gtk_toggle_action_get_active (action);
|
||||||
|
|
||||||
if (playing)
|
if (playing)
|
||||||
timer = g_timeout_add (get_frame_duration (frame_number) * duration_factor,
|
timer = g_timeout_add (get_frame_duration (frame_number) *
|
||||||
|
get_duration_factor (duration_index),
|
||||||
advance_frame_callback, NULL);
|
advance_frame_callback, NULL);
|
||||||
|
|
||||||
g_object_set (action,
|
g_object_set (action,
|
||||||
@ -1408,6 +1446,30 @@ play_callback (GtkToggleAction *action)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gdouble
|
||||||
|
get_duration_factor (gint index)
|
||||||
|
{
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return 0.125;
|
||||||
|
case 1:
|
||||||
|
return 0.25;
|
||||||
|
case 2:
|
||||||
|
return 0.5;
|
||||||
|
case 3:
|
||||||
|
return 1.0;
|
||||||
|
case 4:
|
||||||
|
return 2.0;
|
||||||
|
case 5:
|
||||||
|
return 4.0;
|
||||||
|
case 6:
|
||||||
|
return 8.0;
|
||||||
|
default:
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
step_callback (GtkAction *action)
|
step_callback (GtkAction *action)
|
||||||
{
|
{
|
||||||
@ -1432,45 +1494,45 @@ rewind_callback (GtkAction *action)
|
|||||||
static void
|
static void
|
||||||
speed_up_callback (GtkAction *action)
|
speed_up_callback (GtkAction *action)
|
||||||
{
|
{
|
||||||
if (duration_factor > 0.125)
|
if (duration_index > 0)
|
||||||
duration_factor /= 2.0;
|
--duration_index;
|
||||||
|
|
||||||
gtk_action_set_sensitive (action, duration_factor > 0.125);
|
gtk_action_set_sensitive (action, duration_index > 0);
|
||||||
|
|
||||||
action = gtk_ui_manager_get_action (ui_manager,
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
"/anim-play-popup/speed-reset");
|
"/anim-play-popup/speed-reset");
|
||||||
gtk_action_set_sensitive (action, duration_factor != 1.0);
|
gtk_action_set_sensitive (action, duration_index != 3);
|
||||||
|
|
||||||
action = gtk_ui_manager_get_action (ui_manager,
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
"/anim-play-popup/speed-down");
|
"/anim-play-popup/speed-down");
|
||||||
gtk_action_set_sensitive (action, TRUE);
|
gtk_action_set_sensitive (action, TRUE);
|
||||||
|
|
||||||
update_statusbar ();
|
update_combobox ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
speed_down_callback (GtkAction *action)
|
speed_down_callback (GtkAction *action)
|
||||||
{
|
{
|
||||||
if (duration_factor < 8.0)
|
if (duration_index < 6)
|
||||||
duration_factor *= 2.0;
|
++duration_index;
|
||||||
|
|
||||||
gtk_action_set_sensitive (action, duration_factor < 8.0);
|
gtk_action_set_sensitive (action, duration_index < 6);
|
||||||
|
|
||||||
action = gtk_ui_manager_get_action (ui_manager,
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
"/anim-play-popup/speed-reset");
|
"/anim-play-popup/speed-reset");
|
||||||
gtk_action_set_sensitive (action, duration_factor != 1.0);
|
gtk_action_set_sensitive (action, duration_index != 3);
|
||||||
|
|
||||||
action = gtk_ui_manager_get_action (ui_manager,
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
"/anim-play-popup/speed-up");
|
"/anim-play-popup/speed-up");
|
||||||
gtk_action_set_sensitive (action, TRUE);
|
gtk_action_set_sensitive (action, TRUE);
|
||||||
|
|
||||||
update_statusbar ();
|
update_combobox ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
speed_reset_callback (GtkAction *action)
|
speed_reset_callback (GtkAction *action)
|
||||||
{
|
{
|
||||||
duration_factor = 1.0;
|
duration_index = 3;
|
||||||
|
|
||||||
gtk_action_set_sensitive (action, FALSE);
|
gtk_action_set_sensitive (action, FALSE);
|
||||||
|
|
||||||
@ -1482,33 +1544,34 @@ speed_reset_callback (GtkAction *action)
|
|||||||
"/anim-play-popup/speed-up");
|
"/anim-play-popup/speed-up");
|
||||||
gtk_action_set_sensitive (action, TRUE);
|
gtk_action_set_sensitive (action, TRUE);
|
||||||
|
|
||||||
update_statusbar ();
|
update_combobox ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
speedcombo_changed (GtkWidget *scombo, gpointer data)
|
||||||
|
{
|
||||||
|
GtkAction * action;
|
||||||
|
|
||||||
|
duration_index = gtk_combo_box_get_active (GTK_COMBO_BOX (scombo));
|
||||||
|
|
||||||
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
|
"/anim-play-popup/speed-reset");
|
||||||
|
gtk_action_set_sensitive (action, duration_index != 3);
|
||||||
|
|
||||||
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
|
"/anim-play-popup/speed-down");
|
||||||
|
gtk_action_set_sensitive (action, duration_index < 6);
|
||||||
|
|
||||||
|
action = gtk_ui_manager_get_action (ui_manager,
|
||||||
|
"/anim-play-popup/speed-up");
|
||||||
|
gtk_action_set_sensitive (action, duration_index > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_statusbar (void)
|
update_combobox (void)
|
||||||
{
|
{
|
||||||
gchar *status_message;
|
gtk_combo_box_set_active (GTK_COMBO_BOX (speedcombo), duration_index);
|
||||||
|
|
||||||
if (message_context_id == 0)
|
|
||||||
{
|
|
||||||
message_context_id =
|
|
||||||
gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar),
|
|
||||||
"speed-playback");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_statusbar_pop (GTK_STATUSBAR (statusbar),
|
|
||||||
message_context_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
status_message = g_strdup_printf (_("Playback speed: %d %%"),
|
|
||||||
(gint) ROUND (100.0 / duration_factor));
|
|
||||||
|
|
||||||
gtk_statusbar_push (GTK_STATUSBAR (statusbar),
|
|
||||||
message_context_id, status_message);
|
|
||||||
|
|
||||||
g_free (status_message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tag util. */
|
/* tag util. */
|
||||||
|
Reference in New Issue
Block a user