From 7137a174f8a5f2c0a3b61c0badc1d7aaafba04ef Mon Sep 17 00:00:00 2001
From: 9and3r <9and3r@gmai.com>
Date: Sat, 19 Jul 2014 22:09:41 +0200
Subject: [PATCH] Added progressbar
---
mopidy_touchscreen/.idea/.name | 1 +
mopidy_touchscreen/.idea/encodings.xml | 5 +
mopidy_touchscreen/.idea/misc.xml | 5 +
mopidy_touchscreen/.idea/modules.xml | 9 +
.../.idea/mopidy_touchscreen.iml | 9 +
.../.idea/scopes/scope_settings.xml | 5 +
mopidy_touchscreen/.idea/vcs.xml | 7 +
mopidy_touchscreen/.idea/workspace.xml | 549 ++++++++++++++++++
mopidy_touchscreen/dynamic_background.py~ | 25 +
mopidy_touchscreen/image_manager.py~ | 6 +
mopidy_touchscreen/main_screen.py | 48 +-
mopidy_touchscreen/main_screen.py~ | 84 ++-
mopidy_touchscreen/screen_manager.py | 22 +-
mopidy_touchscreen/screen_manager.py~ | 24 +
mopidy_touchscreen/touch_screen.py | 29 +-
mopidy_touchscreen/touch_screen.py~ | 5 +-
mopidy_touchscreen/touch_text_manager.py | 155 +++++
setup.py | 2 +-
setup.py~ | 49 ++
19 files changed, 991 insertions(+), 48 deletions(-)
create mode 100644 mopidy_touchscreen/.idea/.name
create mode 100644 mopidy_touchscreen/.idea/encodings.xml
create mode 100644 mopidy_touchscreen/.idea/misc.xml
create mode 100644 mopidy_touchscreen/.idea/modules.xml
create mode 100644 mopidy_touchscreen/.idea/mopidy_touchscreen.iml
create mode 100644 mopidy_touchscreen/.idea/scopes/scope_settings.xml
create mode 100644 mopidy_touchscreen/.idea/vcs.xml
create mode 100644 mopidy_touchscreen/.idea/workspace.xml
create mode 100644 mopidy_touchscreen/dynamic_background.py~
create mode 100644 mopidy_touchscreen/image_manager.py~
create mode 100644 mopidy_touchscreen/screen_manager.py~
create mode 100644 mopidy_touchscreen/touch_text_manager.py
create mode 100644 setup.py~
diff --git a/mopidy_touchscreen/.idea/.name b/mopidy_touchscreen/.idea/.name
new file mode 100644
index 0000000..887edce
--- /dev/null
+++ b/mopidy_touchscreen/.idea/.name
@@ -0,0 +1 @@
+mopidy_touchscreen
\ No newline at end of file
diff --git a/mopidy_touchscreen/.idea/encodings.xml b/mopidy_touchscreen/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/mopidy_touchscreen/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/mopidy_touchscreen/.idea/misc.xml b/mopidy_touchscreen/.idea/misc.xml
new file mode 100644
index 0000000..fc86127
--- /dev/null
+++ b/mopidy_touchscreen/.idea/misc.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/mopidy_touchscreen/.idea/modules.xml b/mopidy_touchscreen/.idea/modules.xml
new file mode 100644
index 0000000..d020e29
--- /dev/null
+++ b/mopidy_touchscreen/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/mopidy_touchscreen/.idea/mopidy_touchscreen.iml b/mopidy_touchscreen/.idea/mopidy_touchscreen.iml
new file mode 100644
index 0000000..a34a857
--- /dev/null
+++ b/mopidy_touchscreen/.idea/mopidy_touchscreen.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/mopidy_touchscreen/.idea/scopes/scope_settings.xml b/mopidy_touchscreen/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/mopidy_touchscreen/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/mopidy_touchscreen/.idea/vcs.xml b/mopidy_touchscreen/.idea/vcs.xml
new file mode 100644
index 0000000..def6a6a
--- /dev/null
+++ b/mopidy_touchscreen/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/mopidy_touchscreen/.idea/workspace.xml b/mopidy_touchscreen/.idea/workspace.xml
new file mode 100644
index 0000000..9c4e301
--- /dev/null
+++ b/mopidy_touchscreen/.id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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mopidy_touchscreen/dynamic_background.py~ b/mopidy_touchscreen/dynamic_background.py~
new file mode 100644
index 0000000..eac73da
--- /dev/null
+++ b/mopidy_touchscreen/dynamic_background.py~
@@ -0,0 +1,25 @@
+import random
+
+class DynamicBackground():
+
+ def __init__(self):
+ self.current=[0,0,0]
+ self.target=[0,0,0]
+ for x in range(0, 3):
+ self.target[x]=random.randint(0,255)
+
+ def drawBackground(self,surface):
+ same = True
+ for x in range(0, 3):
+ if self.current[x]> self.target[x]:
+ self.current[x]=self.current[x]-1
+ elif self.current[x] pos2[0]:
+ self.fit_horizontal = False
+ self.text = self.text + " "
+ self.original_text = self.text
+ self.step = 0
+ else:
+ self.fit_horizontal = True
+ if self.pos[1] + self.box.get_rect().height > pos2[1]:
+ self.fit_vertical = False
+ else:
+ self.fit_vertical = True
+ else:
+ 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
+
+
+ def update(self):
+ if not self.fit_horizontal:
+ if self.text == self.original_text:
+ if self.step > 90:
+ self.step = 0
+ new_text = self.text[1:]
+ new_text = new_text + self.text[:1]
+ self.text = new_text
+ else:
+ self.step = self.step + 1
+ elif self.step > 5:
+ self.step = 0
+ new_text = self.text[1:]
+ new_text = new_text + self.text[:1]
+ self.text = new_text
+ else:
+ self.step = self.step + 1
+
+ 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)
+
+ def set_text(self, text):
+ 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)
+ self.active = False
+ self.background_box = pygame.Surface(self.size)
+ self.background_box.fill((0,128,255))
+
+ 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 update(self):
+ TextItem.update()
+
+ 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.surface = pygame.Surface(self.size)
+ self.surface.fill(self.back_color)
+
+ def update(self):
+ pass
+
+ def render(self, surface):
+ surface.blit(self.surface, self.pos)
+
+ def set_value(self, value):
+ 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])
+ self.surface.fill(self.main_color, rect)
+
diff --git a/setup.py b/setup.py
index 673ad73..d6be008 100644
--- a/setup.py
+++ b/setup.py
@@ -46,4 +46,4 @@ setup(
'Programming Language :: Python :: 2',
'Topic :: Multimedia :: Sound/Audio :: Players',
],
-)
\ No newline at end of file
+)
diff --git a/setup.py~ b/setup.py~
new file mode 100644
index 0000000..48fb16a
--- /dev/null
+++ b/setup.py~
@@ -0,0 +1,49 @@
+from __future__ import unicode_literals
+
+import re
+
+from setuptools import find_packages, setup
+
+
+def get_version(filename):
+ content = open(filename).read()
+ metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", content))
+ return metadata['version']
+
+
+setup(
+ name='Mopidy-Touchscreen',
+ version=get_version('mopidy_touchscreen/__init__.py'),
+ url='https://github.com/9and3r/mopidy-touchscreen',
+ license='Apache License, Version 2.0',
+ author='9and3r',
+ author_email='9and3r@gmail.com',
+ description='Mopidy extension to show info on a display and control from it',
+ long_description=open('README.rst').read(),
+ packages=find_packages(exclude=['tests', 'tests.*']),
+ zip_safe=False,
+ include_package_data=True,
+ install_requires=[
+ 'setuptools',
+ 'Mopidy >= 0.17',
+ 'Pykka >= 1.1',
+ ],
+ test_suite='nose.collector',
+ tests_require=[
+ 'nose',
+ 'mock >= 1.0',
+ ],
+ entry_points={
+ 'mopidy.ext': [
+ 'touchscreen = mopidy_touchscreen:Extension',
+ ],
+ },
+ classifiers=[
+ 'Environment :: No Input/Output (Daemon)',
+ 'Intended Audience :: End Users/Desktop',
+ 'License :: OSI Approved :: Apache Software License',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python :: 2',
+ 'Topic :: Multimedia :: Sound/Audio :: Players',
+ ],
+)