Skip to content

Commit 47177c1

Browse files
committed
ui: Make side panels to overlay the center panel in autohide layout.
This commit makes the side panels to overlay the body which avoids squashing and stretching of the message view which improves UX in autohide mode.
1 parent 610517d commit 47177c1

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

zulipterminal/ui.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def set_footer_text(
107107
text = self.get_random_help()
108108
else:
109109
text = text_list
110-
self._w.footer.set_text(text)
111-
self._w.footer.set_attr_map({None: style})
110+
self.frame.footer.set_text(text)
111+
self.frame.footer.set_attr_map({None: style})
112112
self.controller.update_screen()
113113
if duration is not None:
114114
assert duration > 0
@@ -142,17 +142,19 @@ def main_window(self) -> Any:
142142
self.right_panel, self.right_tab = self.right_column_view()
143143
if self.controller.autohide:
144144
body = [
145-
(LEFT_WIDTH, self.left_panel),
145+
(TAB_WIDTH, self.left_tab),
146146
("weight", 10, self.center_panel),
147147
(TAB_WIDTH, self.right_tab),
148148
]
149+
focus_column = 1
149150
else:
150151
body = [
151152
(LEFT_WIDTH, self.left_panel),
152153
("weight", 10, self.center_panel),
153154
(RIGHT_WIDTH, self.right_panel),
154155
]
155-
self.body = urwid.Columns(body, focus_column=0)
156+
focus_column = 0
157+
self.body = urwid.Columns(body, focus_column=focus_column)
156158

157159
# NOTE: message_view is None, but middle_column_view is called above
158160
# and sets it.
@@ -177,24 +179,46 @@ def main_window(self) -> Any:
177179
]
178180
)
179181

180-
w = urwid.Frame(
182+
self.frame = urwid.Frame(
181183
self.body, title_bar, focus_part="body", footer=self.footer_view()
182184
)
183-
return w
185+
186+
# Show overlayed left panel on startup in autohide mode
187+
self.show_left_panel(visible=True)
188+
189+
return self.frame
184190

185191
def show_left_panel(self, *, visible: bool) -> None:
186192
if not self.controller.autohide:
187193
return
188-
option = ("given", LEFT_WIDTH) if visible else ("given", TAB_WIDTH)
189-
widget = self.left_panel if visible else self.left_tab
190-
self.body.contents[0] = (widget, self.body.options(*option))
194+
195+
if visible:
196+
self.frame.body = urwid.Overlay(
197+
urwid.Columns([self.left_panel, (1, urwid.SolidFill("▏"))]),
198+
self.body,
199+
align="left",
200+
width=LEFT_WIDTH,
201+
valign="top",
202+
height=("relative", 100),
203+
)
204+
else:
205+
self.frame.body = self.body
191206

192207
def show_right_panel(self, *, visible: bool) -> None:
193208
if not self.controller.autohide:
194209
return
195-
option = ("given", RIGHT_WIDTH) if visible else ("given", TAB_WIDTH)
196-
widget = self.right_panel if visible else self.right_tab
197-
self.body.contents[2] = (widget, self.body.options(*option))
210+
211+
if visible:
212+
self.frame.body = urwid.Overlay(
213+
urwid.Columns([(1, urwid.SolidFill("▕")), self.right_panel]),
214+
self.body,
215+
align="right",
216+
width=LEFT_WIDTH,
217+
valign="top",
218+
height=("relative", 100),
219+
)
220+
else:
221+
self.frame.body = self.body
198222

199223
def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
200224
self.model.new_user_input = True

0 commit comments

Comments
 (0)