forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
@@ -228,7 +228,9 @@ impl ContextMenu {
|
||||
header: None,
|
||||
}),
|
||||
MenuRow::Separator => {}
|
||||
MenuRow::Submenu { id, items, open, .. } => {
|
||||
MenuRow::Submenu {
|
||||
id, items, open, ..
|
||||
} => {
|
||||
out.push(Selectable {
|
||||
action: MenuAction::ToggleSubmenu(*id),
|
||||
mnemonic: None,
|
||||
@@ -416,7 +418,10 @@ pub fn build_context_menu(ctx: &MenuContext, open_submenu: Option<SubmenuId>) ->
|
||||
),
|
||||
MenuContext::Grip(grip) => grip_rows(grip),
|
||||
};
|
||||
let mut menu = ContextMenu { rows, width: MENU_WIDTH };
|
||||
let mut menu = ContextMenu {
|
||||
rows,
|
||||
width: MENU_WIDTH,
|
||||
};
|
||||
if menu.has_hints() {
|
||||
menu.width = MENU_WIDTH_WITH_HINTS;
|
||||
}
|
||||
@@ -452,7 +457,9 @@ fn command_rows(
|
||||
_ => "⏎".to_string(),
|
||||
};
|
||||
rows.push(MenuRow::Item(
|
||||
MenuItem::new(t!("Enter").into_owned(), MenuAction::Enter).hint(enter_hint).default(),
|
||||
MenuItem::new(t!("Enter").into_owned(), MenuAction::Enter)
|
||||
.hint(enter_hint)
|
||||
.default(),
|
||||
));
|
||||
rows.push(MenuRow::Item(
|
||||
MenuItem::new(t!("Cancel").into_owned(), MenuAction::Cancel).hint("Esc"),
|
||||
@@ -543,8 +550,11 @@ fn navigation_rows(transparent: bool) -> Vec<MenuRow> {
|
||||
let prefix = if transparent { "'" } else { "" };
|
||||
vec![
|
||||
MenuRow::Item(
|
||||
MenuItem::new(t!("Pan").into_owned(), MenuAction::Command(format!("{prefix}PAN")))
|
||||
.icon(MenuIcon::Chrome(crate::ui::icons::pan_icon())),
|
||||
MenuItem::new(
|
||||
t!("Pan").into_owned(),
|
||||
MenuAction::Command(format!("{prefix}PAN")),
|
||||
)
|
||||
.icon(MenuIcon::Chrome(crate::ui::icons::pan_icon())),
|
||||
),
|
||||
MenuRow::Item(
|
||||
MenuItem::new(
|
||||
@@ -600,15 +610,18 @@ fn idle_rows(
|
||||
rows.push(MenuRow::Submenu {
|
||||
id: SubmenuId::Clipboard,
|
||||
label: t!("Clipboard").into_owned(),
|
||||
icon: None,
|
||||
icon: None,
|
||||
items: vec![
|
||||
cmd(t!("Cut").into_owned(), "CUTCLIP").enabled(has_selection),
|
||||
cmd(t!("Copy").into_owned(), "COPYCLIP").enabled(has_selection),
|
||||
cmd(t!("Copy with Base Point").into_owned(), "COPYBASE").enabled(has_selection),
|
||||
cmd(t!("Paste").into_owned(), "PASTECLIP").enabled(clipboard_nonempty),
|
||||
cmd(t!("Paste as Block").into_owned(), "PASTEBLOCK").enabled(clipboard_nonempty),
|
||||
cmd(t!("Paste to Original Coordinates").into_owned(), "PASTEORIG")
|
||||
.enabled(clipboard_nonempty),
|
||||
cmd(
|
||||
t!("Paste to Original Coordinates").into_owned(),
|
||||
"PASTEORIG",
|
||||
)
|
||||
.enabled(clipboard_nonempty),
|
||||
],
|
||||
open: open_submenu == Some(SubmenuId::Clipboard),
|
||||
});
|
||||
@@ -644,7 +657,10 @@ fn idle_rows(
|
||||
.command_icon("ERASE"),
|
||||
));
|
||||
rows.push(MenuRow::Item(cmd(t!("Move").into_owned(), "MOVE")));
|
||||
rows.push(MenuRow::Item(cmd(t!("Copy Selection").into_owned(), "COPY")));
|
||||
rows.push(MenuRow::Item(cmd(
|
||||
t!("Copy Selection").into_owned(),
|
||||
"COPY",
|
||||
)));
|
||||
rows.push(MenuRow::Item(cmd(t!("Scale").into_owned(), "SCALE")));
|
||||
rows.push(MenuRow::Item(cmd(t!("Rotate").into_owned(), "ROTATE")));
|
||||
rows.push(MenuRow::Item(cmd(t!("Mirror").into_owned(), "MIRROR")));
|
||||
@@ -697,7 +713,10 @@ fn idle_rows(
|
||||
// The edit menu is long already; Zoom Extents stays on the idle menu
|
||||
// (and on the middle button's double-click), as in commercial solutions.
|
||||
if !has_selection {
|
||||
rows.push(MenuRow::Item(cmd(t!("Zoom Extents").into_owned(), "ZOOM EXTENTS")));
|
||||
rows.push(MenuRow::Item(cmd(
|
||||
t!("Zoom Extents").into_owned(),
|
||||
"ZOOM EXTENTS",
|
||||
)));
|
||||
}
|
||||
rows.push(MenuRow::Separator);
|
||||
|
||||
@@ -717,7 +736,10 @@ fn idle_rows(
|
||||
)));
|
||||
}
|
||||
if !has_selection {
|
||||
rows.push(MenuRow::Item(cmd(t!("Select All").into_owned(), "SELECTALL")));
|
||||
rows.push(MenuRow::Item(cmd(
|
||||
t!("Select All").into_owned(),
|
||||
"SELECTALL",
|
||||
)));
|
||||
}
|
||||
rows.push(MenuRow::Item(MenuItem::new(
|
||||
t!("Quick Select...").into_owned(),
|
||||
@@ -757,7 +779,11 @@ fn grip_rows(grip: &GripMenuContext) -> Vec<MenuRow> {
|
||||
MenuItem::new(label, MenuAction::Grip(cmd)).command_icon(command)
|
||||
};
|
||||
vec![
|
||||
MenuRow::Item(MenuItem::new(t!("Enter").into_owned(), MenuAction::Enter).hint("⏎").default()),
|
||||
MenuRow::Item(
|
||||
MenuItem::new(t!("Enter").into_owned(), MenuAction::Enter)
|
||||
.hint("⏎")
|
||||
.default(),
|
||||
),
|
||||
MenuRow::Separator,
|
||||
MenuRow::Item(
|
||||
g(t!("Stretch").into_owned(), GripMenuCmd::Stretch)
|
||||
@@ -792,7 +818,9 @@ mod tests {
|
||||
match row {
|
||||
MenuRow::Item(item) => out.push(item.label.clone()),
|
||||
MenuRow::Separator => out.push("---".into()),
|
||||
MenuRow::Submenu { label, items, open, .. } => {
|
||||
MenuRow::Submenu {
|
||||
label, items, open, ..
|
||||
} => {
|
||||
out.push(format!("{label} >"));
|
||||
if *open {
|
||||
out.extend(items.iter().map(|i| format!(" {}", i.label)));
|
||||
@@ -1033,9 +1061,15 @@ mod tests {
|
||||
let undo = t!("Undo %{label}", label = "LINE").into_owned();
|
||||
assert!(rows.contains(&undo), "{rows:?}");
|
||||
let sel = menu.selectable();
|
||||
let redo = sel.iter().find(|s| s.action == MenuAction::Redo).expect("redo row");
|
||||
let redo = sel
|
||||
.iter()
|
||||
.find(|s| s.action == MenuAction::Redo)
|
||||
.expect("redo row");
|
||||
assert!(!redo.enabled);
|
||||
let undo = sel.iter().find(|s| s.action == MenuAction::Undo).expect("undo row");
|
||||
let undo = sel
|
||||
.iter()
|
||||
.find(|s| s.action == MenuAction::Undo)
|
||||
.expect("undo row");
|
||||
assert!(undo.enabled);
|
||||
}
|
||||
|
||||
@@ -1043,7 +1077,9 @@ mod tests {
|
||||
fn selectable_skips_separators_and_closed_submenus() {
|
||||
let menu = build_context_menu(&idle_ctx(false), None);
|
||||
let sel = menu.selectable();
|
||||
assert!(sel.iter().all(|s| s.action != MenuAction::Command("PASTECLIP".into())));
|
||||
assert!(sel
|
||||
.iter()
|
||||
.all(|s| s.action != MenuAction::Command("PASTECLIP".into())));
|
||||
assert!(sel.iter().any(|s| s.header == Some(SubmenuId::Clipboard)));
|
||||
let open = build_context_menu(&idle_ctx(false), Some(SubmenuId::Clipboard));
|
||||
assert!(open
|
||||
|
||||
@@ -26,9 +26,18 @@ pub fn cycle_popup_overlay(
|
||||
) -> Element<'static, Message> {
|
||||
// The type column and the layer column get one shared width each (the
|
||||
// widest entry of their kind, clamped) so the separators line up.
|
||||
let type_w = clamp_col_width(items.iter().map(|c| c.type_name.chars().count()), 11.0, 40.0, 96.0);
|
||||
let layer_w =
|
||||
clamp_col_width(items.iter().map(|c| c.layer.chars().count()), 10.0, 28.0, 84.0);
|
||||
let type_w = clamp_col_width(
|
||||
items.iter().map(|c| c.type_name.chars().count()),
|
||||
11.0,
|
||||
40.0,
|
||||
96.0,
|
||||
);
|
||||
let layer_w = clamp_col_width(
|
||||
items.iter().map(|c| c.layer.chars().count()),
|
||||
10.0,
|
||||
28.0,
|
||||
84.0,
|
||||
);
|
||||
|
||||
let rows: Vec<Element<'static, Message>> = items
|
||||
.into_iter()
|
||||
|
||||
@@ -4,15 +4,12 @@ use iced::widget::{button, row, text};
|
||||
use iced::{Element, Fill};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
use crate::t;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
|
||||
/// - `has_selection`: enables Isolate / Hide (they act on the selection).
|
||||
/// - `isolation_active`: enables End Isolation (something is hidden).
|
||||
pub fn menu_entries(
|
||||
has_selection: bool,
|
||||
isolation_active: bool,
|
||||
) -> Vec<Entry<'static>> {
|
||||
pub fn menu_entries(has_selection: bool, isolation_active: bool) -> Vec<Entry<'static>> {
|
||||
vec![
|
||||
action_entry(
|
||||
"Isolate Objects",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Polar-tracking angle status menu.
|
||||
|
||||
use crate::t;
|
||||
use iced::widget::{button, container, row, text, text_input};
|
||||
use iced::{Element, Fill, Length};
|
||||
use crate::t;
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
@@ -20,10 +20,7 @@ pub fn angle_label(deg: f32) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn menu_entries<'a>(
|
||||
current: f32,
|
||||
custom: &'a str,
|
||||
) -> Vec<Entry<'a>> {
|
||||
pub fn menu_entries<'a>(current: f32, custom: &'a str) -> Vec<Entry<'a>> {
|
||||
let mut entries: Vec<Entry<'a>> = PRESETS
|
||||
.iter()
|
||||
.map(|°| {
|
||||
@@ -40,12 +37,9 @@ pub fn menu_entries<'a>(
|
||||
.padding([2, 6])
|
||||
.width(Length::Fixed(58.0));
|
||||
let custom_row = container(
|
||||
row![
|
||||
custom_field,
|
||||
text("°").size(11),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
row![custom_field, text("°").size(11),]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.padding([5, 10]);
|
||||
entries.push(Entry::stay(custom_row));
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Annotation / viewport scale status menu.
|
||||
|
||||
use crate::t;
|
||||
use iced::widget::{button, row, text};
|
||||
use iced::{Element, Fill};
|
||||
use crate::t;
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
@@ -29,9 +29,7 @@ pub fn menu_entries(
|
||||
label.eq_ignore_ascii_case(current_scale_name)
|
||||
|| (current_scale_name.is_empty()
|
||||
&& viewport_scale
|
||||
.map(|vs| {
|
||||
(vs - vp_scale).abs() < 0.001 * vp_scale.max(0.001)
|
||||
})
|
||||
.map(|vs| (vs - vp_scale).abs() < 0.001 * vp_scale.max(0.001))
|
||||
.unwrap_or(false))
|
||||
};
|
||||
let msg = if is_model {
|
||||
|
||||
@@ -4,19 +4,16 @@
|
||||
|
||||
use rustc_hash::FxHashSet as HashSet;
|
||||
|
||||
use crate::t;
|
||||
use iced::widget::{button, container, row, text};
|
||||
use iced::{Background, Element, Fill, Theme};
|
||||
use crate::t;
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
|
||||
/// - `types`: entity-type names present in the current layout.
|
||||
/// - `excluded`: types currently filtered out (unchecked).
|
||||
pub fn menu_entries(
|
||||
types: &[String],
|
||||
excluded: &HashSet<String>,
|
||||
) -> Vec<Entry<'static>> {
|
||||
pub fn menu_entries(types: &[String], excluded: &HashSet<String>) -> Vec<Entry<'static>> {
|
||||
// "Select All / Clear All" header, mirroring the OSNAP popup: Select All
|
||||
// clears every exclusion, Clear All excludes every present type.
|
||||
let has_types = !types.is_empty();
|
||||
@@ -39,9 +36,7 @@ pub fn menu_entries(
|
||||
|
||||
let divider = container(iced::widget::Space::new().height(1))
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.weak.color,
|
||||
)),
|
||||
background: Some(Background::Color(theme.palette().background.weak.color)),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
@@ -81,25 +76,18 @@ fn type_row(name: String, included: bool) -> Element<'static, Message> {
|
||||
|
||||
fn empty_row() -> Element<'static, Message> {
|
||||
container(
|
||||
text(t!("No objects")).size(11).style(|theme: &Theme| text::Style {
|
||||
color: Some(
|
||||
theme
|
||||
.palette()
|
||||
.background
|
||||
.base
|
||||
.text
|
||||
.scale_alpha(0.42),
|
||||
),
|
||||
}),
|
||||
text(t!("No objects"))
|
||||
.size(11)
|
||||
.style(|theme: &Theme| text::Style {
|
||||
color: Some(theme.palette().background.base.text.scale_alpha(0.42)),
|
||||
}),
|
||||
)
|
||||
.padding([4, 10])
|
||||
.into()
|
||||
.padding([4, 10])
|
||||
.into()
|
||||
}
|
||||
|
||||
fn header_btn(label: &str, msg: Message, enabled: bool) -> Element<'_, Message> {
|
||||
let b = button(text(t!(label)).size(10));
|
||||
let b = if enabled { b.on_press(msg) } else { b };
|
||||
b.style(button::secondary)
|
||||
.padding([3, 8])
|
||||
.into()
|
||||
b.style(button::secondary).padding([3, 8]).into()
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
use iced::widget::{button, checkbox, column, container, row, text};
|
||||
use iced::{Background, Element, Fill, Length, Theme};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::app::settings::IsoPlane;
|
||||
use crate::app::Message;
|
||||
use crate::snap::{SnapType, Snapper, ALL_SNAP_MODES};
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
use crate::t;
|
||||
use crate::ui::statusbar::status_menu::Entry;
|
||||
|
||||
pub fn menu_entries<'a>(
|
||||
snapper: &'a Snapper,
|
||||
@@ -27,9 +27,7 @@ pub fn menu_entries<'a>(
|
||||
// Divider
|
||||
let divider = container(iced::widget::Space::new().height(1))
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.weak.color,
|
||||
)),
|
||||
background: Some(Background::Color(theme.palette().background.weak.color)),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
@@ -64,9 +62,7 @@ pub fn menu_entries<'a>(
|
||||
.padding([5, 8]);
|
||||
let drafting_divider = container(iced::widget::Space::new().height(1))
|
||||
.style(|theme: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
theme.palette().background.weak.color,
|
||||
)),
|
||||
background: Some(Background::Color(theme.palette().background.weak.color)),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
@@ -119,7 +115,5 @@ fn snap_row<'a>(snap_type: SnapType, label: &'a str, active: bool) -> Element<'a
|
||||
fn header_btn(label: &str, msg: Message, enabled: bool) -> Element<'_, Message> {
|
||||
let b = button(text(t!(label)).size(10));
|
||||
let b = if enabled { b.on_press(msg) } else { b };
|
||||
b.style(button::secondary)
|
||||
.padding([3, 8])
|
||||
.into()
|
||||
b.style(button::secondary).padding([3, 8]).into()
|
||||
}
|
||||
Reference in new issue
Block a user