-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCommandBar.py
199 lines (149 loc) · 7.31 KB
/
CommandBar.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import sys
import talkshowConfig
import pyglet
from talkshowLogger import logger
debug = logger.debug
info = logger.info
warn = logger.warn
import talkshowUtils
def loadImage(path):
newpath = talkshowUtils.getRelativePath(path)
return pyglet.image.load(newpath)
class CommandBar(object):
def __init__(self, screen, orientation):
self.style = talkshowConfig.config().parser.style
self.screen = screen
# expecting a list of 4 values for the padding values. no css shorthands allowed.
self.imagePadding = self.style.commandImage.padding
self.pagePadding = map(lambda x:x/100.0, self.style.page.padding)
self.leftPadding = self.screen.w * self.pagePadding[3] + self.imagePadding[3]
self.topPadding = self.screen.w * self.pagePadding[0] + self.imagePadding[0]
# 0 = landscape; 1 = vertical
self.orientation = orientation
# calculate bar size by orientation property
if self.orientation == 0:
self.height = screen.h * self.style.commandBar.height / 100.0
self.width = screen.w * self.style.commandBar.width / 100.0
else:
self.height = screen.h * self.style.sideBar.height / 100.0
self.width = screen.w * self.style.sideBar.width / 100.0
self.increaseX = 0;
self.increaseY = 0;
class MenuBar(CommandBar):
def __init__(self, screen, orientation=0):
super(MenuBar, self).__init__(screen, orientation)
x = self.leftPadding
y = self.topPadding
if self.orientation == 0:
debug("orientation 0")
increaseX = int(self.style.warning.width) + self.imagePadding[1] + self.imagePadding[3]
increaseY = 0
else:
debug("orientation 1")
increaseX = 0
increaseY = int(self.style.warning.height) + self.imagePadding[0] + self.imagePadding[2]
# create the warning button properties
self.warningImage = loadImage(self.style.warning.background_image[5:-2])
self.warningHeight = int(self.style.warning.height)
self.warningWidth = int(self.style.warning.width)
self.warningX = x
self.warningY = y
self.warningSprite = pyglet.sprite.Sprite(self.warningImage, self.warningX, self.warningY)
x = x + increaseX
y = y + increaseY
# create the home button properties
self.homeImage = loadImage(self.style.home.background_image[5:-2])
self.homeHeight = int(self.style.home.height)
self.homeWidth = int(self.style.home.width)
self.homeX = x
self.homeY = y
self.homeSprite = pyglet.sprite.Sprite(self.homeImage, self.homeX, self.homeY)
x = x + increaseX
y = y + increaseY
# create the back button properties
self.backImage = loadImage(self.style.back.background_image[5:-2])
self.backHeight = int(self.style.back.height)
self.backWidth = int(self.style.back.width)
self.backX = x
self.backY = y
self.backSprite = pyglet.sprite.Sprite(self.backImage, self.backX, self.backY)
x = x + increaseX
y = y + increaseY
# create the shutDown button properties
self.shutDownImage = loadImage(self.style.shutDown.background_image[5:-2])
self.shutDownHeight = int(self.style.shutDown.height)
self.shutDownWidth = int(self.style.shutDown.width)
self.shutDownX = x
self.shutDownY = y
self.shutDownSprite = pyglet.sprite.Sprite(self.shutDownImage, self.shutDownX, self.shutDownY)
x = x + increaseX
y = y + increaseY
# create the settings button properties
self.settingsImage = loadImage(self.style.settings.background_image[5:-2])
self.settingsHeight = int(self.style.settings.height)
self.settingsWidth = int(self.style.settings.width)
self.settingsX = x
self.settingsY = y
self.settingsSprite = pyglet.sprite.Sprite(self.settingsImage, self.settingsX, self.settingsY)
class PlayerBar(CommandBar):
def __init__(self, screen, orientation=0):
super(PlayerBar, self).__init__(screen, orientation)
y = self.topPadding
if self.orientation == 0:
increaseX = int(self.style.volumeDown.width) + self.imagePadding[1] + self.imagePadding[3]
increaseY = 0
x = self.screen.w - 5*increaseX
else:
x = self.imagePadding[3] + self.screen.w - self.width
increaseX = 0
increaseY = int(self.style.volumeDown.height) + self.imagePadding[0] + self.imagePadding[2]
# create the volumeDown button properties
self.volumeDownImage = loadImage(self.style.volumeDown.background_image[5:-2])
self.volumeDownHeight = int(self.style.volumeDown.height)
self.volumeDownWidth = int(self.style.volumeDown.width)
self.volumeDownX = x
self.volumeDownY = y
self.volumeDownSprite = pyglet.sprite.Sprite(self.volumeDownImage, self.volumeDownX, self.volumeDownY)
x = x + increaseX
y = y + increaseY
# create the volumeUp button properties
self.volumeUpImage = loadImage(self.style.volumeUp.background_image[5:-2])
self.volumeUpHeight = int(self.style.volumeUp.height)
self.volumeUpWidth = int(self.style.volumeUp.width)
self.volumeUpX = x
self.volumeUpY = y
self.volumeUpSprite = pyglet.sprite.Sprite(self.volumeUpImage, self.volumeUpX, self.volumeUpY)
x = x + increaseX
y = y + increaseY
self.volumeHeight = int(self.style.volumeUp.height)
self.volumeWidth = int(self.style.volumeUp.width)
self.volumeX = x
self.volumeY = y
self.volumeSize = 50
x = x + increaseX
y = y + increaseY
# create the playPrevious button properties
self.playPreviousImage = loadImage(self.style.playPrevious.background_image[5:-2])
self.playPreviousHeight = int(self.style.playPrevious.height)
self.playPreviousWidth = int(self.style.playPrevious.width)
self.playPreviousX = x
self.playPreviousY = y
self.playPreviousSprite = pyglet.sprite.Sprite(self.playPreviousImage, self.playPreviousX, self.playPreviousY)
x = x + increaseX
y = y + increaseY
# create the play button properties
self.playImage = loadImage(self.style.play.background_image[5:-2])
self.playHeight = int(self.style.play.height)
self.playWidth = int(self.style.play.width)
self.playX = x
self.playY = y
self.playSprite = pyglet.sprite.Sprite(self.playImage, self.playX, self.playY)
x = x + increaseX
y = y + increaseY
# create the playNext button properties
self.playNextImage = loadImage(self.style.playNext.background_image[5:-2])
self.playNextHeight = int(self.style.playNext.height)
self.playNextWidth = int(self.style.playNext.width)
self.playNextX = x
self.playNextY = y
self.playNextSprite = pyglet.sprite.Sprite(self.playNextImage, self.playNextX, self.playNextY)