gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] fenfire/org/fenfire bin/fenpdf10.py demo/buoyoi...


From: Matti Katila
Subject: [Gzz-commits] fenfire/org/fenfire bin/fenpdf10.py demo/buoyoi...
Date: Mon, 11 Aug 2003 05:04:40 -0400

CVSROOT:        /cvsroot/fenfire
Module name:    fenfire
Branch:         
Changes by:     Matti Katila <address@hidden>   03/08/11 05:04:40

Modified files:
        org/fenfire/bin: fenpdf10.py 
        org/fenfire/demo: buoyoing.py fenpdfcontext.py 
        org/fenfire/view/buoy: actions.py 

Log message:
        mousemenu fixes + cleaning

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/bin/fenpdf10.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/demo/buoyoing.py.diff?tr1=1.107&tr2=1.108&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/demo/fenpdfcontext.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/view/buoy/actions.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: fenfire/org/fenfire/bin/fenpdf10.py
diff -u fenfire/org/fenfire/bin/fenpdf10.py:1.10 
fenfire/org/fenfire/bin/fenpdf10.py:1.11
--- fenfire/org/fenfire/bin/fenpdf10.py:1.10    Sat Aug  9 13:29:23 2003
+++ fenfire/org/fenfire/bin/fenpdf10.py Mon Aug 11 05:04:39 2003
@@ -22,6 +22,8 @@
 
 # The FenPDF 1.0 !
 
+from __future__ import nested_scopes
+
 dbg = 0
 
 def p(*s):
@@ -76,13 +78,7 @@
 
 from org.nongnu.alph.impl import PageImageScroll
 
-from org.fenfire.view.buoy.actions import \
-     AbstractAction, ZoomPan, ChangeSize, \
-     CanvasNodePressListener, \
-     NodeMover, PanMover, \
-     SelectArea, BrowseClick, IfSelectNodeOnPlane, \
-     MouseMenu
-     
+from org.fenfire.view.buoy import actions
 
 from org.fenfire.demo.fenpdfcontext import Context
 
@@ -236,34 +232,47 @@
 ff.view.buoy.AbstractMainNode2D.context = context
 
 
-# Default controls
+# Default controls for main view
 ## see 
http://himalia.it.jyu.fi/ffdoc/fenfire/pegboard/fenpdf_v1_spec_1--tjl/peg.gen.html
 and 'Bindings'
 mainMouse = vob.mouse.MouseMultiplexer()
 # With button 1
 mainMouse.setListener(1, 0,'Moving the pan around or the node if accursed.', \
-                      CanvasNodePressListener(context, \
-                      NodeMover(context), PanMover(context)))
+                      actions.CanvasNodePressListener(context, \
+                          actions.NodeMover(context), 
actions.PanMover(context)))
 mainMouse.setListener(1, vob.VobMouseEvent.SHIFT_MASK,
                       'Selecting area of main view.',
-                      SelectArea(context))
+                      actions.SelectArea(context))
 mainMouse.setListener(1, 0, 'Browse to clicked point in the main view',
-                      BrowseClick(context))
+                      actions.BrowseClick(context))
 
 # With button 3
 mainMouse.setListener(3, 0, mainMouse.VERTICAL, 1.0, \
-                      'Zooming the main view.', ZoomPan(context))
+                      'Zooming the main view.', actions.ZoomPan(context))
 mainMouse.setListener(3, 0, mainMouse.HORIZONTAL, 1.0, \
                       'Changing the size of main view (currently only for 
pagescroll).', # text
-                      ChangeSize(context))
+                      actions.ChangeSize(context))
 mainMouse.setListener(3, vob.VobMouseEvent.SHIFT_MASK,
                       'Select a node by click or unselect.',
-                      IfSelectNodeOnPlane(context))
+                      actions.IfSelectNodeOnPlane(context))
 mainMouse.setListener(3, 0, 'Show context menu if available (should be).',
-                      MouseMenu(context))
+                      actions.MouseMenu(context))
 
 # With wheel
 mainMouse.setWheelListener(0, 'Moving the pan', \
-                           PanMover(context))
+                           actions.PanMover(context))
+
+
+# Default controls for buoys
+buoyMouse = vob.mouse.MouseMultiplexer()
+# With button 1
+buoyMouse.setListener(1, 0, 'Follow the link buoy.',
+                      actions.BuoyFollowClick(context))
+
+# With button 3
+buoyMouse.setListener(3, 0, 'Show mouse menu for buoy', \
+                      actions.BuoyMouseMenu(context))
+
+
 
 
 plane = Nodes.get(paperA)
@@ -369,25 +378,26 @@
 
         if ev.getType() == ev.MOUSE_RELEASED:
             p('mainMouse released? - there\'s a bug in here!')
-            mousePrint(self.lastEvent, 'lastEvent')
+            mousePrint(self.context.states.lastEvent, 'lastEvent')
 
             # release event must go to mainMouse MouseMultiplexer to work 
correctly!
             # mainMouse.deliverEvent(ev)
             # flush implemented...
             mainMouse.flush()
+            buoyMouse.flush()
             
             self.context.clean()
             w.setCursor('default')
 
             # workaround..
-            if self.lastEvent.getType() == ev.MOUSE_PRESSED:
+            if self.context.states.lastEvent.getType() == ev.MOUSE_PRESSED:
                 p('workaround for a bug')
                 return 1
 
             # There is a bug in AbstractUpdateManager code(?) and that's why 
now is must to return.
             #return 1
             return 0
-        self.lastEvent = ev
+        self.context.states.lastEvent = ev
 
         # ...then see context
         if ev.getType() != ev.MOUSE_CLICKED:
@@ -404,6 +414,10 @@
 
 
     def buoyMouse(self, mgr, ev, single, link):
+        if buoyMouse.deliverEvent(ev):
+            vob.AbstractUpdateManager.chg()
+            return 1
+
         if ev.getType() != ev.MOUSE_CLICKED:
             return 1
 
Index: fenfire/org/fenfire/demo/buoyoing.py
diff -u fenfire/org/fenfire/demo/buoyoing.py:1.107 
fenfire/org/fenfire/demo/buoyoing.py:1.108
--- fenfire/org/fenfire/demo/buoyoing.py:1.107  Sat Aug  9 13:29:23 2003
+++ fenfire/org/fenfire/demo/buoyoing.py        Mon Aug 11 05:04:40 2003
@@ -226,6 +226,7 @@
 #irregu.type = 2
 
 plane = Nodes.get(paperA)
+plane = Nodes.get(ff.demo.bible.Bible('/home/mudyc/bible/finnish/1933,38/', 
ppAct, nodeview, fen).getPaper())
 planeHome = Nodes.get(paperHome)
 
 mainNode = ff.view.buoy.MainNode2D(plane, irregu, mainMouse)
@@ -366,16 +367,17 @@
             p('mainMouse released? - there\'s a bug in here!')
             #mousePrint(self.lastEvent, 'lastEvent')
             
-            # release event must go to mainMouse MouseMultiplexer to work 
correctly!
-            # mainMouse.deliverEvent(ev)
-            # flush implemented...
-            mainMouse.flush()
             
             self.context.clean()
             w.setCursor('default')
             
             # workaround..
             if self.lastEvent.getType() == ev.MOUSE_PRESSED:
+                # release event must go to mainMouse MouseMultiplexer to work 
correctly!
+                # mainMouse.deliverEvent(ev)
+                # flush implemented...
+                mainMouse.flush()
+
                 p('workaround for a bug')
                 return 1
             
Index: fenfire/org/fenfire/demo/fenpdfcontext.py
diff -u fenfire/org/fenfire/demo/fenpdfcontext.py:1.18 
fenfire/org/fenfire/demo/fenpdfcontext.py:1.19
--- fenfire/org/fenfire/demo/fenpdfcontext.py:1.18      Fri Aug  8 08:45:06 2003
+++ fenfire/org/fenfire/demo/fenpdfcontext.py   Mon Aug 11 05:04:40 2003
@@ -162,24 +162,68 @@
         self.ctrl = 0
         
 class MouseMenu:
-    def __init__(self):
-        style = vob.GraphicsAPI.getInstance().getTextStyle('sans', 0, 12)
-        self.list = vob.vobs.SelectListVob(style)
+    class Action:
+        def run(self):
+            pass
+
+    class LinkL(Action):
+        def __init__(self, states):
+            self.s = states
+        def run(self):
+            obj = self.s.objectOnPlane
+            pp = self.s.pp
+            pp.assocNotes(obj, 1, self.s.cursor.getAccursed())
+    class LinkR(Action):
+        def __init__(self, states):
+            self.s = states
+        def run(self):
+            obj = self.s.objectOnPlane
+            pp = self.s.pp
+            pp.assocNotes(obj, 1, self.s.cursor.getAccursed())
+    class UnLinkBuoy(Action):
+        def __init__(self, states):
+            self.s = states
+        def run(self):
+            pp = self.s.pp
+            pp.detachNotes(obj, 1, self.s.cursor.getAccursed())
+    
+    def __init__(self, states):
+        self.states = states
+        self.style = vob.GraphicsAPI.getInstance().getTextStyle('sans', 0, 12)
+        self.link = 0
+        self.makeMainList()
+        self.hideList()
+        
+    def makeMainList(self):
+        self.list = vob.vobs.SelectListVob(self.style)
         self.list.add('Test', 'test')
-        self.list.add('2. Test', 'test2')
-        self.list.add('3. Test', 'test3')
-        self.list.add('4. Test', 'test4')
+        if self.link:
+            self.list.add('Link nodes to left', self.LinkL(self.states))
+            self.list.add('Link nodes to rigth', self.LinkR(self.states))
         self.list.add('Go to home', 'home')
         self.list.add('Save & Quit', 'save_quit')
         self.list.add('Quit without save', 'quit')
-        self.hideList()
+
+    def makeBuoyList(self):
+        self.list = vob.vobs.SelectListVob(self.style)
+        self.list.add('Unlink buoy', 'unlink')
+        self.list.add('Go to home', 'home')
 
     def render(self, vs):
-        cs = vs.orthoBoxCS(0, "MOUSE_MENU",0, self.x, self.y-self.h/2,
+        cs = vs.orthoBoxCS(0, "MOUSE_MENU",-100, self.x, self.y-self.h/2,
                            1,1, self.w, self.h)
         vs.put(self.list, cs)
 
-    def showList(self, x, y):
+    def showList(self, x, y, who):
+        if who == 'buoymenu':
+            self.makeBuoyList()
+        elif who == 'mainmenu':
+            self.makeMainList()
+        else:
+            p('no mouse menu list!')
+            self.hideList()
+            return
+        
         self.w, self.h = self.list.width, self.list.height
         self.x, self.y = x, y
 
@@ -192,7 +236,9 @@
         key = vs.getKeyAt(cs, ev.getX(), ev.getY(), None)
         if key != None:
             key = key.object
-            p('mouse menu key is: ', key)
+            if isinstance(key, self.Action):
+                key.run()
+            else: p('mouse menu key is: ', key)
             self.hideList()
             return 1
 
@@ -206,7 +252,7 @@
         w = win
         self.states = ContextStates(fen, pp, spanImageFactory, nv)
         self.keys = KeyHandler(self.states)
-        self.mousemenu = MouseMenu()
+        self.mousemenu = MouseMenu(self.states)
         
         
     def setMngr(self, mngr):
Index: fenfire/org/fenfire/view/buoy/actions.py
diff -u fenfire/org/fenfire/view/buoy/actions.py:1.6 
fenfire/org/fenfire/view/buoy/actions.py:1.7
--- fenfire/org/fenfire/view/buoy/actions.py:1.6        Sat Aug  9 13:29:23 2003
+++ fenfire/org/fenfire/view/buoy/actions.py    Mon Aug 11 05:04:40 2003
@@ -20,6 +20,7 @@
 # 
 # 
 
+from __future__ import nested_scopes
 from org import fenfire as ff
 from org.fenfire.vocab import CANVAS2D, RDF
 import org.nongnu.libvob as vob
@@ -88,7 +89,12 @@
 class MouseMenu(AbstractAction, vob.mouse.MouseClickListener):
     def clicked(self, x, y):
         self.super()
-        self.context.mousemenu.showList(x,y)
+        obj = self.main.getNodeOnPlane(self.oldVS, x,y)
+        if obj != None:
+            self.context.states.objectOnPlane = obj
+            self.context.mousemenu.link = 1
+        else: self.context.mousemenu.link = 0
+        self.context.mousemenu.showList(x,y,'mainmenu')
         self.context.states.fastChg = 0
         vob.AbstractUpdateManager.setNoAnimation()
 
@@ -117,6 +123,7 @@
         obj = self.main.getNodeOnPlane(self.oldVS, x,y)
         pp = self.context.states.pp
         pp.assocNotes(obj, 1, self.context.states.cursor.getAccursed())
+        self.context.states.fastChg = 0
 
 
 ####### Actions to control selection (Ctrl pressed)
@@ -158,3 +165,36 @@
             return self.nodeMover
         return self.panMover
 
+
+
+
+
+
+
+#######################################################################
+#######################################################################
+#####                                                             #####
+#####   Actions for buoys.                                        #####
+#####                                                             #####
+#######################################################################
+#######################################################################
+
+    
+class BuoyMouseMenu(AbstractAction, vob.mouse.MouseClickListener):
+    def clicked(self, x, y):
+        self.super()
+        mgr = self.context.states.mgr
+        p('hit',mgr.buoyHit)
+        self.context.mousemenu.showList(x,y, 'buoymenu')
+        self.context.states.fastChg = 0
+        vob.AbstractUpdateManager.setNoAnimation()
+
+class BuoyFollowClick(AbstractAction, vob.mouse.MouseClickListener):
+    def clicked(self, x,y):
+        self.super()
+        mgr = self.context.states.mgr
+        p('hit',mgr.buoyHit, mgr.buoyHit.single)
+        mgr.buoyHit.single.followLink(mgr.buoyHit.link)
+        self.context.states.fastChg = 0
+
+        




reply via email to

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