From 6f5a115cff94ec6f226d3012b535cece45895cac Mon Sep 17 00:00:00 2001 From: squid Date: Sun, 8 Nov 2026 14:30:13 +0100 Subject: [PATCH] Fine tuned some dialogs, added some more color settings, enabled drag and drop for profiles and folders in settings --- src/main.rs | 735 +++++++++++++++++++++++++++++++++++++++++++++++---- src/theme.rs | 16 +- 2 files changed, 694 insertions(+), 57 deletions(-) diff --git a/src/main.rs b/src/main.rs index 51ea4ec..fb4bf7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -694,6 +694,8 @@ struct Profile { start_path: String, private_key: String, glyph_color: Color, + /// Hidden profiles stay out of the Start tab list. + hidden: bool, /// UUID of the folder this profile belongs to. folder_id: String, /// File this profile was loaded from or saved to. @@ -716,6 +718,7 @@ struct ProfileDraft { start_path: String, private_key: String, glyph_color: Color, + hidden: bool, color_picker_open: bool, /// Folder and index of the profile being edited. editing: Option<(usize, usize)>, @@ -737,6 +740,7 @@ impl ProfileDraft { start_path: default_start_path(), private_key: String::new(), glyph_color: Color::WHITE, + hidden: false, color_picker_open: false, editing: None, } @@ -757,6 +761,7 @@ impl ProfileDraft { start_path: profile.start_path.clone(), private_key: profile.private_key.clone(), glyph_color: profile.glyph_color, + hidden: profile.hidden, color_picker_open: false, editing: Some((folder, profile_index)), } @@ -1066,6 +1071,8 @@ struct ProfileFile { private_key: String, #[serde(default = "default_profile_glyph_color")] glyph_color: String, + #[serde(default)] + hidden: bool, #[serde(default, skip_serializing_if = "Option::is_none")] trash: Option, } @@ -1157,6 +1164,7 @@ impl ProfileFile { start_path: profile.start_path.clone(), private_key: profile.private_key.clone(), glyph_color: color_to_hex(profile.glyph_color), + hidden: profile.hidden, trash: None, } } @@ -1174,6 +1182,7 @@ impl ProfileFile { start_path: self.start_path, private_key: self.private_key, glyph_color: color_from_hex(&self.glyph_color).unwrap_or(Color::WHITE), + hidden: self.hidden, folder_id: if self.parent_id.trim().is_empty() { self.folder } else { @@ -1194,6 +1203,25 @@ enum Selection { Profile { folder: usize, profile: usize }, } +#[derive(Debug, Clone, Copy)] +struct ProfileMenu { + folder: usize, + profile: usize, + pointer: Point, + /// True when opened from the Settings → Profiles list. + settings: bool, +} + +/// A profile or folder being dragged inside the Settings → Profiles list. +#[derive(Debug, Clone, Copy)] +struct ProfileDrag { + source: Selection, + window: window::Id, + origin: Point, + pointer: Point, + moved: bool, +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum TransferMode { Copy, @@ -1522,8 +1550,8 @@ struct Moorly { command_palette_enabled: bool, command_palette_enabled_draft: bool, advanced_open: bool, - colors: [Color; 6], - saved_colors: [Color; 6], + colors: [Color; 9], + saved_colors: [Color; 9], custom_toasts: bool, toast_colors: [Color; 9], builtin_custom_toasts: bool, @@ -1548,6 +1576,9 @@ struct Moorly { folder_dialog: Option, folder_rename: Option<(usize, String)>, folder_menu: Option<(usize, Point)>, + profile_menu: Option, + profile_drag: Option, + hovered_profile: Option, profile_dialog: Option, dir_picker: Option, next_blank_tab: u32, @@ -1579,16 +1610,22 @@ enum ColorOption { SidebarBackground, Text, Border, + ProfileListBackground, + ProfileVisible, + ProfileHidden, } impl ColorOption { - const ALL: [Self; 6] = [ + const ALL: [Self; 9] = [ Self::Accent, Self::ActiveTabOutline, Self::MainBackground, Self::SidebarBackground, Self::Text, Self::Border, + Self::ProfileListBackground, + Self::ProfileVisible, + Self::ProfileHidden, ]; fn label(self) -> &'static str { @@ -1599,6 +1636,9 @@ impl ColorOption { Self::SidebarBackground => "Sidebar background", Self::Text => "Text color", Self::Border => "Border color", + Self::ProfileListBackground => "Profile list background", + Self::ProfileVisible => "Visible profiles", + Self::ProfileHidden => "Hidden profile", } } @@ -1610,17 +1650,23 @@ impl ColorOption { Self::SidebarBackground => 3, Self::Text => 4, Self::Border => 5, + Self::ProfileListBackground => 6, + Self::ProfileVisible => 7, + Self::ProfileHidden => 8, } } } -const DEFAULT_COLORS: [Color; 6] = [ +const DEFAULT_COLORS: [Color; 9] = [ theme::SETTINGS_ACTIVE, theme::ACTIVE_TAB, theme::TAB_ACTIVE_BG, theme::TAB_INACTIVE_BG, theme::TAB_TEXT, Color::WHITE, + theme::TAB_ACTIVE_BG, + Color::WHITE, + theme::HIDDEN_PROFILE, ]; #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -1719,7 +1765,7 @@ struct CustomTheme { id: String, name: String, based_on: theme::Preference, - colors: [Color; 6], + colors: [Color; 9], custom_toasts: bool, toast_colors: [Color; 9], typography: Typography, @@ -1741,6 +1787,12 @@ struct ThemeFile { text: Option, #[serde(skip_serializing_if = "Option::is_none")] border: Option, + #[serde(skip_serializing_if = "Option::is_none")] + profile_list_background: Option, + #[serde(skip_serializing_if = "Option::is_none")] + visible_profile: Option, + #[serde(skip_serializing_if = "Option::is_none")] + hidden_profile: Option, #[serde(default)] typography: TypographyConfig, #[serde(default)] @@ -1775,8 +1827,8 @@ impl ThemeFile { fn from_colors( name: String, based_on: theme::Preference, - colors: &[Color; 6], - base: &[Color; 6], + colors: &[Color; 9], + base: &[Color; 9], custom_toasts: bool, toast_colors: &[Color; 9], typography: &Typography, @@ -1796,12 +1848,15 @@ impl ThemeFile { sidebar_background: changed(ColorOption::SidebarBackground), text: changed(ColorOption::Text), border: changed(ColorOption::Border), + profile_list_background: changed(ColorOption::ProfileListBackground), + visible_profile: changed(ColorOption::ProfileVisible), + hidden_profile: changed(ColorOption::ProfileHidden), typography: TypographyConfig::from_typography(typography), toast: ToastFile::from_colors(custom_toasts, toast_colors), } } - fn colors(&self, based_on: theme::Preference) -> [Color; 6] { + fn colors(&self, based_on: theme::Preference) -> [Color; 9] { let mut colors = builtin_colors(based_on); let mut apply = |option: ColorOption, value: &Option| { @@ -1816,6 +1871,12 @@ impl ThemeFile { apply(ColorOption::SidebarBackground, &self.sidebar_background); apply(ColorOption::Text, &self.text); apply(ColorOption::Border, &self.border); + apply( + ColorOption::ProfileListBackground, + &self.profile_list_background, + ); + apply(ColorOption::ProfileVisible, &self.visible_profile); + apply(ColorOption::ProfileHidden, &self.hidden_profile); colors } @@ -1860,7 +1921,7 @@ impl ToastFile { } } -fn builtin_colors(_preference: theme::Preference) -> [Color; 6] { +fn builtin_colors(_preference: theme::Preference) -> [Color; 9] { DEFAULT_COLORS } @@ -2618,7 +2679,7 @@ fn write_custom_theme( id: &str, name: &str, based_on: theme::Preference, - colors: &[Color; 6], + colors: &[Color; 9], custom_toasts: bool, toast_colors: &[Color; 9], typography: &Typography, @@ -3593,6 +3654,97 @@ fn apply_transfer(state: &mut Moorly, mode: TransferMode, destination: usize) { save_folders(&state.profile_folders); } +/// Starts a possible drag from a Settings → Profiles row. A drag only begins +/// once the pointer moves far enough to distinguish it from a click. +fn start_profile_drag(state: &mut Moorly, window: window::Id, source: Selection) { + let Some(pointer) = state + .windows + .get(&window) + .and_then(|window_state| window_state.pointer) + else { + return; + }; + + state.profile_drag = Some(ProfileDrag { + source, + window, + origin: pointer, + pointer, + moved: false, + }); + // Reset the drop target so a click without movement never moves anything. + state.hovered_profile = None; + state.hovered_folder = match source { + Selection::Folder(index) => Some(index), + Selection::Profile { .. } => None, + }; +} + +/// Moves the dragged profile or folder (with all its contents) into the folder +/// under the pointer. Reuses the transfer logic used by Copy/Move to. +fn finish_profile_drag(state: &mut Moorly) { + let Some(drag) = state.profile_drag.take() else { + return; + }; + if !drag.moved { + return; + } + + let target = match state.hovered_profile { + Some(Selection::Profile { folder, .. }) => Some(folder), + _ => state.hovered_folder, + }; + let Some(mut target) = target else { + return; + }; + let Some(target_path) = state + .profile_folders + .get(target) + .map(|folder| folder.path.clone()) + else { + return; + }; + + match drag.source { + Selection::Profile { folder, .. } => { + if folder == target { + return; + } + } + Selection::Folder(index) => { + let Some(source_path) = state + .profile_folders + .get(index) + .map(|folder| folder.path.clone()) + else { + return; + }; + + // A folder cannot move into itself or one of its children. + if is_folder_under(&target_path, &source_path) { + return; + } + + let parent = source_path + .rsplit_once('/') + .map(|(parent, _)| parent.to_owned()) + .unwrap_or_default(); + if target_path == parent { + return; + } + + // Dropping onto the ungrouped folder means top level for folders. + if target_path == DEFAULT_PROFILE_FOLDER { + target = ROOT_FOLDER_INDEX; + } + } + } + + state.checked.clear(); + state.checked.insert(drag.source); + apply_transfer(state, TransferMode::Move, target); +} + fn promoted_path(path: &str, selected_folders: &HashSet) -> String { let mut kept = Vec::new(); let mut prefix = String::new(); @@ -4008,7 +4160,7 @@ fn resolve_theme( ) -> ( ThemeChoice, theme::Preference, - [Color; 6], + [Color; 9], bool, [Color; 9], Typography, @@ -4324,6 +4476,9 @@ impl Default for Moorly { folder_dialog: None, folder_rename: None, folder_menu: None, + profile_menu: None, + profile_drag: None, + hovered_profile: None, profile_dialog: None, dir_picker: None, next_blank_tab: 1, @@ -4399,6 +4554,11 @@ enum Message { ToggleAddMenu, CloseAddMenu, ToggleFolder(usize), + SelectFolder(usize), + FolderPressed { + window: window::Id, + index: usize, + }, HoverFolder(Option), HoverTab { tab: Tab, @@ -4408,6 +4568,12 @@ enum Message { folder: usize, profile: usize, }, + ProfilePressed { + window: window::Id, + folder: usize, + profile: usize, + }, + HoverProfile(Option), EditProfile { folder: usize, profile: usize, @@ -4465,6 +4631,21 @@ enum Message { FolderMenuMove(usize), FolderMenuDelete(usize), FolderMenuRename(usize), + OpenProfileMenu { + window: window::Id, + folder: usize, + profile: usize, + settings: bool, + }, + CloseProfileMenu, + ProfileMenuEdit { + folder: usize, + profile: usize, + }, + ProfileMenuToggleHidden { + folder: usize, + profile: usize, + }, FolderRenameChanged(String), ConfirmFolderRename, CancelFolderRename, @@ -4523,14 +4704,36 @@ fn update(state: &mut Moorly, message: Message) -> Task { return scroll_tabs_by(state, window, delta); } } + + if let Some(drag) = state + .profile_drag + .as_mut() + .filter(|drag| drag.window == window) + { + drag.pointer = position; + drag.moved = drag.moved + || (position.x - drag.origin.x).abs() > 4.0 + || (position.y - drag.origin.y).abs() > 4.0; + } + } + Message::PointerReleased(window) => { + finish_profile_drag(state); + return finish_drag(state, window); } - Message::PointerReleased(window) => return finish_drag(state, window), Message::PointerLeft(window) => { if let Some(drag) = state.drag.as_mut() && drag.window == window { drag.detach = true; } + + if state + .profile_drag + .as_ref() + .is_some_and(|drag| drag.window == window) + { + state.profile_drag = None; + } } Message::DragTick => { if let Some(delta) = drag_scroll_delta(state) { @@ -5149,6 +5352,11 @@ fn update(state: &mut Moorly, message: Message) -> Task { } state.selected = Some(Selection::Folder(index)); } + Message::SelectFolder(index) => state.selected = Some(Selection::Folder(index)), + Message::FolderPressed { window, index } => { + state.selected = Some(Selection::Folder(index)); + start_profile_drag(state, window, Selection::Folder(index)); + } Message::HoverFolder(folder) => state.hovered_folder = folder, Message::HoverTab { tab, hovered } => { let now = Instant::now(); @@ -5178,6 +5386,15 @@ fn update(state: &mut Moorly, message: Message) -> Task { Message::SelectProfile { folder, profile } => { state.selected = Some(Selection::Profile { folder, profile }); } + Message::ProfilePressed { + window, + folder, + profile, + } => { + state.selected = Some(Selection::Profile { folder, profile }); + start_profile_drag(state, window, Selection::Profile { folder, profile }); + } + Message::HoverProfile(selection) => state.hovered_profile = selection, Message::EditProfile { folder, profile } => { let Some(existing) = state .profile_folders @@ -5451,6 +5668,7 @@ fn update(state: &mut Moorly, message: Message) -> Task { start_path: draft.start_path.clone(), private_key: draft.private_key.clone(), glyph_color: draft.glyph_color, + hidden: draft.hidden, folder_id, file: existing_file, }; @@ -5553,6 +5771,7 @@ fn update(state: &mut Moorly, message: Message) -> Task { .and_then(|window_state| window_state.pointer) .unwrap_or(Point::new(0.0, 0.0)); state.folder_menu = Some((index, pointer)); + state.profile_menu = None; state.selected = Some(Selection::Folder(index)); } } @@ -5585,6 +5804,51 @@ fn update(state: &mut Moorly, message: Message) -> Task { state.folder_rename = Some((index, folder.name.clone())); return operation::focus(FOLDER_NAME_INPUT); } + Message::OpenProfileMenu { + window, + folder, + profile, + settings, + } => { + if state + .profile_folders + .get(folder) + .is_some_and(|folder| folder.profiles.get(profile).is_some()) + { + let pointer = state + .windows + .get(&window) + .and_then(|window_state| window_state.pointer) + .unwrap_or(Point::new(0.0, 0.0)); + state.profile_menu = Some(ProfileMenu { + folder, + profile, + pointer, + settings, + }); + state.folder_menu = None; + state.selected = Some(Selection::Profile { folder, profile }); + } + } + Message::CloseProfileMenu => state.profile_menu = None, + Message::ProfileMenuEdit { folder, profile } => { + state.profile_menu = None; + return update(state, Message::EditProfile { folder, profile }); + } + Message::ProfileMenuToggleHidden { folder, profile } => { + state.profile_menu = None; + + let Some(folder) = state.profile_folders.get_mut(folder) else { + return Task::none(); + }; + let path = folder.path.clone(); + let Some(profile) = folder.profiles.get_mut(profile) else { + return Task::none(); + }; + + profile.hidden = !profile.hidden; + save_profile(profile, &path); + } Message::FolderRenameChanged(value) => { if let Some((_, draft)) = state.folder_rename.as_mut() { *draft = value.chars().take(150).collect(); @@ -6380,7 +6644,7 @@ fn tab_view( hide_close: bool, close_opacity: f32, width: f32, - colors: [Color; 6], + colors: [Color; 9], ) -> Element<'static, Message> { let title = tab.title(); let padding = Padding::new(10.0); @@ -6494,7 +6758,7 @@ fn tab_view( fn drag_ghost( state: &Moorly, window: window::Id, - colors: [Color; 6], + colors: [Color; 9], ) -> Option> { let drag = state .drag @@ -6553,11 +6817,50 @@ fn drag_ghost( ) } +/// Floating label for the profile or folder being dragged in Settings. +fn profile_drag_ghost(state: &Moorly, window: window::Id) -> Option> { + let drag = state + .profile_drag + .filter(|drag| drag.window == window && drag.moved)?; + let window_state = state.windows.get(&window)?; + + let name = match drag.source { + Selection::Folder(index) => state.profile_folders.get(index)?.name.clone(), + Selection::Profile { folder, profile } => state + .profile_folders + .get(folder)? + .profiles + .get(profile)? + .name + .clone(), + }; + + let x = (drag.pointer.x + 12.0).clamp(0.0, (window_state.size.width - 180.0).max(0.0)); + let y = (drag.pointer.y + 12.0).clamp(0.0, (window_state.size.height - 30.0).max(0.0)); + let ghost = container(text(name).size(12)) + .padding([4, 8]) + .style(theme::menu); + + Some( + container(ghost) + .width(Length::Fill) + .height(Length::Fill) + .align_x(Alignment::Start) + .align_y(Alignment::Start) + .padding(Padding { + top: y, + left: x, + ..Padding::ZERO + }) + .into(), + ) +} + /// Vertical marker showing where the dragged tab will be inserted on release. fn tab_drop_bar( state: &Moorly, window: window::Id, - colors: [Color; 6], + colors: [Color; 9], ) -> Option> { let drag = state .drag @@ -6627,7 +6930,7 @@ fn tab_drop_bar( fn drop_panel( state: &Moorly, window: window::Id, - colors: [Color; 6], + colors: [Color; 9], ) -> Option> { let drag = state.drag.as_ref().filter(|drag| drag.window == window)?; let window_state = state.windows.get(&window)?; @@ -7401,13 +7704,20 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element state.hovered_folder, window, show_add, + state.colors[ColorOption::ProfileVisible.index()], + state.colors[ColorOption::ProfileHidden.index()], )); } + let profile_background = state.colors[ColorOption::ProfileListBackground.index()]; let list = container(scrollable(list).width(Length::Fill).height(Length::Fill)) .width(Length::Fill) .height(Length::Fill) - .style(theme::settings_frame); + .style(move |theme| { + let mut style = theme::settings_frame(theme); + style.background = Some(profile_background.into()); + style + }); let base = column![filter_row] .spacing(12) @@ -7419,7 +7729,6 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element let dialog_open = state.folder_dialog.is_some() || state.folder_rename.is_some() - || state.profile_dialog.is_some() || state.transfer.is_some() || state.trash_open || state.confirm_delete @@ -7454,8 +7763,6 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element Message::CancelTransfer } else if state.confirm_delete { Message::CancelDelete - } else if state.profile_dialog.is_some() { - Message::CancelProfile } else { Message::CloseAddMenu }); @@ -7703,19 +8010,6 @@ fn profiles_panel(state: &Moorly, window: window::Id, show_add: bool) -> Element layers = layers.push(dialog_layer); } - if let Some(draft) = &state.profile_dialog { - let dialog = profile_dialog_view(draft, &state.profile_folders); - let dialog = mouse_area(dialog).on_press(Message::Ignore); - - let dialog_layer = container(dialog) - .width(Length::Fill) - .height(Length::Fill) - .align_x(Alignment::Center) - .align_y(Alignment::Center); - - layers = layers.push(dialog_layer); - } - if let Some(picker) = &state.dir_picker { let dialog = directory_picker_view(picker); let dialog = mouse_area(dialog).on_press(Message::Ignore); @@ -7969,6 +8263,7 @@ fn transfer_dialog_view<'a>(transfer: &TransferDialog, state: &'a Moorly) -> Ele fn profile_dialog_view<'a>( draft: &'a ProfileDraft, folders: &'a [ProfileFolder], + width: f32, ) -> Element<'a, Message> { let title = if draft.editing.is_some() { "Edit profile" @@ -8088,12 +8383,46 @@ fn profile_dialog_view<'a>( .spacing(8); container(column![body, buttons].spacing(16).width(Length::Fill)) - .width(720) + .width(width) .padding(16) .style(theme::menu) .into() } +/// Modal profile dialog rendered above the whole window so the Settings +/// content area does not clip it. +fn profile_dialog_layer(state: &Moorly, window: window::Id) -> Option> { + let draft = state.profile_dialog.as_ref()?; + let window_state = state.windows.get(&window)?; + if window_state.active_tab != Some(Tab::Settings) { + return None; + } + let width = (window_state.size.width * 0.85).clamp(600.0, 1100.0); + + let dialog = mouse_area(profile_dialog_view(draft, &state.profile_folders, width)) + .on_press(Message::Ignore); + let backdrop = mouse_area( + container(space::horizontal()) + .width(Length::Fill) + .height(Length::Fill), + ) + .on_press(Message::CancelProfile); + + Some( + stack![ + backdrop, + container(dialog) + .width(Length::Fill) + .height(Length::Fill) + .align_x(Alignment::Center) + .align_y(Alignment::Center), + ] + .width(Length::Fill) + .height(Length::Fill) + .into(), + ) +} + /// Right-hand side of the profile dialog for the selected profile type. fn profile_kind_view(draft: &ProfileDraft) -> Element<'_, Message> { match draft.kind { @@ -8313,6 +8642,8 @@ fn profile_folder_row<'a>( hovered: Option, window: window::Id, show_checks: bool, + visible_profile_color: Color, + hidden_profile_color: Color, ) -> Element<'a, Message> { let is_selected = selected == Some(Selection::Folder(index)); let expanded = folder.expanded; @@ -8362,7 +8693,6 @@ fn profile_folder_row<'a>( } let heading = button(heading_content) - .on_press(Message::ToggleFolder(index)) .width(Length::Fill) .padding(Padding { top: 8.0, @@ -8370,7 +8700,13 @@ fn profile_folder_row<'a>( bottom: 8.0, left: if show_checks { 0.0 } else { 10.0 + indent }, }) - .style(move |theme, status| { + .style(move |theme, _status| { + // The button is click-through; hover comes from the folder being hovered. + let status = if hovered == Some(index) { + button::Status::Hovered + } else { + button::Status::Active + }; let mut style = theme::selectable_row(theme, status, is_selected); if !expanded { style.text_color = style.text_color.scale_alpha(0.6); @@ -8378,9 +8714,17 @@ fn profile_folder_row<'a>( style }); + let press = if show_checks { + Message::FolderPressed { window, index } + } else { + Message::SelectFolder(index) + }; let mut heading = mouse_area(heading) + .on_press(press) + .on_double_click(Message::ToggleFolder(index)) .on_enter(Message::HoverFolder(Some(index))) - .on_exit(Message::HoverFolder(None)); + .on_exit(Message::HoverFolder(None)) + .interaction(mouse::Interaction::Pointer); if show_checks { heading = heading.on_right_press(Message::OpenFolderMenu(window, index)); @@ -8426,6 +8770,10 @@ fn profile_folder_row<'a>( if expanded { for (profile_index, profile) in folder.profiles.iter().enumerate() { + if profile.hidden && !show_checks { + continue; + } + let profile_selected = selected == Some(Selection::Profile { folder: index, @@ -8435,10 +8783,15 @@ fn profile_folder_row<'a>( folder: index, profile: profile_index, }); + let name_color = if profile.hidden { + hidden_profile_color + } else { + visible_profile_color + }; let profile_row = button( row![ profile_glyph(profile.kind, profile.glyph_color), - text(profile.name.as_str()).size(13) + text(profile.name.as_str()).size(13).color(name_color) ] .spacing(8) .align_y(Alignment::Center), @@ -8451,15 +8804,40 @@ fn profile_folder_row<'a>( left: if show_checks { 0.0 } else { 26.0 + indent }, }) .style(move |theme, status| theme::selectable_row(theme, status, profile_selected)); - let profile_row = mouse_area(profile_row) - .on_press(Message::SelectProfile { + let press = if show_checks { + Message::ProfilePressed { + window, folder: index, profile: profile_index, - }) - .on_double_click(Message::EditProfile { + } + } else { + Message::SelectProfile { folder: index, profile: profile_index, - }); + } + }; + let profile_row = mouse_area(profile_row).on_press(press); + // Only the Settings list edits and drags; the start tab keeps them free. + let profile_row = if show_checks { + profile_row + .on_double_click(Message::EditProfile { + folder: index, + profile: profile_index, + }) + .on_enter(Message::HoverProfile(Some(Selection::Profile { + folder: index, + profile: profile_index, + }))) + .on_exit(Message::HoverProfile(None)) + } else { + profile_row + }; + let profile_row = profile_row.on_right_press(Message::OpenProfileMenu { + window, + folder: index, + profile: profile_index, + settings: show_checks, + }); if show_checks { let profile_checkbox = @@ -8492,7 +8870,7 @@ fn profile_folder_row<'a>( /// Landing tab: the profile listing with a shortcut to the Settings page. fn start_page(state: &Moorly, window: window::Id) -> Element<'_, Message> { - responsive(move |size| { + let page: Element<'_, Message> = responsive(move |size| { // Half the window and 60% of its height, with sensible minimums. let width = (size.width * 0.5).max(400.0); let list_height = (size.height * 0.6).max(300.0); @@ -8518,9 +8896,7 @@ fn start_page(state: &Moorly, window: window::Id) -> Element<'_, Message> { .width(Length::Fill) .align_x(Alignment::Center), ) - .width(width) - .padding(12) - .style(theme::settings_frame), + .width(width), ) .width(Length::Fill) .height(Length::Fill) @@ -8528,7 +8904,23 @@ fn start_page(state: &Moorly, window: window::Id) -> Element<'_, Message> { .padding(16) .into() }) - .into() + .into(); + + if let Some(menu) = profile_context_menu(state, window, false) { + let backdrop = mouse_area( + container(space::horizontal()) + .width(Length::Fill) + .height(Length::Fill), + ) + .on_press(Message::CloseProfileMenu); + + return stack![page, backdrop, menu] + .width(Length::Fill) + .height(Length::Fill) + .into(); + } + + page } /// General settings that are edited as a draft until saved. @@ -8689,6 +9081,89 @@ fn folder_context_menu(state: &Moorly, window: window::Id) -> Option