## GwyCurve

GwyCurve — Widget that displays editable curves

## Synopsis

    #include <libgwydgets/gwydgets.h>

                        GwyPoint;
                        GwyChannelData;
                        GwyCurve;
                        GwyCurveClass;
    GtkWidget*          gwy_curve_new                       (void);
    void                gwy_curve_reset                     (GwyCurve *curve);
    void                gwy_curve_set_range                 (GwyCurve *curve,
                                                             gdouble min_x,
                                                             gdouble max_x,
                                                             gdouble min_y,
                                                             gdouble max_y);
    void                gwy_curve_set_curve_type            (GwyCurve *curve,
                                                             GwyCurveType type);
    void                gwy_curve_set_channels              (GwyCurve *curve,
                                                             gint num_channels,
                                                             GwyRGBA *colors);
    void                gwy_curve_set_control_points        (GwyCurve *curve,
                                                             GwyChannelData *channel_data,
                                                             gboolean prune);
    void                gwy_curve_get_control_points        (GwyCurve *curve,
                                                             GwyChannelData *channel_data,
                                                             gboolean triplets);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkDrawingArea
                               +----GwyCurve

## Implemented Interfaces

GwyCurve implements AtkImplementorIface and GtkBuildable.

## Properties

      "curve-type"               GwyCurveType          : Read / Write
      "max-x"                    gfloat                : Read / Write
      "max-y"                    gfloat                : Read / Write
      "min-x"                    gfloat                : Read / Write
      "min-y"                    gfloat                : Read / Write
      "snap"                     gboolean              : Read / Write

## Signals

      "curve-edited"                                   : Run First
      "curve-type-changed"                             : Run First

## Description

GwyCurve is a widget that can display multiple curves. The user can edit these curves by clicking and dragging control points. New control points are created when a user clicks on a part of a curve where there are no control points. Control points can be deleted by dragging ontop of another control point.

## Details

### GwyPoint

    typedef struct {
        gdouble x;
        gdouble y;
    } GwyPoint;

### GwyChannelData

    typedef struct {
        /* curve points: */
        gint num_points;
        GwyPoint *points;

        /* control points: */
        gint num_ctlpoints;
        GwyPoint *ctlpoints;

        GwyRGBA color;
    } GwyChannelData;

### GwyCurve

    typedef struct _GwyCurve GwyCurve;

### GwyCurveClass

    typedef struct {
        GtkDrawingAreaClass parent_class;

        /* Signals */
        void (*curve_type_changed)(GwyCurve *curve);
        void (*curve_edited)(GwyCurve *curve);

        /* Padding for future expansion */
        void (*_gwy_reserved1) (void);
        void (*_gwy_reserved2) (void);
        void (*_gwy_reserved3) (void);
        void (*_gwy_reserved4) (void);
    } GwyCurveClass;

### gwy_curve_new ()

    GtkWidget*          gwy_curve_new                       (void);

Creates GwyCurve widget. By default, the widget will have 3 curves.

Returns : | new GwyCurve widget.

### gwy_curve_reset ()

    void                gwy_curve_reset                     (GwyCurve *curve);

Removes all control points, resetting the curves to their initial state.

`curve` : | a GwyCurve widget.

### gwy_curve_set_range ()

    void                gwy_curve_set_range                 (GwyCurve *curve,
                                                             gdouble min_x,
                                                             gdouble max_x,
                                                             gdouble min_y,
                                                             gdouble max_y);

`curve` : |
`min_x` : |
`max_x` : |
`min_y` : |
`max_y` : |

### gwy_curve_set_curve_type ()

    void                gwy_curve_set_curve_type            (GwyCurve *curve,
                                                             GwyCurveType type);

`curve` : |
`type` : |

### gwy_curve_set_channels ()

    void                gwy_curve_set_channels              (GwyCurve *curve,
                                                             gint num_channels,
                                                             GwyRGBA *colors);

`curve` : |
`num_channels` : |
`colors` : |

### gwy_curve_set_control_points ()

    void                gwy_curve_set_control_points        (GwyCurve *curve,
                                                             GwyChannelData *channel_data,
                                                             gboolean prune);

`curve` : |
`channel_data` : |
`prune` : |

### gwy_curve_get_control_points ()

    void                gwy_curve_get_control_points        (GwyCurve *curve,
                                                             GwyChannelData *channel_data,
                                                             gboolean triplets);

`curve` : |
`channel_data` : |
`triplets` : |

## Property Details

### The `"curve-type"` property

      "curve-type"               GwyCurveType          : Read / Write

Is this curve linear, spline interpolated, or free-form.

Default value: GWY_CURVE_TYPE_LINEAR

### The `"max-x"` property

      "max-x"                    gfloat                : Read / Write

Maximum possible X value.

Default value: 1

### The `"max-y"` property

      "max-y"                    gfloat                : Read / Write

Maximum possible value for Y.

Default value: 1

### The `"min-x"` property

      "min-x"                    gfloat                : Read / Write

Minimum possible value for X.

Default value: 0

### The `"min-y"` property

      "min-y"                    gfloat                : Read / Write

Minimum possible value for Y.

Default value: 0

### The `"snap"` property

      "snap"                     gboolean              : Read / Write

Snap to control points mode.

Default value: TRUE

## Signal Details

### The `"curve-edited"` signal

    void                user_function                      (GwyCurve *gwycurve,
                                                            gpointer  user_data)      : Run First

`gwycurve` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.

### The `"curve-type-changed"` signal

    void                user_function                      (GwyCurve *gwycurve,
                                                            gpointer  user_data)      : Run First

`gwycurve` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.