[haiku-development] Re: R1/a4 initial planning

  • From: François Revol <revol@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 02 Mar 2012 13:12:18 +0100

On 02/03/2012 04:12, Ingo Weinhold wrote:
> 
> I find most of the app kit nice, too, but I wouldn't go overboard with the 
> praise.
> The event loop mechanism in Qt is rather similar to how BLooper/BHandler 
> works,
> with the difference that the events are typed. Which IMO is much
preferrable for
> event handling and intra-app communication. In the former case the
BMessage::Find*()
> calls are just silly -- with typed events the data can be accessed
directly via getters.
> In the latter case it is very annoying to send objects around. Either
you archive them
> -- which could be expensive or might not even be possible -- or you
send a pointer --
> which requires object lifetime considerations (e.g. transferring
references, which in
> turn requires explicit handling of all possible points of failure in
the messaging process).

Well it should be possible to design some event classes, like

BMouseEvent {
BMouseEvent(BMessage *msg);
BMessage *Message(); // if fMessage not set, creates one and fills it.

BMessage *fMessage;
public:
float x, y;
float tilt;
uint32 buttons;
}

That can be used on stack like:

void
MyView::MouseMoved(...)
{
        BMouseEvent event(Looper()->CurrentMessage());
        ... event.x ...

        // stupid case but...
        event.tilt = 0.5;
        foo->PostMessage(event.Message());
}

François.

Other related posts: