Commit 497ba1ec authored by Michael Natterer's avatar Michael Natterer
Browse files

badly hacked the FractalExplorer (only 18 plugins left... ;-)

parent da57754e
2000-01-30 Michael Natterer <mitch@gimp.org>
* plug-ins/FractalExplorer/*:
- Removed the "Gradient" notebook page and added a gimp gradient
selection widget to the "Color" page instead.
- UI cleanups (use the libgimp stuff).
- Removed the "Languages" and "Callbacks" files.
- Made it actually work (seemed quite important to me :-)
* plug-ins/common/png.c: Fix a typo to make it compile.
Sat Jan 29 22:32:30 GMT 2000 Nick Lamb <njl195@zepler.org.uk>
 
* plug-ins/common/png.c: More conservative resolution behaviour
......
#include "FractalExplorer.h"
#include "Callbacks.h"
#include "Dialogs.h"
#include <stdlib.h>
/**********************************************************************
FUNCTION: dialog_close_callback
*********************************************************************/
void
dialog_close_callback(GtkWidget * widget, gpointer data)
{
gtk_main_quit();
} /* dialog_close_callback */
/**********************************************************************
FUNCTION: dialog_save_callback
*********************************************************************/
void
dialog_save_callback(GtkWidget * widget, gpointer data)
{
create_file_selection();
} /* dialog_save_callback */
/**********************************************************************
FUNCTION: load_button_press
*********************************************************************/
void
load_button_press(GtkWidget * widget,
gpointer data)
{
create_load_file_selection();
}
/**********************************************************************
FUNCTION: dialog_ok_callback
*********************************************************************/
void
dialog_ok_callback(GtkWidget * widget, gpointer data)
{
wint.run = TRUE;
gtk_widget_destroy(GTK_WIDGET(data));
} /* dialog_ok_callback */
/**********************************************************************
FUNCTION: dialog_reset_callback
*********************************************************************/
void
dialog_reset_callback(GtkWidget * widget, gpointer data)
{
wvals.xmin = standardvals.xmin;
wvals.xmax = standardvals.xmax;
wvals.ymin = standardvals.ymin;
wvals.ymax = standardvals.ymax;
wvals.iter = standardvals.iter;
wvals.cx = standardvals.cx;
wvals.cy = standardvals.cy;
dialog_change_scale();
set_cmap_preview();
dialog_update_preview();
}
/**********************************************************************
FUNCTION: dialog_redraw_callback
*********************************************************************/
void
dialog_redraw_callback(GtkWidget * widget, gpointer data)
{
int alwaysprev = wvals.alwayspreview;
wvals.alwayspreview = TRUE;
set_cmap_preview();
dialog_update_preview();
wvals.alwayspreview = alwaysprev;
}
/**********************************************************************
FUNCTION: dialog_cancel_callback
*********************************************************************/
void
dialog_cancel_callback(GtkWidget * widget, gpointer data)
{
gtk_widget_destroy(GTK_WIDGET(data));
} /* dialog_cancel_callback */
/**********************************************************************
FUNCTION: dialog_undo_zoom_callback
*********************************************************************/
void
dialog_undo_zoom_callback(GtkWidget * widget, gpointer data)
{
if (zoomindex > 1) {
zooms[zoomindex] = wvals;
zoomindex--;
wvals = zooms[zoomindex];
dialog_change_scale();
set_cmap_preview();
dialog_update_preview();
}
} /* dialog_undo_zoom_callback */
/**********************************************************************
FUNCTION: dialog_redo_zoom_callback
*********************************************************************/
void
dialog_redo_zoom_callback(GtkWidget * widget, gpointer data)
{
if (zoomindex < zoommax) {
zoomindex++;
wvals = zooms[zoomindex];
dialog_change_scale();
set_cmap_preview();
dialog_update_preview();
}
} /* dialog_redo_zoom_callback */
/**********************************************************************
FUNCTION: dialog_step_in_callback
*********************************************************************/
void
dialog_step_in_callback(GtkWidget * widget, gpointer data)
{
double xdifferenz;
double ydifferenz;
if (zoomindex < zoommax) {
zooms[zoomindex]=wvals;
zoomindex++;
}
xdifferenz=wvals.xmax-wvals.xmin;
ydifferenz=wvals.ymax-wvals.ymin;
wvals.xmin+=1.0/6.0*xdifferenz;
wvals.ymin+=1.0/6.0*ydifferenz;
wvals.xmax-=1.0/6.0*xdifferenz;
wvals.ymax-=1.0/6.0*ydifferenz;
zooms[zoomindex]=wvals;
dialog_change_scale();
set_cmap_preview();
dialog_update_preview();
} /* dialog_step_in_callback */
/**********************************************************************
FUNCTION: dialog_step_out_callback
*********************************************************************/
void
dialog_step_out_callback(GtkWidget * widget, gpointer data)
{
double xdifferenz;
double ydifferenz;
if (zoomindex < zoommax) {
zooms[zoomindex]=wvals;
zoomindex++;
}
xdifferenz=wvals.xmax-wvals.xmin;
ydifferenz=wvals.ymax-wvals.ymin;
wvals.xmin-=1.0/4.0*xdifferenz;
wvals.ymin-=1.0/4.0*ydifferenz;
wvals.xmax+=1.0/4.0*xdifferenz;
wvals.ymax+=1.0/4.0*ydifferenz;
zooms[zoomindex]=wvals;
dialog_change_scale();
set_cmap_preview();
dialog_update_preview();
} /* dialog_step_out_callback */
/**********************************************************************
FUNCTION: explorer_logo_ok_callback
*********************************************************************/
void
explorer_logo_ok_callback(GtkWidget * widget, gpointer data)
{
gtk_widget_set_sensitive(maindlg, TRUE);
gtk_widget_destroy(logodlg);
}
/**********************************************************************
FUNCTION: explorer_about_callback
*********************************************************************/
void
explorer_about_callback(GtkWidget * widget, gpointer data)
{
gtk_widget_set_sensitive(maindlg, FALSE);
explorer_logo_dialog();
}
/**********************************************************************
FUNCTION: explorer_toggle_update
*********************************************************************/
void
explorer_toggle_update(GtkWidget * widget,
gpointer data)
{
int *toggle_val;
toggle_val = (int *) data;
if (GTK_TOGGLE_BUTTON(widget)->active)
*toggle_val = TRUE;
else
*toggle_val = FALSE;
if (do_redsinus)
wvals.redmode = SINUS;
else if (do_redcosinus)
wvals.redmode = COSINUS;
else if (do_rednone)
wvals.redmode = NONE;
if (do_greensinus)
wvals.greenmode = SINUS;
else if (do_greencosinus)
wvals.greenmode = COSINUS;
else if (do_greennone)
wvals.greenmode = NONE;
if (do_bluesinus)
wvals.bluemode = SINUS;
else if (do_bluecosinus)
wvals.bluemode = COSINUS;
else if (do_bluenone)
wvals.bluemode = NONE;
if (do_colormode1)
wvals.colormode = 0;
else if (do_colormode2)
wvals.colormode = 1;
if (do_type0)
wvals.fractaltype = 0;
else if (do_type1)
wvals.fractaltype = 1;
else if (do_type2)
wvals.fractaltype = 2;
else if (do_type3)
wvals.fractaltype = 3;
else if (do_type4)
wvals.fractaltype = 4;
else if (do_type5)
wvals.fractaltype = 5;
else if (do_type6)
wvals.fractaltype = 6;
else if (do_type7)
wvals.fractaltype = 7;
else if (do_type8)
wvals.fractaltype = 8;
set_cmap_preview();
dialog_update_preview();
}
/**********************************************************************
FUNCTION: dialog_scale_update
*********************************************************************/
void
dialog_scale_update(GtkAdjustment * adjustment, gdouble * value)
{
GtkWidget *entry;
char buf[MAXSTRLEN];
if (*value != adjustment->value) {
*value = adjustment->value;
entry = gtk_object_get_user_data(GTK_OBJECT(adjustment));
sprintf(buf, "%0.15f", *value);
gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value);
gtk_entry_set_text(GTK_ENTRY(entry), buf);
gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value);
set_cmap_preview();
dialog_update_preview();
}
} /* dialog_scale_update */
/**********************************************************************
FUNCTION: dialog_scale_int_update
*********************************************************************/
void
dialog_scale_int_update(GtkAdjustment * adjustment, gint * value)
{
GtkWidget *entry;
char buf[MAXSTRLEN];
if (*value != adjustment->value) {
*value = (int) adjustment->value;
entry = gtk_object_get_user_data(GTK_OBJECT(adjustment));
sprintf(buf, "%i", *value);
gtk_signal_handler_block_by_data(GTK_OBJECT(entry), value);
gtk_entry_set_text(GTK_ENTRY(entry), buf);
gtk_signal_handler_unblock_by_data(GTK_OBJECT(entry), value);
set_cmap_preview();
dialog_update_preview();
}
} /* dialog_scale_int_update */
/**********************************************************************
FUNCTION: dialog_entry_update
*********************************************************************/
void
dialog_entry_update(GtkWidget * widget, gdouble * value)
{
GtkAdjustment *adjustment;
gdouble new_value;
new_value = atof(gtk_entry_get_text(GTK_ENTRY(widget)));
if (*value != new_value) {
adjustment = gtk_object_get_user_data(GTK_OBJECT(widget));
if ((new_value >= adjustment->lower) &&
(new_value <= adjustment->upper)) {
*value = new_value;
adjustment->value = new_value;
gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed");
dialog_update_preview();
}
}
} /* dialog_entry_update */
/**********************************************************************
FUNCTION: dialog_entry_int_update
*********************************************************************/
void
dialog_entry_int_update(GtkWidget * widget, gint * value)
{
GtkAdjustment *adjustment;
gint new_value;
new_value = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
if (*value != new_value) {
adjustment = gtk_object_get_user_data(GTK_OBJECT(widget));
if ((1.0*new_value >= adjustment->lower) &&
(1.0*new_value <= adjustment->upper)) {
*value = new_value;
adjustment->value = 1.0*new_value;
gtk_signal_emit_by_name(GTK_OBJECT(adjustment), "value_changed");
dialog_update_preview();
}
}
} /* dialog_entry_update */
#ifndef __FRACTALEXPLORER_CALLBACKS_H__
#define __FRACTALEXPLORER_CALLBACKS_H__
#include "gtk/gtk.h"
void dialog_close_callback(GtkWidget * widget, gpointer data);
void dialog_save_callback(GtkWidget * widget, gpointer data);
void load_button_press(GtkWidget * widget, gpointer data);
void dialog_ok_callback(GtkWidget * widget, gpointer data);
void dialog_reset_callback(GtkWidget * widget, gpointer data);
void dialog_redraw_callback(GtkWidget * widget, gpointer data);
void dialog_cancel_callback(GtkWidget * widget, gpointer data);
void dialog_undo_zoom_callback(GtkWidget * widget, gpointer data);
void dialog_redo_zoom_callback(GtkWidget * widget, gpointer data);
void dialog_step_in_callback(GtkWidget * widget, gpointer data);
void dialog_step_out_callback(GtkWidget * widget, gpointer data);
void explorer_logo_ok_callback(GtkWidget * widget, gpointer data);
void explorer_about_callback(GtkWidget * widget, gpointer data);
void explorer_toggle_update(GtkWidget * widget, gpointer data);
void dialog_scale_update(GtkAdjustment * adjustment, gdouble * value);
void dialog_scale_int_update(GtkAdjustment * adjustment, gint * value);
void dialog_entry_update(GtkWidget * widget, gdouble * value);
void dialog_entry_int_update(GtkWidget * widget, gint * value);
#endif
This diff is collapsed.
#ifndef __FRACTALEXPLORER_DIALOGS_H__
#define __FRACTALEXPLORER_DIALOGS_H__
gint explorer_dialog(void);
void dialog_update_preview(void);
gint explorer_dialog (void);
void dialog_update_preview (void);
void dialog_create_value(char *title, GtkTable * table,
int row, gdouble * value,
int left, int right,
const char *desc,
scaledata * scalevalues);
void set_cmap_preview (void);
void make_color_map (void);
void dialog_create_int_value(char *title, GtkTable * table,
int row, int * value,
int left, int right,
const char *desc,
scaledata * scalevalues);
void set_cmap_preview(void);
void make_color_map(void);
GtkWidget *explorer_logo_dialog();
GtkWidget *explorer_load_dialog();
void set_tooltip(GtkTooltips * tooltips, GtkWidget * widget, const char *desc);
void dialog_change_scale(void);
void save_options(FILE * fp);
void save_callback();
void file_selection_ok(GtkWidget * w,
GtkFileSelection * fs,
gpointer data);
void destroy_window(GtkWidget * widget,
GtkWidget ** window);
void load_file_selection_ok(GtkWidget * w,
GtkFileSelection * fs,
gpointer data);
void create_load_file_selection();
void create_file_selection();
char *get_line(gchar * buf, gint s, FILE * from, gint init);
gint load_options(fractalexplorerOBJ * xxx, FILE * fp);
gint gradient_load_options(gradientOBJ * xxx, FILE * fp);
void explorer_load();
void dialog_change_scale (void);
void save_options (FILE *fp);
void save_callback (void);
void file_selection_ok (GtkWidget *widget,
GtkFileSelection *fs,
gpointer data);
void load_file_selection_ok (GtkWidget *widget,
GtkFileSelection *fs,
gpointer data);
void create_load_file_selection (void);
void create_file_selection (void);
gchar * get_line (gchar *buf,
gint s,
FILE *from,
gint init);
gint load_options (fractalexplorerOBJ *xxx,
FILE *fp);
void explorer_load (void);
#endif
This diff is collapsed.
#ifndef __FRACTALEXPLORER_EVENTS_H__
#define __FRACTALEXPLORER_EVENTS_H__
/* Preview events */
gint preview_button_press_event(GtkWidget * widget, GdkEventButton * event);
gint preview_button_release_event(GtkWidget * widget, GdkEventButton * event);
gint preview_motion_notify_event(GtkWidget * widget, GdkEventButton * event);
gint preview_leave_notify_event(GtkWidget * widget, GdkEventButton * event);
gint preview_enter_notify_event(GtkWidget * widget, GdkEventButton * event);
gint preview_button_press_event (GtkWidget * widget, GdkEventButton * event);
gint preview_button_release_event (GtkWidget * widget, GdkEventButton * event);
gint preview_motion_notify_event (GtkWidget * widget, GdkEventButton * event);
gint preview_leave_notify_event (GtkWidget * widget, GdkEventButton * event);
gint preview_enter_notify_event (GtkWidget * widget, GdkEventButton * event);
#endif
This diff is collapsed.
......@@ -2,9 +2,10 @@
#define __FRACTALEXPLORER_H__
#include "config.h"
#include <glib.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
/**********************************************************************
Magic numbers
......@@ -19,130 +20,141 @@
#define MAXNCOLORS 8192
#define MAXSTRLEN 256
#define SINUS 0
#define COSINUS 1
#define NONE 2
#define FRACTAL_HEADER "Fractal Explorer Plug-In Version 2 - (c) 1997 <cotting@mygale.org>\n"
#define fractalexplorer_HEADER "Fractal Explorer Plug-In Version 2 - (c) 1997 <cotting@mygale.org>\n"
enum
{
SINUS,
COSINUS,
NONE
};
enum
{
TYPE_MANDELBROT,
TYPE_JULIA,
TYPE_BARNSLEY_1,
TYPE_BARNSLEY_2,
TYPE_BARNSLEY_3,
TYPE_SPIDER,
TYPE_MAN_O_WAR,
TYPE_LAMBDA,
TYPE_SIERPINSKI,
NUM_TYPES
};
/**********************************************************************
Types
*********************************************************************/
typedef struct {
gint fractaltype;
gdouble xmin;
gdouble xmax;
gdouble ymin;
gdouble ymax;
gdouble iter;
gdouble cx;
gdouble cy;
gint colormode;
gdouble redstretch;
gdouble greenstretch;
gdouble bluestretch;
gint redmode;
gint greenmode;
gint bluemode;
gint redinvert;
gint greeninvert;
gint blueinvert;
gint alwayspreview;
gint language;
gint ncolors;
gint useloglog;
typedef struct
{
gint fractaltype;
gdouble xmin;
gdouble xmax;
gdouble ymin;
gdouble ymax;
gdouble iter;
gdouble cx;
gdouble cy;
gint colormode;
gdouble redstretch;
gdouble greenstretch;
gdouble bluestretch;
gint redmode;
gint greenmode;
gint bluemode;
gint redinvert;
gint greeninvert;
gint blueinvert;
gint alwayspreview;
gint ncolors;
gint useloglog;
} explorer_vals_t;
typedef struct {
GtkWidget *preview;
guchar *wimage;
gint run;
typedef struct
{
GtkWidget *preview;
guchar *wimage;
gint run;
} explorer_interface_t;
typedef int colorvalue[3];
typedef gint colorvalue[3];
typedef colorvalue clrmap[MAXNCOLORS];
typedef colorvalue clrmap[MAXNCOLORS];