Skip to main content

blockworx/tools/
help_menu.rs

1//! The Help submenu: where a reader goes for the whole library, and for the
2//! project itself.
3//!
4//! R15 needed another surface for ยง7's walkthrough entry when the user struck
5//! the parameter bar. There are two, and they answer different questions: the
6//! selection overlay offers the one walkthrough that applies *here*, and this
7//! opens the navigator onto all of them.
8
9use egui::{TextWrapMode, Ui};
10
11const GITHUB_URL: &str = "https://github.com/samitbasu/blockworx";
12
13/// What the menu was asked for. Opening a URL is done here; opening the
14/// navigator is the shell's, since a panel is chrome state.
15#[derive(Clone, Copy, PartialEq, Eq, Debug)]
16pub enum Pick {
17    Learn,
18}
19
20/// See `preferences_menu::no_wrap`: menu popups shrink-to-fit and proportional
21/// fonts can round a label just past the popup width, wrapping the last glyph.
22fn no_wrap(ui: &mut Ui) {
23    ui.style_mut().wrap_mode = Some(TextWrapMode::Extend);
24}
25
26/// Populate the Help submenu.
27pub fn menu(ui: &mut Ui) -> Option<Pick> {
28    no_wrap(ui);
29    let mut picked = None;
30    if ui.button("Tutorials").clicked() {
31        picked = Some(Pick::Learn);
32    }
33    if ui.button("GitHub").clicked() {
34        ui.ctx().open_url(egui::OpenUrl::new_tab(GITHUB_URL));
35    }
36    picked
37}