1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimptoolline.h
5  * Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __GIMP_TOOL_LINE_H__
22 #define __GIMP_TOOL_LINE_H__
23 
24 
25 #include "gimptoolwidget.h"
26 
27 
28 /* in the context of GimpToolLine, "handle" is a collective term for either an
29  * endpoint or a slider.  a handle value may be either a (nonnegative) slider
30  * index, or one of the values below:
31  */
32 #define GIMP_TOOL_LINE_HANDLE_NONE  (-3)
33 #define GIMP_TOOL_LINE_HANDLE_START (-2)
34 #define GIMP_TOOL_LINE_HANDLE_END   (-1)
35 
36 #define GIMP_TOOL_LINE_HANDLE_IS_SLIDER(handle) ((handle) >= 0)
37 
38 
39 #define GIMP_TYPE_TOOL_LINE            (gimp_tool_line_get_type ())
40 #define GIMP_TOOL_LINE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_LINE, GimpToolLine))
41 #define GIMP_TOOL_LINE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_LINE, GimpToolLineClass))
42 #define GIMP_IS_TOOL_LINE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_LINE))
43 #define GIMP_IS_TOOL_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_LINE))
44 #define GIMP_TOOL_LINE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_LINE, GimpToolLineClass))
45 
46 
47 typedef struct _GimpToolLine        GimpToolLine;
48 typedef struct _GimpToolLinePrivate GimpToolLinePrivate;
49 typedef struct _GimpToolLineClass   GimpToolLineClass;
50 
51 struct _GimpToolLine
52 {
53   GimpToolWidget       parent_instance;
54 
55   GimpToolLinePrivate *private;
56 };
57 
58 struct _GimpToolLineClass
59 {
60   GimpToolWidgetClass  parent_class;
61 
62   /*  signals  */
63   gboolean (* can_add_slider)           (GimpToolLine        *line,
64                                          gdouble              value);
65   gint     (* add_slider)               (GimpToolLine        *line,
66                                          gdouble              value);
67   void     (* prepare_to_remove_slider) (GimpToolLine        *line,
68                                          gint                 slider,
69                                          gboolean             remove);
70   void     (* remove_slider)            (GimpToolLine        *line,
71                                          gint                 slider);
72   void     (* selection_changed)        (GimpToolLine        *line);
73   gboolean (* handle_clicked)           (GimpToolLine        *line,
74                                          gint                 handle,
75                                          GdkModifierType      state,
76                                          GimpButtonPressType  press_type);
77 };
78 
79 
80 GType                        gimp_tool_line_get_type      (void) G_GNUC_CONST;
81 
82 GimpToolWidget             * gimp_tool_line_new           (GimpDisplayShell           *shell,
83                                                            gdouble                     x1,
84                                                            gdouble                     y1,
85                                                            gdouble                     x2,
86                                                            gdouble                     y2);
87 
88 void                         gimp_tool_line_set_sliders   (GimpToolLine               *line,
89                                                            const GimpControllerSlider *sliders,
90                                                            gint                        n_sliders);
91 const GimpControllerSlider * gimp_tool_line_get_sliders   (GimpToolLine               *line,
92                                                            gint                       *n_sliders);
93 
94 void                         gimp_tool_line_set_selection (GimpToolLine               *line,
95                                                            gint                        handle);
96 gint                         gimp_tool_line_get_selection (GimpToolLine               *line);
97 
98 
99 #endif /* __GIMP_TOOL_LINE_H__ */
100