@@ -71,6 +71,26 @@ def _window_stats(app):
7171 return stats
7272
7373
74+ def _taskbar_buttons (app , width , stats = None ):
75+ """Return taskbar button layout as `(start_x, end_x, label, win)` tuples."""
76+ window_mgr = getattr (app , "window_mgr" , None )
77+ if window_mgr is not None and hasattr (window_mgr , "taskbar_buttons" ):
78+ return tuple (window_mgr .taskbar_buttons (width ))
79+
80+ if stats is None :
81+ stats = _window_stats (app )
82+
83+ x = 1
84+ buttons = []
85+ for label in stats ["minimized_labels" ]:
86+ btn_w = len (label ) + 2 # [label]
87+ if x + btn_w > width :
88+ break
89+ buttons .append ((x , x + btn_w , label , None ))
90+ x += btn_w + 1
91+ return tuple (buttons )
92+
93+
7494def draw_desktop (app , frame_size = None ):
7595 """Draw the desktop background pattern."""
7696 h , w = _resolve_frame_size (app , frame_size )
@@ -119,39 +139,27 @@ def draw_taskbar(app, frame_size=None):
119139 # Always clear the taskbar line
120140 safe_addstr (app .stdscr , taskbar_y , 0 , ' ' * w , attr )
121141
122- window_mgr = getattr (app , "window_mgr" , None )
123- if window_mgr is not None and hasattr (window_mgr , "taskbar_buttons" ):
124- buttons = window_mgr .taskbar_buttons (w )
125- for start_x , _end_x , label , _win in buttons :
126- safe_addstr (app .stdscr , taskbar_y , start_x , f'[{ label } ]' , attr | curses .A_BOLD )
127- return
128-
129142 stats = _window_stats (app )
130- minimized_labels = stats ["minimized_labels" ]
131- if not minimized_labels :
132- return
133- x = 1
134- for label in minimized_labels :
135- btn = f'[{ label } ]'
136- if x + len (btn ) > w :
137- break
138- safe_addstr (app .stdscr , taskbar_y , x , btn , attr | curses .A_BOLD )
139- x += len (btn ) + 1
143+ buttons = _taskbar_buttons (app , w , stats = stats )
144+ for start_x , _end_x , label , _win in buttons :
145+ safe_addstr (app .stdscr , taskbar_y , start_x , f'[{ label } ]' , attr | curses .A_BOLD )
140146
141147
142148def draw_statusbar (app , version , frame_size = None ):
143- """Draw the bottom status bar."""
149+ """Draw status text on the unified bottom bar without clearing taskbar buttons ."""
144150 h , w = _resolve_frame_size (app , frame_size )
145151 attr = theme_attr ("status" )
146152 stats = _window_stats (app )
147153 visible = stats ["visible" ]
148154 total = stats ["total" ]
149-
150- left_status = f' RetroTUI v{ version } | Windows: { visible } /{ total } | Mouse: Enabled'
151-
152- statusbar_y = h - BOTTOM_BARS_HEIGHT + 1 # Last row: below taskbar
153- # Draw background
154- safe_addstr (app .stdscr , statusbar_y , 0 , ' ' * w , attr )
155+ status_text = f' RetroTUI v{ version } | Windows: { visible } /{ total } | Mouse: Enabled '
155156
156- # Draw left text
157- safe_addstr (app .stdscr , statusbar_y , 0 , left_status , attr )
157+ statusbar_y = h - BOTTOM_BARS_HEIGHT
158+ buttons = _taskbar_buttons (app , w , stats = stats )
159+ left_reserved = buttons [- 1 ][1 ] + 1 if buttons else 0
160+
161+ status_x = left_reserved + 1
162+ max_status_len = w - status_x
163+ if max_status_len <= 0 :
164+ return
165+ safe_addstr (app .stdscr , statusbar_y , status_x , status_text [:max_status_len ], attr )
0 commit comments