Added a brush indicator to the toolbar. Its a start :)
This commit is contained in:
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
1999-06-02 Seth Burgess <sjburges@gimp.org>
|
||||
|
||||
* app/Makefile.am : Added new Files, indicator_area.[ch]
|
||||
|
||||
* app/devices.c
|
||||
* app/interface.c
|
||||
* app/indicator_area.[ch] : Added a brush preview in the toolbar.
|
||||
Still needs a full size preview, and could use a patterns and a
|
||||
gradient next to it :) These will happen, relatively soon.
|
||||
|
||||
Thanks to the KDE guy (Torsten Rahn) on the gimp-devel mailing list
|
||||
that gave the idea for this by pointing out that it wasn't easy
|
||||
to find the size of the brush. It seems obvious now.
|
||||
|
||||
1999-06-02 Michael Natterer <mitschel@cs.tu-berlin.de>
|
||||
|
||||
* app/disp_callbacks.c
|
||||
|
@ -222,6 +222,8 @@ gimp_SOURCES = \
|
||||
image_map.h \
|
||||
image_render.c \
|
||||
image_render.h \
|
||||
indicator_area.c \
|
||||
indicator_area.h \
|
||||
info_dialog.c \
|
||||
info_dialog.h \
|
||||
info_window.c \
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "indicator_area.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
@ -689,7 +690,7 @@ create_device_status (void)
|
||||
deviceD->num_devices++;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* devices table */
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
@ -1359,6 +1360,7 @@ device_status_update (guint32 deviceid)
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
brush_area_update();
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "general.h"
|
||||
#include "indicator_area.h"
|
||||
#include "interface.h"
|
||||
#include "menus.h"
|
||||
#include "dialog_handler.h"
|
||||
@ -205,6 +206,38 @@ allocate_colors (GtkWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
create_indicator_area (GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkPixmap *swap_pixmap;
|
||||
|
||||
gtk_widget_realize (parent);
|
||||
|
||||
default_pixmap = create_pixmap (parent->window, NULL, default_bits,
|
||||
default_width, default_height);
|
||||
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits,
|
||||
swap_width, swap_height);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_box_pack_start (GTK_BOX (parent), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_realize (frame);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
ind_area = indicator_area_create (54, 42);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
create_color_area (GtkWidget *parent)
|
||||
{
|
||||
@ -517,6 +550,7 @@ create_toolbox ()
|
||||
/*create_tool_label (vbox);*/
|
||||
/*create_progress_area (vbox);*/
|
||||
create_color_area (vbox);
|
||||
create_indicator_area (vbox);
|
||||
gtk_widget_show (window);
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "general.h"
|
||||
#include "indicator_area.h"
|
||||
#include "interface.h"
|
||||
#include "menus.h"
|
||||
#include "dialog_handler.h"
|
||||
@ -205,6 +206,38 @@ allocate_colors (GtkWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
create_indicator_area (GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkPixmap *swap_pixmap;
|
||||
|
||||
gtk_widget_realize (parent);
|
||||
|
||||
default_pixmap = create_pixmap (parent->window, NULL, default_bits,
|
||||
default_width, default_height);
|
||||
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits,
|
||||
swap_width, swap_height);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_box_pack_start (GTK_BOX (parent), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_realize (frame);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
ind_area = indicator_area_create (54, 42);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
create_color_area (GtkWidget *parent)
|
||||
{
|
||||
@ -517,6 +550,7 @@ create_toolbox ()
|
||||
/*create_tool_label (vbox);*/
|
||||
/*create_progress_area (vbox);*/
|
||||
create_color_area (vbox);
|
||||
create_indicator_area (vbox);
|
||||
gtk_widget_show (window);
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "indicator_area.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
@ -689,7 +690,7 @@ create_device_status (void)
|
||||
deviceD->num_devices++;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* devices table */
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
@ -1359,6 +1360,7 @@ device_status_update (guint32 deviceid)
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
brush_area_update();
|
||||
}
|
||||
|
||||
|
||||
|
167
app/gui/indicator-area.c
Normal file
167
app/gui/indicator-area.c
Normal file
@ -0,0 +1,167 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "indicator_area.h"
|
||||
#include "gimpbrushlist.h"
|
||||
|
||||
#define CELL_SIZE 19 /* The size of the previews */
|
||||
#define CELL_PADDING 2 /* How much between brush and pattern cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
/* Global variables */
|
||||
|
||||
/* Static variables */
|
||||
static GtkWidget *indicator_table;
|
||||
static GtkWidget *brush_preview;
|
||||
|
||||
/* brush_area_edit */
|
||||
static gint
|
||||
brush_area_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
case GDK_BUTTON_RELEASE:
|
||||
brush_area_update();
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* pop up the brush selection dialog accordingly */
|
||||
create_brush_dialog();
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width,
|
||||
int height)
|
||||
{
|
||||
/* Put the brush in the table */
|
||||
indicator_table = gtk_table_new (1,3, FALSE);
|
||||
brush_preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (brush_preview), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (brush_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_preview), "event",
|
||||
(GtkSignalFunc) brush_area_events,
|
||||
NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE(indicator_table), brush_preview,
|
||||
0, 1, 0, 1);
|
||||
|
||||
brush_area_update();
|
||||
gtk_widget_show(indicator_table);
|
||||
/* Not yet - get the brush working first
|
||||
pattern_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (pattern_preview, CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (pattern_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (pattern_preview), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
NULL;
|
||||
|
||||
gtk_table_attach (GTK_TABLE(indicator_table), pattern_preview,
|
||||
1, 2, 0, 1,
|
||||
0, 0, CELL_SPACING, CELL_SPACING);
|
||||
*/
|
||||
|
||||
return indicator_table;
|
||||
}
|
||||
|
||||
void
|
||||
brush_area_update ()
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
GimpBrushP brush;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
brush = get_active_brush();
|
||||
if (!brush)
|
||||
{
|
||||
g_warning("No gimp brush found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
src += brush_buf->width;
|
||||
}
|
||||
gtk_widget_draw(brush_preview, NULL);
|
||||
gtk_widget_show(brush_preview);
|
||||
}
|
||||
|
28
app/gui/indicator-area.h
Normal file
28
app/gui/indicator-area.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimpbrushlist.h"
|
||||
#ifndef __INDICATOR_AREA_H__
|
||||
#define __INDICATOR_AREA_H__
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width, int height);
|
||||
|
||||
void brush_area_update(void);
|
||||
|
||||
#endif /* __INDICATOR_AREA_H__ */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "indicator_area.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
@ -689,7 +690,7 @@ create_device_status (void)
|
||||
deviceD->num_devices++;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* devices table */
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
@ -1359,6 +1360,7 @@ device_status_update (guint32 deviceid)
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
brush_area_update();
|
||||
}
|
||||
|
||||
|
||||
|
167
app/indicator_area.c
Normal file
167
app/indicator_area.c
Normal file
@ -0,0 +1,167 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "indicator_area.h"
|
||||
#include "gimpbrushlist.h"
|
||||
|
||||
#define CELL_SIZE 19 /* The size of the previews */
|
||||
#define CELL_PADDING 2 /* How much between brush and pattern cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
/* Global variables */
|
||||
|
||||
/* Static variables */
|
||||
static GtkWidget *indicator_table;
|
||||
static GtkWidget *brush_preview;
|
||||
|
||||
/* brush_area_edit */
|
||||
static gint
|
||||
brush_area_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
case GDK_BUTTON_RELEASE:
|
||||
brush_area_update();
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* pop up the brush selection dialog accordingly */
|
||||
create_brush_dialog();
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width,
|
||||
int height)
|
||||
{
|
||||
/* Put the brush in the table */
|
||||
indicator_table = gtk_table_new (1,3, FALSE);
|
||||
brush_preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (brush_preview), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (brush_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_preview), "event",
|
||||
(GtkSignalFunc) brush_area_events,
|
||||
NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE(indicator_table), brush_preview,
|
||||
0, 1, 0, 1);
|
||||
|
||||
brush_area_update();
|
||||
gtk_widget_show(indicator_table);
|
||||
/* Not yet - get the brush working first
|
||||
pattern_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (pattern_preview, CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (pattern_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (pattern_preview), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
NULL;
|
||||
|
||||
gtk_table_attach (GTK_TABLE(indicator_table), pattern_preview,
|
||||
1, 2, 0, 1,
|
||||
0, 0, CELL_SPACING, CELL_SPACING);
|
||||
*/
|
||||
|
||||
return indicator_table;
|
||||
}
|
||||
|
||||
void
|
||||
brush_area_update ()
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
GimpBrushP brush;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
brush = get_active_brush();
|
||||
if (!brush)
|
||||
{
|
||||
g_warning("No gimp brush found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
src += brush_buf->width;
|
||||
}
|
||||
gtk_widget_draw(brush_preview, NULL);
|
||||
gtk_widget_show(brush_preview);
|
||||
}
|
||||
|
28
app/indicator_area.h
Normal file
28
app/indicator_area.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimpbrushlist.h"
|
||||
#ifndef __INDICATOR_AREA_H__
|
||||
#define __INDICATOR_AREA_H__
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width, int height);
|
||||
|
||||
void brush_area_update(void);
|
||||
|
||||
#endif /* __INDICATOR_AREA_H__ */
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gimage.h"
|
||||
#include "gimprc.h"
|
||||
#include "general.h"
|
||||
#include "indicator_area.h"
|
||||
#include "interface.h"
|
||||
#include "menus.h"
|
||||
#include "dialog_handler.h"
|
||||
@ -205,6 +206,38 @@ allocate_colors (GtkWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
create_indicator_area (GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkPixmap *swap_pixmap;
|
||||
|
||||
gtk_widget_realize (parent);
|
||||
|
||||
default_pixmap = create_pixmap (parent->window, NULL, default_bits,
|
||||
default_width, default_height);
|
||||
swap_pixmap = create_pixmap (parent->window, NULL, swap_bits,
|
||||
swap_width, swap_height);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_box_pack_start (GTK_BOX (parent), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_realize (frame);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
ind_area = indicator_area_create (54, 42);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
create_color_area (GtkWidget *parent)
|
||||
{
|
||||
@ -517,6 +550,7 @@ create_toolbox ()
|
||||
/*create_tool_label (vbox);*/
|
||||
/*create_progress_area (vbox);*/
|
||||
create_color_area (vbox);
|
||||
create_indicator_area (vbox);
|
||||
gtk_widget_show (window);
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "indicator_area.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
@ -689,7 +690,7 @@ create_device_status (void)
|
||||
deviceD->num_devices++;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* devices table */
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
@ -1359,6 +1360,7 @@ device_status_update (guint32 deviceid)
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
brush_area_update();
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "session.h"
|
||||
#include "tools.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "indicator_area.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "libgimp/gimpenv.h"
|
||||
@ -689,7 +690,7 @@ create_device_status (void)
|
||||
deviceD->num_devices++;
|
||||
tmp_list = tmp_list->next;
|
||||
}
|
||||
|
||||
/* devices table */
|
||||
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
||||
gtk_container_border_width (GTK_CONTAINER(deviceD->table), 3);
|
||||
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
||||
@ -1359,6 +1360,7 @@ device_status_update (guint32 deviceid)
|
||||
gtk_widget_show (deviceD->patterns[i]);
|
||||
}
|
||||
}
|
||||
brush_area_update();
|
||||
}
|
||||
|
||||
|
||||
|
167
app/widgets/gimptoolbox-indicator-area.c
Normal file
167
app/widgets/gimptoolbox-indicator-area.c
Normal file
@ -0,0 +1,167 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "indicator_area.h"
|
||||
#include "gimpbrushlist.h"
|
||||
|
||||
#define CELL_SIZE 19 /* The size of the previews */
|
||||
#define CELL_PADDING 2 /* How much between brush and pattern cells */
|
||||
#define PREVIEW_EVENT_MASK GDK_EXPOSURE_MASK | \
|
||||
GDK_BUTTON_PRESS_MASK | \
|
||||
GDK_BUTTON_RELEASE_MASK | \
|
||||
GDK_BUTTON1_MOTION_MASK | \
|
||||
GDK_ENTER_NOTIFY_MASK | \
|
||||
GDK_LEAVE_NOTIFY_MASK
|
||||
|
||||
/* Global variables */
|
||||
|
||||
/* Static variables */
|
||||
static GtkWidget *indicator_table;
|
||||
static GtkWidget *brush_preview;
|
||||
|
||||
/* brush_area_edit */
|
||||
static gint
|
||||
brush_area_events (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case GDK_EXPOSE:
|
||||
break;
|
||||
case GDK_BUTTON_RELEASE:
|
||||
brush_area_update();
|
||||
break;
|
||||
|
||||
case GDK_BUTTON_PRESS:
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
/* pop up the brush selection dialog accordingly */
|
||||
create_brush_dialog();
|
||||
}
|
||||
break;
|
||||
case GDK_DELETE:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width,
|
||||
int height)
|
||||
{
|
||||
/* Put the brush in the table */
|
||||
indicator_table = gtk_table_new (1,3, FALSE);
|
||||
brush_preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
gtk_preview_size (GTK_PREVIEW (brush_preview), CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (brush_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (brush_preview), "event",
|
||||
(GtkSignalFunc) brush_area_events,
|
||||
NULL);
|
||||
gtk_table_attach_defaults (GTK_TABLE(indicator_table), brush_preview,
|
||||
0, 1, 0, 1);
|
||||
|
||||
brush_area_update();
|
||||
gtk_widget_show(indicator_table);
|
||||
/* Not yet - get the brush working first
|
||||
pattern_preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (pattern_preview, CELL_SIZE, CELL_SIZE);
|
||||
gtk_widget_set_events (pattern_preview, PREVIEW_EVENT_MASK);
|
||||
gtk_signal_connect (GTK_OBJECT (pattern_preview), "event",
|
||||
(GtkSignalFunc) pattern_preview_events,
|
||||
NULL;
|
||||
|
||||
gtk_table_attach (GTK_TABLE(indicator_table), pattern_preview,
|
||||
1, 2, 0, 1,
|
||||
0, 0, CELL_SPACING, CELL_SPACING);
|
||||
*/
|
||||
|
||||
return indicator_table;
|
||||
}
|
||||
|
||||
void
|
||||
brush_area_update ()
|
||||
{
|
||||
guchar buffer[CELL_SIZE];
|
||||
TempBuf * brush_buf;
|
||||
GimpBrushP brush;
|
||||
unsigned char * src, *s = NULL;
|
||||
unsigned char *b;
|
||||
int width,height;
|
||||
int offset_x, offset_y;
|
||||
int yend;
|
||||
int ystart;
|
||||
int i, j;
|
||||
|
||||
brush = get_active_brush();
|
||||
if (!brush)
|
||||
{
|
||||
g_warning("No gimp brush found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
brush_buf = brush->mask;
|
||||
|
||||
/* Get the pointer into the brush mask data */
|
||||
src = mask_buf_data (brush_buf);
|
||||
|
||||
/* Limit to cell size */
|
||||
width = (brush_buf->width > CELL_SIZE) ? CELL_SIZE: brush_buf->width;
|
||||
height = (brush_buf->height > CELL_SIZE) ? CELL_SIZE: brush_buf->height;
|
||||
|
||||
/* Set buffer to white */
|
||||
memset(buffer, 255, sizeof(buffer));
|
||||
for (i = 0; i < CELL_SIZE; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview), buffer, 0, i, CELL_SIZE);
|
||||
|
||||
offset_x = ((CELL_SIZE - width) >> 1);
|
||||
offset_y = ((CELL_SIZE - height) >> 1);
|
||||
ystart = BOUNDS (offset_y, 0, CELL_SIZE);
|
||||
yend = BOUNDS (offset_y + height, 0, CELL_SIZE);
|
||||
|
||||
for (i = ystart; i < yend; i++)
|
||||
{
|
||||
/* Invert the mask for display. We're doing this because
|
||||
* a value of 255 in the mask means it is full intensity.
|
||||
* However, it makes more sense for full intensity to show
|
||||
* up as black in this brush preview window...
|
||||
*/
|
||||
s = src;
|
||||
b = buffer;
|
||||
for (j = 0; j < width ; j++)
|
||||
*b++ = 255 - *s++;
|
||||
|
||||
gtk_preview_draw_row (GTK_PREVIEW(brush_preview),
|
||||
buffer,
|
||||
offset_x, i, width);
|
||||
src += brush_buf->width;
|
||||
}
|
||||
gtk_widget_draw(brush_preview, NULL);
|
||||
gtk_widget_show(brush_preview);
|
||||
}
|
||||
|
28
app/widgets/gimptoolbox-indicator-area.h
Normal file
28
app/widgets/gimptoolbox-indicator-area.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "gimpbrushlist.h"
|
||||
#ifndef __INDICATOR_AREA_H__
|
||||
#define __INDICATOR_AREA_H__
|
||||
|
||||
GtkWidget *
|
||||
indicator_area_create (int width, int height);
|
||||
|
||||
void brush_area_update(void);
|
||||
|
||||
#endif /* __INDICATOR_AREA_H__ */
|
||||
|
Reference in New Issue
Block a user