Commit 0527d023 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

themes/Default/images/Makefile.am added a stock icon that shows a simple

2004-09-27  Sven Neumann  <sven@gimp.org>

	* themes/Default/images/Makefile.am
	* themes/Default/images/stock-frame-64.png: added a stock icon
	that shows a simple drop shadow but could be exchanged for other
	image decorations.

	* libgimpwidgets/gimpstock.[ch]: register the new icon.

	* app/widgets/Makefile.am
	* app/widgets/gimpviewrenderer-frame.[ch]: new file that holds some
	ugly code to draw a frame around a preview pixbuf.

	* app/widgets/gimpviewrenderer.[ch]: the frame pixbuf is attached
	to the GimpViewRenderer class so it can be shared by all renderers.

	* app/widgets/gimpviewrendererimagefile.c: use the new functionality
	to draw a nice frame around imagefile previews.

	* app/widgets/gimpcontainerbox.c: draw imagefile preview w/o a border.
parent 24f8d7e7
2004-09-27 Sven Neumann <sven@gimp.org>
* themes/Default/images/Makefile.am
* themes/Default/images/stock-frame-64.png: added a stock icon
that shows a simple drop shadow but could be exchanged for other
image decorations.
* libgimpwidgets/gimpstock.[ch]: register the new icon.
* app/widgets/Makefile.am
* app/widgets/gimpviewrenderer-frame.[ch]: new file that holds some
ugly code to draw a frame around a preview pixbuf.
* app/widgets/gimpviewrenderer.[ch]: the frame pixbuf is attached
to the GimpViewRenderer class so it can be shared by all renderers.
* app/widgets/gimpviewrendererimagefile.c: use the new functionality
to draw a nice frame around imagefile previews.
* app/widgets/gimpcontainerbox.c: draw imagefile preview w/o a border.
2004-09-27 Michael Natterer <mitch@gimp.org>
* app/actions/data-commands.c: cleanup.
......
......@@ -248,6 +248,8 @@ libappwidgets_a_sources = \
gimpviewabledialog.h \
gimpviewrenderer.c \
gimpviewrenderer.h \
gimpviewrenderer-frame.c \
gimpviewrenderer-frame.h \
gimpviewrenderer-utils.c \
gimpviewrenderer-utils.h \
gimpviewrendererbrush.c \
......
......@@ -231,7 +231,8 @@ gimp_container_box_get_preview (GimpDocked *docked,
prop_name = gimp_context_type_to_prop_name (container->children_type);
if (! strcmp (prop_name, "tool") ||
if (! strcmp (prop_name, "imagefile") ||
! strcmp (prop_name, "tool") ||
! strcmp (prop_name, "template"))
border_width = 0;
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewrenderer-frame.c
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* Contains code taken from eel, the Eazel Extensions Library.
*
* 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 "config.h"
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "core/gimpviewable.h"
#include "gimpviewrenderer.h"
#include "gimpviewrenderer-frame.h"
/* utility to stretch a frame to the desired size */
static void
draw_frame_row (GdkPixbuf *frame_image,
gint target_width,
gint source_width,
gint source_v_position,
gint dest_v_position,
GdkPixbuf *result_pixbuf,
gint left_offset,
gint height)
{
gint remaining_width = target_width;
gint h_offset = 0;
while (remaining_width > 0)
{
gint slab_width = (remaining_width > source_width ?
source_width : remaining_width);
gdk_pixbuf_copy_area (frame_image,
left_offset, source_v_position,
slab_width, height,
result_pixbuf,
left_offset + h_offset, dest_v_position);
remaining_width -= slab_width;
h_offset += slab_width;
}
}
/* utility to draw the middle section of the frame in a loop */
static void
draw_frame_column (GdkPixbuf *frame_image,
gint target_height,
gint source_height,
gint source_h_position,
gint dest_h_position,
GdkPixbuf *result_pixbuf,
gint top_offset, int width)
{
gint remaining_height = target_height;
gint v_offset = 0;
while (remaining_height > 0)
{
gint slab_height = (remaining_height > source_height ?
source_height : remaining_height);
gdk_pixbuf_copy_area (frame_image,
source_h_position, top_offset,
width, slab_height,
result_pixbuf,
dest_h_position, top_offset + v_offset);
remaining_height -= slab_height;
v_offset += slab_height;
}
}
GdkPixbuf *
stretch_frame_image (GdkPixbuf *frame_image,
gint left_offset,
gint top_offset,
gint right_offset,
gint bottom_offset,
gint dest_width,
gint dest_height)
{
GdkPixbuf *pixbuf;
guchar *pixels;
gint frame_width, frame_height;
gint row_stride;
gint target_width, target_frame_width;
gint target_height, target_frame_height;
frame_width = gdk_pixbuf_get_width (frame_image);
frame_height = gdk_pixbuf_get_height (frame_image );
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
dest_width, dest_height);
gdk_pixbuf_fill (pixbuf, 0);
row_stride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
target_width = dest_width - left_offset - right_offset;
target_height = dest_height - top_offset - bottom_offset;
target_frame_width = frame_width - left_offset - right_offset;
target_frame_height = frame_height - top_offset - bottom_offset;
left_offset += MIN (target_width / 2, target_frame_width / 2);
right_offset += MIN (target_width / 2, target_frame_width / 2);
top_offset += MIN (target_height / 2, target_frame_height / 2);
bottom_offset += MIN (target_height / 2, target_frame_height / 2);
target_width = dest_width - left_offset - right_offset;
target_height = dest_height - top_offset - bottom_offset;
target_frame_width = frame_width - left_offset - right_offset;
target_frame_height = frame_height - top_offset - bottom_offset;
/* draw the left top corner and top row */
gdk_pixbuf_copy_area (frame_image,
0, 0, left_offset, top_offset,
pixbuf, 0, 0);
draw_frame_row (frame_image, target_width, target_frame_width,
0, 0,
pixbuf,
left_offset, top_offset);
/* draw the right top corner and left column */
gdk_pixbuf_copy_area (frame_image,
frame_width - right_offset, 0,
right_offset, top_offset,
pixbuf,
dest_width - right_offset, 0);
draw_frame_column (frame_image, target_height, target_frame_height, 0, 0,
pixbuf, top_offset, left_offset);
/* draw the bottom right corner and bottom row */
gdk_pixbuf_copy_area (frame_image,
frame_width - right_offset, frame_height - bottom_offset,
right_offset, bottom_offset,
pixbuf,
dest_width - right_offset, dest_height - bottom_offset);
draw_frame_row (frame_image, target_width, target_frame_width,
frame_height - bottom_offset, dest_height - bottom_offset,
pixbuf, left_offset, bottom_offset);
/* draw the bottom left corner and the right column */
gdk_pixbuf_copy_area (frame_image,
0, frame_height - bottom_offset,
left_offset, bottom_offset,
pixbuf,
0, dest_height - bottom_offset);
draw_frame_column (frame_image, target_height, target_frame_height,
frame_width - right_offset, dest_width - right_offset,
pixbuf, top_offset, right_offset);
return pixbuf;
}
static GdkPixbuf *
gimp_view_renderer_get_frame (GimpViewRenderer *renderer,
gint width,
gint height)
{
GimpViewRendererClass *class = GIMP_VIEW_RENDERER_GET_CLASS (renderer);
return stretch_frame_image (class->frame,
class->frame_left,
class->frame_top,
class->frame_right,
class->frame_bottom,
width, height);
}
static void
gimp_view_renderer_ensure_frame (GimpViewRenderer *renderer,
GtkWidget *widget)
{
GimpViewRendererClass *class = GIMP_VIEW_RENDERER_GET_CLASS (renderer);
if (! class->frame)
{
class->frame = gtk_widget_render_icon (widget,
GIMP_STOCK_FRAME,
GTK_ICON_SIZE_DIALOG, NULL);
/* FIXME: shouldn't be hardcoded */
class->frame_left = 2;
class->frame_top = 2;
class->frame_right = 6;
class->frame_bottom = 6;
}
}
GdkPixbuf *
gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
GtkWidget *widget,
gint width,
gint height)
{
GimpViewRendererClass *class;
GdkPixbuf *frame;
GdkPixbuf *pixbuf;
gint w, h;
gint x, y;
g_return_val_if_fail (GIMP_IS_VIEW_RENDERER (renderer), NULL);
g_return_val_if_fail (GIMP_IS_VIEWABLE (renderer->viewable), NULL);
gimp_view_renderer_ensure_frame (renderer, widget);
class = GIMP_VIEW_RENDERER_GET_CLASS (renderer);
w = width - class->frame_left - class->frame_right;
h = height - class->frame_top - class->frame_bottom;
if (w > 12 && h > 12)
{
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable, w, h);
if (!pixbuf)
return NULL;
x = class->frame_left;
y = class->frame_top;
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
frame = gimp_view_renderer_get_frame (renderer,
w + x + class->frame_right,
h + y + class->frame_bottom);
}
else
{
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
width - 2, height - 2);
if (!pixbuf)
return NULL;
x = 1;
y = 1;
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w + 2, h + 2);
gdk_pixbuf_fill (frame, 0);
}
gdk_pixbuf_copy_area (pixbuf, 0, 0, w, h, frame, x, y);
return frame;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpviewrenderer-frame.h
* Copyright (C) 2004 Sven Neumann <sven@gimp.org>
*
* 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.
*/
#ifndef __GIMP_VIEW_RENDERER_FRAME_H__
#define __GIMP_VIEW_RENDERER_FRAME_H__
GdkPixbuf * gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
GtkWidget *widget,
gint width,
gint height);
#endif /* __GIMP_VIEW_RENDERER_FRAME_H__ */
......@@ -56,26 +56,27 @@ enum
};
static void gimp_view_renderer_class_init (GimpViewRendererClass *klass);
static void gimp_view_renderer_init (GimpViewRenderer *renderer);
static void gimp_view_renderer_class_init (GimpViewRendererClass *klass);
static void gimp_view_renderer_dispose (GObject *object);
static void gimp_view_renderer_finalize (GObject *object);
static void gimp_view_renderer_init (GimpViewRenderer *renderer);
static gboolean gimp_view_renderer_idle_update (GimpViewRenderer *renderer);
static void gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
GdkWindow *window,
GtkWidget *widget,
const GdkRectangle *draw_area,
const GdkRectangle *expose_area);
static void gimp_view_renderer_real_render (GimpViewRenderer *renderer,
GtkWidget *widget);
static void gimp_view_renderer_dispose (GObject *object);
static void gimp_view_renderer_finalize (GObject *object);
static void gimp_view_renderer_size_changed (GimpViewRenderer *renderer,
GimpViewable *viewable);
static GdkGC * gimp_view_renderer_create_gc (GimpViewRenderer *renderer,
GdkWindow *window,
GtkWidget *widget);
static gboolean gimp_view_renderer_idle_update (GimpViewRenderer *renderer);
static void gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
GdkWindow *window,
GtkWidget *widget,
const GdkRectangle *draw_area,
const GdkRectangle *expose_area);
static void gimp_view_renderer_real_render (GimpViewRenderer *renderer,
GtkWidget *widget);
static void gimp_view_renderer_size_changed (GimpViewRenderer *renderer,
GimpViewable *viewable);
static GdkGC * gimp_view_renderer_create_gc (GimpViewRenderer *renderer,
GdkWindow *window,
GtkWidget *widget);
static guint renderer_signals[LAST_SIGNAL] = { 0 };
......@@ -98,14 +99,14 @@ gimp_view_renderer_get_type (void)
static const GTypeInfo renderer_info =
{
sizeof (GimpViewRendererClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gimp_view_renderer_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
NULL, /* class_data */
sizeof (GimpViewRenderer),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_view_renderer_init,
0, /* n_preallocs */
(GInstanceInitFunc) gimp_view_renderer_init,
};
renderer_type = g_type_register_static (G_TYPE_OBJECT,
......@@ -142,6 +143,12 @@ gimp_view_renderer_class_init (GimpViewRendererClass *klass)
gimp_rgba_set (&white_color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
gimp_rgba_set (&green_color, 0.0, 0.94, 0.0, GIMP_OPACITY_OPAQUE);
gimp_rgba_set (&red_color, 1.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
klass->frame = NULL;
klass->frame_left = 0;
klass->frame_right = 0;
klass->frame_top = 0;
klass->frame_bottom = 0;
}
static void
......
......@@ -67,7 +67,13 @@ struct _GimpViewRenderer
struct _GimpViewRendererClass
{
GObjectClass parent_class;
GObjectClass parent_class;
GdkPixbuf *frame;
gint frame_left;
gint frame_right;
gint frame_bottom;
gint frame_top;
/* signals */
void (* update) (GimpViewRenderer *renderer);
......@@ -126,7 +132,6 @@ void gimp_view_renderer_draw (GimpViewRenderer *renderer,
const GdkRectangle *draw_area,
const GdkRectangle *expose_area);
/* protected */
void gimp_view_renderer_default_render_buffer (GimpViewRenderer *renderer,
......
......@@ -33,6 +33,7 @@
#include "core/gimpimagefile.h"
#include "gimpviewrendererimagefile.h"
#include "gimpviewrenderer-frame.h"
#ifdef ENABLE_FILE_SYSTEM_ICONS
#define GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
......@@ -100,33 +101,31 @@ static void
gimp_view_renderer_imagefile_render (GimpViewRenderer *renderer,
GtkWidget *widget)
{
GdkPixbuf *pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
renderer->width,
renderer->height);
GdkPixbuf *pixbuf = gimp_view_renderer_get_frame_pixbuf (renderer, widget,
renderer->width,
renderer->height);
#ifdef ENABLE_FILE_SYSTEM_ICONS
if (! pixbuf)
if (! pixbuf &&
GIMP_VIEW_RENDERER_IMAGEFILE (renderer)->file_system)
{
if (GIMP_VIEW_RENDERER_IMAGEFILE (renderer)->file_system)
const gchar *uri;
uri = gimp_object_get_name (GIMP_OBJECT (renderer->viewable));
if (uri)
{
GtkFileSystem *file_system;
const gchar *uri;
GtkFilePath *path;
file_system = GIMP_VIEW_RENDERER_IMAGEFILE (renderer)->file_system;
uri = gimp_object_get_name (GIMP_OBJECT (renderer->viewable));
if (uri)
{
GtkFilePath *path;
path = gtk_file_system_uri_to_path (file_system, uri);
path = gtk_file_system_uri_to_path (file_system, uri);
pixbuf = gtk_file_system_render_icon (file_system, path, widget,
MIN (renderer->width,
renderer->height),
NULL);
gtk_file_path_free (path);
}
pixbuf = gtk_file_system_render_icon (file_system, path, widget,
MIN (renderer->width,
renderer->height),
NULL);
gtk_file_path_free (path);
}
}
#endif /* ENABLE_FILE_SYSTEM_ICONS */
......
......@@ -224,7 +224,6 @@ static GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_SELECTION_BORDER, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_NAVIGATION, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TEXTURE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_QMASK_OFF, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_QMASK_ON, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_LIST, NULL, 0, 0, LIBGIMP_DOMAIN },
......@@ -254,6 +253,9 @@ static GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_WILBER, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_WILBER_EEK, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_FRAME, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TEXTURE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_AIRBRUSH, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_BLEND, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_BLUR, NULL, 0, 0, LIBGIMP_DOMAIN },
......@@ -619,6 +621,7 @@ gimp_stock_dialog_pixbufs[] =
{ GIMP_STOCK_WILBER, stock_wilber_64 },
{ GIMP_STOCK_WILBER_EEK, stock_wilber_eek_64 },
{ GIMP_STOCK_FRAME, stock_frame_64 },
{ GIMP_STOCK_TEXTURE, stock_texture_64 }
};
......
......@@ -226,6 +226,7 @@ G_BEGIN_DECLS
#define GIMP_STOCK_WARNING "gimp-warning"
#define GIMP_STOCK_WILBER "gimp-wilber"
#define GIMP_STOCK_WILBER_EEK "gimp-wilber-eek"
#define GIMP_STOCK_FRAME "gimp-frame"
#define GIMP_STOCK_TEXTURE "gimp-texture"
......
......@@ -222,6 +222,7 @@ STOCK_DIALOG_IMAGES = \
stock-channel-red-48.png \
stock-error-64.png \
stock-floating-selection-48.png \
stock-frame-64.png \
stock-image-48.png \
stock-info-64.png \
stock-layer-48.png \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment