root/plgtkimageview/ImageToolSelector.xs

Revision 462, 4.4 kB (checked in by jeffrey, 1 year ago)

fixed some test failures

Line 
1 #include "gtkimageviewperl.h"
2
3
4 MODULE = Gtk2::ImageView::Tool::Selector  PACKAGE = Gtk2::ImageView::Tool::Selector  PREFIX = gtk_image_tool_selector_
5
6 =for object Gtk2::ImageView::Tool::Selector Image tool for selecting rectangular regions
7
8 =head1 DESCRIPTION
9
10 Gtk2::ImageView::Tool::Selector is a tool for selecting areas of an image. It is useful for cropping an image, for example. The tool is an implementor of the Gtk2::ImageView::Tool inteface which means that it can be plugged into a Gtk2::ImageView by using the Gtk2::ImageView::Tool::set_tool() method.
11
12 Gtk2::ImageView::Tool::Selector changes the default display of the Gtk2::ImageView. It darkens down the unselected region of the image which provides a nice effect and makes it clearer what part of the image that is currently selected. Unfortunately, this effect is somewhat incompatible with how Gtk2::ImageView::Nav behaves because that widget will show the image without darkening it.
13
14 The tool also changes the default behaviour of the mouse. When a Gtk2::ImageView::Tool::Selector is set on a Gtk2::ImageView, mouse presses do not "grab" the image and you cannot scroll by dragging. Instead mouse presses and dragging is used to resize and move the selection rectangle. When the mouse drags the selection rectangle to the border of the widget, the view autoscrolls which is a convenient way for a user to position the selection.
15
16 Please note that Gtk2::ImageView::Tool::Selector draws the image in two layers. One darkened and the selection rectangle in normal luminosity. Because it uses two draw operations instead one one like Gtk2::ImageView::Tool::Dragger does, it is significantly slower than that tool. Therefore, it makes sense for a user of this library to set the interpolation to GDK_INTERP_NEAREST when using this tool to ensure that performance is acceptable to the users of the program.
17
18 =head2 Zoom bug
19
20 There is a small bug in Gtk2::ImageView::Tool::Selector that becomes apparent when the zoom factor is greater than about 30. The edge of the selection rectangle may in that case intersect a pixel.
21
22 The bug is caused by bug 389832 in gdk-pixbuf. There is no way to solve this bug on Gtk2::ImageView's level (but if someone knows how, I'd really like to know).
23
24 =cut
25
26
27 =for apidoc
28
29 Creates a new selector tool for the specified view with default values. The default values are:
30
31 =over
32
33 =item  selection : (0, 0) - [0, 0]
34
35 =back
36
37 =over
38
39 =item view : a Gtk2::ImageView.
40
41 =back
42
43 =head3 Returns
44
45 =over
46
47 =item a new Gtk2::ImageView::Tool::Selector
48
49 =back
50
51 =cut
52 GtkIImageTool *
53 gtk_image_tool_selector_new (class, view)
54                 GtkImageView *  view
55         C_ARGS:
56                 view
57
58
59 =for apidoc
60
61 Returns a Gtk2::Gdk::Rectangle with the current selection. If either the width or the height of the selection is zero, then nothing is selected and undef is returned. See "selection-changed" for an example.
62
63 =over
64
65 =item selector : a Gtk2::ImageView::Tool::Selector
66
67 =back
68
69 =head3 Returns
70
71 =over
72
73 =item a Gtk2::Gdk::Rectangle with the current selection.
74
75 =back
76
77 =cut
78 ## call as $rectangle = $selector->get_selection
79 ## void gtk_image_tool_selector_get_selection (GtkImageToolSelector *selector, GdkRectangle *rect);
80 GdkRectangle_copy *
81 gtk_image_tool_selector_get_selection (selector)
82                 GtkImageToolSelector *  selector
83         PREINIT:
84                 GdkRectangle    rect = { 0, };
85         CODE:
86                 gtk_image_tool_selector_get_selection(selector, &rect);
87                 if (!rect.width || !rect.height)
88                         XSRETURN_UNDEF;
89                 RETVAL = ▭
90         OUTPUT:
91                 RETVAL
92
93
94 =for apidoc
95
96 Sets the selection rectangle for the tool. Setting this attribute will cause the widget to immidiately repaint itself if its view is realized.
97
98 This method does nothing under the following circumstances:
99
100 =over
101
102 =item If the views pixbuf is NULL.
103
104 =item If rect is wider or taller than the size of the pixbuf
105
106 =item If rect equals the current selection rectangle.
107
108 =back
109
110 If the selection falls outside the pixbufs area, its position is moved so that it is within the pixbuf.
111
112 Calling this method causes the ::selection-changed signal to be emitted.
113
114 The default selection is (0,0) - [0,0].
115
116 =over
117
118 =item selector : a Gtk2::ImageView::Tool::Selector
119
120 =item rect : Selection rectangle in image space coordinates.
121
122 =back
123
124 =cut
125 ## call as $selector->set_selection($rectangle)
126 ## void gtk_image_tool_selector_set_selection (GtkImageToolSelector *selector, GdkRectangle *rect);
127 void
128 gtk_image_tool_selector_set_selection (selector, rect)
129                 GtkImageToolSelector *  selector
130                 GdkRectangle_ornull *   rect
131
Note: See TracBrowser for help on using the browser.