[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Events, tools and pointer devices
From:       Thomas Zander <zander () kde ! org>
Date:       2006-10-13 19:38:07
Message-ID: 200610132138.08092.zander () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Friday 13 October 2006 21:07, Boudewijn Rempt wrote:
> I thought the idea was not just to determine whether we should change
> tools, but to actually forward the events to the current tool.

In the start of my email I used the word 'proxy' indeed. But later I stopped 
using that and corrected myself in stating we really only need one or two 
methods on the ToolManager.

So, the KoToolManager can just have the factory method for our event and keep 
on using the member of the canvas to actually forward the events to.

Note we will not eliminate the usage of the m_tool member in Canvas even if we 
stop forwarding events directly from the canvas.

But who calls KoTool::mousePressEvent? I would prefer it if all event routing 
to the tools went through the KoToolManager for the following reasons:

> * consistency -- having the move events, but not the others go through
> KoToolManager is confusing.

I think you misunderstood. Nothing goes via the toolManager.

> * encapsulation -- if the toolmanager is the sole way to get the current
> tool to do something, we never have to worry about things getting out of
> sync, which would be possible if both the canvas implementation and the
> toolmanager have their own pointers to the current tool.

This doesn't make sense to me.
the toolmanager sets the tool on the canvas. There is no way things can get 
out of sync.

In short;
KWCanvas::mouseMoveEvent(QMouseEvent *event) {
  KoPointerEvent *pe = KoToolManager::instance()->create(event);
  m_tool->mouseMoveEvent(pe);
  delete pe;
}

KWCanvas::tabletEvent(QTabletEvent *event) {
  KoPointerEvent *pe = KoToolManager::instance()->create(event);
  switch(event->type()) {
   case QEvent::TabletMove:
     m_tool->mouseMoveEvent(pe); break;
    case QEvent::TabletPress:
       // foo bar
    case QEvent::TabletRelease:
    case QEvent::TabletEnterProximity:
    case QEvent::TabletLeaveProximity:
    default:
  }
  delete pe; 
}


-- 
Thomas Zander

[Attachment #5 (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic