1 |
|
from __future__ import nested_scopes |
2 |
|
|
3 |
"""A pagespan scroll shown in a buoy view. |
"""A pagespan scroll shown in a buoy view. |
4 |
|
|
5 |
An interesting point: if this is from a transclusion, we |
An interesting point: if this is from a transclusion, we |
9 |
""" |
""" |
10 |
|
|
11 |
import jarray |
import jarray |
12 |
|
import java |
13 |
|
|
14 |
# Page span scrollblock as a whole; |
# Page span scrollblock as a whole; |
15 |
# in buoys, a part is shown. |
# in buoys, a part is shown. |
16 |
|
|
17 |
import gzz |
import gzz |
18 |
|
import gfx |
19 |
from gzz.view.buoy import BuoyViewNodeType, BuoyViewMainNode |
from gzz.view.buoy import BuoyViewNodeType, BuoyViewMainNode |
20 |
|
from gfx.util.misc import coloredQuad |
21 |
|
|
22 |
pscv = gzz.view.PageSpanCellView() |
pscv = gzz.view.PageSpanCellView() |
23 |
pscv.useBg = 0 |
pscv.useBg = 0 |
54 |
|
|
55 |
class AnchorPageSpanNodeType(AbstractPageSpanNodeType): |
class AnchorPageSpanNodeType(AbstractPageSpanNodeType): |
56 |
def renderBuoy(self, vs, into, linkId, anchorSpan, layout): |
def renderBuoy(self, vs, into, linkId, anchorSpan, layout): |
57 |
|
if 1: |
58 |
|
dbg1 = vs.unitSqCS(into, "U") |
59 |
|
vs.put(coloredQuad((1,0,0)), dbg1) |
60 |
|
|
61 |
if layout == None: |
if layout == None: |
62 |
layout = pscv.getLayout(anchorSpan.getScrollBlock()) |
layout = pscv.getLayout(anchorSpan.getScrollBlock()) |
63 |
|
vs.coords.getSqSize(into, size) |
64 |
|
extents = layout.getExtents(anchorSpan, None) |
65 |
|
print "ExtentsInit: ", [i for i in extents] |
66 |
|
print "size: ", [s for s in size] |
67 |
|
scalex = size[0] / extents[2] |
68 |
|
scaley = size[1] / extents[3] |
69 |
|
scale = min(scalex, scaley) |
70 |
|
|
71 |
|
# Shift it so we hit the given cs exactly |
72 |
|
# extents[0] -= .5 * (scalex / scale - 1) * extents[2] |
73 |
|
# extents[1] -= .5 * (scaley / scale - 1) * extents[3] |
74 |
|
extents[2] *= scalex / scale |
75 |
|
extents[3] *= scaley / scale |
76 |
|
|
77 |
|
print "Extents: ", [i for i in extents] |
78 |
|
|
79 |
|
paperCS = vs.orthoCS(into, "paper", 0, -extents[0] * scale, |
80 |
|
-extents[1] * scale, scale, scale) |
81 |
|
|
82 |
|
irregu = gfx.libutil.effects.IrreguFrame(0, 0, layout.w, layout.h, |
83 |
|
.05, .25, type="square") |
84 |
|
# irregu = gfx.libutil.effects.IrreguFrame(-100, -100, 100*layout.w, 100*layout.h, |
85 |
|
# .05, .25, type="square") |
86 |
|
|
87 |
|
paperLoc = vs.coords.ortho(0, 0, extents[0], extents[1], extents[2], extents[3]) |
88 |
|
vs.matcher.add(paperCS, paperLoc, "VIEWPORT") |
89 |
|
|
90 |
|
class FrameR(java.lang.Runnable): |
91 |
|
def run(rself): |
92 |
|
vs.map.put(irregu.frame, paperCS, paperLoc) |
93 |
|
class ContentR(java.lang.Runnable): |
94 |
|
def run(rself): |
95 |
|
vs.map.put(irregu.content, paperCS, paperLoc) |
96 |
|
class LayoutR(java.lang.Runnable): |
97 |
|
def run(rself): |
98 |
|
layout.place(vs, paperCS, .5, 200, into) |
99 |
|
|
100 |
|
gzz.gfx.gl.Stencil.drawStenciled(vs, ContentR(), None, FrameR(), LayoutR(), 1) |
101 |
|
|
102 |
|
|
103 |
# XXX!!!! |
# XXX!!!! |
104 |
# Irregu! |
# Irregu! |
105 |
# find edges of span |
# find edges of span |
106 |
# should place only that region surrounded by irregu |
# should place only that region surrounded by irregu |
|
layout.place(vs, into, .5, 200, into) |
|
107 |
return into |
return into |
108 |
|
|
109 |
size = jarray.zeros(3, 'f') |
size = jarray.zeros(3, 'f') |