[core/theme|output] Add separators

Add a way for themes to specify custom separators. Doing that, make
nicer interfaces for drawing "supplementary" components (separators)
for widgets and generalize the attribute retrieval within the theme.
This commit is contained in:
Tobias Witek 2020-02-22 13:42:44 +01:00
parent d3fc648c08
commit 38410adcb8
6 changed files with 63 additions and 15 deletions

View file

@ -19,14 +19,18 @@ class Theme(object):
self.__data = raw_data
else:
self.__data = self.load(name)
core.event.register('start', self.__start)
core.event.register('update', self.__start)
core.event.register('next-widget', self.__next_widget)
for attr, default in [
('fg', None), ('bg', None),
('default-separators', True),
('separator-block-width', 0),
('separator', None)
('separator', None),
('border-top', 0),
('border-bottom', 0),
('border-left', 0),
('border-right', 0),
]:
setattr(self, attr.replace('-', '_'), lambda widget=None, default=default, attr=attr: self.__get(widget, attr, default))
@ -41,6 +45,14 @@ class Theme(object):
def __start(self):
self.__widget_count = 0
def prev_bg(self, widget):
if self.__widget_count == 0:
return None
self.__widget_count = self.__widget_count - 1
value = self.bg(widget)
self.__widget_count = self.__widget_count + 1
return value
def __next_widget(self):
self.__widget_count = self.__widget_count + 1