scroller = Gtk.ScrolledWindow(propagate_natural_height=True)
self._col_headers_frame = Gtk.Fixed()
self._col_headers_grid = None
- self._vlabel_height_ref = [0]
+ self._slot_size_ref = [0]
self.frame = Gtk.Box(orientation=OR_V)
self.frame.append(self._col_headers_frame)
self.frame.append(scroller)
if 1 == len(remaining):
for i, attr in enumerate(ancestors):
vlabel = VerticalLabel(f'<b>{attr[0]}</b>: {attr[1]}',
- self._vlabel_height_ref)
+ self._slot_size_ref)
self._grid.attach(vlabel, i, i_row_ref[0], 1, 1)
row = [None] * len(attr_values)
for item in items_of_parent:
vp_top = vp_scroll.get_value()
vp_bottom = vp_top + vp_height
side_offset, i_vlabels = 0, 0
- while True:
- widget = self._grid.get_child_at(i_vlabels, 0)
- if isinstance(widget, VerticalLabel):
- side_offset += widget.width
- else:
- break
- i_vlabels += 1
+ if self._by_1st:
+ while True:
+ widget = self._grid.get_child_at(i_vlabels, 0)
+ if isinstance(widget, VerticalLabel):
+ side_offset += widget.width
+ else:
+ break
+ i_vlabels += 1
max_slot_width = (vp_width - side_offset) // self._per_row
slot_size = min(vp_height, max_slot_width)
- self._vlabel_height_ref[0] = slot_size
+ self._slot_size_ref[0] = slot_size
if self._by_1st:
i_widgets = 0
while True:
for idx, slot in enumerate(self.slots):
slot.ensure_slot_size(slot_size_sans_margin, self._slot_margin)
vp_scroll.set_upper(slot_size * ceil(len(self.slots) / self._per_row))
- if self._scroll_to_focus(slot_size, vp_scroll, vp_top, vp_bottom):
+ if self._scroll_to_focus(vp_scroll, vp_top, vp_bottom):
return
for idx, slot in enumerate(self.slots):
- in_vp, _, _ = self._position_to_viewport(
- idx, slot_size, vp_top, vp_bottom, True)
+ in_vp, _, _ = self._position_to_viewport(idx,
+ vp_top, vp_bottom, True)
slot.update_widget(in_vp)
self._start_redraw_wait = datetime.now()
def _position_to_viewport(
- self, idx, slot_size, vp_top, vp_bottom, in_vp_greedy=False):
+ self, idx, vp_top, vp_bottom, in_vp_greedy=False):
+ slot_size = self._slot_size_ref[0]
slot_top = (idx // self._per_row) * slot_size
slot_bottom = slot_top + slot_size
if in_vp_greedy:
in_vp = (slot_top >= vp_top and slot_bottom <= vp_bottom)
return in_vp, slot_top, slot_bottom
- def _scroll_to_focus(self, slot_size, vp_scroll, vp_top, vp_bottom):
+ def _scroll_to_focus(self, vp_scroll, vp_top, vp_bottom):
+ slot_size = self._slot_size_ref[0]
scroll_to_focus = self._shall_scroll_to_focus
self._shall_redraw, self._shall_scroll_to_focus = False, False
if scroll_to_focus: