summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--presentty/slide.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/presentty/slide.py b/presentty/slide.py
index 4894f45..06860fc 100644
--- a/presentty/slide.py
+++ b/presentty/slide.py
@@ -20,6 +20,10 @@ class SlidePile(urwid.Pile):
20 cols = 0 20 cols = 0
21 rows = 0 21 rows = 0
22 for x in self.contents: 22 for x in self.contents:
23 # If we have no columns to use, we won't render, so don't
24 # erroneously accumulate rows.
25 if not size[0]:
26 continue
23 c,r = x[0].pack((size[0],)) 27 c,r = x[0].pack((size[0],))
24 if c>cols: 28 if c>cols:
25 cols = c 29 cols = c
@@ -35,16 +39,25 @@ class SlidePadding(urwid.Padding):
35 39
36class SlideColumns(urwid.Columns): 40class SlideColumns(urwid.Columns):
37 def pack(self, size, focus=False): 41 def pack(self, size, focus=False):
42 # Unlike the normal Columns widget, find the mininum number of
43 # (character) columns necessary to render. This probably only
44 # works for the limited 2-column case we have for bulleted
45 # lists.
46 # cols is the resulting number of columns needed
38 cols = self.dividechars * (len(self.contents)-1) 47 cols = self.dividechars * (len(self.contents)-1)
39 rows = 0 48 rows = 0
49 # Given our current width, col_budget is the number of columns
50 # remaining available.
51 col_budget = size[0]-cols
40 for widget, packing in self.contents: 52 for widget, packing in self.contents:
41 if packing[0] == 'given': 53 if packing[0] == 'given':
42 allocated_cols = packing[1] 54 allocated_cols = packing[1]
43 else: 55 else:
44 allocated_cols = size[0] 56 allocated_cols = col_budget
45 c,r = widget.pack((allocated_cols,)) 57 c,r = widget.pack((allocated_cols,))
46 if packing[0] == 'given': 58 if packing[0] == 'given':
47 c = allocated_cols 59 c = allocated_cols
60 col_budget -= c
48 if r>rows: 61 if r>rows:
49 rows = r 62 rows = r
50 cols += c 63 cols += c