+class glNotification(glFrame):
+ def __init__(self, parent, pos):
+ self._anim = None
+ super(glNotification, self).__init__(parent, pos)
+ glGuiLayoutGrid(self)._alignBottom = False
+ self._label = glLabel(self, "Notification", (0, 0))
+ self._buttonExtra = glButton(self, 31, "???", (1, 0), self.onExtraButton, 25)
+ self._button = glButton(self, 30, "", (2, 0), self.onClose, 25)
+ self._padding = glLabel(self, "", (0, 1))
+ self.setHidden(True)
+
+ def setSize(self, x, y, w, h):
+ w, h = self._layout.getLayoutSize()
+ baseSize = self._base.GetSizeTuple()
+ if self._anim is not None:
+ super(glNotification, self).setSize(baseSize[0] / 2 - w / 2, baseSize[1] - self._anim.getPosition() - self._base._buttonSize * 0.2, 1, 1)
+ else:
+ super(glNotification, self).setSize(baseSize[0] / 2 - w / 2, baseSize[1] - self._base._buttonSize * 0.2, 1, 1)
+
+ def draw(self):
+ self.setSize(0,0,0,0)
+ self.updateLayout()
+ super(glNotification, self).draw()
+
+ def message(self, text, extraButtonCallback = None, extraButtonIcon = None, extraButtonTooltip = None):
+ self._anim = animation(self._base, -20, 25, 1)
+ self.setHidden(False)
+ self._label.setLabel(text)
+ self._buttonExtra.setHidden(extraButtonCallback is None)
+ self._buttonExtra._imageID = extraButtonIcon
+ self._buttonExtra._tooltip = extraButtonTooltip
+ self._extraButtonCallback = extraButtonCallback
+ self._base._queueRefresh()
+ self.updateLayout()
+
+ def onExtraButton(self, button):
+ self.onClose(button)
+ self._extraButtonCallback()
+
+ def onClose(self, button):
+ if self._anim is not None:
+ self._anim = animation(self._base, self._anim.getPosition(), -20, 1)
+ else:
+ self._anim = animation(self._base, 25, -20, 1)
+