forked from JackD83/PyMenu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFooter.py
63 lines (50 loc) · 2.31 KB
/
Footer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import RenderObject, Configuration, Common
import os
import pygame, sys
class Footer(RenderObject.RenderObject):
config = Configuration.getConfiguration()
theme = Configuration.getTheme()
pygame.font.init()
footerFont = pygame.font.Font('theme/NotoSans-Regular.ttf', 14)
footerHeight = 24
footer = None
spacing = 6
yPos = config["screenHeight"] - footerHeight
enabled = True
def getHeight(self):
return self.footerHeight
def setEnabled(self, enabled):
self.enabled = enabled
def setYPosition(self, yPos):
self.yPos = yPos
def render(self, screen):
if(self.enabled):
screen.blit(self.footer, (0,self.yPos ))
def initFooter(self):
self.footer = pygame.Surface((self.config["screenWidth"], self.footerHeight))
self.footer.fill(Configuration.toColor(self.theme["side"]["color"]))
leftOffset = 10
for entry in self.left:
if(entry[0] != None):
icon = Common.loadImage(entry[0])
self.footer.blit(icon, (leftOffset , (self.footerHeight - icon.get_height()) / 2))
leftOffset = leftOffset + icon.get_width() + self.spacing
if(entry[1] != None):
text = self.footerFont.render(entry[1], True, self.textColor)
self.footer.blit(text, (leftOffset,(self.footerHeight - text.get_height()) / 2))
leftOffset = leftOffset + text.get_width() + self.spacing
rightOffset = self.config["screenWidth"] - 10
for entry in self.right:
if(entry[1] != None):
text = self.footerFont.render(entry[1], True, self.textColor)
self.footer.blit(text, (rightOffset - text.get_width(),(self.footerHeight - text.get_height()) / 2))
rightOffset = rightOffset - text.get_width() - self.spacing
if(entry[0] != None):
icon = Common.loadImage(entry[0])
self.footer.blit(icon, (rightOffset - icon.get_width() , (self.footerHeight - icon.get_height()) / 2))
rightOffset = rightOffset - icon.get_width() - self.spacing
def __init__(self,left,right, textColor):
self.left = left
self.right = right
self.textColor = textColor
self.initFooter()