Implement and archive Phase 5 form designer
This commit is contained in:
@@ -101,7 +101,6 @@ impl Command {
|
||||
pub fn feature_phase(self) -> Option<u8> {
|
||||
use Command::*;
|
||||
match self {
|
||||
Events | Grid | Palette | MenuDesign | Toolbox | Tool(_) => Some(5),
|
||||
NextStatement | AddWatch | InstantWatch | Watchpoint | DeleteWatch | DeleteWatches
|
||||
| Trace | History | Breakpoint | ClearBreakpoints | BreakErrors | SetStatement
|
||||
| RunToCursor | Step | ProcedureStep | HistoryBack | HistoryForward => Some(6),
|
||||
@@ -113,7 +112,7 @@ impl Command {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Item {
|
||||
/// & markiert das sichtbare Mnemonic, … einen Dialog.
|
||||
pub label: &'static str,
|
||||
pub label: String,
|
||||
pub command: Option<Command>,
|
||||
}
|
||||
impl Item {
|
||||
@@ -136,12 +135,12 @@ pub struct Menu {
|
||||
}
|
||||
pub fn menus(designer: bool) -> Vec<Menu> {
|
||||
use Command::*;
|
||||
let item = |label, command| Item {
|
||||
label,
|
||||
let item = |label: &str, command| Item {
|
||||
label: label.into(),
|
||||
command: Some(command),
|
||||
};
|
||||
let sep = || Item {
|
||||
label: "────────",
|
||||
label: "────────".into(),
|
||||
command: None,
|
||||
};
|
||||
let menu = |title, mnemonic, items| Menu {
|
||||
@@ -211,27 +210,30 @@ pub fn menus(designer: bool) -> Vec<Menu> {
|
||||
result[2]
|
||||
.items
|
||||
.extend([sep(), item("&Menu Bar", MenuBar), item("&Grid Lines", Grid)]);
|
||||
result.push(menu(
|
||||
"Tools",
|
||||
't',
|
||||
vec![
|
||||
item("&Check Box", Tool("CheckBox")),
|
||||
item("C&ombo Box", Tool("ComboBox")),
|
||||
item("Command &Button", Tool("CommandButton")),
|
||||
item("&Dir List", Tool("DirListBox")),
|
||||
item("D&rive List", Tool("DriveListBox")),
|
||||
item("&File List", Tool("FileListBox")),
|
||||
item("Fr&ame", Tool("Frame")),
|
||||
item("&HScrollBar", Tool("HScrollBar")),
|
||||
item("&Label", Tool("Label")),
|
||||
item("L&ist Box", Tool("ListBox")),
|
||||
item("O&ption Button", Tool("OptionButton")),
|
||||
item("Pict&ure Box", Tool("PictureBox")),
|
||||
item("&Text Box", Tool("TextBox")),
|
||||
item("Ti&mer", Tool("Timer")),
|
||||
item("&VScrollBar", Tool("VScrollBar")),
|
||||
],
|
||||
));
|
||||
result.push(menu("Tools", 't', {
|
||||
let mut used = std::collections::BTreeSet::new();
|
||||
crate::designer::tools()
|
||||
.into_iter()
|
||||
.map(|(name, _, _)| {
|
||||
let mut label = name.to_owned();
|
||||
if let Some((at, c)) = name
|
||||
.char_indices()
|
||||
.find(|(_, c)| !used.contains(&c.to_ascii_lowercase()))
|
||||
{
|
||||
used.insert(c.to_ascii_lowercase());
|
||||
label.insert(at, '&');
|
||||
} else {
|
||||
let c = ('1'..='9').find(|c| !used.contains(c)).unwrap();
|
||||
used.insert(c);
|
||||
label = format!("&{c} {label}");
|
||||
}
|
||||
Item {
|
||||
label,
|
||||
command: Some(Tool(name)),
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}));
|
||||
} else {
|
||||
result.extend([
|
||||
menu(
|
||||
|
||||
Reference in New Issue
Block a user