app: allow adding and removing sliders to/from a GimpToolLine

Add support for adding and removing sliders to/from a GimpToolLine,
using three new signals:

  - can-add-slider:  Takes a double argument in the range [0,1],
    indicating a location along the line, and returns a boolean
    value, indicating whether a slider can be added at that
    location.

  - add-slider:  Takes a double argument in the range [0,1],
    indicating a location along the line, for which can-add-slider
    returned TRUE.  In response, should add a new slider at that
    location, and return its index, or a negative value if no
    slider was added.

  - remove-slider:  Takes a slider index.  In response, may remove
    the slider.

On the UI side, when the cursor is close enough to the line, but
not within the hit area of an existing handle, GimpToolLine checks
if a slider can be added at the cursor position, using can-add-
slider.  If a slider can be added, a dashed circle appears at the
cursor position along the line, indicating where a slider will be
added.  The cursor is added by clicking, which emits an add-slider
signal; if the signal returns a slider index, the new slider is
selected, and can be subsequently dragged.

Removing a slider is done by either selecting the slider and
pressing backspace (or delete, although we don't actually forward
it to the tool atm,) or by "tearing" the slider: when dragging
the slider, if the cursor is far enough from the liner, a dashed
circle appears around the slider, and releasing the mouse removes
the slider.
This commit is contained in:
Ell
2017-07-23 19:06:11 -04:00
parent 86954037de
commit bac7dac4ba
3 changed files with 291 additions and 57 deletions

View File

@ -60,7 +60,13 @@ struct _GimpToolLineClass
GimpToolWidgetClass parent_class;
/* signals */
void (* selection_changed) (GimpToolLine *line);
gboolean (* can_add_slider) (GimpToolLine *line,
gdouble value);
gint (* add_slider) (GimpToolLine *line,
gdouble value);
void (* remove_slider) (GimpToolLine *line,
gint slider);
void (* selection_changed) (GimpToolLine *line);
};