changed the apparence of athmos.py and added max_width property
This commit is contained in:
28
athmos.py
28
athmos.py
@ -13,6 +13,7 @@ class Athmos:
|
|||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.show_list = True
|
self.show_list = True
|
||||||
self.surface = pygame.Surface((0,0), pygame.SRCALPHA)
|
self.surface = pygame.Surface((0,0), pygame.SRCALPHA)
|
||||||
|
self.max_name_width = 350
|
||||||
|
|
||||||
def set_filenames(self,filenames):
|
def set_filenames(self,filenames):
|
||||||
self.filenames = filenames
|
self.filenames = filenames
|
||||||
@ -27,18 +28,23 @@ class Athmos:
|
|||||||
if self.show_list:
|
if self.show_list:
|
||||||
self.surface.fill("black")
|
self.surface.fill("black")
|
||||||
for i in range(self.get_display_count()):
|
for i in range(self.get_display_count()):
|
||||||
# text = self.filenames[(i-self.index-math.floor(self.get_display_count()/2))%len(self.filenames)]
|
text = self.filenames[(i+self.index-math.floor(self.get_display_count()/2))%len(self.filenames)]
|
||||||
text = self.filenames[i]
|
if len(text)> math.floor(self.max_name_width/10):
|
||||||
# if i == math.floor(self.get_display_count()/2):
|
text = text[0:math.floor(self.max_name_width/10)-2]
|
||||||
if i == self.index:
|
text += '...'
|
||||||
text_surface = font_helvetica16.render(text, False, "black", color_primary_light)
|
#text = self.filenames[i]
|
||||||
else:
|
if i == math.floor(self.get_display_count()/2):
|
||||||
|
#if i == self.index:
|
||||||
text_surface = font_helvetica16.render(text, False, color_primary_light)
|
text_surface = font_helvetica16.render(text, False, color_primary_light)
|
||||||
opacity = math.floor((i+1) * 2 * 255 / MAX_COUNT
|
else:
|
||||||
|
text_surface = font_helvetica16.render(text, False, color_primary)
|
||||||
|
opacity = -20 + math.floor((i+1) * 2 * 255 / MAX_COUNT
|
||||||
if i < MAX_COUNT/2
|
if i < MAX_COUNT/2
|
||||||
else (MAX_COUNT-i) * 2 * 255 / MAX_COUNT)
|
else (MAX_COUNT-i) * 2 * 255 / MAX_COUNT)
|
||||||
# text_surface.set_alpha(opacity)
|
text_surface.set_alpha(opacity)
|
||||||
self.surface.blit(text_surface, ((0, self.surface.get_height()/self.get_display_count()*i)))
|
#if text_surface.get_width() > self.max_name_width: self.max_name_width = text_surface.get_width()
|
||||||
|
self.surface.blit(text_surface, ((10, self.surface.get_height()/self.get_display_count()*i)))
|
||||||
self.screen.blit(self.surface, (self.screen.get_width()/3,
|
pygame.draw.rect(self.surface, color_primary_light, (0, self.surface.get_height()/2-25, self.max_name_width+20, 40), 2)
|
||||||
|
|
||||||
|
self.screen.blit(self.surface, ((self.screen.get_width()-self.max_name_width)/2,
|
||||||
(self.screen.get_height() - self.surface.get_height())/2))
|
(self.screen.get_height() - self.surface.get_height())/2))
|
||||||
Reference in New Issue
Block a user