Introduce maxlines for alerts
This commit is contained in:
parent
1cae3824b2
commit
67008b9c57
@ -135,7 +135,8 @@ class AlertsModule:
|
|||||||
(self.icon_size - 5, align),
|
(self.icon_size - 5, align),
|
||||||
alert["description"],
|
alert["description"],
|
||||||
fill="white", font=fnt_R,
|
fill="white", font=fnt_R,
|
||||||
maxwidth=width-self.icon_size-5
|
maxwidth=width-self.icon_size-5,
|
||||||
|
maxlines=1 if "oneline" in alert and alert["oneline"] else 99,
|
||||||
)
|
)
|
||||||
|
|
||||||
return align + 7
|
return align + 7
|
||||||
@ -196,7 +197,7 @@ class AlertsModule:
|
|||||||
|
|
||||||
return image, more_alerts
|
return image, more_alerts
|
||||||
|
|
||||||
def display_longtext(draw, pos, text, font, anchor="lt", maxwidth=9999, **kwargs):
|
def display_longtext(draw, pos, text, font, anchor="lt", maxwidth=9999, maxlines=999, **kwargs):
|
||||||
x,y = pos
|
x,y = pos
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
@ -218,6 +219,11 @@ def display_longtext(draw, pos, text, font, anchor="lt", maxwidth=9999, **kwargs
|
|||||||
if len(cur) > 0:
|
if len(cur) > 0:
|
||||||
lines.append(cur)
|
lines.append(cur)
|
||||||
|
|
||||||
|
maxlines -= 1
|
||||||
|
if maxlines <= 0:
|
||||||
|
lines[-1] += "…"
|
||||||
|
break
|
||||||
|
|
||||||
line_height = font.getsize("test")[1]
|
line_height = font.getsize("test")[1]
|
||||||
if anchor[1] == "m":
|
if anchor[1] == "m":
|
||||||
y -= line_height * len(lines) / 2
|
y -= line_height * len(lines) / 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user