Generalize bias handling
This commit is contained in:
parent
3fdf47c535
commit
5158d49781
1 changed files with 10 additions and 8 deletions
|
|
@ -42,14 +42,15 @@ def calc_window_length(cells_in_window):
|
|||
inner_length = cells_in_window * cell_length
|
||||
return 2 * (border_length + margin_length) + inner_length
|
||||
|
||||
if bias is not None and number_of_windows == 2:
|
||||
cells_per_window = int(bias * number_of_cells)
|
||||
window_length = calc_window_length(cells_per_window)
|
||||
yield pos, cells_per_window
|
||||
pos += window_length
|
||||
cells_per_window = number_of_cells - cells_per_window
|
||||
window_length = calc_window_length(cells_per_window)
|
||||
yield pos, cells_per_window
|
||||
if bias is not None and number_of_windows > 1 and len(bias) == number_of_windows:
|
||||
cells_map = [int(b * number_of_cells) for b in bias]
|
||||
extra = number_of_cells - sum(cells_map)
|
||||
if extra:
|
||||
cells_map[-1] += extra
|
||||
for cells_per_window in cells_map:
|
||||
window_length = calc_window_length(cells_per_window)
|
||||
yield pos, cells_per_window
|
||||
pos += window_length
|
||||
return
|
||||
|
||||
window_length = calc_window_length(cells_per_window)
|
||||
|
|
@ -318,6 +319,7 @@ def parse_layout_opts(self, layout_opts):
|
|||
except Exception:
|
||||
ans['bias'] = 0.5
|
||||
ans['bias'] = max(0.1, min(ans['bias'], 0.9))
|
||||
ans['bias'] = ans['bias'], 1.0 - ans['bias']
|
||||
return ans
|
||||
|
||||
def do_layout(self, windows, active_window_idx):
|
||||
|
|
|
|||
Loading…
Reference in a new issue