Exemple #1
0
static void shift_btn(shifter_dd *dt, void **wdata, int what, void **where)
{
	int i;

	if ((what == op_EVT_OK) || (what == op_EVT_CANCEL))
	{
		shift_play_state = FALSE; // Stop

		mem_pal_copy(mem_pal, dt->old_pal);
		update_stuff(UPD_PAL);

		run_destroy(wdata);
		return;
	}

	if (what == op_EVT_CHANGE) // Play toggle
	{
		cmd_read(where, dt);
		if (shift_play_state && !shift_timer_state) // Start timer
			shift_timer_state = threads_timeout_add(100,
				shift_play_timer_call, dt);
		return;
	}

	where = origin_slot(where);

	if (where == dt->fix)	// Button to fix palette pressed
	{
		i = dt->frame[0];
		if (!i || (i > dt->frame[2])) return; // Nothing to do

		mem_pal_copy(mem_pal, dt->old_pal);
		spot_undo(UNDO_PAL);
		shifter_set_palette(dt, i);
		mem_pal_copy(dt->old_pal, mem_pal);
		cmd_set(dt->slider, 0);
		update_stuff(UPD_PAL);
	}

	else if (where == dt->clear)	// Button to clear all of the values
	{
		for (i = 0; i < NSHIFT; i++)
			spins[i][0][0] = spins[i][1][0] = spins[i][2][0] = 0;
		cmd_reset(dt->spinpack, dt);
		shifter_moved(dt, wdata, op_EVT_CHANGE, dt->spinpack);
	}

	else if (where == dt->create)	// Button to create a sequence of undo images
	{
		if (!dt->frame[2]) return;	// Nothing to do

		for (i = 0; i <= dt->frame[2]; i++)
		{
			shifter_set_palette(dt, i);
			spot_undo(UNDO_PAL);
		}
		shifter_set_palette(dt, dt->frame[0]);
		update_stuff(UPD_PAL);
	}
}
Exemple #2
0
void pressed_shifter()
{
	GtkWidget *vbox, *hbox, *table, *button, *label;
	GtkAccelGroup* ag = gtk_accel_group_new();
	int i, j, max;
	char txt[32];


	shifter_window = add_a_window(GTK_WINDOW_TOPLEVEL, _("Palette Shifter"),
		GTK_WIN_POS_CENTER, TRUE);
	vbox = add_vbox(shifter_window);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);

	table = add_a_table(9, 4, 5, vbox);

	label = add_to_table( _("Start"),  table, 0, 1, 1 );
	gtk_misc_set_alignment( GTK_MISC(label), 0.5, 0.5 );
	label = add_to_table( _("Finish"), table, 0, 2, 1 );
	gtk_misc_set_alignment( GTK_MISC(label), 0.5, 0.5 );
	label = add_to_table( _("Delay"),  table, 0, 3, 1 );
	gtk_misc_set_alignment( GTK_MISC(label), 0.5, 0.5 );

	for ( i=0; i<8; i++ )
	{
		sprintf(txt, "%i", i);
		add_to_table( txt, table, i+1, 0, 5 );

		for ( j=0; j<3; j++ )
		{
			if ( j==2 ) max=255; else max=mem_cols-1;
			shifter_spin[i][j] = spin_to_table( table, i+1, j+1, 2,
						shifter_in[i][j], 0, max );
			spin_connect(shifter_spin[i][j],
				GTK_SIGNAL_FUNC(shifter_moved), NULL);
		}
	}


	hbox = pack(vbox, gtk_hbox_new(FALSE, 0));
	gtk_widget_show (hbox);

	button = pack(hbox, sig_toggle_button(_("Play"), FALSE, NULL,
		GTK_SIGNAL_FUNC(shift_but_playstop)));
	shift_play_state = FALSE;			// Stopped

	shifter_label = xpack(hbox, gtk_label_new(""));
	gtk_widget_show( shifter_label );
	gtk_misc_set_alignment( GTK_MISC(shifter_label), 0.5, 0.5 );


	shifter_slider = xpack5(vbox, mt_spinslide_new(-1, -1));
	mt_spinslide_set_range(shifter_slider, 0, 0);
	mt_spinslide_set_value(shifter_slider, 0);
	mt_spinslide_connect(shifter_slider, GTK_SIGNAL_FUNC(shifter_slider_moved), NULL);


	add_hseparator( vbox, -2, 10 );

	hbox = pack(vbox, gtk_hbox_new(FALSE, 0));
	gtk_widget_show (hbox);

	button = xpack5(hbox, gtk_button_new_with_label(_("Clear")));
	gtk_widget_show(button);
	gtk_signal_connect(GTK_OBJECT(button), "clicked",
		GTK_SIGNAL_FUNC(click_shift_clear), NULL);

	button = xpack5(hbox, gtk_button_new_with_label(_("Fix Palette")));
	gtk_widget_show(button);
	gtk_signal_connect(GTK_OBJECT(button), "clicked",
		GTK_SIGNAL_FUNC(click_shift_fix), NULL);

	button = xpack5(hbox, gtk_button_new_with_label(_("Create Frames")));
	gtk_widget_show(button);
	gtk_signal_connect(GTK_OBJECT(button), "clicked",
		GTK_SIGNAL_FUNC(click_shift_create), NULL);

	button = xpack5(hbox, gtk_button_new_with_label(_("Close")));
	gtk_widget_show(button);
	gtk_signal_connect(GTK_OBJECT(button), "clicked",
		GTK_SIGNAL_FUNC(click_shift_close), NULL );
	gtk_widget_add_accelerator (button, "clicked", ag, GDK_Escape, 0, (GtkAccelFlags) 0);
	delete_to_click(shifter_window, button);

	gtk_window_add_accel_group(GTK_WINDOW (shifter_window), ag);
// !!! Transient windows cannot be minimized; don't know if that's desirable here
//	gtk_window_set_transient_for(GTK_WINDOW(shifter_window), GTK_WINDOW(main_window));
	gtk_widget_show(shifter_window);

#if GTK_MAJOR_VERSION == 1
	gtk_widget_queue_resize(shifter_window); /* Re-render sliders */
#endif

	mem_pal_copy( sh_old_pal, mem_pal );			// Backup the current palette
	shifter_pos = 0;
	shifter_max = 0;
	shifter_moved();					// Initialize the input array
}