Mir

Code review comment for lp:~andreas-pokorny/mir/add-geometry-transformation

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think the right answer is to expose a simple interface to convert screen coordinates (touch/pointer coords) into surface space by adding a function:

  geometry::Point Surface::screen_to_local(geometry:Point const& p) const
  {
      // calculate some answer using transformation(), top_left() and size() info.
      // You may even wish to ignore per-surface transformations and only return valid results
      // when transformation() == identity. In which case it could be as trivial as:
      // return p - top_left();
      // or more complicated like:
      // auto centre = top_left() + (size() / 2);
      // return inverse(transformation()) * (p - centre);
  }

That's a function instead of a class. It doesn't even need to be a method of Surface because it just uses existing public interface functions.

« Back to merge proposal