Exemple #1
0
    def populate_thumbs(self, theme_key, *args):
        c = self.thumbs_container
        if not c or c.height <= 0:
            self.bind(thumbs_container=partial(self.populate_thumbs, theme_key=theme_key))
            return
        if theme_key != self.current_theme:
            theme = get_post_theme(theme_key)
            thumbs = theme.thumbs
            # really sorting here?
            colors = sorted(theme.colors.keys())
            if len(colors) < len(thumbs):
                missing = len(thumbs) - len(colors)
                colors.extend([colors[-1]] * missing)
            Clock.unschedule(self._select_initial_thumb)
            c.clear_widgets()
            w = (c.height - (c.spacing[1] + c.padding[1] + c.padding[3])) / 2
            h = w
            total = len(thumbs)
            num_colors = len(colors)
            for i in range(0, int(total/2)):
                self._add_thumb(theme_key, thumbs[i*2 + 0], h)
                self._add_color(colors[(i*2 + 0) % num_colors], h)
                self._add_color(colors[(i*2 + 1) % num_colors], h)
                self._add_thumb(theme_key, thumbs[i*2 + 1], h)
            if total % 2 != 0:
                self._add_thumb(theme_key, thumbs[total-1], h)
                self._add_color(colors[(total-1) % num_colors], h)
            self.current_theme = theme_key

        Clock.schedule_once(self._select_initial_thumb, .1)
Exemple #2
0
    def populate_thumbs(self, theme_key, *args):
        c = self.thumbs_container
        if not c or c.height <= 0:
            self.bind(thumbs_container=partial(self.populate_thumbs,
                                               theme_key=theme_key))
            return
        if theme_key != self.current_theme:
            theme = get_post_theme(theme_key)
            thumbs = theme.thumbs
            # really sorting here?
            colors = sorted(theme.colors.keys())
            if len(colors) < len(thumbs):
                missing = len(thumbs) - len(colors)
                colors.extend([colors[-1]] * missing)
            Clock.unschedule(self._select_initial_thumb)
            c.clear_widgets()
            w = (c.height - (c.spacing[1] + c.padding[1] + c.padding[3])) / 2
            h = w
            total = len(thumbs)
            num_colors = len(colors)
            for i in range(0, int(total / 2)):
                self._add_thumb(theme_key, thumbs[i * 2 + 0], h)
                self._add_color(colors[(i * 2 + 0) % num_colors], h)
                self._add_color(colors[(i * 2 + 1) % num_colors], h)
                self._add_thumb(theme_key, thumbs[i * 2 + 1], h)
            if total % 2 != 0:
                self._add_thumb(theme_key, thumbs[total - 1], h)
                self._add_color(colors[(total - 1) % num_colors], h)
            self.current_theme = theme_key

        Clock.schedule_once(self._select_initial_thumb, .1)
Exemple #3
0
 def _resolve_color(self, data):
     theme = get_post_theme(data.get('theme', 'unknown'))
     color = 'ffffff'
     if theme:
         background = data['background']
         color = theme.get_color(background)
         if not color:
             color = theme.get_color_by_image(background)
     return get_color_from_hex(color)
Exemple #4
0
 def thumb_changed(self, instance, value):
     if value == 'down':
         t = get_post_theme(self.current_theme)
         if not t:
             return
         if isinstance(instance, BackgroundImage):
             LogTestFairy('Write Post image bkg pressed')
             self.set_image_key(t, instance.thumb_key)
         elif isinstance(instance, BackgroundColor):
             LogTestFairy('Write Post color bkg pressed')
             self.set_color(t, instance.color)
Exemple #5
0
 def thumb_changed(self, instance, value):
     if value == 'down':
         t = get_post_theme(self.current_theme)
         if not t:
             return
         if isinstance(instance, BackgroundImage):
             LogTestFairy('Write Post image bkg pressed')
             self.set_image_key(t, instance.thumb_key)
         elif isinstance(instance, BackgroundColor):
             LogTestFairy('Write Post color bkg pressed')
             self.set_color(t, instance.color)
Exemple #6
0
 def _resolve_user_data(self, data):
     background = data.get('background', 'unknown')
     theme = data.get('theme', 'unknown')
     icon_set = None
     image = None
     color = None
     t = get_post_theme(theme)
     if t:
         icon_set = t.get_iconset(background)
         color = PostTheme.get_color(background)
         if not color:
             image = get_image_path(t.key, background)
     if icon_set:
         data['icon_set'] = icon_set
     if image:
         data['image'] = image
     if color:
         data['color'] = get_color_from_hex(color)
Exemple #7
0
 def _resolve_user_data(self, data):
     background = data.get('background', 'unknown')
     theme = data.get('theme', 'unknown')
     icon_set = None
     image = None
     color = None
     t = get_post_theme(theme)
     if t:
         icon_set = t.get_iconset(background)
         color = PostTheme.get_color(background)
         if not color:
             image = get_image_path(t.key, background)
     if icon_set:
         data['icon_set'] = icon_set
     if image:
         data['image'] = image
     if color:
         data['color'] = get_color_from_hex(color)
Exemple #8
0
 def on_theme_key(self, *largs):
     self.theme = get_post_theme(largs[-1])
Exemple #9
0
 def on_theme_key(self, *largs):
     self.theme = get_post_theme(largs[-1])