Revert "Code clean"

This reverts commit b8bec3327d.
This commit is contained in:
9and3r
2014-08-04 02:27:30 +02:00
parent b8bec3327d
commit 375c73d89f
15 changed files with 70 additions and 64 deletions

View File

@@ -36,5 +36,5 @@ class Extension(ext.Extension):
def setup(self, registry):
registry.add('frontend', TouchScreen)
# Backend used for controling volume
#Backend used for controling volume
registry.add('backend', TouchScreenBackend)

View File

@@ -24,7 +24,7 @@ class DynamicBackground():
# Returns an array with 3 integers in range of 0-255
# The sum of the three integers will be lower than 255*2 (510) to avoid very bright colors
#The sum of the three integers will be lower than 255*2 (510) to avoid very bright colors
#White text should be seen ok with this background color

View File

@@ -77,6 +77,6 @@ class LibraryScreen():
self.manager.core.tracklist.add(uri=uri)
self.manager.core.playback.play()
else:
# TODO: add folder to tracks to play
#TODO: add folder to tracks to play
pass

View File

@@ -19,7 +19,7 @@ class ListView():
self.set_list([])
self.selected = []
# Sets the list for the lisview. It should be an iterable of strings
#Sets the list for the lisview. It should be an iterable of strings
def set_list(self, item_list):
self.list = item_list
self.list_size = len(item_list)

View File

@@ -58,7 +58,7 @@ class MainScreen():
(width, self.size[1]))
self.touch_text_manager.set_object("track_name", label)
# Album name
#Album name
label = TextItem(self.fonts['base'], MainScreen.get_track_album_name(track), (x, self.base_size * 3),
(width, self.size[1]))
self.touch_text_manager.set_object("album_name", label)

View File

@@ -21,7 +21,7 @@ class MenuScreen():
None)
self.screen_objects.set_touch_object("exit", button)
# Shutdown button
#Shutdown button
button = TouchAndTextItem(self.manager.fonts['icon'], u"\ue60b", (0, self.base_size * 2), None)
self.screen_objects.set_touch_object("shutdown_icon", button)
button = TouchAndTextItem(self.manager.fonts['base'], "Shutdown", (button.get_right_pos(), self.base_size * 2),
@@ -62,7 +62,7 @@ class MenuScreen():
elif key == "ip":
self.check_connection()
# Will check internet connection
#Will check internet connection
def check_connection(self):
try:
self.manager.set_connection(False, True)

View File

@@ -28,7 +28,7 @@ class ScreenManager():
self.background = DynamicBackground()
self.current_screen = 0
self.base_size = self.size[1] / 8
font = resource_filename(Requirement.parse("mopidy-touchscreen"), "mopidy_touchscreen/icomoon.ttf")
font = resource_filename(Requirement.parse("mopidy-touchscreen"),"mopidy_touchscreen/icomoon.ttf")
self.fonts['base'] = pygame.font.SysFont("verdana", self.base_size)
self.fonts['icon'] = pygame.font.Font(font, self.base_size)
try:
@@ -52,7 +52,7 @@ class ScreenManager():
self.screen_objects_manager.set_touch_object("pause_play", button)
x = button.get_right_pos()
# Random
#Random
button = TouchAndTextItem(self.fonts['icon'], u"\ue629 ", (x, 0), None)
self.screen_objects_manager.set_touch_object("random", button)
x = button.get_right_pos()

View File

@@ -31,7 +31,7 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener):
screen = pygame.display.set_mode(self.screen_size, pygame.FULLSCREEN)
else:
screen = pygame.display.set_mode(self.screen_size)
pygame.mouse.set_visible(self.cursor)
pygame.mouse.set_visible(self.cursor)
while self.running:
clock.tick(15)
screen.blit(self.screen_manager.update(), (0, 0))

View File

@@ -3,16 +3,18 @@ import logging
logger = logging.getLogger(__name__)
class TouchTextManager():
def __init__(self, size, base_size):
def __init__(self,size,base_size):
self.size = size
self.base_size = base_size
self.touch_objects = {}
self.text_objects = {}
def add_object(self, key, text, pos, pos2, color):
self.text_objects[key] = TextItem(text, pos, pos2, color, self.base_size)
self.text_objects[key] = TextItem(text, pos,pos2,color,self.base_size)
def get_object(self, key):
return self.text_objects[key]
@@ -20,11 +22,11 @@ class TouchTextManager():
def add_touch_object(self, key, text, pos, color):
self.touch_objects['key'] = TouchAndTextItem(text, pos, color, self.base_size)
def get_touch_object(self, key):
def get_touch_object(self,key):
return self.touch_objects['key']
def add_progressbar(self, key, pos, pos2, max):
self.touch_objects['key'] = Progressbar(pos, pos2, max)
self.touch_objects['key'] = Progressbar(pos,pos2,max)
def render(self, surface):
for key in self.text_objects:
@@ -35,19 +37,21 @@ class TouchTextManager():
class BaseItem():
def __init__(self, pos, pos2):
def __init__(self,pos,pos2):
self.pos = pos
self.pos2 = pos2
self.size = [0, 0]
self.size=[0,0]
self.size[0] = self.pos2[0] - self.pos[0]
self.size[1] = self.pos2[1] - self.pos[1]
self.rect = pygame.Rect(0, 0, self.size[0], self.size[1])
self.rect = pygame.Rect(0,0,self.size[0],self.size[1])
class TextItem(BaseItem):
def __init__(self, text, pos, pos2, color, text_size):
def __init__(self, text, pos,pos2, color,text_size):
if pos2 is not None:
BaseItem.__init__(self, pos, pos2)
BaseItem.__init__(self,pos,pos2)
self.text_size = text_size
self.font = pygame.font.SysFont("arial", text_size)
self.text = text
@@ -66,7 +70,7 @@ class TextItem(BaseItem):
else:
self.fit_vertical = True
else:
BaseItem.__init__(self, pos, (pos[0] + self.box.get_rect().width, pos[1] + self.box.get_rect().height))
BaseItem.__init__(self,pos,(pos[0]+self.box.get_rect().width,pos[1]+self.box.get_rect().height))
self.fit_horizontal = True
self.fit_vertical = True
@@ -89,49 +93,50 @@ class TextItem(BaseItem):
else:
self.step = self.step + 1
def render(self, surface):
def render(self,surface):
if self.fit_horizontal:
self.box
else:
self.box = self.font.render(self.text, True, self.color)
surface.blit(self.box, self.pos, area=self.rect)
surface.blit(self.box,self.pos,area=self.rect)
def set_text(self, text):
self.__init__(text, self.pos, self.pos2, self.color, self.text_size)
self.__init__(text,self.pos,self.pos2,self.color,self.text_size)
class TouchObject(BaseItem):
def __init__(self, pos, pos2):
BaseItem.__init__(self, pos, pos2)
def __init__(self,pos,pos2):
BaseItem.__init__(self,pos,pos2)
self.active = False
self.background_box = pygame.Surface(self.size)
self.background_box.fill((0, 128, 255))
self.background_box.fill((0,128,255))
def render(self, surface):
def render(self,surface):
surface.blit(self.background_box, self.pos)
class TouchAndTextItem(TouchObject, TextItem):
def __init__(self, text, pos, color, text_size):
TextItem.__init__(self, text, pos, None, color, text_size)
TouchObject.__init__(self, pos, self.pos2)
def __init__(self, text, pos, color,text_size):
TextItem.__init__(self,text, pos,None, color,text_size)
TouchObject.__init__(self,pos,self.pos2)
def update(self):
TextItem.update()
def render(self, surface):
TouchObject.render(self, surface)
TextItem.render(self, surface)
def render(self,surface):
TouchObject.render(self,surface)
TextItem.render(self,surface)
class Progressbar(BaseItem):
def __init__(self, pos, pos2, max):
BaseItem.__init__(self, pos, pos2)
logger.error(pos2)
self.value = 0
self.max = max
self.back_color = (0, 0, 0)
self.main_color = (255, 255, 255)
self.back_color = (0,0,0)
self.main_color = (255,255,255)
self.surface = pygame.Surface(self.size)
self.surface.fill(self.back_color)
@@ -145,6 +150,6 @@ class Progressbar(BaseItem):
self.value = value
self.surface.fill(self.back_color)
pos_pixel = value * self.size[0] / self.max
rect = pygame.Rect(0, 0, pos_pixel, self.size[1])
rect = pygame.Rect(0,0,pos_pixel,self.size[1])
self.surface.fill(self.main_color, rect)