Anim: Improved support of extreme durations (O included to 655.350s included); Adding frames now inherits parent's duration cleanly; Default duration now 100ms (instead of 1ms). Removed blanks in Time window and made tooltips more explicit for next/prev frame, thanks to 00ai99 for reporting.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1931 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
8081c9527d
commit
be96447f3b
@ -2636,8 +2636,10 @@ void Save_GIF(T_IO_Context * context)
|
|||||||
if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION)
|
if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION)
|
||||||
{
|
{
|
||||||
// Animation frame
|
// Animation frame
|
||||||
|
int duration;
|
||||||
GCE.Packed_fields=(2<<2)|(context->Background_transparent);
|
GCE.Packed_fields=(2<<2)|(context->Background_transparent);
|
||||||
GCE.Delay_time=Get_frame_duration(context)/10;
|
duration=Get_frame_duration(context)/10;
|
||||||
|
GCE.Delay_time=duration<0xFFFF?duration:0xFFFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1308,7 +1308,7 @@ void Init_buttons(void)
|
|||||||
Do_nothing,
|
Do_nothing,
|
||||||
FAMILY_INSTANT);
|
FAMILY_INSTANT);
|
||||||
Init_button(BUTTON_ANIM_PREV_FRAME,
|
Init_button(BUTTON_ANIM_PREV_FRAME,
|
||||||
"Go to previous frame ",
|
"Go to prev. frame/Rewind",
|
||||||
130,0,
|
130,0,
|
||||||
13,13,
|
13,13,
|
||||||
BUTTON_SHAPE_RECTANGLE,
|
BUTTON_SHAPE_RECTANGLE,
|
||||||
@ -1317,7 +1317,7 @@ void Init_buttons(void)
|
|||||||
Do_nothing,
|
Do_nothing,
|
||||||
FAMILY_INSTANT);
|
FAMILY_INSTANT);
|
||||||
Init_button(BUTTON_ANIM_NEXT_FRAME,
|
Init_button(BUTTON_ANIM_NEXT_FRAME,
|
||||||
"Go to next frame ",
|
"Go to next frame / Play ",
|
||||||
144,0,
|
144,0,
|
||||||
13,13,
|
13,13,
|
||||||
BUTTON_SHAPE_RECTANGLE,
|
BUTTON_SHAPE_RECTANGLE,
|
||||||
|
|||||||
38
src/layers.c
38
src/layers.c
@ -436,16 +436,16 @@ void Button_Anim_time(void)
|
|||||||
short clicked_button;
|
short clicked_button;
|
||||||
int mode=0;
|
int mode=0;
|
||||||
int frame;
|
int frame;
|
||||||
char buffer[5+1];
|
char buffer[6+1];
|
||||||
T_Special_button * input_duration_button;
|
T_Special_button * input_duration_button;
|
||||||
int duration=Main_backups->Pages->Image[Main_current_layer].Duration;
|
int duration=Main_backups->Pages->Image[Main_current_layer].Duration;
|
||||||
|
|
||||||
Open_window(166,110,"Animation speed");
|
Open_window(166,110,"Animation speed");
|
||||||
|
|
||||||
Print_in_window(80,20,"ms",MC_Black,MC_Light);
|
Print_in_window(88,20,"ms",MC_Black,MC_Light);
|
||||||
input_duration_button = Window_set_input_button(33,18,5); // 1
|
input_duration_button = Window_set_input_button(33,18,6); // 1
|
||||||
|
|
||||||
Num2str(duration,buffer,5);
|
Num2str(duration,buffer,6);
|
||||||
Print_in_window_limited(input_duration_button->Pos_X+2,input_duration_button->Pos_Y+2,buffer,input_duration_button->Width/8,MC_Black,MC_Light);
|
Print_in_window_limited(input_duration_button->Pos_X+2,input_duration_button->Pos_Y+2,buffer,input_duration_button->Width/8,MC_Black,MC_Light);
|
||||||
|
|
||||||
Print_in_window(24,37,"Set this frame",MC_Black,MC_Light);
|
Print_in_window(24,37,"Set this frame",MC_Black,MC_Light);
|
||||||
@ -472,12 +472,18 @@ void Button_Anim_time(void)
|
|||||||
switch(clicked_button)
|
switch(clicked_button)
|
||||||
{
|
{
|
||||||
case 1: // duration
|
case 1: // duration
|
||||||
Num2str(duration,buffer,5);
|
// safety
|
||||||
|
if (duration <= -10000)
|
||||||
|
sprintf(buffer,"-99999");
|
||||||
|
else if (duration >= 1000000)
|
||||||
|
sprintf(buffer,"999999");
|
||||||
|
else
|
||||||
|
sprintf(buffer,"%d", duration);
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
if (Readline(input_duration_button->Pos_X+2,
|
if (Readline(input_duration_button->Pos_X+2,
|
||||||
input_duration_button->Pos_Y+2,
|
input_duration_button->Pos_Y+2,
|
||||||
buffer,
|
buffer,
|
||||||
5,
|
6,
|
||||||
INPUT_TYPE_DECIMAL))
|
INPUT_TYPE_DECIMAL))
|
||||||
{
|
{
|
||||||
duration=atoi(buffer);
|
duration=atoi(buffer);
|
||||||
@ -509,13 +515,17 @@ void Button_Anim_time(void)
|
|||||||
switch(mode)
|
switch(mode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (duration<1)
|
if (duration<0)
|
||||||
duration=1;
|
duration=0;
|
||||||
|
else if (duration>655350)
|
||||||
|
duration=655350;
|
||||||
Main_backups->Pages->Image[Main_current_layer].Duration = duration;
|
Main_backups->Pages->Image[Main_current_layer].Duration = duration;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (duration<1)
|
if (duration<0)
|
||||||
duration=1;
|
duration=0;
|
||||||
|
else if (duration>655350)
|
||||||
|
duration=655350;
|
||||||
for (frame=0; frame<Main_backups->Pages->Nb_layers; frame++)
|
for (frame=0; frame<Main_backups->Pages->Nb_layers; frame++)
|
||||||
{
|
{
|
||||||
Main_backups->Pages->Image[frame].Duration = duration;
|
Main_backups->Pages->Image[frame].Duration = duration;
|
||||||
@ -525,10 +535,10 @@ void Button_Anim_time(void)
|
|||||||
for (frame=0; frame<Main_backups->Pages->Nb_layers; frame++)
|
for (frame=0; frame<Main_backups->Pages->Nb_layers; frame++)
|
||||||
{
|
{
|
||||||
int cur_duration = Main_backups->Pages->Image[frame].Duration+duration;
|
int cur_duration = Main_backups->Pages->Image[frame].Duration+duration;
|
||||||
if (cur_duration<1)
|
if (cur_duration<0)
|
||||||
cur_duration=1;
|
cur_duration=0;
|
||||||
else if (cur_duration>32767)
|
else if (cur_duration>655350)
|
||||||
cur_duration=32767;
|
cur_duration=655350;
|
||||||
Main_backups->Pages->Image[frame].Duration = cur_duration;
|
Main_backups->Pages->Image[frame].Duration = cur_duration;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
13
src/pages.c
13
src/pages.c
@ -67,7 +67,7 @@ T_Page * New_page(int nb_layers)
|
|||||||
for (i=0; i<nb_layers; i++)
|
for (i=0; i<nb_layers; i++)
|
||||||
{
|
{
|
||||||
page->Image[i].Pixels=NULL;
|
page->Image[i].Pixels=NULL;
|
||||||
page->Image[i].Duration=1;
|
page->Image[i].Duration=100;
|
||||||
}
|
}
|
||||||
page->Width=0;
|
page->Width=0;
|
||||||
page->Height=0;
|
page->Height=0;
|
||||||
@ -445,7 +445,7 @@ void Clear_page(T_Page * page)
|
|||||||
{
|
{
|
||||||
Free_layer(page, i);
|
Free_layer(page, i);
|
||||||
page->Image[i].Pixels=NULL;
|
page->Image[i].Pixels=NULL;
|
||||||
page->Image[i].Duration=1;
|
page->Image[i].Duration=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free_gradient() : This data is reference-counted
|
// Free_gradient() : This data is reference-counted
|
||||||
@ -1319,6 +1319,7 @@ byte Add_layer(T_List_of_pages *list, int layer)
|
|||||||
T_Page * new_page;
|
T_Page * new_page;
|
||||||
byte * new_image;
|
byte * new_image;
|
||||||
int i;
|
int i;
|
||||||
|
int duration;
|
||||||
|
|
||||||
source_page = list->Pages;
|
source_page = list->Pages;
|
||||||
|
|
||||||
@ -1359,7 +1360,13 @@ byte Add_layer(T_List_of_pages *list, int layer)
|
|||||||
new_page->Image[i]=new_page->Image[i-1];
|
new_page->Image[i]=new_page->Image[i-1];
|
||||||
}
|
}
|
||||||
new_page->Image[layer].Pixels=new_image;
|
new_page->Image[layer].Pixels=new_image;
|
||||||
new_page->Image[layer].Duration=1;
|
if (list->Pages->Nb_layers==0)
|
||||||
|
duration=100;
|
||||||
|
else if (layer>0)
|
||||||
|
duration=new_page->Image[layer-1].Duration;
|
||||||
|
else
|
||||||
|
duration=new_page->Image[1].Duration;
|
||||||
|
new_page->Image[layer].Duration=duration;
|
||||||
// Fill with transparency, initially
|
// Fill with transparency, initially
|
||||||
memset(new_image, Main_backups->Pages->Transparent_color, list->Pages->Height*list->Pages->Width); // transparent color
|
memset(new_image, Main_backups->Pages->Transparent_color, list->Pages->Height*list->Pages->Width); // transparent color
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user