forked from 1b-agent/opencadstudio-upstream
Selection tools on the right-edge toolbar instead of contextual tabs
The PDF Underlay and External Reference ribbon tabs are gone. While only PDF underlays are selected their tools (Display in Monochrome, Create Clipping Boundary, Remove Clipping, Show Underlay, Enable Snap, External References, Edit Layers, Import As Objects) sit on the right-edge toolbar, the switches drawn as on while on; while only xrefs are selected the xref tools do. Contrast and fade stay in Properties. Toolbar tooltips are translated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5d3987791e
commit
5a31d2089a
10 files changed
+163
-412
No files matched your search
+19
-4
@@ -26,6 +26,8 @@ fn icon_el(icon: IconKind) -> Element<'static, Message> {
|
||||
}
|
||||
|
||||
fn tip_panel(label: &'static str) -> Element<'static, Message> {
|
||||
// Ribbon labels break over two lines; a tooltip reads them on one.
|
||||
let label = crate::t!(label).replace('\n', " ");
|
||||
container(text(label).size(11))
|
||||
.padding([2, 6])
|
||||
.style(|theme: &Theme| {
|
||||
@@ -48,12 +50,21 @@ fn tip_panel(label: &'static str) -> Element<'static, Message> {
|
||||
/// centred over the canvas. Returns `None` when `tools` is empty so the caller
|
||||
/// can skip pushing an overlay.
|
||||
pub fn view(tools: &[ToolDef]) -> Option<Element<'static, Message>> {
|
||||
view_with_active(tools, &|_| false)
|
||||
}
|
||||
|
||||
/// As [`view`], with the tools `active` names drawn as switched on.
|
||||
pub fn view_with_active(
|
||||
tools: &[ToolDef],
|
||||
active: &dyn Fn(&str) -> bool,
|
||||
) -> Option<Element<'static, Message>> {
|
||||
if tools.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut col = column![].spacing(4).align_x(iced::Center);
|
||||
for t in tools {
|
||||
let on = active(t.id);
|
||||
let btn = button(icon_el(t.icon))
|
||||
.on_press(Message::RibbonToolClick {
|
||||
tool_id: t.id.to_string(),
|
||||
@@ -61,18 +72,22 @@ pub fn view(tools: &[ToolDef]) -> Option<Element<'static, Message>> {
|
||||
})
|
||||
.width(Length::Fixed(BTN_SIZE))
|
||||
.height(Length::Fixed(BTN_SIZE))
|
||||
.style(|theme: &Theme, status| {
|
||||
.style(move |theme: &Theme, status| {
|
||||
let palette = theme.palette();
|
||||
let hovered = matches!(
|
||||
status,
|
||||
button::Status::Hovered | button::Status::Pressed
|
||||
);
|
||||
button::Style {
|
||||
background: hovered
|
||||
.then_some(Background::Color(palette.background.strong.color)),
|
||||
background: if on {
|
||||
Some(Background::Color(palette.primary.weak.color))
|
||||
} else {
|
||||
hovered.then_some(Background::Color(palette.background.strong.color))
|
||||
},
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
..Default::default()
|
||||
color: palette.primary.base.color,
|
||||
width: if on { 1.0 } else { 0.0 },
|
||||
},
|
||||
text_color: palette.background.base.text,
|
||||
..Default::default()
|
||||
|
||||
Reference in new issue
Block a user