There are now 24 bugs that have a 2.4 milestone and 6 of these are
related or directly uses the code in app/tools/gimprectangletool.c.

As most of you know the code in there is a mess. In the last few days
I've been thinking about a way to clean up this mess, and I have a plan
I'd like to throw out there in an attempt to synchronize the direction
we are taking the code in.

With the introduction of helper functions like

void gimp_rectangle_tool_constrain_aspect (GimpRectangleTool
*rectangle_tool, gdouble aspect, const gchar *apply_on_x, const gchar
  /* apply_on_x may be "x1", "x2" or "center_x", same for on_y */

and verbose comments and member/variables names, it would be possible to
 apply these modifications on the rectangle in different order depending
on the state of GimpRectangleOptions

We would also avoid weaving in different logic on the same line of code,
which currently is what the code in gimp_rectangle_tool_motion is
horribly close to doing.

For a taste of what I mean, checkout this patch:

attached to this bug:
(CTRL modifier on a selection does not snap the starting corner back...)

It introduces e.g.

void gimp_rectangle_tool_set_other_side_coord (GimpRectangleTool
*rectangle_tool, gint other_side_x, gint other_side_y)

and verbose commenting.

Personally I intend to realize this plan in the following weeks, I just
wanted to throw it out to the mailing list. Partly because, as I said,
to synchronize the direction the code is taking, but also to get
feedback and to avoid clashes with other Big Plans.

- Martin Nordholts

Gimp-developer mailing list

Reply via email to