users: Improve avatar crop mechanics

The resizing and movement mechanics for the avatar crop can be finicky, because:

  1. The crop resets to the last valid crop when you drag out of range, so that a somewhat quick drag does not go to the edge.
  2. A corner drag only works in one direction, as the use of eval_radial_line is not correct.
  3. A side drag acts the same as a corner drag.
  4. A slow drag won't move the crop, especially if the widget is larger.

All these issues are fixed with this partial rewrite of the resize and movement logic:

  1. A drag out of range will result in a size that is guaranteed to touch the edge, making a crop to the edge much easier.
  2. Instead of fixing eval_radial_line, we just "bind" one side to the pointer position, making both directions act the same for a corner drag.
  3. A side drag now scales around the center for the orthogonal side.
  4. Rounding errors in calculating the previous delta are prevented.

Note that the behavior is now similar to how for example a textbox is resized in LibreOffice Writer (while holding shift). I am sure there are more examples of similar mechanics.



The videos demonstrate the issues and fixes (on top of !1824 (merged) to make it easier to see).

This problem was also shown in #2514 (closed).

Edited by velsinki

Merge request reports