Skip to content

Commit

Permalink
refactor(layout): move some logic from Layout to BonsaiTree
Browse files Browse the repository at this point in the history
  • Loading branch information
aravinda0 committed Feb 13, 2024
1 parent a6a295a commit d992c0c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/qtile_bonsai/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,7 @@ def layout(self, windows: Sequence[Window], screen_rect: ScreenRect):
for each window, as there are other elements such as tab-bar panels to process
as well.
"""
for node in self._tree.iter_walk():
if self._tree.is_visible(node):
node.render(screen_rect, self._tree)
else:
node.hide()
self._tree.render(screen_rect)

def configure(self, window: Window, screen_rect: ScreenRect):
"""Defined since this is an abstract method, but not implemented since things
Expand Down Expand Up @@ -358,7 +354,7 @@ def hide(self):
# consistenty with the default tab layout here.
self._on_next_window = self._handle_default_next_window

self._hide_all_internal_windows()
self._tree.hide()

def finalize(self):
self._persist_tree_state()
Expand Down Expand Up @@ -855,10 +851,6 @@ def _handle_rename_tab(self, new_title: str):
tab.title = new_title
self._request_relayout()

def _hide_all_internal_windows(self):
for node in self._tree.iter_walk():
node.hide()

def _request_focus(self, pane: BonsaiPane):
self.group.focus(pane.window)

Expand Down
11 changes: 11 additions & 0 deletions src/qtile_bonsai/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,21 @@ def create_tab(self, title: str = "") -> BonsaiTab:
def create_tab_container(self) -> BonsaiTabContainer:
return BonsaiTabContainer()

def render(self, screen_rect: ScreenRect):
for node in self.iter_walk():
if self.is_visible(node):
node.render(screen_rect, self)
else:
node.hide()

def finalize(self):
for node in self.iter_walk():
node.finalize()

def hide(self):
for node in self.iter_walk():
node.hide()


def place_window_using_box(
window: Window | Internal, box: Box, border_color: str, screen_rect: ScreenRect
Expand Down

0 comments on commit d992c0c

Please sign in to comment.