DirectDialog--removal of model-loading by default and a bug-fix

Signed-off-by: rdb <git@rdb.name>
This commit is contained in:
alan eborn 2014-10-15 15:06:25 +00:00 committed by rdb
parent 223620e27e
commit 2e555db30e

View File

@ -94,8 +94,9 @@ class DirectDialog(DirectFrame):
('text', '', None), ('text', '', None),
('text_align', TextNode.ALeft, None), ('text_align', TextNode.ALeft, None),
('text_scale', 0.06, None), ('text_scale', 0.06, None),
('image', DGG.getDefaultDialogGeom(), None), ('image', None, None),
('relief', None, None), ('relief', DGG.RAISED, None),
('borderWidth', (0.01, 0.01), None),
('buttonTextList', [], DGG.INITOPT), ('buttonTextList', [], DGG.INITOPT),
('buttonGeomList', [], DGG.INITOPT), ('buttonGeomList', [], DGG.INITOPT),
('buttonImageList', [], DGG.INITOPT), ('buttonImageList', [], DGG.INITOPT),
@ -210,6 +211,12 @@ class DirectDialog(DirectFrame):
bounds = self.stateNodePath[0].getTightBounds() bounds = self.stateNodePath[0].getTightBounds()
if image: if image:
image.reparentTo(self.stateNodePath[0]) image.reparentTo(self.stateNodePath[0])
if bounds is None:
l = 0
r = 0
b = 0
t = 0
else:
l = bounds[0][0] l = bounds[0][0]
r = bounds[1][0] r = bounds[1][0]
b = bounds[0][2] b = bounds[0][2]
@ -246,6 +253,12 @@ class DirectDialog(DirectFrame):
bl = br = bb = bt = 0 bl = br = bb = bt = 0
for button in self.buttonList: for button in self.buttonList:
bounds = button.stateNodePath[0].getTightBounds() bounds = button.stateNodePath[0].getTightBounds()
if bounds is None:
bl = 0
br = 0
bb = 0
bt = 0
else:
bl = min(bl, bounds[0][0]) bl = min(bl, bounds[0][0])
br = max(br, bounds[1][0]) br = max(br, bounds[1][0])
bb = min(bb, bounds[0][2]) bb = min(bb, bounds[0][2])
@ -303,6 +316,7 @@ class DirectDialog(DirectFrame):
# reduce bottom by pad, button height and 2*button pad # reduce bottom by pad, button height and 2*button pad
b = min(b - self['midPad'] - bpad[1] - bHeight - bpad[1], b) - pad[1] b = min(b - self['midPad'] - bpad[1] - bHeight - bpad[1], b) - pad[1]
t = t + self['topPad'] + pad[1] t = t + self['topPad'] + pad[1]
self['frameSize'] = (l, r, b, t)
self['image_scale'] = (r - l, 1, t - b) self['image_scale'] = (r - l, 1, t - b)
# Center frame about text and buttons # Center frame about text and buttons
self['image_pos'] = ((l+r)*0.5, 0.0, (b+t)*0.5) self['image_pos'] = ((l+r)*0.5, 0.0, (b+t)*0.5)