Commit ae73a6d4 authored by David Odin's avatar David Odin
Browse files

plug-ins/gfig/gfig-dialog.[ch] plug-ins/gfig/gfig-poly.[ch]

* plug-ins/gfig/gfig-dialog.[ch]
* plug-ins/gfig/gfig-poly.[ch]
* plug-ins/gfig/gfig-spiral.[ch]
* plug-ins/gfig/gfig-star.[ch]
* plug-ins/gfig/gfig.h: first step of moving all the hidden popup
  dialogs for the tool options in a GtkNotebook showing the options
  within one page for each tool.
parent df38e3d1
2004-10-27 DindinX <dindinx@gimp.org>
* plug-ins/gfig/gfig-dialog.[ch]
* plug-ins/gfig/gfig-poly.[ch]
* plug-ins/gfig/gfig-spiral.[ch]
* plug-ins/gfig/gfig-star.[ch]
* plug-ins/gfig/gfig.h: first step of moving all the hidden popup
dialogs for the tool options in a GtkNotebook showing the options
within one page for each tool.
2004-10-27 Sven Neumann <sven@gimp.org>
 
* tools/pdbgen/enumcode.pl: fixed loop control in
......
......@@ -389,12 +389,8 @@ gfig_dialog (void)
TRUE, TRUE, 0);
/* Add buttons beside the preview frame */
vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (vbox),
draw_buttons (top_level_dlg), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_hbox), draw_buttons (top_level_dlg),
FALSE, FALSE, 0);
/* Preview itself */
gtk_box_pack_start (GTK_BOX (main_hbox), make_preview (), FALSE, FALSE, 0);
......@@ -411,7 +407,7 @@ gfig_dialog (void)
gtk_widget_show (vbox);
/* foreground color button in Style frame*/
gfig_context->fg_color = (GimpRGB*)g_malloc (sizeof (GimpRGB));
gfig_context->fg_color = g_new (GimpRGB, 1);
gfig_context->fg_color_button = gimp_color_button_new ("Foreground",
SEL_BUTTON_WIDTH,
SEL_BUTTON_HEIGHT,
......@@ -828,6 +824,32 @@ create_save_file_chooser (GFigObj *obj,
gtk_window_present (GTK_WINDOW (window));
}
void
tool_option_page_update (GtkWidget *button,
GtkWidget *notebook)
{
gint page = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "page"));
gtk_notebook_set_page (GTK_NOTEBOOK (notebook), page);
}
static void
tool_option_no_option (GtkWidget *notebook,
GtkWidget *button)
{
GtkWidget *label;
gint page;
label = gtk_label_new (_("This tool has no options"));
gtk_widget_show (label);
page = gtk_notebook_append_page (GTK_NOTEBOOK (notebook), label, NULL);
g_object_set_data (G_OBJECT (button), "page", GINT_TO_POINTER (page));
g_signal_connect (button, "clicked",
G_CALLBACK (tool_option_page_update),
notebook);
}
#define SKIP_ROW if (col != 0) {++row; col = 0;} \
gtk_table_set_row_spacing (GTK_TABLE (table), row, 12); ++row
......@@ -840,6 +862,7 @@ create_save_file_chooser (GFigObj *obj,
static GtkWidget *
draw_buttons (GtkWidget *ww)
{
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *frame;
GtkWidget *image;
......@@ -847,10 +870,15 @@ draw_buttons (GtkWidget *ww)
GtkWidget *table;
gint col, row;
gint ncol;
GtkWidget *notebook;
vbox = gtk_vbox_new (FALSE, 12);
gtk_widget_show (vbox);
/* Create group */
frame = gimp_frame_new ("Toolbox");
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
table = gtk_table_new (9, 4, FALSE);
gtk_container_add (GTK_CONTAINER (frame), table);
......@@ -859,36 +887,45 @@ draw_buttons (GtkWidget *ww)
ncol = 4;
row = col = 0;
/* Tool options notebook */
frame = gimp_frame_new ( _("Tool options"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (frame), notebook);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
gtk_widget_show (notebook);
/* Put buttons in */
button = but_with_pix (GFIG_STOCK_LINE, &group, LINE);
TABLE_APPEND (button, _("Create line"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_CIRCLE, &group, CIRCLE);
TABLE_APPEND (button, _("Create circle"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_ELLIPSE, &group, ELLIPSE);
TABLE_APPEND (button, _("Create ellipse"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_CURVE, &group, ARC);
TABLE_APPEND (button, _("Create arc"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_POLYGON, &group, POLY);
g_signal_connect (button, "button_press_event",
G_CALLBACK (poly_button_press),
NULL);
TABLE_APPEND (button, _("Create reg polygon"));
tool_options_poly (notebook, button);
button = but_with_pix (GFIG_STOCK_STAR, &group, STAR);
g_signal_connect (button, "button_press_event",
G_CALLBACK (star_button_press),
NULL);
TABLE_APPEND (button, _("Create star"));
tool_options_star (notebook, button);
button = but_with_pix (GFIG_STOCK_SPIRAL, &group, SPIRAL);
g_signal_connect (button, "button_press_event",
G_CALLBACK (spiral_button_press),
NULL);
TABLE_APPEND (button, _("Create spiral"));
tool_options_spiral (notebook, button);
button = but_with_pix (GFIG_STOCK_BEZIER, &group, BEZIER);
g_signal_connect (button, "button_press_event",
......@@ -901,18 +938,23 @@ draw_buttons (GtkWidget *ww)
button = but_with_pix (GFIG_STOCK_MOVE_OBJECT, &group, MOVE_OBJ);
TABLE_APPEND (button, _("Move an object"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_MOVE_POINT, &group, MOVE_POINT);
TABLE_APPEND (button, _("Move a single point"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_COPY_OBJECT, &group, COPY_OBJ);
TABLE_APPEND (button, _("Copy an object"));
tool_option_no_option (notebook, button);
button = but_with_pix (GFIG_STOCK_DELETE_OBJECT, &group, DEL_OBJ);
TABLE_APPEND (button, _("Delete an object"));
tool_option_no_option (notebook, button);
button = but_with_pix (GIMP_STOCK_TOOL_RECT_SELECT, &group, SELECT_OBJ);
TABLE_APPEND (button, _("Select an object"));
tool_option_no_option (notebook, button);
SKIP_ROW;
......@@ -982,9 +1024,7 @@ draw_buttons (GtkWidget *ww)
GINT_TO_POINTER (OBJ_SELECT_EQ));
TABLE_APPEND (button, _("Show all objects"));
gtk_widget_show (frame);
return frame;
return vbox;
}
static void
......@@ -1591,7 +1631,7 @@ but_with_pix (const gchar *stock_id,
G_CALLBACK (toggle_obj_type),
GINT_TO_POINTER (baction));
gtk_widget_show (button);
*group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
return button;
......@@ -1600,39 +1640,24 @@ but_with_pix (const gchar *stock_id,
/* Special case for now - options on poly/star/spiral button */
void
num_sides_dialog (gchar *d_title,
GtkWidget *
num_sides_widget (gchar *d_title,
gint *num_sides,
gint *which_way,
gint adj_min,
gint adj_max)
{
GtkWidget *window;
GtkWidget *table;
GtkObject *size_data;
window = gimp_dialog_new (d_title, "gfig",
NULL, 0,
gimp_standard_help_func, HELP_ID,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
g_signal_connect (window, "response",
G_CALLBACK (gtk_widget_destroy),
NULL);
table = gtk_table_new (which_way ? 2 : 1, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), table,
FALSE, FALSE, 0);
gtk_widget_show (table);
size_data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Number of Sides/Points/Turns:"), 0, 0,
_("Sides:"), 0, 0,
*num_sides, adj_min, adj_max, 1, 10, 0,
TRUE, 0, 0,
NULL, NULL);
......@@ -1656,8 +1681,7 @@ num_sides_dialog (gchar *d_title,
_("Orientation:"), 0.0, 0.5,
combo, 1, FALSE);
}
gtk_widget_show (window);
return table;
}
static gint
......
......@@ -37,4 +37,7 @@ void update_options (GFigObj *old_obj);
gint undo_water_mark; /* Last slot filled in -1 = no undo */
DAllObjs *undo_table[MAX_UNDO];
void tool_option_page_update (GtkWidget *button,
GtkWidget *notebook);
#endif /* __GFIG_DIALOG_H__ */
......@@ -37,41 +37,47 @@
#include "gfig.h"
#include "gfig-dobject.h"
#include "gfig-line.h"
#include "gfig-dialog.h"
#include "libgimp/stdplugins-intl.h"
static gint poly_num_sides = 3; /* Default to three sided object */
static void d_draw_poly (Dobject *obj);
static Dobject * d_copy_poly (Dobject * obj);
static void d_draw_poly (Dobject *obj);
static Dobject * d_copy_poly (Dobject * obj);
gboolean
poly_button_press (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
void
tool_options_poly (GtkWidget *notebook,
GtkWidget *button)
{
if ((event->type == GDK_2BUTTON_PRESS) &&
(event->button == 1))
num_sides_dialog (_("Regular Polygon Number of Sides"),
&poly_num_sides, NULL, 3, 200);
return FALSE;
GtkWidget *sides;
gint page;
sides = num_sides_widget (_("Regular Polygon Number of Sides"),
&poly_num_sides, NULL, 3, 200);
page = gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sides, NULL);
g_object_set_data (G_OBJECT (button), "page", GINT_TO_POINTER (page));
g_signal_connect (button, "clicked",
G_CALLBACK (tool_option_page_update),
notebook);
}
static void
d_draw_poly (Dobject *obj)
{
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint start_pnt;
GdkPoint first_pnt;
gboolean do_line = FALSE;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint start_pnt;
GdkPoint first_pnt;
gboolean do_line = FALSE;
center_pnt = obj->points;
......@@ -146,20 +152,20 @@ d_paint_poly (Dobject *obj)
{
/* first point center */
/* Next point is radius */
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
g_assert (obj != NULL);
......@@ -253,18 +259,18 @@ d_poly2lines (Dobject *obj)
{
/* first point center */
/* Next point is radius */
gint seg_count = 0;
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
gint seg_count = 0;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
g_assert (obj != NULL);
......@@ -345,20 +351,20 @@ d_star2lines (Dobject *obj)
{
/* first point center */
/* Next point is radius */
gint seg_count = 0;
DobjPoints * center_pnt;
DobjPoints * outer_radius_pnt;
DobjPoints * inner_radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble outer_radius;
gdouble inner_radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
gint seg_count = 0;
DobjPoints *center_pnt;
DobjPoints *outer_radius_pnt;
DobjPoints *inner_radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble outer_radius;
gdouble inner_radius;
gdouble offset_angle;
gint loop;
GdkPoint first_pnt, last_pnt;
gboolean first = TRUE;
g_assert (obj != NULL);
......@@ -493,8 +499,9 @@ d_poly_object_class_init ()
void
d_update_poly (GdkPoint *pnt)
{
DobjPoints *center_pnt, *edge_pnt;
gint saved_cnt_pnt = selvals.opts.showcontrol;
DobjPoints *center_pnt;
DobjPoints *edge_pnt;
gint saved_cnt_pnt = selvals.opts.showcontrol;
/* Undraw last one then draw new one */
center_pnt = obj_creating->points;
......
......@@ -26,18 +26,19 @@
#ifndef __GFIG_POLY_H__
#define __GFIG_POLY_H__
gboolean poly_button_press (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
void tool_options_poly (GtkWidget *notebook,
GtkWidget *button);
void d_update_poly (GdkPoint *pnt);
void d_poly_start (GdkPoint *pnt, gint shift_down);
void d_poly_end (GdkPoint *pnt, gint shift_down);
void d_update_poly (GdkPoint *pnt);
void d_poly_start (GdkPoint *pnt,
gint shift_down);
void d_poly_end (GdkPoint *pnt,
gint shift_down);
void d_paint_poly (Dobject *obj);
void d_paint_poly (Dobject *obj);
void d_poly2lines (Dobject *obj);
void d_star2lines (Dobject *obj);
void d_poly_object_class_init (void);
void d_poly2lines (Dobject *obj);
void d_star2lines (Dobject *obj);
void d_poly_object_class_init (void);
#endif /* __GFIG_POLY_H__ */
......@@ -37,45 +37,52 @@
#include "gfig.h"
#include "gfig-dobject.h"
#include "gfig-dialog.h"
#include "libgimp/stdplugins-intl.h"
static void d_draw_spiral (Dobject *obj);
static void d_paint_spiral (Dobject *obj);
static Dobject *d_copy_spiral (Dobject * obj);
static void d_draw_spiral (Dobject *obj);
static void d_paint_spiral (Dobject *obj);
static Dobject *d_copy_spiral (Dobject * obj);
static gint spiral_num_turns = 4; /* Default to 4 turns */
static gint spiral_toggle = 0; /* 0 = clockwise -1 = anti-clockwise */
gint
spiral_button_press (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
void
tool_options_spiral (GtkWidget *notebook,
GtkWidget *button)
{
if ((event->type == GDK_2BUTTON_PRESS) &&
(event->button == 1))
num_sides_dialog (_("Spiral Number of Turns"),
&spiral_num_turns, &spiral_toggle, 1, 20);
return FALSE;
GtkWidget *sides;
gint page;
sides = num_sides_widget (_("Spiral Number of Turns"),
&spiral_num_turns, &spiral_toggle, 1, 20);
page = gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sides, NULL);
g_object_set_data (G_OBJECT (button), "page", GINT_TO_POINTER (page));
g_signal_connect (button, "clicked",
G_CALLBACK (tool_option_page_update),
notebook);
}
static void
d_draw_spiral (Dobject *obj)
{
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gdouble sp_cons;
gint loop;
GdkPoint start_pnt;
GdkPoint first_pnt;
gboolean do_line = FALSE;
gint clock_wise = 1;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gdouble sp_cons;
gint loop;
GdkPoint start_pnt;
GdkPoint first_pnt;
gboolean do_line = FALSE;
gint clock_wise = 1;
center_pnt = obj->points;
......@@ -106,24 +113,24 @@ d_draw_spiral (Dobject *obj)
shift_x = radius_pnt->pnt.x - center_pnt->pnt.x;
shift_y = radius_pnt->pnt.y - center_pnt->pnt.y;
radius = sqrt ((shift_x*shift_x) + (shift_y*shift_y));
radius = sqrt ((shift_x * shift_x) + (shift_y * shift_y));
offset_angle = atan2 (shift_y, shift_x);
clock_wise = obj->type_data / abs (obj->type_data);
if (offset_angle < 0)
offset_angle += 2*G_PI;
offset_angle += 2.0 * G_PI;
sp_cons = radius/(obj->type_data * 2 * G_PI + offset_angle);
/* Lines */
ang_grid = 2.0*G_PI/(gdouble)180;
ang_grid = 2.0 * G_PI / 180.0;
for (loop = 0 ; loop <= abs (obj->type_data * 180) +
clock_wise * (gint)RINT (offset_angle/ang_grid) ; loop++)
{
gdouble lx, ly;
gdouble lx, ly;
GdkPoint calc_pnt;
ang_loop = (gdouble)loop * ang_grid;
......@@ -156,21 +163,21 @@ d_paint_spiral (Dobject *obj)
{
/* first point center */
/* Next point is radius */
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints * center_pnt;
DobjPoints * radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gdouble sp_cons;
gint loop;
GdkPoint last_pnt;
gint clock_wise = 1;
gdouble *line_pnts;
gint seg_count = 0;
gint i = 0;
DobjPoints *center_pnt;
DobjPoints *radius_pnt;
gint16 shift_x;
gint16 shift_y;
gdouble ang_grid;
gdouble ang_loop;
gdouble radius;
gdouble offset_angle;
gdouble sp_cons;
gint loop;
GdkPoint last_pnt;
gint clock_wise = 1;
g_assert (obj != NULL);
......@@ -187,28 +194,27 @@ d_paint_spiral (Dobject *obj)
shift_x = radius_pnt->pnt.x - center_pnt->pnt.x;
shift_y = radius_pnt->pnt.y - center_pnt->pnt.y;
radius = sqrt ((shift_x*shift_x) + (shift_y*shift_y));
radius = sqrt ((shift_x * shift_x) + (shift_y * shift_y));
clock_wise = obj->type_data / abs (obj->type_data);
offset_angle = atan2 (shift_y, shift_x);
if (offset_angle < 0)
offset_angle += 2*G_PI;