Add support for predesigned covers to Marquise. Remove support for changing cover...
[librarian.git] / src / librarian / covers / widgets / base.py
1 class Widget:
2     transparency = True
3     margin_top = 0
4
5     def __init__(self, cover):
6         self.cover = cover
7         self.setup()
8
9     def setup(self):
10         pass
11         
12     def build(self, w, h):
13         raise NotImplementedError()
14
15     def apply(self, img, x, y, w=None, h=None):
16         my_img = self.build(w, h)
17         if my_img is not None:
18             img.paste(
19                 my_img,
20                 (round(x), round(y - self.margin_top)),
21                 my_img if self.transparency else None
22             )