MCPcopy Create free account
hub / github.com/GCWing/BitFun / render

Method render

src/apps/cli/src/ui/skill_selector.rs:177–226  ·  view source on GitHub ↗

Render the skill selector popup as an overlay

(&mut self, frame: &mut Frame, area: Rect, theme: &Theme)

Source from the content-addressed store, hash-verified

175
176 /// Render the skill selector popup as an overlay
177 pub fn render(&mut self, frame: &mut Frame, area: Rect, theme: &Theme) {
178 if !self.visible || self.len() == 0 {
179 self.last_area = None;
180 return;
181 }
182
183 let popup_width = area.width.saturating_sub(4).min(92);
184 let popup_height = (self.len() as u16 + 4).min(area.height.saturating_sub(2));
185 if popup_height < 5 || popup_width < 20 {
186 self.last_area = None;
187 return;
188 }
189
190 let popup_x = area.x + (area.width.saturating_sub(popup_width)) / 2;
191 let popup_y = area.y + (area.height.saturating_sub(popup_height)) / 2;
192
193 let popup_area = Rect {
194 x: popup_x,
195 y: popup_y,
196 width: popup_width,
197 height: popup_height,
198 };
199 self.last_area = Some(popup_area);
200
201 let list_items = self.render_items(theme);
202 let title = match self.screen {
203 SkillSelectorScreen::Menu => " Skills ",
204 SkillSelectorScreen::List => " List Skills (current mode) ",
205 SkillSelectorScreen::Configure => " Enable/Disable Skills (Space/Enter Toggle) ",
206 };
207
208 let block = Block::default()
209 .borders(Borders::ALL)
210 .border_style(theme.style(StyleKind::Primary))
211 .style(Style::default().bg(theme.background))
212 .title(title);
213
214 let list = List::new(list_items)
215 .block(block)
216 .style(Style::default().bg(theme.background))
217 .highlight_style(
218 Style::default()
219 .bg(theme.primary)
220 .fg(theme.selection_foreground())
221 .add_modifier(Modifier::BOLD),
222 );
223
224 frame.render_widget(Clear, popup_area);
225 frame.render_stateful_widget(list, popup_area, &mut self.list_state);
226 }
227
228 /// Handle mouse events
229 pub fn handle_mouse_event(&mut self, mouse: &MouseEvent) -> Option<SkillSelectorAction> {

Callers

nothing calls this directly

Calls 5

titleMethod · 0.80
styleMethod · 0.80
selection_foregroundMethod · 0.80
lenMethod · 0.45
render_itemsMethod · 0.45

Tested by

no test coverage detected