Merge pull request #7 from Syco54645/develop

Added groundwork for supporting a better resolution
This commit is contained in:
9and3r
2015-05-23 13:19:47 +02:00
4 changed files with 19 additions and 15 deletions

View File

@@ -24,6 +24,7 @@ class Extension(ext.Extension):
schema = super(Extension, self).get_config_schema() schema = super(Extension, self).get_config_schema()
schema['screen_width'] = config.Integer(minimum=1) schema['screen_width'] = config.Integer(minimum=1)
schema['screen_height'] = config.Integer(minimum=1) schema['screen_height'] = config.Integer(minimum=1)
schema['resolution_factor'] = config.Integer(minimum=0)
schema['cursor'] = config.Boolean() schema['cursor'] = config.Boolean()
schema['fullscreen'] = config.Boolean() schema['fullscreen'] = config.Boolean()
schema['cache_dir'] = config.Path() schema['cache_dir'] = config.Path()

View File

@@ -2,6 +2,7 @@
enabled = true enabled = true
screen_width = 320 screen_width = 320
screen_height = 240 screen_height = 240
resolution_factor = 8
cursor = True cursor = True
fullscreen = False fullscreen = False
cache_dir = $XDG_CACHE_DIR/mopidy/touchscreen cache_dir = $XDG_CACHE_DIR/mopidy/touchscreen

View File

@@ -25,7 +25,7 @@ menu_index = 5
class ScreenManager(): class ScreenManager():
def __init__(self, size, core, cache): def __init__(self, size, core, cache, resolution_factor):
self.core = core self.core = core
self.cache = cache self.cache = cache
self.fonts = {} self.fonts = {}
@@ -43,12 +43,13 @@ class ScreenManager():
self.keyboard = None self.keyboard = None
self.update_type = BaseScreen.update_all self.update_type = BaseScreen.update_all
self.init_manager(size) self.init_manager(size, resolution_factor)
def init_manager(self, size): def init_manager(self, size, resolution_factor):
self.size = size self.size = size
self.resolution_factor = resolution_factor
self.background = DynamicBackground(self.size) self.background = DynamicBackground(self.size)
self.base_size = self.size[1] / 8 self.base_size = self.size[1] / self.resolution_factor
font = resource_filename( font = resource_filename(
Requirement.parse("mopidy-touchscreen"), Requirement.parse("mopidy-touchscreen"),
"mopidy_touchscreen/icomoon.ttf") "mopidy_touchscreen/icomoon.ttf")
@@ -75,35 +76,35 @@ class ScreenManager():
# Search button # Search button
button = TouchAndTextItem(self.fonts['icon'], u" \ue986", button = TouchAndTextItem(self.fonts['icon'], u" \ue986",
(0, self.base_size * 7), (0, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, center=True) button_size, center=True)
self.down_bar_objects.set_touch_object("menu_0", button) self.down_bar_objects.set_touch_object("menu_0", button)
x = button.get_right_pos() x = button.get_right_pos()
# Main button # Main button
button = TouchAndTextItem(self.fonts['icon'], u" \ue600", button = TouchAndTextItem(self.fonts['icon'], u" \ue600",
(x, self.base_size * 7), (x, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, center=True) button_size, center=True)
self.down_bar_objects.set_touch_object("menu_1", button) self.down_bar_objects.set_touch_object("menu_1", button)
x = button.get_right_pos() x = button.get_right_pos()
# Tracklist button # Tracklist button
button = TouchAndTextItem(self.fonts['icon'], u" \ue60d", button = TouchAndTextItem(self.fonts['icon'], u" \ue60d",
(x, self.base_size * 7), (x, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, center=True) button_size, center=True)
self.down_bar_objects.set_touch_object("menu_2", button) self.down_bar_objects.set_touch_object("menu_2", button)
x = button.get_right_pos() x = button.get_right_pos()
# Library button # Library button
button = TouchAndTextItem(self.fonts['icon'], u" \ue604", button = TouchAndTextItem(self.fonts['icon'], u" \ue604",
(x, self.base_size * 7), (x, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, center=True) button_size, center=True)
self.down_bar_objects.set_touch_object("menu_3", button) self.down_bar_objects.set_touch_object("menu_3", button)
x = button.get_right_pos() x = button.get_right_pos()
# Playlist button # Playlist button
button = TouchAndTextItem(self.fonts['icon'], u" \ue605", button = TouchAndTextItem(self.fonts['icon'], u" \ue605",
(x, self.base_size * 7), (x, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, center=True) button_size, center=True)
self.down_bar_objects.set_touch_object("menu_4", button) self.down_bar_objects.set_touch_object("menu_4", button)
@@ -111,18 +112,18 @@ class ScreenManager():
# Menu button # Menu button
button = TouchAndTextItem(self.fonts['icon'], u" \ue60a", button = TouchAndTextItem(self.fonts['icon'], u" \ue60a",
(x, self.base_size * 7), (x, self.size[1] - self.base_size), #change these to move the location of the icons
button_size, button_size,
center=True) center=True)
self.down_bar_objects.set_touch_object("menu_5", button) self.down_bar_objects.set_touch_object("menu_5", button)
# Down bar Solid # Down bar Solid
self.down_bar_solid = pygame.Surface( self.down_bar_solid = pygame.Surface(
(self.size[0], self.size[1] - self.base_size * 7)) (self.size[0], self.size[1] - self.base_size )) #change the 7 to move the bar
# Down bar # Down bar
self.down_bar = pygame.Surface( self.down_bar = pygame.Surface(
(self.size[0], self.size[1] - self.base_size * 7), (self.size[0], self.size[1] - self.base_size ), #change the 7 to move the bar
pygame.SRCALPHA) pygame.SRCALPHA)
self.down_bar.fill((0, 0, 0, 200)) self.down_bar.fill((0, 0, 0, 200))
@@ -161,7 +162,7 @@ class ScreenManager():
else: else:
self.screens[self.current_screen].\ self.screens[self.current_screen].\
update(surface, update_type, rects) update(surface, update_type, rects)
surface.blit(self.down_bar, (0, self.base_size * 7)) surface.blit(self.down_bar, (0, self.size[1] - self.base_size))
self.down_bar_objects.render(surface) self.down_bar_objects.render(surface)
if update_type == BaseScreen.update_all or len(rects) < 1: if update_type == BaseScreen.update_all or len(rects) < 1:

View File

@@ -25,7 +25,7 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener):
self.fullscreen = config['touchscreen']['fullscreen'] self.fullscreen = config['touchscreen']['fullscreen']
self.screen_size = (config['touchscreen']['screen_width'], self.screen_size = (config['touchscreen']['screen_width'],
config['touchscreen']['screen_height']) config['touchscreen']['screen_height'])
self.resolution_factor = (config['touchscreen']['resolution_factor'])
if config['touchscreen']['sdl_fbdev'].lower() != "none": if config['touchscreen']['sdl_fbdev'].lower() != "none":
os.environ["SDL_FBDEV"] = config['touchscreen']['sdl_fbdev'] os.environ["SDL_FBDEV"] = config['touchscreen']['sdl_fbdev']
if config['touchscreen']['sdl_mousdrv'].lower() != "none": if config['touchscreen']['sdl_mousdrv'].lower() != "none":
@@ -46,7 +46,8 @@ class TouchScreen(pykka.ThreadingActor, core.CoreListener):
pygame.mouse.set_visible(self.cursor) pygame.mouse.set_visible(self.cursor)
self.screen_manager = ScreenManager(self.screen_size, self.screen_manager = ScreenManager(self.screen_size,
self.core, self.core,
self.cache_dir) self.cache_dir,
self.resolution_factor)
# Raspberry pi GPIO # Raspberry pi GPIO
self.gpio = config['touchscreen']['gpio'] self.gpio = config['touchscreen']['gpio']