gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gzz-commits] fenfire/org/fenfire demo/buoyoing.py util/Contr...


From: Matti Katila
Subject: Re: [Gzz-commits] fenfire/org/fenfire demo/buoyoing.py util/Contr...
Date: Tue, 24 Jun 2003 10:44:49 +0300 (EEST)

Hi Benja, 

I didn't fully understand your changes so please comment.


On Mon, 23 Jun 2003, Benja Fallenstein wrote:
> Log message:
>       small steps in event handling
> 
> 
> Patches:
> Index: fenfire/org/fenfire/demo/buoyoing.py
> diff -u fenfire/org/fenfire/demo/buoyoing.py:1.78 
> fenfire/org/fenfire/demo/buoyoing.py:1.79
> --- fenfire/org/fenfire/demo/buoyoing.py:1.78 Mon Jun 23 08:37:04 2003
> +++ fenfire/org/fenfire/demo/buoyoing.py      Mon Jun 23 14:16:19 2003
> @@ -47,6 +47,8 @@
>  
>  from org.nongnu.alph.impl import PageImageScroll
>  
> +from org.fenfire.demo.actions import *
> +
>  
>  import vob
>  w.setCursor('wait')
> @@ -112,6 +114,105 @@
>      ppAct.assocNotes(noteHome, 1, noteA1)
>  
>  
> +ctrl = ff.util.ControlBinding()
> +ctrl.add(MovePanFast(), -1, ctrl.WHEEL, 7,0, ctrl.VERTICAL)
> +ctrl.add(MovePanFast(), 1, ctrl.DRAG, 1, 0, ctrl.ALL)
> +ctrl.add(MovePanSlow(), 1, ctrl.CLICK)
> +ctrl.add(ZoomPan(), 3, ctrl.DRAG, 1, 0, ctrl.VERTICAL)
> +ctrl.add(PanSize(), 3, ctrl.DRAG, 1, 0, ctrl.HORIZONTAL)
> +ctrl.add(UnSelectNodeOnPlane(), 3, ctrl.CLICK)
> +
> +node_ctrl = ff.util.ControlBinding()
> +node_ctrl.add(SelectNodeOnPlane(), 3, node_ctrl.CLICK)
> +node_ctrl.add(MoveNodeOnPlane(), 1, node_ctrl.DRAG)

This is ok for me.


[...]

> +#                     return
> +
> +#                 if self.controlMains.handleEvent(mngr.singles[i].mainNode, 
> ev, mngr.vs):
> +#                mngr.replaceScene = mngr.vs
> +#                vob.AbstractUpdateManager.setNoAnimation()
> +#            vob.AbstractUpdateManager.chg()
> +#            return
> +
> +#         # ...then see context
> +#         if ev.getID() != ev.MOUSE_CLICKED:
> +#             return
> +#         self.context.setMainNodeIndex(self.lastIndex)
> +#         planes = []
> +#         for single in mngr.singles:
> +#             planes.append(single.getMainNode())
> +#         newPlanes = self.context.doMouse(ev, mngr.vs, planes)
> +#         if newPlanes != None and planes != newPlanes:
> +#             for i in range(0, len(newPlanes)):
> +#                 mngr.singles[i] = vob.buoy.buoymanager.SingleFocusManager(
> +#                     newPlanes[i],
> +#                     mngr.connectors)
> +#             vob.AbstractUpdateManager.chg()

Now context events don't get handled. If buoymanager handles events it 
should know only about buoys. The problem with buoymanager, as an event 
handler, is that it doesn't give a change to handle other events than 
those directly associated with buoys or main nodes(Ok, this can be 
changed but does it make the code more beautiful anyway?).

For example moving notes worked with old code. Moving notes were done with 
dragging which usually is implemented like:

   if mouse():
       setNoAnimation()
       replaceVobScene()
   UpdateMngr.chg()

That code cannot be used because vobscene must change(probably this will 
change in future =) if note's coordinates change.


> -    def mouse(self, mngr, ev):
> -#        pa(ev)
> -        
> -     if hasattr(mngr.geometer, 'mouse') and \
> -               mngr.geometer.mouse(ev, mngr.vs):
> -         return 
> -     x, y = ev.getX(), ev.getY()
> -     cs = mngr.vs.getCSAt(0, x, y, None)
> -
> -        if ev.getID() == ev.MOUSE_RELEASED:
> -            w.setCursor('default')
> -            for ctrl in self.controls:
> -                ctrl.removePressState()
> -            return
> -        if ev.getID() == ev.MOUSE_DRAGGED:
> -            for ctrl in self.controls:
> -                if ctrl.hasPressState():
> -                    ctrl.handleEvent(None, ev, mngr.vs)
> -                    if ctrl.replaceVS:
> -                        mngr.replaceScene = mngr.vs
> -                 vob.AbstractUpdateManager.setNoAnimation()
> -                    vob.AbstractUpdateManager.chg()
> -                    return

That code made it possible to drag in the whole window.


> -     ### Fall through if no link - need main node
> -     for i in range(0, len(mngr.singles)):
> -         if mngr.singles[i].mainNode.isHitInsidePlane(x,y,mngr.vs):
> -                self.context.setMainNodeIndex(i)
> -                self.lastIndex = i
> -
> -                ### See if there's something on a plane.
> -                obj = mngr.singles[i].mainNode.getNodeOnPlane(mngr.vs, x,y)
> -                if obj != None and \
> -                       self.controlNodesOnMain.hasBinding(ev):
> -                    if self.controlNodesOnMain.handleEvent( \
> -                        Pair(mngr.singles[i].mainNode, obj), ev, mngr.vs):
> -                        # can't replace vobscene!!
> -                        #  mngr.replaceScene = mngr.vs
> -                        vob.AbstractUpdateManager.setNoAnimation()
> -                    vob.AbstractUpdateManager.chg()
> -                    return

That code made it possible to move notes etc. We discussed about this in 
irc and you said this can be done with controller interface in 
AbstractMainNode2D. I still don't understand why do we have to put any 
event in AbstractMainNode2D because it just controls the Focus and we can 
control the Focus from outside. 

I would remove anything related to events from BuoyViewMainNode interface.
It was not like that when the buoyoing was new thing but now I can see 
things differently. Event handling in MainNode2D is fine if we talk about
small programs and want reusable demo code fast. Can you convince me that 
I am wrong with this?


> Index: fenfire/org/fenfire/util/ControlBinding.java
> diff -u fenfire/org/fenfire/util/ControlBinding.java:1.5 
> fenfire/org/fenfire/util/ControlBinding.java:1.6
> --- fenfire/org/fenfire/util/ControlBinding.java:1.5  Mon Jun 23 08:30:42 2003
> +++ fenfire/org/fenfire/util/ControlBinding.java      Mon Jun 23 14:16:19 2003
> @@ -56,7 +56,6 @@
>  
>      static private boolean FAST = true;
>      static private boolean ANIMATE = false;
> -    public boolean replaceVS = true;

Yes this was fast kludge. Unfortunately it worked, do you have 
better working ideas?

>          if (event.getID() == event.MOUSE_PRESSED) {
>              pressState = event;
>              return FAST;
> -        }
> +        } else if(event.getID() == event.MOUSE_RELEASED) {
> +         removePressState();
> +         return FAST;
> +     }

This probably doesn't work. Before I wrote something about dragging. See 
that code.


> diff -u fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.24 
> fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.25
> --- fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java:1.24        Mon Jun 
> 23 08:25:52 2003
> +++ fenfire/org/fenfire/view/buoy/AbstractMainNode2D.java     Mon Jun 23 
> 14:16:19 2003
> @@ -26,8 +26,9 @@
>  
>  package org.fenfire.view.buoy;
>  import org.fenfire.view.*;
> -
>  import org.fenfire.view.View2D;
> +import org.fenfire.util.ControlBinding;
> +
>  import org.nongnu.libvob.*;
>  import org.nongnu.libvob.impl.DefaultVobMatcher;
>  import org.nongnu.libvob.buoy.*;
> @@ -47,6 +48,9 @@
>      protected Object plane;
>      public Object getPlane() { return plane; }
>  
> +    /** The controller associated with this main node. */
> +    protected ControlBinding controller;
> +
>      /** An object representing a focus on a 2D plane.
>       *  The SimpleFocus implementation below just stores
>       *  an X and Y coordinate, but other implementations
> @@ -105,9 +109,9 @@
>      protected float boxw, boxh;
>  
>      public AbstractMainNode2D(Object plane, View2D view2d,
> -                           Focus focus) {
> +                           Focus focus, ControlBinding controller ) {

I do not understand why something which is just an util is given in one 
of the parameters.


   -Matti





reply via email to

[Prev in Thread] Current Thread [Next in Thread]