Commits

anatoly techtonik committed eb9dc50

FilePanel: Fix label backgrounds.

Comments (0)

Files changed (1)

     foreground = (255, 255, 255, 255)
     background = (0, 0, 0, 0)
     active = (255, 255, 0, 255)
-    background_active = (255, 0, 255, 255)
+    background_active = (128, 128, 128, 255)
 
 class DNPalette(Palette):
     '''DOS Navigator Palette'''
     in symbols.
     """
     # a list of unique directory entries, one entry is always active
-    # [ ] background color (pyglet bug)
+    # [x] background color ([ ] fix pyglet inconsistency)
     # [x] up/down arrows move cursor
     # [x] scrolling
     # [x] border
         return (idx >= self.offset and idx < self.offset + self.height)
 
     def add_entry(self, name):
-        label = pyglet.text.Label(name, font_name=font_family, anchor_y='top')
+        label = pyglet.text.Label(name, font_name=font_family, anchor_y='top',
+                                  color=palette.foreground)
+        label.set_style('background_color', palette.background)
         idx = len(self.items)  # index that will be assigned to the new entry
         self.items.append((name, label))
         if self._is_item_visible(idx):
         
     def _color_entry(self, idx, foreground, background=None):
         self.items[idx][1].color = foreground
-        self.items[idx][1].background_color = background
+        # TODO [ ] - document styles
+        # TODO [ ] - deprecate label.color or implement label.background
+        self.items[idx][1].set_style('background_color', background)
         
     def _refresh_label_positions(self, idx=None):
         """Change position of visible label on the canvas. If idx is not None,
             
         # draw layer1 - title
         avail_width = self.width-2-2  # width-border-margin
-        label_title = self.title
+        label_title = ' ' + self.title + ' '
         if len(self.title) > avail_width:
             # [ ] TODO: crop symbols from the middle
-            label_title = ' ' + self.title[:len(self.width)-5] + '...' + ' '
+            label_title = self.title[:len(self.width)-5] + '...'
         # center title label
         xpos = 3 + avail_width//2 - len(label_title)//2
         label = pyglet.text.Label(label_title, anchor_y='top',
                     font_name=font_family,
                     x=font_width*xpos, y=font_height*self.height)
-        # [ ] TODO label background
+        label.set_style('background_color', palette.background_active)
         label.draw()
         
         yspace = self.height-2