app/brush_select.[ch] made the previews change their size in sync with
1999-04-23 Michael Natterer <mitschel@cs.tu-berlin.de> * app/brush_select.[ch] * app/pattern_select.[ch]: made the previews change their size in sync with resizing the dialog. The previews auto-resize with their parent frame now. Connect to the preview's "size_allocate" signal, not to the frame's, don't "signal_connect_after". Get the size of the preview from it's allocation and not from it's requisition. There's no need to remember width, height and the frame in the structures anymore, so I kicked them out. Tweaked the code to look more similar.
This commit is contained in:

committed by
Michael Natterer

parent
7499e231b3
commit
f3c85b0175
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
1999-04-23 Michael Natterer <mitschel@cs.tu-berlin.de>
|
||||
|
||||
* app/brush_select.[ch]
|
||||
* app/pattern_select.[ch]: made the previews change their size in
|
||||
sync with resizing the dialog. The previews auto-resize with their
|
||||
parent frame now. Connect to the preview's "size_allocate" signal,
|
||||
not to the frame's, don't "signal_connect_after". Get the size of
|
||||
the preview from it's allocation and not from it's requisition.
|
||||
There's no need to remember width, height and the frame in the
|
||||
structures anymore, so I kicked them out. Tweaked the code to look
|
||||
more similar.
|
||||
|
||||
Fri Apr 23 08:31:50 1999 ape@lrdpf.spacetec.no (Asbjorn Pettersen)
|
||||
|
||||
* app/gimpbrushlist.c: <sys/types.h> before <sys/stat.h>
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -26,7 +25,6 @@
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "brush_edit.h"
|
||||
#include "brush_select.h"
|
||||
#include "brush_select.h"
|
||||
#include "colormaps.h"
|
||||
#include "disp_callbacks.h"
|
||||
#include "errors.h"
|
||||
@ -92,9 +90,6 @@ static void spacing_scale_update (GtkAdjustment *, gpointer);
|
||||
|
||||
/* local variables */
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
@ -104,8 +99,11 @@ static GSList *active_dialogs = NULL;
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
||||
/* If title is null then it is the main brush dialog */
|
||||
|
||||
/* If title == NULL then it is the main brush dialog */
|
||||
BrushSelectP
|
||||
brush_select_new (gchar *title,
|
||||
/* These are the required initial vals
|
||||
@ -119,6 +117,7 @@ brush_select_new (gchar *title,
|
||||
BrushSelectP bsp;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *sbar;
|
||||
GtkWidget *label;
|
||||
GtkWidget *sep;
|
||||
@ -172,7 +171,7 @@ brush_select_new (gchar *title,
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), vbox);
|
||||
|
||||
/* handle the wm close signal */
|
||||
/* Handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (bsp->shell), "delete_event",
|
||||
GTK_SIGNAL_FUNC (brush_select_delete_callback),
|
||||
bsp);
|
||||
@ -189,9 +188,9 @@ brush_select_new (gchar *title,
|
||||
bsp->brush_selection_box = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (bsp->left_box), bsp->brush_selection_box);
|
||||
|
||||
bsp->frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (bsp->frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), bsp->frame,
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), frame,
|
||||
TRUE, TRUE, 0);
|
||||
bsp->sbar_data = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT(bsp), 1, 1, MAX_WIN_HEIGHT(bsp)));
|
||||
sbar = gtk_vscrollbar_new (bsp->sbar_data);
|
||||
@ -201,33 +200,33 @@ brush_select_new (gchar *title,
|
||||
|
||||
|
||||
/* Create the brush preview window and the underlying image */
|
||||
/* Get the maximum brush extents */
|
||||
|
||||
/* Get the maximum brush extents */
|
||||
bsp->cell_width = STD_CELL_WIDTH;
|
||||
bsp->cell_height = STD_CELL_HEIGHT;
|
||||
|
||||
bsp->width = MAX_WIN_WIDTH(bsp);
|
||||
bsp->height = MAX_WIN_HEIGHT(bsp);
|
||||
|
||||
bsp->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview), bsp->width, bsp->height);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview),
|
||||
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
|
||||
gtk_preview_set_expand (GTK_PREVIEW (bsp->preview), TRUE);
|
||||
gtk_widget_set_events (bsp->preview, BRUSH_EVENT_MASK);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (bsp->preview), "event",
|
||||
(GtkSignalFunc) brush_select_events,
|
||||
bsp);
|
||||
gtk_signal_connect_after (GTK_OBJECT(bsp->frame), "size_allocate",
|
||||
gtk_signal_connect (GTK_OBJECT(bsp->preview), "size_allocate",
|
||||
(GtkSignalFunc) brush_select_resize,
|
||||
bsp);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (bsp->frame), bsp->preview);
|
||||
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
|
||||
gtk_widget_show (bsp->preview);
|
||||
|
||||
gtk_widget_show (sbar);
|
||||
gtk_widget_show (bsp->frame);
|
||||
gtk_widget_show (frame);
|
||||
gtk_widget_show (bsp->brush_selection_box);
|
||||
gtk_widget_show (bsp->left_box);
|
||||
|
||||
/* options box */
|
||||
/* Options box */
|
||||
bsp->options_box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), bsp->options_box, FALSE, FALSE, 0);
|
||||
|
||||
@ -253,7 +252,7 @@ brush_select_new (gchar *title,
|
||||
gtk_box_pack_start (GTK_BOX (bsp->right_box), bsp->paint_options_box,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* a separator before the paint options */
|
||||
/* A separator before the paint options */
|
||||
sep = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
|
||||
gtk_widget_show (sep);
|
||||
@ -376,7 +375,8 @@ brush_select_new (gchar *title,
|
||||
if(!title)
|
||||
{
|
||||
/* add callbacks to keep the display area current */
|
||||
gimp_list_foreach(GIMP_LIST(brush_list), (GFunc)connect_signals_to_brush,
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) connect_signals_to_brush,
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
(GtkSignalFunc) brush_added_callback,
|
||||
@ -498,7 +498,8 @@ brush_select_free (BrushSelectP bsp)
|
||||
}
|
||||
|
||||
void
|
||||
brush_change_callbacks (BrushSelectP bsp, gint closing)
|
||||
brush_change_callbacks (BrushSelectP bsp,
|
||||
gint closing)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
@ -580,7 +581,8 @@ brush_select_show_paint_options (BrushSelectP bsp,
|
||||
}
|
||||
|
||||
static void
|
||||
brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
|
||||
brush_select_brush_changed (BrushSelectP bsp,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
/* TODO: be smarter here and only update the part of the preview
|
||||
* that has changed */
|
||||
@ -592,14 +594,16 @@ brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_select_brush_dirty_callback(GimpBrushP brush, BrushSelectP bsp)
|
||||
brush_select_brush_dirty_callback (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
brush_select_brush_changed (bsp, brush);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
connect_signals_to_brush (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
@ -607,14 +611,16 @@ connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_signals_from_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
disconnect_signals_from_brush (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
if (!GTK_OBJECT_DESTROYED (brush))
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
brush_added_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
brush_added_callback (GimpBrushList *list,
|
||||
GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
connect_signals_to_brush (brush, bsp);
|
||||
@ -623,7 +629,8 @@ brush_added_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
}
|
||||
|
||||
static void
|
||||
brush_removed_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
brush_removed_callback (GimpBrushList *list,
|
||||
GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
disconnect_signals_from_brush (brush, bsp);
|
||||
@ -675,7 +682,8 @@ brush_popup_open (BrushSelectP bsp,
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview), brush->mask->width, brush->mask->height);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview),
|
||||
brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (bsp->brush_popup, x, y);
|
||||
|
||||
@ -691,7 +699,8 @@ brush_popup_open (BrushSelectP bsp,
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)buf,
|
||||
0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
@ -737,8 +746,8 @@ display_brush (BrushSelectP bsp,
|
||||
offset_y = row * bsp->cell_height + ((bsp->cell_height - height) >> 1)
|
||||
- bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y, 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf) + (ystart - offset_y) * brush_buf->width;
|
||||
@ -770,21 +779,26 @@ display_setup (BrushSelectP bsp)
|
||||
unsigned char * buf;
|
||||
int i;
|
||||
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * bsp->preview->requisition.width);
|
||||
buf =
|
||||
(unsigned char *) g_malloc (sizeof (char) * bsp->preview->allocation.width);
|
||||
|
||||
/* Set the buffer to white */
|
||||
memset (buf, 255, bsp->preview->requisition.width);
|
||||
memset (buf, 255, bsp->preview->allocation.width);
|
||||
|
||||
/* Set the image buffer to white */
|
||||
for (i = 0; i < bsp->preview->requisition.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i, bsp->preview->requisition.width);
|
||||
for (i = 0; i < bsp->preview->allocation.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i,
|
||||
bsp->preview->allocation.width);
|
||||
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
|
||||
static int brush_counter = 0;
|
||||
static void do_display_brush (GimpBrush *brush, BrushSelectP bsp)
|
||||
|
||||
static void
|
||||
do_display_brush (GimpBrush *brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
display_brush (bsp, brush, brush_counter % (bsp->NUM_BRUSH_COLUMNS),
|
||||
brush_counter / (bsp->NUM_BRUSH_COLUMNS));
|
||||
@ -831,8 +845,8 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
offset_x = bsp->old_col * bsp->cell_width;
|
||||
offset_y = bsp->old_row * bsp->cell_height - bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* set the buf to white */
|
||||
memset (buf, 255, bsp->cell_width);
|
||||
@ -840,11 +854,14 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, bsp->cell_width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, bsp->cell_width);
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x + bsp->cell_width - 1, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x + bsp->cell_width - 1, i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,8 +879,8 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
offset_x = col * bsp->cell_width;
|
||||
offset_y = row * bsp->cell_height - bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* set the buf to black */
|
||||
memset (buf, 0, bsp->cell_width);
|
||||
@ -871,11 +888,14 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, bsp->cell_width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
||||
buf, offset_x, i, bsp->cell_width);
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x + bsp->cell_width - 1, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x + bsp->cell_width - 1, i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,13 +946,11 @@ brush_select_resize (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
bsp->NUM_BRUSH_COLUMNS = (gint)((widget->allocation.width - 4) / STD_CELL_WIDTH);
|
||||
bsp->NUM_BRUSH_ROWS = (gimp_brush_list_length(brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
||||
bsp->width = widget->allocation.width - 4;
|
||||
bsp->height = widget->allocation.height - 4;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview), bsp->width, bsp->height);
|
||||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) ((widget->allocation.width) / STD_CELL_WIDTH);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_brush_list_length (brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
/* recalculate scrollbar extents */
|
||||
preview_calc_scrollbar (bsp);
|
||||
@ -1073,7 +1091,9 @@ brush_select_events (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gint
|
||||
edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
edit_brush_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
if (GIMP_IS_BRUSH_GENERATED (get_active_brush ()))
|
||||
{
|
||||
@ -1100,7 +1120,9 @@ edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
}
|
||||
|
||||
static gint
|
||||
new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
new_brush_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
@ -1114,7 +1136,9 @@ new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_select_delete_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
brush_select_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
brush_select_close_callback (w, data);
|
||||
|
||||
@ -1281,7 +1305,6 @@ brushes_check_dialogs()
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
|
||||
while (list)
|
||||
{
|
||||
bsp = (BrushSelectP) list->data;
|
||||
|
@ -34,15 +34,16 @@ struct _BrushSelect {
|
||||
GtkWidget *brush_selection_box;
|
||||
GtkWidget *paint_options_box;
|
||||
|
||||
GtkWidget *frame;
|
||||
/* The preview and it's vscale data */
|
||||
GtkWidget *preview;
|
||||
GtkAdjustment *sbar_data;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *brush_name;
|
||||
GtkWidget *brush_size;
|
||||
GtkWidget *options_box;
|
||||
|
||||
GtkAdjustment *opacity_data;
|
||||
GtkAdjustment *spacing_data;
|
||||
GtkAdjustment *sbar_data;
|
||||
GtkWidget *edit_button;
|
||||
GtkWidget *option_menu;
|
||||
|
||||
@ -62,7 +63,6 @@ struct _BrushSelect {
|
||||
gint paint_mode;
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
int width, height;
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
int redraw;
|
||||
|
@ -15,7 +15,6 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -26,7 +25,6 @@
|
||||
#include "gimpbrushgenerated.h"
|
||||
#include "brush_edit.h"
|
||||
#include "brush_select.h"
|
||||
#include "brush_select.h"
|
||||
#include "colormaps.h"
|
||||
#include "disp_callbacks.h"
|
||||
#include "errors.h"
|
||||
@ -92,9 +90,6 @@ static void spacing_scale_update (GtkAdjustment *, gpointer);
|
||||
|
||||
/* local variables */
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
@ -104,8 +99,11 @@ static GSList *active_dialogs = NULL;
|
||||
/* The main brush dialog */
|
||||
extern BrushSelectP brush_select_dialog;
|
||||
|
||||
/* Brush editor dialog (main brush dialog only) */
|
||||
static BrushEditGeneratedWindow *brush_edit_generated_dialog;
|
||||
|
||||
/* If title is null then it is the main brush dialog */
|
||||
|
||||
/* If title == NULL then it is the main brush dialog */
|
||||
BrushSelectP
|
||||
brush_select_new (gchar *title,
|
||||
/* These are the required initial vals
|
||||
@ -119,6 +117,7 @@ brush_select_new (gchar *title,
|
||||
BrushSelectP bsp;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *sbar;
|
||||
GtkWidget *label;
|
||||
GtkWidget *sep;
|
||||
@ -172,7 +171,7 @@ brush_select_new (gchar *title,
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (bsp->shell)->vbox), vbox);
|
||||
|
||||
/* handle the wm close signal */
|
||||
/* Handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (bsp->shell), "delete_event",
|
||||
GTK_SIGNAL_FUNC (brush_select_delete_callback),
|
||||
bsp);
|
||||
@ -189,9 +188,9 @@ brush_select_new (gchar *title,
|
||||
bsp->brush_selection_box = gtk_hbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (bsp->left_box), bsp->brush_selection_box);
|
||||
|
||||
bsp->frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (bsp->frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), bsp->frame,
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (bsp->brush_selection_box), frame,
|
||||
TRUE, TRUE, 0);
|
||||
bsp->sbar_data = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT(bsp), 1, 1, MAX_WIN_HEIGHT(bsp)));
|
||||
sbar = gtk_vscrollbar_new (bsp->sbar_data);
|
||||
@ -201,33 +200,33 @@ brush_select_new (gchar *title,
|
||||
|
||||
|
||||
/* Create the brush preview window and the underlying image */
|
||||
/* Get the maximum brush extents */
|
||||
|
||||
/* Get the maximum brush extents */
|
||||
bsp->cell_width = STD_CELL_WIDTH;
|
||||
bsp->cell_height = STD_CELL_HEIGHT;
|
||||
|
||||
bsp->width = MAX_WIN_WIDTH(bsp);
|
||||
bsp->height = MAX_WIN_HEIGHT(bsp);
|
||||
|
||||
bsp->preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview), bsp->width, bsp->height);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview),
|
||||
MAX_WIN_WIDTH (bsp), MAX_WIN_HEIGHT (bsp));
|
||||
gtk_preview_set_expand (GTK_PREVIEW (bsp->preview), TRUE);
|
||||
gtk_widget_set_events (bsp->preview, BRUSH_EVENT_MASK);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (bsp->preview), "event",
|
||||
(GtkSignalFunc) brush_select_events,
|
||||
bsp);
|
||||
gtk_signal_connect_after (GTK_OBJECT(bsp->frame), "size_allocate",
|
||||
gtk_signal_connect (GTK_OBJECT(bsp->preview), "size_allocate",
|
||||
(GtkSignalFunc) brush_select_resize,
|
||||
bsp);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (bsp->frame), bsp->preview);
|
||||
gtk_container_add (GTK_CONTAINER (frame), bsp->preview);
|
||||
gtk_widget_show (bsp->preview);
|
||||
|
||||
gtk_widget_show (sbar);
|
||||
gtk_widget_show (bsp->frame);
|
||||
gtk_widget_show (frame);
|
||||
gtk_widget_show (bsp->brush_selection_box);
|
||||
gtk_widget_show (bsp->left_box);
|
||||
|
||||
/* options box */
|
||||
/* Options box */
|
||||
bsp->options_box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), bsp->options_box, FALSE, FALSE, 0);
|
||||
|
||||
@ -253,7 +252,7 @@ brush_select_new (gchar *title,
|
||||
gtk_box_pack_start (GTK_BOX (bsp->right_box), bsp->paint_options_box,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* a separator before the paint options */
|
||||
/* A separator before the paint options */
|
||||
sep = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (bsp->paint_options_box), sep, FALSE, FALSE, 0);
|
||||
gtk_widget_show (sep);
|
||||
@ -376,7 +375,8 @@ brush_select_new (gchar *title,
|
||||
if(!title)
|
||||
{
|
||||
/* add callbacks to keep the display area current */
|
||||
gimp_list_foreach(GIMP_LIST(brush_list), (GFunc)connect_signals_to_brush,
|
||||
gimp_list_foreach (GIMP_LIST (brush_list),
|
||||
(GFunc) connect_signals_to_brush,
|
||||
bsp);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_list), "add",
|
||||
(GtkSignalFunc) brush_added_callback,
|
||||
@ -498,7 +498,8 @@ brush_select_free (BrushSelectP bsp)
|
||||
}
|
||||
|
||||
void
|
||||
brush_change_callbacks (BrushSelectP bsp, gint closing)
|
||||
brush_change_callbacks (BrushSelectP bsp,
|
||||
gint closing)
|
||||
{
|
||||
gchar * name;
|
||||
ProcRecord *prec = NULL;
|
||||
@ -580,7 +581,8 @@ brush_select_show_paint_options (BrushSelectP bsp,
|
||||
}
|
||||
|
||||
static void
|
||||
brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
|
||||
brush_select_brush_changed (BrushSelectP bsp,
|
||||
GimpBrushP brush)
|
||||
{
|
||||
/* TODO: be smarter here and only update the part of the preview
|
||||
* that has changed */
|
||||
@ -592,14 +594,16 @@ brush_select_brush_changed(BrushSelectP bsp, GimpBrushP brush)
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_select_brush_dirty_callback(GimpBrushP brush, BrushSelectP bsp)
|
||||
brush_select_brush_dirty_callback (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
brush_select_brush_changed (bsp, brush);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
connect_signals_to_brush (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
|
||||
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
|
||||
@ -607,14 +611,16 @@ connect_signals_to_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_signals_from_brush(GimpBrushP brush, BrushSelectP bsp)
|
||||
disconnect_signals_from_brush (GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
if (!GTK_OBJECT_DESTROYED (brush))
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), bsp);
|
||||
}
|
||||
|
||||
static void
|
||||
brush_added_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
brush_added_callback (GimpBrushList *list,
|
||||
GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
connect_signals_to_brush (brush, bsp);
|
||||
@ -623,7 +629,8 @@ brush_added_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
}
|
||||
|
||||
static void
|
||||
brush_removed_callback(GimpBrushList *list, GimpBrushP brush,
|
||||
brush_removed_callback (GimpBrushList *list,
|
||||
GimpBrushP brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
disconnect_signals_from_brush (brush, bsp);
|
||||
@ -675,7 +682,8 @@ brush_popup_open (BrushSelectP bsp,
|
||||
y = (y < 0) ? 0 : y;
|
||||
x = (x + brush->mask->width > scr_w) ? scr_w - brush->mask->width : x;
|
||||
y = (y + brush->mask->height > scr_h) ? scr_h - brush->mask->height : y;
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview), brush->mask->width, brush->mask->height);
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->brush_preview),
|
||||
brush->mask->width, brush->mask->height);
|
||||
|
||||
gtk_widget_popup (bsp->brush_popup, x, y);
|
||||
|
||||
@ -691,7 +699,8 @@ brush_popup_open (BrushSelectP bsp,
|
||||
*/
|
||||
for (x = 0; x < brush->mask->width; x++)
|
||||
buf[x] = 255 - src[x];
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)buf, 0, y, brush->mask->width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->brush_preview), (guchar *)buf,
|
||||
0, y, brush->mask->width);
|
||||
src += brush->mask->width;
|
||||
}
|
||||
g_free(buf);
|
||||
@ -737,8 +746,8 @@ display_brush (BrushSelectP bsp,
|
||||
offset_y = row * bsp->cell_height + ((bsp->cell_height - height) >> 1)
|
||||
- bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y, 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf) + (ystart - offset_y) * brush_buf->width;
|
||||
@ -770,21 +779,26 @@ display_setup (BrushSelectP bsp)
|
||||
unsigned char * buf;
|
||||
int i;
|
||||
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * bsp->preview->requisition.width);
|
||||
buf =
|
||||
(unsigned char *) g_malloc (sizeof (char) * bsp->preview->allocation.width);
|
||||
|
||||
/* Set the buffer to white */
|
||||
memset (buf, 255, bsp->preview->requisition.width);
|
||||
memset (buf, 255, bsp->preview->allocation.width);
|
||||
|
||||
/* Set the image buffer to white */
|
||||
for (i = 0; i < bsp->preview->requisition.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i, bsp->preview->requisition.width);
|
||||
for (i = 0; i < bsp->preview->allocation.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, 0, i,
|
||||
bsp->preview->allocation.width);
|
||||
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
|
||||
static int brush_counter = 0;
|
||||
static void do_display_brush (GimpBrush *brush, BrushSelectP bsp)
|
||||
|
||||
static void
|
||||
do_display_brush (GimpBrush *brush,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
display_brush (bsp, brush, brush_counter % (bsp->NUM_BRUSH_COLUMNS),
|
||||
brush_counter / (bsp->NUM_BRUSH_COLUMNS));
|
||||
@ -831,8 +845,8 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
offset_x = bsp->old_col * bsp->cell_width;
|
||||
offset_y = bsp->old_row * bsp->cell_height - bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* set the buf to white */
|
||||
memset (buf, 255, bsp->cell_width);
|
||||
@ -840,11 +854,14 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, bsp->cell_width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, bsp->cell_width);
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x + bsp->cell_width - 1, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x + bsp->cell_width - 1, i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,8 +879,8 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
offset_x = col * bsp->cell_width;
|
||||
offset_y = row * bsp->cell_height - bsp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, bsp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + bsp->cell_height, 0, bsp->preview->allocation.height);
|
||||
|
||||
/* set the buf to black */
|
||||
memset (buf, 0, bsp->cell_width);
|
||||
@ -871,11 +888,14 @@ brush_select_show_selected (BrushSelectP bsp,
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
if (i == offset_y || i == (offset_y + bsp->cell_height - 1))
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, bsp->cell_width);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview),
|
||||
buf, offset_x, i, bsp->cell_width);
|
||||
else
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf, offset_x + bsp->cell_width - 1, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x, i, 1);
|
||||
gtk_preview_draw_row (GTK_PREVIEW (bsp->preview), buf,
|
||||
offset_x + bsp->cell_width - 1, i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,13 +946,11 @@ brush_select_resize (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
BrushSelectP bsp)
|
||||
{
|
||||
bsp->NUM_BRUSH_COLUMNS = (gint)((widget->allocation.width - 4) / STD_CELL_WIDTH);
|
||||
bsp->NUM_BRUSH_ROWS = (gimp_brush_list_length(brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) / bsp->NUM_BRUSH_COLUMNS;
|
||||
|
||||
bsp->width = widget->allocation.width - 4;
|
||||
bsp->height = widget->allocation.height - 4;
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (bsp->preview), bsp->width, bsp->height);
|
||||
bsp->NUM_BRUSH_COLUMNS =
|
||||
(gint) ((widget->allocation.width) / STD_CELL_WIDTH);
|
||||
bsp->NUM_BRUSH_ROWS =
|
||||
(gint) ((gimp_brush_list_length (brush_list) + bsp->NUM_BRUSH_COLUMNS - 1) /
|
||||
bsp->NUM_BRUSH_COLUMNS);
|
||||
|
||||
/* recalculate scrollbar extents */
|
||||
preview_calc_scrollbar (bsp);
|
||||
@ -1073,7 +1091,9 @@ brush_select_events (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gint
|
||||
edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
edit_brush_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
if (GIMP_IS_BRUSH_GENERATED (get_active_brush ()))
|
||||
{
|
||||
@ -1100,7 +1120,9 @@ edit_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
}
|
||||
|
||||
static gint
|
||||
new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
new_brush_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
GimpBrushGenerated *brush;
|
||||
brush = gimp_brush_generated_new (10, .5, 0.0, 1.0);
|
||||
@ -1114,7 +1136,9 @@ new_brush_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
}
|
||||
|
||||
static gint
|
||||
brush_select_delete_callback (GtkWidget *w, GdkEvent *e, gpointer data)
|
||||
brush_select_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer data)
|
||||
{
|
||||
brush_select_close_callback (w, data);
|
||||
|
||||
@ -1281,7 +1305,6 @@ brushes_check_dialogs()
|
||||
|
||||
list = active_dialogs;
|
||||
|
||||
|
||||
while (list)
|
||||
{
|
||||
bsp = (BrushSelectP) list->data;
|
||||
|
@ -34,15 +34,16 @@ struct _BrushSelect {
|
||||
GtkWidget *brush_selection_box;
|
||||
GtkWidget *paint_options_box;
|
||||
|
||||
GtkWidget *frame;
|
||||
/* The preview and it's vscale data */
|
||||
GtkWidget *preview;
|
||||
GtkAdjustment *sbar_data;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *brush_name;
|
||||
GtkWidget *brush_size;
|
||||
GtkWidget *options_box;
|
||||
|
||||
GtkAdjustment *opacity_data;
|
||||
GtkAdjustment *spacing_data;
|
||||
GtkAdjustment *sbar_data;
|
||||
GtkWidget *edit_button;
|
||||
GtkWidget *option_menu;
|
||||
|
||||
@ -62,7 +63,6 @@ struct _BrushSelect {
|
||||
gint paint_mode;
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
int width, height;
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
int redraw;
|
||||
|
@ -34,11 +34,6 @@
|
||||
#define MIN_CELL_SIZE 32
|
||||
#define MAX_CELL_SIZE 45
|
||||
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
static GSList *active_dialogs = NULL; /* List of active dialogs */
|
||||
|
||||
/*
|
||||
#define STD_PATTERN_COLUMNS 6
|
||||
#define STD_PATTERN_ROWS 5
|
||||
@ -70,19 +65,23 @@ static gint pattern_select_events (GtkWidget *, GdkEvent *, PatternSe
|
||||
static gint pattern_select_resize (GtkWidget *, GdkEvent *, PatternSelectP);
|
||||
static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
|
||||
|
||||
/* the action area structure */
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("Refresh"), pattern_select_refresh_callback, NULL, NULL },
|
||||
{ N_("Close"), pattern_select_close_callback, NULL, NULL }
|
||||
};
|
||||
|
||||
/* local variables */
|
||||
gint NUM_PATTERN_COLUMNS = 6;
|
||||
gint NUM_PATTERN_ROWS = 5;
|
||||
gint STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main pattern dialog */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
|
||||
|
||||
/* If title == NULL then it is the main pattern dialog */
|
||||
PatternSelectP
|
||||
pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern)
|
||||
@ -91,9 +90,16 @@ pattern_select_new (gchar * title,
|
||||
GPatternP active = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *sbar;
|
||||
GtkWidget *label_box;
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("Refresh"), pattern_select_refresh_callback, NULL, NULL },
|
||||
{ N_("Close"), pattern_select_close_callback, NULL, NULL }
|
||||
};
|
||||
|
||||
psp = g_malloc (sizeof (_PatternSelect));
|
||||
psp->preview = NULL;
|
||||
psp->old_col = psp->old_row = 0;
|
||||
@ -103,14 +109,15 @@ pattern_select_new (gchar * title,
|
||||
psp->NUM_PATTERN_ROWS = 5;
|
||||
psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
|
||||
/* The shell and main vbox */
|
||||
psp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp");
|
||||
|
||||
if(!title)
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (psp->shell), _("Pattern Selection"));
|
||||
session_set_window_geometry (psp->shell, &pattern_select_session_info, TRUE);
|
||||
session_set_window_geometry (psp->shell, &pattern_select_session_info,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -131,7 +138,8 @@ pattern_select_new (gchar * title,
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
/* handle the wm close event */
|
||||
gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event",
|
||||
@ -147,7 +155,7 @@ pattern_select_new (gchar * title,
|
||||
gtk_box_pack_start (GTK_BOX (psp->options_box), label_box, FALSE, FALSE, 0);
|
||||
psp->pattern_name = gtk_label_new (_("Active"));
|
||||
gtk_box_pack_start (GTK_BOX (label_box), psp->pattern_name, FALSE, FALSE, 2);
|
||||
psp->pattern_size = gtk_label_new ("(0x0)");
|
||||
psp->pattern_size = gtk_label_new ("(0 X 0)");
|
||||
gtk_box_pack_start (GTK_BOX (label_box), psp->pattern_size, FALSE, FALSE, 5);
|
||||
|
||||
gtk_widget_show (psp->pattern_name);
|
||||
@ -157,10 +165,9 @@ pattern_select_new (gchar * title,
|
||||
/* The horizontal box containing preview & scrollbar */
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
psp->frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (psp->frame), GTK_SHADOW_IN);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), psp->frame, TRUE, TRUE, 0);
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
psp->sbar_data = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT(psp), 1, 1, MAX_WIN_HEIGHT(psp)));
|
||||
gtk_signal_connect (GTK_OBJECT (psp->sbar_data), "value_changed",
|
||||
@ -170,30 +177,30 @@ pattern_select_new (gchar * title,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), sbar, FALSE, FALSE, 0);
|
||||
|
||||
/* Create the pattern preview window and the underlying image */
|
||||
|
||||
/* Get the initial pattern extents */
|
||||
psp->cell_width = STD_CELL_SIZE;
|
||||
psp->cell_height = STD_CELL_SIZE;
|
||||
|
||||
psp->width = MAX_WIN_WIDTH(psp);
|
||||
psp->height = MAX_WIN_HEIGHT(psp);
|
||||
|
||||
psp->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview), psp->width, psp->height);
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview),
|
||||
MAX_WIN_WIDTH (psp), MAX_WIN_HEIGHT (psp));
|
||||
gtk_preview_set_expand (GTK_PREVIEW (psp->preview), TRUE);
|
||||
gtk_widget_set_events (psp->preview, PATTERN_EVENT_MASK);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (psp->preview), "event",
|
||||
(GtkSignalFunc) pattern_select_events,
|
||||
psp);
|
||||
|
||||
gtk_signal_connect_after (GTK_OBJECT(psp->frame), "size_allocate",
|
||||
gtk_signal_connect (GTK_OBJECT (psp->preview), "size_allocate",
|
||||
(GtkSignalFunc) pattern_select_resize,
|
||||
psp);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (psp->frame), psp->preview);
|
||||
gtk_container_add (GTK_CONTAINER (frame), psp->preview);
|
||||
gtk_widget_show (psp->preview);
|
||||
|
||||
gtk_widget_show (sbar);
|
||||
gtk_widget_show (hbox);
|
||||
gtk_widget_show (psp->frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = psp;
|
||||
@ -209,7 +216,6 @@ pattern_select_new (gchar * title,
|
||||
preview_calc_scrollbar (psp);
|
||||
display_patterns (psp);
|
||||
|
||||
|
||||
if (active)
|
||||
pattern_select_select (psp, active->index);
|
||||
|
||||
@ -287,7 +293,6 @@ pattern_select_free (PatternSelectP psp)
|
||||
g_free(psp->callback_name);
|
||||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
|
||||
g_free (psp);
|
||||
@ -407,8 +412,8 @@ display_pattern (PatternSelectP psp,
|
||||
offset_y = row * psp->cell_height + ((cell_height - height) >> 1)
|
||||
- psp->scroll_offset + MARGIN_HEIGHT;
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y, 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* Get the pointer into the pattern mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
@ -448,14 +453,15 @@ display_setup (PatternSelectP psp)
|
||||
unsigned char * buf;
|
||||
int i;
|
||||
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * psp->preview->requisition.width * 3);
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * psp->preview->allocation.width * 3);
|
||||
|
||||
/* Set the buffer to white */
|
||||
memset (buf, 255, psp->preview->requisition.width * 3);
|
||||
memset (buf, 255, psp->preview->allocation.width * 3);
|
||||
|
||||
/* Set the image buffer to white */
|
||||
for (i = 0; i < psp->preview->requisition.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (psp->preview), buf, 0, i, psp->preview->requisition.width);
|
||||
for (i = 0; i < psp->preview->allocation.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (psp->preview), buf, 0, i,
|
||||
psp->preview->allocation.width);
|
||||
|
||||
g_free (buf);
|
||||
}
|
||||
@ -519,8 +525,8 @@ pattern_select_show_selected (PatternSelectP psp,
|
||||
offset_x = psp->old_col * psp->cell_width;
|
||||
offset_y = psp->old_row * psp->cell_height - psp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* set the buf to white */
|
||||
memset (buf, 255, psp->cell_width * 3);
|
||||
@ -547,8 +553,8 @@ pattern_select_show_selected (PatternSelectP psp,
|
||||
offset_x = col * psp->cell_width;
|
||||
offset_y = row * psp->cell_height - psp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* set the buf to black */
|
||||
memset (buf, 0, psp->cell_width * 3);
|
||||
@ -636,9 +642,9 @@ pattern_select_resize (GtkWidget *widget,
|
||||
gint wid;
|
||||
gint now;
|
||||
|
||||
wid = widget->allocation.width-4;
|
||||
wid = widget->allocation.width;
|
||||
|
||||
for(now = MIN_CELL_SIZE, psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
for(now = psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
now < MAX_CELL_SIZE; ++now)
|
||||
{
|
||||
if ((wid % now) < (wid % psp->STD_CELL_SIZE)) psp->STD_CELL_SIZE = now;
|
||||
@ -646,22 +652,20 @@ pattern_select_resize (GtkWidget *widget,
|
||||
break;
|
||||
}
|
||||
|
||||
psp->NUM_PATTERN_COLUMNS = wid / psp->STD_CELL_SIZE;
|
||||
psp->NUM_PATTERN_ROWS = (gint) (num_patterns + psp->NUM_PATTERN_COLUMNS-1) / psp->NUM_PATTERN_COLUMNS;
|
||||
psp->NUM_PATTERN_COLUMNS =
|
||||
(gint) (wid / psp->STD_CELL_SIZE);
|
||||
psp->NUM_PATTERN_ROWS =
|
||||
(gint) ((num_patterns + psp->NUM_PATTERN_COLUMNS-1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
|
||||
psp->cell_width = psp->STD_CELL_SIZE;
|
||||
psp->cell_height = psp->STD_CELL_SIZE;
|
||||
psp->width = widget->allocation.width - 4;
|
||||
psp->height = widget->allocation.height - 4;
|
||||
|
||||
/*
|
||||
NUM_PATTERN_COLUMNS=(gint)(widget->allocation.width/STD_CELL_WIDTH);
|
||||
NUM_PATTERN_ROWS = (num_patterns + NUM_PATTERN_COLUMNS - 1) / NUM_PATTERN_COLUMNS;
|
||||
*/
|
||||
/* psp->width=widget->allocation.width;
|
||||
psp->height=widget->allocation.height; */
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview), psp->width, psp->height);
|
||||
/* recalculate scrollbar extents */
|
||||
preview_calc_scrollbar (psp);
|
||||
|
||||
@ -749,11 +753,11 @@ pattern_select_events (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_select_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
pattern_select_delete_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer client_data)
|
||||
{
|
||||
pattern_select_close_callback (w, client_data);
|
||||
pattern_select_close_callback (widget, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -24,26 +24,31 @@ typedef struct _PatternSelect _PatternSelect, *PatternSelectP;
|
||||
|
||||
struct _PatternSelect {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The preview and it's vscale data */
|
||||
GtkWidget *preview;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
GtkWidget *options_box;
|
||||
GdkGC *gc;
|
||||
GtkAdjustment *sbar_data;
|
||||
int width, height;
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
|
||||
/* Pattern popup */
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
|
||||
/* Call back function name */
|
||||
gchar * callback_name;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
|
||||
/* Current pattern */
|
||||
GPatternP pattern;
|
||||
/* To calc column pos. */
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
gint STD_CELL_SIZE;
|
||||
|
@ -34,11 +34,6 @@
|
||||
#define MIN_CELL_SIZE 32
|
||||
#define MAX_CELL_SIZE 45
|
||||
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
static GSList *active_dialogs = NULL; /* List of active dialogs */
|
||||
|
||||
/*
|
||||
#define STD_PATTERN_COLUMNS 6
|
||||
#define STD_PATTERN_ROWS 5
|
||||
@ -70,19 +65,23 @@ static gint pattern_select_events (GtkWidget *, GdkEvent *, PatternSe
|
||||
static gint pattern_select_resize (GtkWidget *, GdkEvent *, PatternSelectP);
|
||||
static void pattern_select_scroll_update (GtkAdjustment *, gpointer);
|
||||
|
||||
/* the action area structure */
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("Refresh"), pattern_select_refresh_callback, NULL, NULL },
|
||||
{ N_("Close"), pattern_select_close_callback, NULL, NULL }
|
||||
};
|
||||
|
||||
/* local variables */
|
||||
gint NUM_PATTERN_COLUMNS = 6;
|
||||
gint NUM_PATTERN_ROWS = 5;
|
||||
gint STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
/* PDB interface data */
|
||||
static int success;
|
||||
|
||||
/* List of active dialogs */
|
||||
static GSList *active_dialogs = NULL;
|
||||
|
||||
/* The main pattern dialog */
|
||||
extern PatternSelectP pattern_select_dialog;
|
||||
|
||||
|
||||
/* If title == NULL then it is the main pattern dialog */
|
||||
PatternSelectP
|
||||
pattern_select_new (gchar *title,
|
||||
gchar *initial_pattern)
|
||||
@ -91,9 +90,16 @@ pattern_select_new (gchar * title,
|
||||
GPatternP active = NULL;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *sbar;
|
||||
GtkWidget *label_box;
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("Refresh"), pattern_select_refresh_callback, NULL, NULL },
|
||||
{ N_("Close"), pattern_select_close_callback, NULL, NULL }
|
||||
};
|
||||
|
||||
psp = g_malloc (sizeof (_PatternSelect));
|
||||
psp->preview = NULL;
|
||||
psp->old_col = psp->old_row = 0;
|
||||
@ -103,14 +109,15 @@ pattern_select_new (gchar * title,
|
||||
psp->NUM_PATTERN_ROWS = 5;
|
||||
psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
|
||||
|
||||
/* The shell and main vbox */
|
||||
psp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (psp->shell), "patternselection", "Gimp");
|
||||
|
||||
if(!title)
|
||||
{
|
||||
gtk_window_set_title (GTK_WINDOW (psp->shell), _("Pattern Selection"));
|
||||
session_set_window_geometry (psp->shell, &pattern_select_session_info, TRUE);
|
||||
session_set_window_geometry (psp->shell, &pattern_select_session_info,
|
||||
TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -131,7 +138,8 @@ pattern_select_new (gchar * title,
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (psp->shell)->vbox), vbox,
|
||||
TRUE, TRUE, 0);
|
||||
|
||||
/* handle the wm close event */
|
||||
gtk_signal_connect (GTK_OBJECT (psp->shell), "delete_event",
|
||||
@ -147,7 +155,7 @@ pattern_select_new (gchar * title,
|
||||
gtk_box_pack_start (GTK_BOX (psp->options_box), label_box, FALSE, FALSE, 0);
|
||||
psp->pattern_name = gtk_label_new (_("Active"));
|
||||
gtk_box_pack_start (GTK_BOX (label_box), psp->pattern_name, FALSE, FALSE, 2);
|
||||
psp->pattern_size = gtk_label_new ("(0x0)");
|
||||
psp->pattern_size = gtk_label_new ("(0 X 0)");
|
||||
gtk_box_pack_start (GTK_BOX (label_box), psp->pattern_size, FALSE, FALSE, 5);
|
||||
|
||||
gtk_widget_show (psp->pattern_name);
|
||||
@ -157,10 +165,9 @@ pattern_select_new (gchar * title,
|
||||
/* The horizontal box containing preview & scrollbar */
|
||||
hbox = gtk_hbox_new (FALSE, 1);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
psp->frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (psp->frame), GTK_SHADOW_IN);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), psp->frame, TRUE, TRUE, 0);
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
psp->sbar_data = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, MAX_WIN_HEIGHT(psp), 1, 1, MAX_WIN_HEIGHT(psp)));
|
||||
gtk_signal_connect (GTK_OBJECT (psp->sbar_data), "value_changed",
|
||||
@ -170,30 +177,30 @@ pattern_select_new (gchar * title,
|
||||
gtk_box_pack_start (GTK_BOX (hbox), sbar, FALSE, FALSE, 0);
|
||||
|
||||
/* Create the pattern preview window and the underlying image */
|
||||
|
||||
/* Get the initial pattern extents */
|
||||
psp->cell_width = STD_CELL_SIZE;
|
||||
psp->cell_height = STD_CELL_SIZE;
|
||||
|
||||
psp->width = MAX_WIN_WIDTH(psp);
|
||||
psp->height = MAX_WIN_HEIGHT(psp);
|
||||
|
||||
psp->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview), psp->width, psp->height);
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview),
|
||||
MAX_WIN_WIDTH (psp), MAX_WIN_HEIGHT (psp));
|
||||
gtk_preview_set_expand (GTK_PREVIEW (psp->preview), TRUE);
|
||||
gtk_widget_set_events (psp->preview, PATTERN_EVENT_MASK);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (psp->preview), "event",
|
||||
(GtkSignalFunc) pattern_select_events,
|
||||
psp);
|
||||
|
||||
gtk_signal_connect_after (GTK_OBJECT(psp->frame), "size_allocate",
|
||||
gtk_signal_connect (GTK_OBJECT (psp->preview), "size_allocate",
|
||||
(GtkSignalFunc) pattern_select_resize,
|
||||
psp);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (psp->frame), psp->preview);
|
||||
gtk_container_add (GTK_CONTAINER (frame), psp->preview);
|
||||
gtk_widget_show (psp->preview);
|
||||
|
||||
gtk_widget_show (sbar);
|
||||
gtk_widget_show (hbox);
|
||||
gtk_widget_show (psp->frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = psp;
|
||||
@ -209,7 +216,6 @@ pattern_select_new (gchar * title,
|
||||
preview_calc_scrollbar (psp);
|
||||
display_patterns (psp);
|
||||
|
||||
|
||||
if (active)
|
||||
pattern_select_select (psp, active->index);
|
||||
|
||||
@ -287,7 +293,6 @@ pattern_select_free (PatternSelectP psp)
|
||||
g_free(psp->callback_name);
|
||||
|
||||
/* remove from active list */
|
||||
|
||||
active_dialogs = g_slist_remove(active_dialogs,psp);
|
||||
|
||||
g_free (psp);
|
||||
@ -407,8 +412,8 @@ display_pattern (PatternSelectP psp,
|
||||
offset_y = row * psp->cell_height + ((cell_height - height) >> 1)
|
||||
- psp->scroll_offset + MARGIN_HEIGHT;
|
||||
|
||||
ystart = BOUNDS (offset_y, 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y, 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* Get the pointer into the pattern mask data */
|
||||
rowstride = pattern_buf->width * pattern_buf->bytes;
|
||||
@ -448,14 +453,15 @@ display_setup (PatternSelectP psp)
|
||||
unsigned char * buf;
|
||||
int i;
|
||||
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * psp->preview->requisition.width * 3);
|
||||
buf = (unsigned char *) g_malloc (sizeof (char) * psp->preview->allocation.width * 3);
|
||||
|
||||
/* Set the buffer to white */
|
||||
memset (buf, 255, psp->preview->requisition.width * 3);
|
||||
memset (buf, 255, psp->preview->allocation.width * 3);
|
||||
|
||||
/* Set the image buffer to white */
|
||||
for (i = 0; i < psp->preview->requisition.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (psp->preview), buf, 0, i, psp->preview->requisition.width);
|
||||
for (i = 0; i < psp->preview->allocation.height; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (psp->preview), buf, 0, i,
|
||||
psp->preview->allocation.width);
|
||||
|
||||
g_free (buf);
|
||||
}
|
||||
@ -519,8 +525,8 @@ pattern_select_show_selected (PatternSelectP psp,
|
||||
offset_x = psp->old_col * psp->cell_width;
|
||||
offset_y = psp->old_row * psp->cell_height - psp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* set the buf to white */
|
||||
memset (buf, 255, psp->cell_width * 3);
|
||||
@ -547,8 +553,8 @@ pattern_select_show_selected (PatternSelectP psp,
|
||||
offset_x = col * psp->cell_width;
|
||||
offset_y = row * psp->cell_height - psp->scroll_offset;
|
||||
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->requisition.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->requisition.height);
|
||||
ystart = BOUNDS (offset_y , 0, psp->preview->allocation.height);
|
||||
yend = BOUNDS (offset_y + psp->cell_height, 0, psp->preview->allocation.height);
|
||||
|
||||
/* set the buf to black */
|
||||
memset (buf, 0, psp->cell_width * 3);
|
||||
@ -636,9 +642,9 @@ pattern_select_resize (GtkWidget *widget,
|
||||
gint wid;
|
||||
gint now;
|
||||
|
||||
wid = widget->allocation.width-4;
|
||||
wid = widget->allocation.width;
|
||||
|
||||
for(now = MIN_CELL_SIZE, psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
for(now = psp->STD_CELL_SIZE = MIN_CELL_SIZE;
|
||||
now < MAX_CELL_SIZE; ++now)
|
||||
{
|
||||
if ((wid % now) < (wid % psp->STD_CELL_SIZE)) psp->STD_CELL_SIZE = now;
|
||||
@ -646,22 +652,20 @@ pattern_select_resize (GtkWidget *widget,
|
||||
break;
|
||||
}
|
||||
|
||||
psp->NUM_PATTERN_COLUMNS = wid / psp->STD_CELL_SIZE;
|
||||
psp->NUM_PATTERN_ROWS = (gint) (num_patterns + psp->NUM_PATTERN_COLUMNS-1) / psp->NUM_PATTERN_COLUMNS;
|
||||
psp->NUM_PATTERN_COLUMNS =
|
||||
(gint) (wid / psp->STD_CELL_SIZE);
|
||||
psp->NUM_PATTERN_ROWS =
|
||||
(gint) ((num_patterns + psp->NUM_PATTERN_COLUMNS-1) /
|
||||
psp->NUM_PATTERN_COLUMNS);
|
||||
|
||||
psp->cell_width = psp->STD_CELL_SIZE;
|
||||
psp->cell_height = psp->STD_CELL_SIZE;
|
||||
psp->width = widget->allocation.width - 4;
|
||||
psp->height = widget->allocation.height - 4;
|
||||
|
||||
/*
|
||||
NUM_PATTERN_COLUMNS=(gint)(widget->allocation.width/STD_CELL_WIDTH);
|
||||
NUM_PATTERN_ROWS = (num_patterns + NUM_PATTERN_COLUMNS - 1) / NUM_PATTERN_COLUMNS;
|
||||
*/
|
||||
/* psp->width=widget->allocation.width;
|
||||
psp->height=widget->allocation.height; */
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (psp->preview), psp->width, psp->height);
|
||||
/* recalculate scrollbar extents */
|
||||
preview_calc_scrollbar (psp);
|
||||
|
||||
@ -749,11 +753,11 @@ pattern_select_events (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static gint
|
||||
pattern_select_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
pattern_select_delete_callback (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer client_data)
|
||||
{
|
||||
pattern_select_close_callback (w, client_data);
|
||||
pattern_select_close_callback (widget, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -24,26 +24,31 @@ typedef struct _PatternSelect _PatternSelect, *PatternSelectP;
|
||||
|
||||
struct _PatternSelect {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *frame;
|
||||
|
||||
/* The preview and it's vscale data */
|
||||
GtkWidget *preview;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
GtkWidget *options_box;
|
||||
GdkGC *gc;
|
||||
GtkAdjustment *sbar_data;
|
||||
int width, height;
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
|
||||
GtkWidget *options_box;
|
||||
GtkWidget *pattern_name;
|
||||
GtkWidget *pattern_size;
|
||||
|
||||
/* Pattern popup */
|
||||
GtkWidget *pattern_popup;
|
||||
GtkWidget *pattern_preview;
|
||||
|
||||
/* Call back function name */
|
||||
gchar * callback_name;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
|
||||
/* Current pattern */
|
||||
GPatternP pattern;
|
||||
/* To calc column pos. */
|
||||
|
||||
/* Some variables to keep the GUI consistent */
|
||||
int cell_width, cell_height;
|
||||
int scroll_offset;
|
||||
gint old_row;
|
||||
gint old_col;
|
||||
gint NUM_PATTERN_COLUMNS;
|
||||
gint NUM_PATTERN_ROWS;
|
||||
gint STD_CELL_SIZE;
|
||||
|
Reference in New Issue
Block a user