Commit d4cb1623 authored by Ell's avatar Ell

app: add persistent handle selection to GimpToolLine

En route to on-canvas gradient editing, add support for persistent
handle selection to GimpToolLine (a handle being either an endpoint
or a slider).  Handles are selected through clicking, however,
unlike before, the selection persists after the mouse is released.
A new "selection" property specifies the currently-selected handle
(who knows, maybe in the future we'll add multi-selection), and a
new "selection-changed" signal is emitted when the selection changes.

The visual feedback has been changed to better suit the new behavior,
and the behaviors yet to be added:  The selected handle is marked
using highlighting; the highlighting doesn't change while hovering
over other handles.  Only the hit-test circle is used as hover
indication, however, we use a fixed-size circle, and only show the
circle for the currently hovered-over handle -- no more trippy
expanding circles :)

A few minor changes along the way:

  - The selected handle is now the (first) one that's closest to the
    cursor, instead of the first one to pass hit-testing.

  - We don't move the selectd handle upon button-press, only upon
    motion, so that handles can be selected without moving them.

  - Show a MOVE cursor modifier when hovering over a handle.
parent 042650e1
This diff is collapsed.
......@@ -25,6 +25,17 @@
#include "gimptoolwidget.h"
/* in the context of GimpToolLine, "handle" is a collective term for either an
* endpoint or a slider. a handle value may be either a (nonnegative) slider
* index, or one of the values below:
*/
#define GIMP_TOOL_LINE_HANDLE_NONE (-3)
#define GIMP_TOOL_LINE_HANDLE_START (-2)
#define GIMP_TOOL_LINE_HANDLE_END (-1)
#define GIMP_TOOL_LINE_HANDLE_IS_SLIDER(handle) ((handle) >= 0)
#define GIMP_TYPE_TOOL_LINE (gimp_tool_line_get_type ())
#define GIMP_TOOL_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_LINE, GimpToolLine))
#define GIMP_TOOL_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_LINE, GimpToolLineClass))
......@@ -47,22 +58,29 @@ struct _GimpToolLine
struct _GimpToolLineClass
{
GimpToolWidgetClass parent_class;
/* signals */
void (* selection_changed) (GimpToolLine *line);
};
GType gimp_tool_line_get_type (void) G_GNUC_CONST;
GType gimp_tool_line_get_type (void) G_GNUC_CONST;
GimpToolWidget * gimp_tool_line_new (GimpDisplayShell *shell,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
GimpToolWidget * gimp_tool_line_new (GimpDisplayShell *shell,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
void gimp_tool_line_set_sliders (GimpToolLine *line,
const GimpControllerSlider *sliders,
gint n_sliders);
const GimpControllerSlider * gimp_tool_line_get_sliders (GimpToolLine *line,
gint *n_sliders);
void gimp_tool_line_set_sliders (GimpToolLine *line,
const GimpControllerSlider *sliders,
gint n_sliders);
const GimpControllerSlider * gimp_tool_line_get_sliders (GimpToolLine *line,
gint *n_sliders);
void gimp_tool_line_set_selection (GimpToolLine *line,
gint handle);
gint gimp_tool_line_get_selection (GimpToolLine *line);
#endif /* __GIMP_TOOL_LINE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment