mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Improve buffer viewer display:
Buffer views no longer go off screen except when there are way too many buffers (since the min buffer frame size is now 5 pixels). Fix a case where too many buffers being displayed results in a divide by zero.
This commit is contained in:
parent
dc3173c1fb
commit
615d92440f
@ -343,8 +343,9 @@ class BufferViewer(DirectObject):
|
|||||||
# an 800x600 display. Then, it double checks that the
|
# an 800x600 display. Then, it double checks that the
|
||||||
# readout will fit on the screen, and if not, it shrinks it.
|
# readout will fit on the screen, and if not, it shrinks it.
|
||||||
|
|
||||||
if (float(self.sizex)==0.0) and (float(self.sizey)==0.0):
|
bordersize = 4.0
|
||||||
|
|
||||||
|
if (float(self.sizex)==0.0) and (float(self.sizey)==0.0):
|
||||||
sizey = int(0.4266666667 * base.win.getYSize())
|
sizey = int(0.4266666667 * base.win.getYSize())
|
||||||
sizex = (sizey * aspectx) / aspecty
|
sizex = (sizey * aspectx) / aspecty
|
||||||
v_sizey = (base.win.getYSize() - (rows-1) - (rows*2)) / rows
|
v_sizey = (base.win.getYSize() - (rows-1) - (rows*2)) / rows
|
||||||
@ -352,23 +353,27 @@ class BufferViewer(DirectObject):
|
|||||||
if (v_sizey < sizey) or (v_sizex < sizex):
|
if (v_sizey < sizey) or (v_sizex < sizex):
|
||||||
sizey = v_sizey
|
sizey = v_sizey
|
||||||
sizex = v_sizex
|
sizex = v_sizex
|
||||||
h_sizex = (base.win.getXSize() - (cols-1) - (cols*2)) / cols
|
|
||||||
|
adjustment = 2
|
||||||
|
h_sizex = float (base.win.getXSize() - adjustment) / float (cols)
|
||||||
|
|
||||||
|
h_sizex -= bordersize
|
||||||
|
if (h_sizex < 1.0):
|
||||||
|
h_sizex = 1.0
|
||||||
|
|
||||||
h_sizey = (h_sizex * aspecty) / aspectx
|
h_sizey = (h_sizex * aspecty) / aspectx
|
||||||
if (h_sizey < sizey) or (h_sizex < sizex):
|
if (h_sizey < sizey) or (h_sizex < sizex):
|
||||||
sizey = h_sizey
|
sizey = h_sizey
|
||||||
sizex = h_sizex
|
sizex = h_sizex
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
sizex = int(self.sizex * 0.5 * base.win.getXSize())
|
sizex = int(self.sizex * 0.5 * base.win.getXSize())
|
||||||
sizey = int(self.sizey * 0.5 * base.win.getYSize())
|
sizey = int(self.sizey * 0.5 * base.win.getYSize())
|
||||||
if (sizex == 0): sizex = (sizey*aspectx) / aspecty
|
if (sizex == 0): sizex = (sizey*aspectx) / aspecty
|
||||||
if (sizey == 0): sizey = (sizex*aspecty) / aspectx
|
if (sizey == 0): sizey = (sizex*aspecty) / aspectx
|
||||||
|
|
||||||
# Convert from pixels to render2d-units.
|
# Convert from pixels to render2d-units.
|
||||||
|
fsizex = (2.0 * sizex) / float(base.win.getXSize())
|
||||||
fsizex = (2.0*sizex) / float(base.win.getXSize())
|
fsizey = (2.0 * sizey) / float(base.win.getYSize())
|
||||||
fsizey = (2.0*sizey) / float(base.win.getYSize())
|
|
||||||
fpixelx = 2.0 / float(base.win.getXSize())
|
fpixelx = 2.0 / float(base.win.getXSize())
|
||||||
fpixely = 2.0 / float(base.win.getYSize())
|
fpixely = 2.0 / float(base.win.getYSize())
|
||||||
|
|
||||||
@ -399,8 +404,9 @@ class BufferViewer(DirectObject):
|
|||||||
index = c + r*cols
|
index = c + r*cols
|
||||||
if (index < ncards):
|
if (index < ncards):
|
||||||
index = (index + self.cardindex) % len(cards)
|
index = (index + self.cardindex) % len(cards)
|
||||||
posx = dirx * (1.0 - fsizex*0.5 - 3*fpixelx - (c*(fsizex+6*fpixelx)))
|
|
||||||
posy = diry * (1.0 - fsizey*0.5 - 3*fpixely - (r*(fsizey+6*fpixely)))
|
posx = dirx * (1.0 - ((c + 0.5) * (fsizex + fpixelx * bordersize))) - (fpixelx * dirx)
|
||||||
|
posy = diry * (1.0 - ((r + 0.5) * (fsizey + fpixely * bordersize))) - (fpixely * diry)
|
||||||
placer = NodePath("card-structure")
|
placer = NodePath("card-structure")
|
||||||
placer.setPos(posx, 0, posy)
|
placer.setPos(posx, 0, posy)
|
||||||
placer.setScale(fsizex*0.5, 1.0, fsizey*0.5)
|
placer.setScale(fsizex*0.5, 1.0, fsizey*0.5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user