use crate::config::Config;
use crate::ui_constants::{
TAB_NEW_PROFILE_MENU_OFFSET_X, TAB_NEW_PROFILE_MENU_OFFSET_Y, TAB_NEW_PROFILE_MENU_WIDTH,
};
use super::TabBarAction;
use super::TabBarUI;
impl TabBarUI {
pub(super) fn render_new_tab_profile_menu(
&mut self,
ctx: &egui::Context,
profiles: &crate::profile::ProfileManager,
config: &Config,
) -> TabBarAction {
let mut action = TabBarAction::None;
if !self.show_new_tab_profile_menu {
return action;
}
if ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
self.show_new_tab_profile_menu = false;
return action;
}
let mut open = true;
egui::Window::new("New Tab")
.collapsible(false)
.resizable(false)
.order(egui::Order::Foreground)
.fixed_size(egui::vec2(TAB_NEW_PROFILE_MENU_WIDTH, 0.0))
.anchor(
egui::Align2::RIGHT_TOP,
egui::vec2(TAB_NEW_PROFILE_MENU_OFFSET_X, TAB_NEW_PROFILE_MENU_OFFSET_Y),
)
.open(&mut open)
.show(ctx, |ui| {
if ui
.selectable_label(false, " Default")
.on_hover_text("Open a new tab with default settings")
.clicked()
{
action = TabBarAction::NewTab;
self.show_new_tab_profile_menu = false;
}
ui.separator();
for profile in profiles.profiles_ordered() {
let icon = profile.icon.as_deref().unwrap_or(" ");
let label = format!("{} {}", icon, profile.name);
if ui.selectable_label(false, &label).clicked() {
action = TabBarAction::NewTabWithProfile(profile.id);
self.show_new_tab_profile_menu = false;
}
}
if config.ai_inspector.ai_inspector_enabled {
ui.separator();
if ui
.selectable_label(false, " Assistant Panel")
.on_hover_text("Toggle the AI assistant panel")
.clicked()
{
action = TabBarAction::ToggleAssistantPanel;
self.show_new_tab_profile_menu = false;
}
}
});
if !open {
self.show_new_tab_profile_menu = false;
}
action
}
}