1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimptoolrectangle.h
5  * Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
6  *
7  * Based on GimpRectangleTool
8  * Copyright (C) 2007 Martin Nordholts
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef __GIMP_TOOL_RECTANGLE_H__
25 #define __GIMP_TOOL_RECTANGLE_H__
26 
27 
28 #include "gimptoolwidget.h"
29 
30 
31 typedef enum
32 {
33   GIMP_TOOL_RECTANGLE_DEAD,
34   GIMP_TOOL_RECTANGLE_CREATING,
35   GIMP_TOOL_RECTANGLE_MOVING,
36   GIMP_TOOL_RECTANGLE_RESIZING_UPPER_LEFT,
37   GIMP_TOOL_RECTANGLE_RESIZING_UPPER_RIGHT,
38   GIMP_TOOL_RECTANGLE_RESIZING_LOWER_LEFT,
39   GIMP_TOOL_RECTANGLE_RESIZING_LOWER_RIGHT,
40   GIMP_TOOL_RECTANGLE_RESIZING_LEFT,
41   GIMP_TOOL_RECTANGLE_RESIZING_RIGHT,
42   GIMP_TOOL_RECTANGLE_RESIZING_TOP,
43   GIMP_TOOL_RECTANGLE_RESIZING_BOTTOM,
44   GIMP_TOOL_RECTANGLE_AUTO_SHRINK,
45   GIMP_TOOL_RECTANGLE_EXECUTING,
46   GIMP_N_TOOL_RECTANGLE_FUNCTIONS
47 } GimpRectangleFunction;
48 
49 
50 #define GIMP_TYPE_TOOL_RECTANGLE            (gimp_tool_rectangle_get_type ())
51 #define GIMP_TOOL_RECTANGLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_RECTANGLE, GimpToolRectangle))
52 #define GIMP_TOOL_RECTANGLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_RECTANGLE, GimpToolRectangleClass))
53 #define GIMP_IS_TOOL_RECTANGLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_RECTANGLE))
54 #define GIMP_IS_TOOL_RECTANGLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_RECTANGLE))
55 #define GIMP_TOOL_RECTANGLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_RECTANGLE, GimpToolRectangleClass))
56 
57 
58 typedef struct _GimpToolRectangle        GimpToolRectangle;
59 typedef struct _GimpToolRectanglePrivate GimpToolRectanglePrivate;
60 typedef struct _GimpToolRectangleClass   GimpToolRectangleClass;
61 
62 struct _GimpToolRectangle
63 {
64   GimpToolWidget            parent_instance;
65 
66   GimpToolRectanglePrivate *private;
67 };
68 
69 struct _GimpToolRectangleClass
70 {
71   GimpToolWidgetClass  parent_class;
72 
73   /*  signals  */
74 
75   gboolean (* change_complete) (GimpToolRectangle *rectangle);
76 };
77 
78 
79 GType    gimp_tool_rectangle_get_type         (void) G_GNUC_CONST;
80 
81 GimpToolWidget * gimp_tool_rectangle_new      (GimpDisplayShell       *shell);
82 
83 GimpRectangleFunction
84          gimp_tool_rectangle_get_function     (GimpToolRectangle      *rectangle);
85 void     gimp_tool_rectangle_set_function     (GimpToolRectangle      *rectangle,
86                                                GimpRectangleFunction   function);
87 
88 void     gimp_tool_rectangle_set_constraint   (GimpToolRectangle      *rectangle,
89                                                GimpRectangleConstraint constraint);
90 GimpRectangleConstraint
91          gimp_tool_rectangle_get_constraint   (GimpToolRectangle      *rectangle);
92 
93 void     gimp_tool_rectangle_get_public_rect  (GimpToolRectangle      *rectangle,
94                                                gdouble                *pub_x1,
95                                                gdouble                *pub_y1,
96                                                gdouble                *pub_x2,
97                                                gdouble                *pub_y2);
98 
99 void     gimp_tool_rectangle_pending_size_set (GimpToolRectangle      *rectangle,
100                                                GObject                *object,
101                                                const gchar            *width_property,
102                                                const gchar            *height_property);
103 
104 void     gimp_tool_rectangle_constraint_size_set
105                                               (GimpToolRectangle      *rectangle,
106                                                GObject                *object,
107                                                const gchar            *width_property,
108                                                const gchar            *height_property);
109 
110 gboolean gimp_tool_rectangle_rectangle_is_first
111                                               (GimpToolRectangle      *rectangle);
112 gboolean gimp_tool_rectangle_rectangle_is_new (GimpToolRectangle      *rectangle);
113 gboolean gimp_tool_rectangle_point_in_rectangle
114                                               (GimpToolRectangle      *rectangle,
115                                                gdouble                 x,
116                                                gdouble                 y);
117 
118 void     gimp_tool_rectangle_frame_item       (GimpToolRectangle      *rectangle,
119                                                GimpItem               *item);
120 void     gimp_tool_rectangle_auto_shrink      (GimpToolRectangle      *rectrectangle,
121                                                gboolean                shrink_merged);
122 
123 
124 #endif /* __GIMP_TOOL_RECTANGLE_H__ */
125