Converted LineBoxes to RoundedLineBoxes that look nicer

This commit is contained in:
Daniel Schwarz 2024-01-09 23:36:35 -05:00
parent fb36561923
commit 593c95ea62
4 changed files with 36 additions and 6 deletions

View File

@ -20,7 +20,7 @@ from .overlays import StatusDeleteConfirmation, Account
from .poll import Poll
from .timeline import Timeline
from .utils import get_max_toot_chars, parse_content_links, copy_to_clipboard
from .widgets import ModalBox
from .widgets import ModalBox, RoundedLineBox
logger = logging.getLogger(__name__)
@ -769,7 +769,7 @@ class TUI(urwid.Frame):
)
def open_overlay(self, widget, options={}, title=""):
top_widget = urwid.LineBox(widget, title=title)
top_widget = RoundedLineBox(widget, title=title)
bottom_widget = self.body
_options = self.default_overlay_options.copy()

View File

@ -3,7 +3,7 @@ import urwid
from toot import api
from toot.exceptions import ApiError
from toot.utils.datetime import parse_datetime
from .widgets import Button, CheckBox, RadioButton
from .widgets import Button, CheckBox, RadioButton, RoundedLineBox
from .richtext import html_to_widgets
@ -27,7 +27,7 @@ class Poll(urwid.ListBox):
def build_linebox(self, contents):
contents = urwid.Pile(list(contents))
contents = urwid.Padding(contents, left=1, right=1)
return urwid.LineBox(contents)
return RoundedLineBox(contents)
def vote(self, button_widget):
poll = self.status.original.data.get("poll")

View File

@ -12,7 +12,7 @@ from toot.utils.language import language_name
from toot.entities import Status
from toot.tui.scroll import Scrollable, ScrollBar
from toot.tui.utils import highlight_keys
from toot.tui.widgets import SelectableText, SelectableColumns
from toot.tui.widgets import SelectableText, SelectableColumns, RoundedLineBox
logger = logging.getLogger("toot")
@ -415,7 +415,7 @@ class StatusDetails(urwid.Pile):
def build_linebox(self, contents):
contents = urwid.Pile(list(contents))
contents = urwid.Padding(contents, left=1, right=1)
return urwid.LineBox(contents)
return RoundedLineBox(contents)
def card_generator(self, card):
yield urwid.Text(("card_title", card["title"].strip()))

View File

@ -75,3 +75,33 @@ class ModalBox(urwid.Frame):
filler = urwid.Filler(text, valign='top', top=1, bottom=1)
padding = urwid.Padding(filler, left=1, right=1)
return super().__init__(padding)
class RoundedLineBox(urwid.LineBox):
"""LineBox that defaults to rounded corners."""
def __init__(self,
original_widget,
title="",
title_align="center",
title_attr=None,
tlcorner="\u256d",
tline="",
lline="",
trcorner="\u256e",
blcorner="\u2570",
rline="",
bline="",
brcorner="\u256f",
) -> None:
return super().__init__(original_widget,
title,
title_align,
title_attr,
tlcorner,
tline,
lline,
trcorner,
blcorner,
rline,
bline,
brcorner)