GimpUi.PreviewArea

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned GimpUi.PreviewArea GimpUi.PreviewArea Gtk.Buildable->Gtk.Widget Gtk.DrawingArea Gtk.DrawingArea Gtk.DrawingArea->GimpUi.PreviewArea Gtk.Widget->Gtk.DrawingArea

Subclasses:

None

Methods

Inherited:

Gtk.DrawingArea (1), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)

Structs:

Gtk.WidgetClass (12), GObject.ObjectClass (5)

class

new ()

blend (x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, opacity)

draw (x, y, width, height, type, buf, rowstride)

fill (x, y, width, height, red, green, blue)

get_size ()

mask (x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, mask, rowstride_mask)

menu_popup (event)

reset ()

set_color_config (config)

set_colormap (colormap, num_colors)

set_max_size (width, height)

set_offsets (x, y)

Virtual Methods

Inherited:

Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

Properties

Inherited:

Gtk.Widget (39)

Name

Type

Flags

Short Description

check-custom-color1

Gegl.Color

r/w

The first color of the checkerboard pattern indicating transparency

check-custom-color2

Gegl.Color

r/w

The second color of the checkerboard pattern indicating transparency

check-size

Gimp.CheckSize

r/w

The size of the checkerboard pattern indicating transparency

check-type

Gimp.CheckType

r/w

The colors of the checkerboard pattern indicating transparency

Style Properties

Inherited:

Gtk.Widget (17)

Signals

Inherited:

Gtk.Widget (69), GObject.Object (1)

Fields

Inherited:

Gtk.Widget (69), GObject.Object (1)

Class Details

class GimpUi.PreviewArea(**kwargs)
Bases:

Gtk.DrawingArea

Abstract:

No

Structure:

GimpUi.PreviewAreaClass

A general purpose preview widget which caches its pixel data.

classmethod new()
Returns:

a new GimpUi.PreviewArea widget.

Since GIMP 2.2

Return type:

Gtk.Widget

Creates a new GimpUi.PreviewArea widget.

If the preview area is used to draw an image with transparency, you might want to default the checkboard size and colors to user-set Preferences. To do this, you may set the following properties on the newly created GimpUi.PreviewArea:

g_object_set (area,
"check-size",          gimp_check_size (),
"check-type",          gimp_check_type (),
"check-custom-color1", gimp_check_custom_color1 (),
"check-custom-color2", gimp_check_custom_color2 (),
NULL);
blend(x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, opacity)
Parameters:
  • x (int) – x offset in preview

  • y (int) – y offset in preview

  • width (int) – buffer width

  • height (int) – buffer height

  • type (Gimp.ImageType) – the Gimp.ImageType of buf1 and buf2

  • buf1 (bytes) – a #guchar buffer that contains the pixel data for the lower layer

  • rowstride1 (int) – rowstride of buf1

  • buf2 (bytes) – a #guchar buffer that contains the pixel data for the upper layer

  • rowstride2 (int) – rowstride of buf2

  • opacity (int) – The opacity of the first layer.

Composites buf1 on buf2 with the given opacity, draws the result to self and queues a redraw on the given rectangle.

Since GIMP 2.2

draw(x, y, width, height, type, buf, rowstride)
Parameters:
  • x (int) – x offset in preview

  • y (int) – y offset in preview

  • width (int) – buffer width

  • height (int) – buffer height

  • type (Gimp.ImageType) – the Gimp.ImageType of buf

  • buf (bytes) – a #guchar buffer that contains the preview pixel data.

  • rowstride (int) – rowstride of buf

Draws buf on self and queues a redraw on the given rectangle.

Since GIMP 2.2

fill(x, y, width, height, red, green, blue)
Parameters:
  • x (int) – x offset in preview

  • y (int) – y offset in preview

  • width (int) – width of the rectangle to fill

  • height (int) – height of the rectangle to fill

  • red (int) – red component of the fill color (0-255)

  • green (int) – green component of the fill color (0-255)

  • blue (int) – red component of the fill color (0-255)

Fills the given rectangle of self in the given color and queues a redraw.

Since GIMP 2.2

get_size()
Returns:

width:

The preview areay width

height:

The preview areay height

Return type:

(width: int, height: int)

Gets the preview area size

mask(x, y, width, height, type, buf1, rowstride1, buf2, rowstride2, mask, rowstride_mask)
Parameters:
  • x (int) – x offset in preview

  • y (int) – y offset in preview

  • width (int) – buffer width

  • height (int) – buffer height

  • type (Gimp.ImageType) – the Gimp.ImageType of buf1 and buf2

  • buf1 (bytes) – a #guchar buffer that contains the pixel data for the lower layer

  • rowstride1 (int) – rowstride of buf1

  • buf2 (bytes) – a #guchar buffer that contains the pixel data for the upper layer

  • rowstride2 (int) – rowstride of buf2

  • mask (bytes) – a #guchar buffer representing the mask of the second layer.

  • rowstride_mask (int) – rowstride for the mask.

Composites buf1 on buf2 with the given mask, draws the result on self and queues a redraw on the given rectangle.

Since GIMP 2.2

menu_popup(event)
Parameters:

event (Gdk.EventButton or None) – the button event that causes the menu to popup or None

Creates a popup menu that allows one to configure the size and type of the checkerboard pattern that the self uses to visualize transparency.

New in version 2.2.

reset()

Reset any previous drawing done through [class`GimpUi`.PreviewArea] functions.

New in version 3.0.

set_color_config(config)
Parameters:

config (Gimp.ColorConfig) – a Gimp.ColorConfig object.

Sets the color management configuration to use with this preview area.

New in version 2.10.

set_colormap(colormap, num_colors)
Parameters:
  • colormap (bytes) – a #guchar buffer that contains the colormap

  • num_colors (int) – the number of colors in the colormap

Sets the colormap for the GimpUi.PreviewArea widget. You need to call this function before you use GimpUi.PreviewArea.draw() with an image type of Gimp.ImageType.INDEXED_IMAGE or Gimp.ImageType.INDEXEDA_IMAGE.

Since GIMP 2.2

set_max_size(width, height)
Parameters:
  • width (int) – the maximum width in pixels or -1 to unset the limit

  • height (int) – the maximum height in pixels or -1 to unset the limit

Usually a GimpUi.PreviewArea fills the size that it is allocated. This function allows you to limit the preview area to a maximum size. If a larger size is allocated for the widget, the preview will draw itself centered into the allocated area.

New in version 2.2.

set_offsets(x, y)
Parameters:
  • x (int) – horizontal offset

  • y (int) – vertical offset

Sets the offsets of the previewed area. This information is used when drawing the checkerboard and to determine the dither offsets.

New in version 2.2.

Property Details

GimpUi.PreviewArea.props.check_custom_color1
Name:

check-custom-color1

Type:

Gegl.Color

Default Value:

<Color object at 0x000000000000 (GeglColor at 0x0000000)>

Flags:

READABLE, WRITABLE

The first color of the checkerboard pattern indicating transparency

GimpUi.PreviewArea.props.check_custom_color2
Name:

check-custom-color2

Type:

Gegl.Color

Default Value:

<Color object at 0x000000000000 (GeglColor at 0x0000000)>

Flags:

READABLE, WRITABLE

The second color of the checkerboard pattern indicating transparency

GimpUi.PreviewArea.props.check_size
Name:

check-size

Type:

Gimp.CheckSize

Default Value:

Gimp.CheckSize.MEDIUM_CHECKS

Flags:

READABLE, WRITABLE

The size of the checkerboard pattern indicating transparency

GimpUi.PreviewArea.props.check_type
Name:

check-type

Type:

Gimp.CheckType

Default Value:

Gimp.CheckType.GRAY_CHECKS

Flags:

READABLE, WRITABLE

The colors of the checkerboard pattern indicating transparency