[haiku-commits] Re: haiku: hrev46641 - src/preferences/keymap

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 04 Jan 2014 22:12:47 +0100

On 01/04/2014 06:05 PM, Humdinger wrote:
Not this way.
But this should work:

BRect rect(ceilf(keyFrame.left * fFactor), ceilf(keyFrame.top *
      fFactor), 0, 0);
rect.right = floorf(keyFrame.Width() * fFactor + rect.left - fGap - 1);
rect.bottom = floorf(keyFrame.Height() * fFactor + rect.top - fGap - 1);

That would work, thanks.
But is this really nice and elegant? If you could do the complete
initializing(?) in one go, I'd see it, but like this...

I wait on a nod of axel before committing stuff I may have to revert again. :)

Good thinking :-)
IIRC, directly after this line, there was a call to rect.OffsetBy(). So you could do this:

BRect rect(0, 0, floorf(keyFrame.Width() * fFactor - fGap - 1),
        floorf(keyFrame.Height() * fFactor - fGap - 1));
rect.OffsetBy(ceilf(keyFrame.left * fFactor),
        ceilf(keyFrame.top * fFactor));

and add the previous offset-by values to that one.

Bye,
   Axel.


Other related posts: