mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
*** empty log message ***
This commit is contained in:
parent
41656709f5
commit
2fddc9ceed
@ -19,6 +19,7 @@ class Button(DirectObject):
|
|||||||
bottom = None,
|
bottom = None,
|
||||||
top = None):
|
top = None):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.width = width
|
||||||
# if no label given, use the button name
|
# if no label given, use the button name
|
||||||
if (label == None):
|
if (label == None):
|
||||||
label = self.name
|
label = self.name
|
||||||
@ -30,6 +31,11 @@ class Button(DirectObject):
|
|||||||
|
|
||||||
self.l1 = Label.textLabel(self.label, Label.ButtonUp,
|
self.l1 = Label.textLabel(self.label, Label.ButtonUp,
|
||||||
scale, width, drawOrder, font)
|
scale, width, drawOrder, font)
|
||||||
|
|
||||||
|
if width == None:
|
||||||
|
width = self.l1.getWidth() / scale
|
||||||
|
self.width = width
|
||||||
|
|
||||||
self.l2 = Label.textLabel(self.label, Label.ButtonLit,
|
self.l2 = Label.textLabel(self.label, Label.ButtonLit,
|
||||||
scale, width, drawOrder, font)
|
scale, width, drawOrder, font)
|
||||||
self.l3 = Label.textLabel(self.label, Label.ButtonDown,
|
self.l3 = Label.textLabel(self.label, Label.ButtonDown,
|
||||||
@ -50,6 +56,10 @@ class Button(DirectObject):
|
|||||||
self.l1 = Label.modelLabel(label, 1, 1,
|
self.l1 = Label.modelLabel(label, 1, 1,
|
||||||
scale = scale,
|
scale = scale,
|
||||||
drawOrder = drawOrder)
|
drawOrder = drawOrder)
|
||||||
|
|
||||||
|
if width == None:
|
||||||
|
width = self.l1.getWidth() / scale
|
||||||
|
self.width = width
|
||||||
|
|
||||||
self.l2 = self.l1
|
self.l2 = self.l1
|
||||||
self.l3 = self.l1
|
self.l3 = self.l1
|
||||||
@ -57,6 +67,8 @@ class Button(DirectObject):
|
|||||||
else:
|
else:
|
||||||
# label provided, use it for all labels
|
# label provided, use it for all labels
|
||||||
self.l1 = self.l2 = self.l3 = label
|
self.l1 = self.l2 = self.l3 = label
|
||||||
|
if width == None:
|
||||||
|
width = self.l1.getWidth()
|
||||||
|
|
||||||
self.button = GuiButton.GuiButton(self.name, self.l1, self.l2,
|
self.button = GuiButton.GuiButton(self.name, self.l1, self.l2,
|
||||||
self.l3, self.l3, self.l1)
|
self.l3, self.l3, self.l1)
|
||||||
@ -87,8 +99,7 @@ class Button(DirectObject):
|
|||||||
return self.button
|
return self.button
|
||||||
|
|
||||||
def getWidth(self):
|
def getWidth(self):
|
||||||
# assume all labels have the same width
|
return self.width
|
||||||
return self.l1.getWidth()
|
|
||||||
|
|
||||||
def setWidth(self, width):
|
def setWidth(self, width):
|
||||||
self.l1.setWidth(width)
|
self.l1.setWidth(width)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user