Coding style.

- Remove similar partition functions.
- Change 40% to 38.198%.  Now the summary and listing panes widths
  are in the golden ratio!
This commit is contained in:
Andrew Hamilton 2021-05-10 23:50:59 +10:00
parent 77ce5c68b0
commit 4eb2334e41

View file

@ -720,17 +720,9 @@ class Screen:
worker_.result.reset()
worker_.kill()
def _partition(self, widgets, height):
smaller_height = max(height // 4, 10)
return [height - smaller_height, smaller_height]
def _partition_2(self, widgets, height):
smaller_height = max(height // 4, 10)
return [smaller_height, height - smaller_height]
def _partition_3(self, widgets, width):
smaller_width = max(int(width // 2.5), 10)
return [smaller_width, width - smaller_width]
def _partition(self, percentage, widgets, length):
smaller_length = max(int(length * (percentage / 100)), 10)
return [smaller_length, length - smaller_length]
def _make_widgets(self):
self._help_widget = Help(self._summary, self)
@ -746,12 +738,15 @@ class Screen:
self._listing = fill3.Border(Listing(self._view))
log = fill3.Border(self._log, title="Log",
characters=Screen._DIMMED_BORDER)
port_log = fill3.Row([fill3.Column([summary, log], self._partition),
self._listing], self._partition_3)
quarter_cut = functools.partial(self._partition, 25)
golden_cut = functools.partial(self._partition, 38.198)
three_quarter_cut = functools.partial(self._partition, 75)
port_log = fill3.Row([fill3.Column([summary, log], three_quarter_cut),
self._listing], golden_cut)
land_log = fill3.Column([fill3.Row([summary, log]), self._listing],
self._partition_2)
port_no_log = fill3.Row([summary, self._listing], self._partition_3)
land_no_log = fill3.Column([summary, self._listing], self._partition_2)
quarter_cut)
port_no_log = fill3.Row([summary, self._listing], golden_cut)
land_no_log = fill3.Column([summary, self._listing], quarter_cut)
self._layouts = [[land_no_log, port_no_log], [land_log, port_log]]
self._set_focus()