mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 04:22:29 +00:00
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:
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>
|
||||
|
||||
* 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_down_callback (GtkAction *action);
|
||||
static void speed_reset_callback (GtkAction *action);
|
||||
static void speedcombo_changed (GtkWidget *scombo,
|
||||
gpointer data);
|
||||
static gboolean repaint_sda (GtkWidget *darea,
|
||||
GdkEventExpose *event,
|
||||
gpointer data);
|
||||
|
@ -82,7 +84,8 @@ static void render_frame (gint32 whichframe);
|
|||
static void show_frame (void);
|
||||
static void total_alpha_preview (guchar *ptr);
|
||||
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*/
|
||||
|
@ -129,7 +132,7 @@ static guint timer = 0;
|
|||
static GimpImageBaseType imagetype;
|
||||
static guchar *palette;
|
||||
static gint ncolours;
|
||||
static gdouble duration_factor = 1.0;
|
||||
static gint duration_index = 3;
|
||||
|
||||
|
||||
/* for shaping */
|
||||
|
@ -142,9 +145,7 @@ static gchar *shape_preview_mask = NULL;
|
|||
static GtkWidget *shape_window = NULL;
|
||||
static GdkWindow *root_win = NULL;
|
||||
static gboolean detached = FALSE;
|
||||
static GtkWidget *statusbar = NULL;
|
||||
static guint message_context_id = 0;
|
||||
|
||||
static GtkWidget *speedcombo = NULL;
|
||||
|
||||
MAIN ()
|
||||
|
||||
|
@ -564,12 +565,16 @@ build_dialog (GimpImageBaseType basetype,
|
|||
{
|
||||
GtkWidget *toolbar;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *abox;
|
||||
GtkWidget *ebox;
|
||||
GtkToolItem *item;
|
||||
GtkAction *action;
|
||||
GdkCursor *cursor;
|
||||
gchar *name;
|
||||
gint index;
|
||||
|
||||
gimp_ui_init (PLUG_IN_BINARY, TRUE);
|
||||
|
||||
|
@ -592,12 +597,12 @@ build_dialog (GimpImageBaseType basetype,
|
|||
|
||||
ui_manager = ui_manager_new (window);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
main_vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
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);
|
||||
|
||||
item =
|
||||
|
@ -606,6 +611,10 @@ build_dialog (GimpImageBaseType basetype,
|
|||
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
|
||||
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);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (abox);
|
||||
|
@ -625,14 +634,38 @@ build_dialog (GimpImageBaseType basetype,
|
|||
G_CALLBACK (button_press),
|
||||
NULL);
|
||||
|
||||
progress = gtk_progress_bar_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0);
|
||||
gtk_widget_show (progress);
|
||||
hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
|
||||
gtk_widget_show (statusbar);
|
||||
update_statusbar ();
|
||||
ebox = gtk_event_box_new ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), ebox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (ebox);
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -1379,9 +1412,13 @@ window_destroy (GtkWidget *widget)
|
|||
static gint
|
||||
advance_frame_callback (gpointer data)
|
||||
{
|
||||
gdouble duration;
|
||||
|
||||
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);
|
||||
|
||||
do_step ();
|
||||
|
@ -1400,7 +1437,8 @@ play_callback (GtkToggleAction *action)
|
|||
playing = gtk_toggle_action_get_active (action);
|
||||
|
||||
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);
|
||||
|
||||
g_object_set (action,
|
||||
|
@ -1408,6 +1446,30 @@ play_callback (GtkToggleAction *action)
|
|||
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
|
||||
step_callback (GtkAction *action)
|
||||
{
|
||||
|
@ -1432,45 +1494,45 @@ rewind_callback (GtkAction *action)
|
|||
static void
|
||||
speed_up_callback (GtkAction *action)
|
||||
{
|
||||
if (duration_factor > 0.125)
|
||||
duration_factor /= 2.0;
|
||||
if (duration_index > 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,
|
||||
"/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,
|
||||
"/anim-play-popup/speed-down");
|
||||
gtk_action_set_sensitive (action, TRUE);
|
||||
|
||||
update_statusbar ();
|
||||
update_combobox ();
|
||||
}
|
||||
|
||||
static void
|
||||
speed_down_callback (GtkAction *action)
|
||||
{
|
||||
if (duration_factor < 8.0)
|
||||
duration_factor *= 2.0;
|
||||
if (duration_index < 6)
|
||||
++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,
|
||||
"/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,
|
||||
"/anim-play-popup/speed-up");
|
||||
gtk_action_set_sensitive (action, TRUE);
|
||||
|
||||
update_statusbar ();
|
||||
update_combobox ();
|
||||
}
|
||||
|
||||
static void
|
||||
speed_reset_callback (GtkAction *action)
|
||||
{
|
||||
duration_factor = 1.0;
|
||||
duration_index = 3;
|
||||
|
||||
gtk_action_set_sensitive (action, FALSE);
|
||||
|
||||
|
@ -1482,33 +1544,34 @@ speed_reset_callback (GtkAction *action)
|
|||
"/anim-play-popup/speed-up");
|
||||
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
|
||||
update_statusbar (void)
|
||||
update_combobox (void)
|
||||
{
|
||||
gchar *status_message;
|
||||
|
||||
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);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (speedcombo), duration_index);
|
||||
}
|
||||
|
||||
/* tag util. */
|
||||
|
|
Loading…
Reference in a new issue