## GwyGradientSwatch

GwyGradientSwatch — A swatch displaying a colour

## Functions

GtkWidget * | gwy_gradient_swatch_new ()
void | gwy_gradient_swatch_set_gradient ()
GwyGradient * | gwy_gradient_swatch_get_gradient ()
void | gwy_gradient_swatch_set_use_alpha ()
gboolean | gwy_gradient_swatch_get_use_alpha ()
void | gwy_gradient_swatch_set_editable ()
gboolean | gwy_gradient_swatch_get_editable ()
void | gwy_gradient_swatch_set_has_marker ()
gboolean | gwy_gradient_swatch_get_has_marker ()
void | gwy_gradient_swatch_set_adjustment ()
GtkAdjustment * | gwy_gradient_swatch_get_adjustment ()

## Properties

GtkAdjustment * | adjustment | Read / Write
gboolean | editable | Read / Write
GwyGradient * | gradient | Read / Write
gboolean | has-marker | Read / Write
gboolean | use-alpha | Read / Write

## Types and Values

struct | GwyGradientSwatch
struct | GwyGradientSwatchClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GwyGradientSwatch

## Implemented Interfaces

GwyGradientSwatch implements AtkImplementorIface and GtkBuildable.

## Includes

    #include <libgwyui/gwyui.h>

## Description

The widget is a simple rectangle displaying a colour gradient, with some support for visualisation of the alpha value.

## Functions

### gwy_gradient_swatch_new()

    GtkWidget *
    gwy_gradient_swatch_new (void);

Creates a new color swatch.

#### Returns

A new color swatch.

### gwy_gradient_swatch_set_gradient()

    void
    gwy_gradient_swatch_set_gradient (GwyGradientSwatch *swatch,
                                      GwyGradient *gradient);

Sets the current gradient of a gradient swatch.

The gradient can be `NULL`. The default gradient is then displayed, although it is not terribly useful.

#### Parameters

swatch | A gradient swatch. |
gradient | The gradient to display. |

### gwy_gradient_swatch_get_gradient()

    GwyGradient *
    gwy_gradient_swatch_get_gradient (GwyGradientSwatch *swatch);

Obtains the current gradient displayed by a gradient swatch.

#### Parameters

swatch | A gradient swatch. |

#### Returns

The displayed gradient.

### gwy_gradient_swatch_set_use_alpha()

    void
    gwy_gradient_swatch_set_use_alpha (GwyGradientSwatch *swatch,
                                       gboolean use_alpha);

Sets whether a gradient swatch should use the alpha channel.

#### Parameters

swatch | A gradient swatch. |
use_alpha | `TRUE` if gradient swatch should visualise the alpha channel, `FALSE` to ignore it. |

### gwy_gradient_swatch_get_use_alpha()

    gboolean
    gwy_gradient_swatch_get_use_alpha (GwyGradientSwatch *swatch);

Reports whether a gradient swatch uses the alpha channel.

#### Parameters

swatch | A gradient swatch. |

#### Returns

`TRUE` if the gradient swatch visualises alpha channel, `FALSE` if it ignores it.

### gwy_gradient_swatch_set_editable()

    void
    gwy_gradient_swatch_set_editable (GwyGradientSwatch *swatch,
                                      gboolean editable);

Sets whether a gradient swatch adjustment is user editable.

Making the swatch editable permits the user to move the marker. It is possible, although possibly confusing to the user, to make the swatch editable while keeping the marker disabled. It will respond identically as if the marker was visible.

#### Parameters

swatch | A gradient swatch. |
editable | `TRUE` to let user modify the adjustment value. |

### gwy_gradient_swatch_get_editable()

    gboolean
    gwy_gradient_swatch_get_editable (GwyGradientSwatch *swatch);

Reports whether a gradient swatch is user editable.

#### Parameters

swatch | A gradient swatch. |

#### Returns

`TRUE` if the adjustment is user-editable.

### gwy_gradient_swatch_set_has_marker()

    void
    gwy_gradient_swatch_set_has_marker (GwyGradientSwatch *swatch,
                                        gboolean has_marker);

Sets whether a gradient swatch should have a marker.

Use `gwy_gradient_swatch_set_editable()` to make the marker user-editable or passive. By default, the marker is passive.

#### Parameters

swatch | A gradient swatch. |
has_marker | `TRUE` to add an editable marker, `FALSE` to remove it. |

### gwy_gradient_swatch_get_has_marker()

    gboolean
    gwy_gradient_swatch_get_has_marker (GwyGradientSwatch *swatch);

Reports whether a gradient swatch should have a marker.

#### Parameters

swatch | A gradient swatch. |

#### Returns

`TRUE` if the swatch has a marker, `FALSE` if it does not have any.

### gwy_gradient_swatch_set_adjustment()

    void
    gwy_gradient_swatch_set_adjustment (GwyGradientSwatch *swatch,
                                        GtkAdjustment *adj);

Sets the adjustment used for the editable marker of a gradient swatch.

Often the implicitly created adjustment is sufficient. If you do not set any adjustment and enable a marker or editability, an implicit adjustment with [0,1] range is created. It is also created when you pass `NULL` as `adj` and the swatch already has a marker or is editable.

#### Parameters

swatch | A gradient swatch. |
adj | New adjustment to use. | [nullable]

### gwy_gradient_swatch_get_adjustment()

    GtkAdjustment *
    gwy_gradient_swatch_get_adjustment (GwyGradientSwatch *swatch);

Gets the adjustment used for the editable marker of a gradient swatch.

Connect to the returned adjustment to watch marker movement. If the gradient swatch has never had an editable marker (nor any adjustment set explicitly) the function can return `NULL`.

#### Parameters

swatch | A gradient swatch. |

#### Returns

The adjustment or `NULL`.

[nullable]

## Types and Values

### struct GwyGradientSwatch

    struct GwyGradientSwatch;

### struct GwyGradientSwatchClass

    struct GwyGradientSwatchClass {
        GtkWidgetClass parent_class;
    };

## Property Details

### The `“adjustment”` property

      “adjustment”               GtkAdjustment *

Adjustment used with the marker.

Owner: GwyGradientSwatch

Flags: Read / Write

### The `“editable”` property

      “editable”                 gboolean

Whether the adjustment is user-editable.

Owner: GwyGradientSwatch

Flags: Read / Write

Default value: FALSE

### The `“gradient”` property

      “gradient”                 GwyGradient *

Color gradient to display.

Owner: GwyGradientSwatch

Flags: Read / Write

### The `“has-marker”` property

      “has-marker”               gboolean

Whether the swatch has a marker.

Owner: GwyGradientSwatch

Flags: Read / Write

Default value: FALSE

### The `“use-alpha”` property

      “use-alpha”                gboolean

Whether to display the color with an alpha value.

Owner: GwyGradientSwatch

Flags: Read / Write

Default value: FALSE