cargo fmt
This commit is contained in:
parent
468cbde5e1
commit
ca07268c7c
204 changed files with 13988 additions and 5516 deletions
|
|
@ -12,10 +12,10 @@ use acadrust::types::{Color as AcadColor, LineWeight};
|
|||
use iced::widget::{button, column, container, mouse_area, row, scrollable, svg, text};
|
||||
use iced::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
|
||||
|
||||
use crate::app::Message;
|
||||
use crate::modules::registry;
|
||||
use crate::modules::{CadModule, IconKind, RibbonItem};
|
||||
use crate::ui::properties::{LinetypeItem, color_picker_dropdown, lw_options};
|
||||
use crate::app::Message;
|
||||
use crate::ui::properties::{color_picker_dropdown, lw_options, LinetypeItem};
|
||||
|
||||
mod widgets;
|
||||
use widgets::{StyleContext, *};
|
||||
|
|
@ -104,10 +104,14 @@ impl Ribbon {
|
|||
|
||||
pub fn set_styles(
|
||||
&mut self,
|
||||
text: Vec<String>, active_text: &str,
|
||||
dim: Vec<String>, active_dim: &str,
|
||||
mleader: Vec<String>, active_mleader: &str,
|
||||
table: Vec<String>, active_table: &str,
|
||||
text: Vec<String>,
|
||||
active_text: &str,
|
||||
dim: Vec<String>,
|
||||
active_dim: &str,
|
||||
mleader: Vec<String>,
|
||||
active_mleader: &str,
|
||||
table: Vec<String>,
|
||||
active_table: &str,
|
||||
) {
|
||||
self.text_style_names = text;
|
||||
self.active_text_style = active_text.to_string();
|
||||
|
|
@ -187,7 +191,12 @@ impl Ribbon {
|
|||
|
||||
// ── View ──────────────────────────────────────────────────────────────
|
||||
|
||||
pub fn view(&self, is_paper: bool, undo_count: usize, redo_count: usize) -> Element<'_, Message> {
|
||||
pub fn view(
|
||||
&self,
|
||||
is_paper: bool,
|
||||
undo_count: usize,
|
||||
redo_count: usize,
|
||||
) -> Element<'_, Message> {
|
||||
// ── Logo ──────────────────────────────────────────────────────────
|
||||
let logo_svg = {
|
||||
let handle = svg::Handle::from_memory(include_bytes!("../../../assets/logo.svg"));
|
||||
|
|
@ -217,14 +226,28 @@ impl Ribbon {
|
|||
|
||||
// ── Tab buttons ───────────────────────────────────────────────────
|
||||
let history_controls = row![
|
||||
render_history_control("↶", "Undo", UNDO_HISTORY_ID, undo_count, &self.open_dropdown),
|
||||
render_history_control("↷", "Redo", REDO_HISTORY_ID, redo_count, &self.open_dropdown),
|
||||
render_history_control(
|
||||
"↶",
|
||||
"Undo",
|
||||
UNDO_HISTORY_ID,
|
||||
undo_count,
|
||||
&self.open_dropdown
|
||||
),
|
||||
render_history_control(
|
||||
"↷",
|
||||
"Redo",
|
||||
REDO_HISTORY_ID,
|
||||
redo_count,
|
||||
&self.open_dropdown
|
||||
),
|
||||
]
|
||||
.spacing(TOP_HIST_GAP)
|
||||
.align_y(iced::Center);
|
||||
|
||||
let tab_buttons = self.modules.iter().enumerate().fold(
|
||||
row![logo, history_controls].align_y(iced::Center).spacing(6),
|
||||
row![logo, history_controls]
|
||||
.align_y(iced::Center)
|
||||
.spacing(6),
|
||||
|row_acc, (i, module)| {
|
||||
if module.id() == "layout" && !is_paper {
|
||||
return row_acc;
|
||||
|
|
@ -232,16 +255,40 @@ impl Ribbon {
|
|||
|
||||
let is_active = i == self.active;
|
||||
let is_contextual = module.id() == "layout";
|
||||
let accent = if is_contextual { ACCENT_GOLD } else { ACCENT_BLUE };
|
||||
let text_inactive = if is_contextual {
|
||||
Color { r: 0.90, g: 0.72, b: 0.30, a: 1.0 }
|
||||
let accent = if is_contextual {
|
||||
ACCENT_GOLD
|
||||
} else {
|
||||
Color { r: 0.75, g: 0.75, b: 0.75, a: 1.0 }
|
||||
ACCENT_BLUE
|
||||
};
|
||||
let text_inactive = if is_contextual {
|
||||
Color {
|
||||
r: 0.90,
|
||||
g: 0.72,
|
||||
b: 0.30,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color {
|
||||
r: 0.75,
|
||||
g: 0.75,
|
||||
b: 0.75,
|
||||
a: 1.0,
|
||||
}
|
||||
};
|
||||
let hover_bg = if is_contextual {
|
||||
Color { r: 0.28, g: 0.24, b: 0.12, a: 1.0 }
|
||||
Color {
|
||||
r: 0.28,
|
||||
g: 0.24,
|
||||
b: 0.12,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color { r: 0.25, g: 0.25, b: 0.25, a: 1.0 }
|
||||
Color {
|
||||
r: 0.25,
|
||||
g: 0.25,
|
||||
b: 0.25,
|
||||
a: 1.0,
|
||||
}
|
||||
};
|
||||
let btn = container(
|
||||
button(text(module.title()).size(12))
|
||||
|
|
@ -252,9 +299,17 @@ impl Ribbon {
|
|||
(false, button::Status::Hovered) => hover_bg,
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
text_color: if is_active { Color::WHITE } else { text_inactive },
|
||||
text_color: if is_active {
|
||||
Color::WHITE
|
||||
} else {
|
||||
text_inactive
|
||||
},
|
||||
border: Border {
|
||||
color: if is_active { accent } else { Color::TRANSPARENT },
|
||||
color: if is_active {
|
||||
accent
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
},
|
||||
width: if is_active { 2.0 } else { 0.0 },
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
|
|
@ -265,7 +320,11 @@ impl Ribbon {
|
|||
)
|
||||
.style(move |_: &Theme| container::Style {
|
||||
border: Border {
|
||||
color: if is_active { accent } else { Color::TRANSPARENT },
|
||||
color: if is_active {
|
||||
accent
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
},
|
||||
width: if is_active { 2.0 } else { 0.0 },
|
||||
radius: 0.0.into(),
|
||||
},
|
||||
|
|
@ -344,10 +403,10 @@ impl Ribbon {
|
|||
let is_large = matches!(
|
||||
&item,
|
||||
RibbonItem::LargeTool(_)
|
||||
| RibbonItem::LargeDropdown { .. }
|
||||
| RibbonItem::LayerComboGroup { .. }
|
||||
| RibbonItem::PropertiesGroup { .. }
|
||||
| RibbonItem::StyleComboGroup { .. }
|
||||
| RibbonItem::LargeDropdown { .. }
|
||||
| RibbonItem::LayerComboGroup { .. }
|
||||
| RibbonItem::PropertiesGroup { .. }
|
||||
| RibbonItem::StyleComboGroup { .. }
|
||||
);
|
||||
|
||||
if is_large {
|
||||
|
|
@ -391,8 +450,7 @@ impl Ribbon {
|
|||
widgets.push(
|
||||
column![
|
||||
tools_el,
|
||||
container(text(group.title).size(9).color(GROUP_LABEL))
|
||||
.padding([1, 4]),
|
||||
container(text(group.title).size(9).color(GROUP_LABEL)).padding([1, 4]),
|
||||
]
|
||||
.spacing(0)
|
||||
.padding([3u16, 4])
|
||||
|
|
@ -518,8 +576,12 @@ impl Ribbon {
|
|||
'outer: for group in &groups {
|
||||
for item in &group.tools {
|
||||
let (id, items, default) = match item {
|
||||
RibbonItem::Dropdown { id, items, default, .. } => (id, items, default),
|
||||
RibbonItem::LargeDropdown { id, items, default, .. } => (id, items, default),
|
||||
RibbonItem::Dropdown {
|
||||
id, items, default, ..
|
||||
} => (id, items, default),
|
||||
RibbonItem::LargeDropdown {
|
||||
id, items, default, ..
|
||||
} => (id, items, default),
|
||||
_ => continue,
|
||||
};
|
||||
if *id == open_id {
|
||||
|
|
@ -539,7 +601,11 @@ impl Ribbon {
|
|||
let is_current = *cmd == last_cmd;
|
||||
let checkmark = text(if is_current { "✓" } else { " " })
|
||||
.size(11)
|
||||
.color(if is_current { CHECK_COLOR } else { Color::TRANSPARENT })
|
||||
.color(if is_current {
|
||||
CHECK_COLOR
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
})
|
||||
.width(Length::Fixed(14.0));
|
||||
let icon_el: Element<Message> = match *item_icon {
|
||||
IconKind::Glyph(s) => text(s)
|
||||
|
|
@ -552,9 +618,10 @@ impl Ribbon {
|
|||
svg(handle).width(20).height(20).into()
|
||||
}
|
||||
};
|
||||
let label_el = text(*label)
|
||||
.size(11)
|
||||
.color(if is_current { LABEL_ON } else { LABEL_OFF });
|
||||
let label_el =
|
||||
text(*label)
|
||||
.size(11)
|
||||
.color(if is_current { LABEL_ON } else { LABEL_OFF });
|
||||
|
||||
button(
|
||||
row![checkmark, icon_el, label_el]
|
||||
|
|
@ -626,7 +693,12 @@ impl Ribbon {
|
|||
.style(move |_: &Theme| container::Style {
|
||||
background: Some(Background::Color(lc)),
|
||||
border: Border {
|
||||
color: Color { r: 0.0, g: 0.0, b: 0.0, a: 0.5 },
|
||||
color: Color {
|
||||
r: 0.0,
|
||||
g: 0.0,
|
||||
b: 0.0,
|
||||
a: 0.5,
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
|
|
@ -635,30 +707,63 @@ impl Ribbon {
|
|||
.width(12)
|
||||
.height(12);
|
||||
|
||||
let vis = text(if lv { "●" } else { "○" })
|
||||
.size(10)
|
||||
.color(if lv {
|
||||
Color { r: 0.95, g: 0.85, b: 0.20, a: 1.0 }
|
||||
} else {
|
||||
Color { r: 0.45, g: 0.45, b: 0.45, a: 1.0 }
|
||||
});
|
||||
let freeze = text("✱").size(10).color(if lf {
|
||||
Color { r: 0.40, g: 0.80, b: 1.00, a: 1.0 }
|
||||
let vis = text(if lv { "●" } else { "○" }).size(10).color(if lv {
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.85,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color { r: 0.95, g: 0.85, b: 0.20, a: 1.0 }
|
||||
Color {
|
||||
r: 0.45,
|
||||
g: 0.45,
|
||||
b: 0.45,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let freeze = text("✱").size(10).color(if lf {
|
||||
Color {
|
||||
r: 0.40,
|
||||
g: 0.80,
|
||||
b: 1.00,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.85,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let lock = text(if ll { "🔒" } else { "🔓" }).size(10).color(if ll {
|
||||
Color { r: 0.95, g: 0.70, b: 0.20, a: 1.0 }
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.70,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color { r: 0.55, g: 0.55, b: 0.55, a: 1.0 }
|
||||
Color {
|
||||
r: 0.55,
|
||||
g: 0.55,
|
||||
b: 0.55,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let checkmark = text(if is_active { "✓" } else { " " })
|
||||
.size(11)
|
||||
.color(if is_active { CHECK_COLOR } else { Color::TRANSPARENT })
|
||||
.color(if is_active {
|
||||
CHECK_COLOR
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
})
|
||||
.width(Length::Fixed(14.0));
|
||||
let label = text(&info.name)
|
||||
.size(11)
|
||||
.color(if is_active { LABEL_ON } else { LABEL_OFF });
|
||||
let label =
|
||||
text(&info.name)
|
||||
.size(11)
|
||||
.color(if is_active { LABEL_ON } else { LABEL_OFF });
|
||||
|
||||
button(
|
||||
row![checkmark, vis, freeze, lock, swatch, label]
|
||||
|
|
@ -682,7 +787,11 @@ impl Ribbon {
|
|||
let panel = container(column(rows))
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(PANEL_BG)),
|
||||
border: Border { color: PANEL_BORDER, width: 1.0, radius: 3.0.into() },
|
||||
border: Border {
|
||||
color: PANEL_BORDER,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(220.0));
|
||||
|
|
@ -693,11 +802,19 @@ impl Ribbon {
|
|||
let positioned = container(panel)
|
||||
.align_left(Fill)
|
||||
.align_top(Fill)
|
||||
.padding(Padding { top: top_offset, left: left_offset, ..Default::default() })
|
||||
.padding(Padding {
|
||||
top: top_offset,
|
||||
left: left_offset,
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
Some(mouse_area(positioned).on_press(Message::CloseRibbonDropdown).into())
|
||||
Some(
|
||||
mouse_area(positioned)
|
||||
.on_press(Message::CloseRibbonDropdown)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn prop_color_overlay(&self) -> Option<Element<'_, Message>> {
|
||||
|
|
@ -712,7 +829,11 @@ impl Ribbon {
|
|||
let panel = container(picker)
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(PANEL_BG)),
|
||||
border: Border { color: PANEL_BORDER, width: 1.0, radius: 3.0.into() },
|
||||
border: Border {
|
||||
color: PANEL_BORDER,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(200.0));
|
||||
|
|
@ -723,19 +844,33 @@ impl Ribbon {
|
|||
let positioned = container(panel)
|
||||
.align_left(Fill)
|
||||
.align_top(Fill)
|
||||
.padding(Padding { top: top_offset, left: left_offset, ..Default::default() })
|
||||
.padding(Padding {
|
||||
top: top_offset,
|
||||
left: left_offset,
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
Some(mouse_area(positioned).on_press(Message::CloseRibbonDropdown).into())
|
||||
Some(
|
||||
mouse_area(positioned)
|
||||
.on_press(Message::CloseRibbonDropdown)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn prop_linetype_overlay(&self) -> Option<Element<'_, Message>> {
|
||||
let active_lt = &self.active_linetype;
|
||||
|
||||
let mut items: Vec<LinetypeItem> = vec![
|
||||
LinetypeItem { name: "ByLayer".to_string(), art: String::new() },
|
||||
LinetypeItem { name: "ByBlock".to_string(), art: String::new() },
|
||||
LinetypeItem {
|
||||
name: "ByLayer".to_string(),
|
||||
art: String::new(),
|
||||
},
|
||||
LinetypeItem {
|
||||
name: "ByBlock".to_string(),
|
||||
art: String::new(),
|
||||
},
|
||||
];
|
||||
for lt in &self.available_linetypes {
|
||||
if lt.name != "ByLayer" && lt.name != "ByBlock" {
|
||||
|
|
@ -749,34 +884,50 @@ impl Ribbon {
|
|||
let is_cur = lt.name == *active_lt;
|
||||
let check = text(if is_cur { "✓" } else { " " })
|
||||
.size(11)
|
||||
.color(if is_cur { CHECK_COLOR } else { Color::TRANSPARENT })
|
||||
.color(if is_cur {
|
||||
CHECK_COLOR
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
})
|
||||
.width(Length::Fixed(14.0));
|
||||
let name_col = text(lt.name.clone())
|
||||
.size(11)
|
||||
.color(if is_cur { LABEL_ON } else { LABEL_OFF })
|
||||
.width(Length::Fixed(90.0));
|
||||
let art_col =
|
||||
text(lt.art.clone()).size(9).color(Color { r: 0.55, g: 0.55, b: 0.55, a: 1.0 });
|
||||
let art_col = text(lt.art.clone()).size(9).color(Color {
|
||||
r: 0.55,
|
||||
g: 0.55,
|
||||
b: 0.55,
|
||||
a: 1.0,
|
||||
});
|
||||
let name = lt.name.clone();
|
||||
button(row![check, name_col, art_col].spacing(4).align_y(iced::Center))
|
||||
.on_press(Message::RibbonLinetypeChanged(name))
|
||||
.style(|_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered | button::Status::Pressed => ROW_HOVER,
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.padding([4, 6])
|
||||
.into()
|
||||
button(
|
||||
row![check, name_col, art_col]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.on_press(Message::RibbonLinetypeChanged(name))
|
||||
.style(|_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered | button::Status::Pressed => ROW_HOVER,
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.padding([4, 6])
|
||||
.into()
|
||||
})
|
||||
.collect();
|
||||
|
||||
let list = container(scrollable(column(rows)).height(Length::Fixed(200.0)))
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(PANEL_BG)),
|
||||
border: Border { color: PANEL_BORDER, width: 1.0, radius: 3.0.into() },
|
||||
border: Border {
|
||||
color: PANEL_BORDER,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(220.0));
|
||||
|
|
@ -787,11 +938,19 @@ impl Ribbon {
|
|||
let positioned = container(list)
|
||||
.align_left(Fill)
|
||||
.align_top(Fill)
|
||||
.padding(Padding { top: top_offset, left: left_offset, ..Default::default() })
|
||||
.padding(Padding {
|
||||
top: top_offset,
|
||||
left: left_offset,
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
Some(mouse_area(positioned).on_press(Message::CloseRibbonDropdown).into())
|
||||
Some(
|
||||
mouse_area(positioned)
|
||||
.on_press(Message::CloseRibbonDropdown)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
fn prop_lw_overlay(&self) -> Option<Element<'_, Message>> {
|
||||
|
|
@ -803,7 +962,11 @@ impl Ribbon {
|
|||
let label = item.to_string();
|
||||
let check = text(if is_cur { "✓" } else { " " })
|
||||
.size(11)
|
||||
.color(if is_cur { CHECK_COLOR } else { Color::TRANSPARENT })
|
||||
.color(if is_cur {
|
||||
CHECK_COLOR
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
})
|
||||
.width(Length::Fixed(14.0));
|
||||
button(
|
||||
row![
|
||||
|
|
@ -841,7 +1004,11 @@ impl Ribbon {
|
|||
let panel = container(column(rows))
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(PANEL_BG)),
|
||||
border: Border { color: PANEL_BORDER, width: 1.0, radius: 3.0.into() },
|
||||
border: Border {
|
||||
color: PANEL_BORDER,
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(width));
|
||||
|
|
@ -852,11 +1019,19 @@ impl Ribbon {
|
|||
let positioned = container(panel)
|
||||
.align_left(Fill)
|
||||
.align_top(Fill)
|
||||
.padding(Padding { top: top_offset, left: left_offset, ..Default::default() })
|
||||
.padding(Padding {
|
||||
top: top_offset,
|
||||
left: left_offset,
|
||||
..Default::default()
|
||||
})
|
||||
.width(Fill)
|
||||
.height(Fill);
|
||||
|
||||
Some(mouse_area(positioned).on_press(Message::CloseRibbonDropdown).into())
|
||||
Some(
|
||||
mouse_area(positioned)
|
||||
.on_press(Message::CloseRibbonDropdown)
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use iced::{Background, Border, Color, Element, Fill, Length, Padding, Theme};
|
|||
|
||||
use crate::app::Message;
|
||||
use crate::modules::{IconKind, ModuleEvent, RibbonGroup, RibbonItem, StyleKey, ToolDef};
|
||||
use crate::ui::properties::{LwItem, acad_color_display};
|
||||
use crate::ui::properties::{acad_color_display, LwItem};
|
||||
|
||||
use super::LayerInfo;
|
||||
|
||||
|
|
@ -51,24 +51,114 @@ pub(super) const PROP_LW_ID: &str = "PROP_LW";
|
|||
|
||||
// ── Colours ────────────────────────────────────────────────────────────────
|
||||
|
||||
pub(super) const LOGO_RED: Color = Color { r: 0.75, g: 0.10, b: 0.10, a: 1.0 };
|
||||
pub(super) const TOPBAR_BG: Color = Color { r: 0.17, g: 0.17, b: 0.17, a: 1.0 };
|
||||
pub(super) const RIBBON_BG: Color = Color { r: 0.22, g: 0.22, b: 0.22, a: 1.0 };
|
||||
pub(super) const BORDER_DARK: Color = Color { r: 0.12, g: 0.12, b: 0.12, a: 1.0 };
|
||||
pub(super) const ACCENT_BLUE: Color = Color { r: 0.20, g: 0.55, b: 0.90, a: 1.0 };
|
||||
pub(super) const ACCENT_GOLD: Color = Color { r: 0.90, g: 0.65, b: 0.10, a: 1.0 };
|
||||
pub(super) const LABEL_COLOR: Color = Color { r: 0.82, g: 0.82, b: 0.82, a: 1.0 };
|
||||
pub(super) const GROUP_LABEL: Color = Color { r: 0.50, g: 0.50, b: 0.50, a: 1.0 };
|
||||
pub(super) const TOOL_HOVER: Color = Color { r: 0.32, g: 0.32, b: 0.32, a: 1.0 };
|
||||
pub(super) const TOOL_ACTIVE: Color = Color { r: 0.18, g: 0.42, b: 0.70, a: 1.0 };
|
||||
pub(super) const ARROW_COLOR: Color = Color { r: 0.65, g: 0.65, b: 0.65, a: 1.0 };
|
||||
pub(super) const PANEL_BG: Color = Color { r: 0.16, g: 0.16, b: 0.16, a: 0.98 };
|
||||
pub(super) const PANEL_BORDER: Color = Color { r: 0.32, g: 0.32, b: 0.32, a: 1.0 };
|
||||
pub(super) const ROW_HOVER: Color = Color { r: 0.24, g: 0.24, b: 0.24, a: 1.0 };
|
||||
pub(super) const CHECK_COLOR: Color = Color { r: 0.20, g: 0.75, b: 0.35, a: 1.0 };
|
||||
pub(super) const ICON_COLOR: Color = Color { r: 0.25, g: 0.75, b: 0.45, a: 1.0 };
|
||||
pub(super) const LABEL_ON: Color = Color { r: 0.92, g: 0.92, b: 0.92, a: 1.0 };
|
||||
pub(super) const LABEL_OFF: Color = Color { r: 0.72, g: 0.72, b: 0.72, a: 1.0 };
|
||||
pub(super) const LOGO_RED: Color = Color {
|
||||
r: 0.75,
|
||||
g: 0.10,
|
||||
b: 0.10,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const TOPBAR_BG: Color = Color {
|
||||
r: 0.17,
|
||||
g: 0.17,
|
||||
b: 0.17,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const RIBBON_BG: Color = Color {
|
||||
r: 0.22,
|
||||
g: 0.22,
|
||||
b: 0.22,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const BORDER_DARK: Color = Color {
|
||||
r: 0.12,
|
||||
g: 0.12,
|
||||
b: 0.12,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const ACCENT_BLUE: Color = Color {
|
||||
r: 0.20,
|
||||
g: 0.55,
|
||||
b: 0.90,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const ACCENT_GOLD: Color = Color {
|
||||
r: 0.90,
|
||||
g: 0.65,
|
||||
b: 0.10,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const LABEL_COLOR: Color = Color {
|
||||
r: 0.82,
|
||||
g: 0.82,
|
||||
b: 0.82,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const GROUP_LABEL: Color = Color {
|
||||
r: 0.50,
|
||||
g: 0.50,
|
||||
b: 0.50,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const TOOL_HOVER: Color = Color {
|
||||
r: 0.32,
|
||||
g: 0.32,
|
||||
b: 0.32,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const TOOL_ACTIVE: Color = Color {
|
||||
r: 0.18,
|
||||
g: 0.42,
|
||||
b: 0.70,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const ARROW_COLOR: Color = Color {
|
||||
r: 0.65,
|
||||
g: 0.65,
|
||||
b: 0.65,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const PANEL_BG: Color = Color {
|
||||
r: 0.16,
|
||||
g: 0.16,
|
||||
b: 0.16,
|
||||
a: 0.98,
|
||||
};
|
||||
pub(super) const PANEL_BORDER: Color = Color {
|
||||
r: 0.32,
|
||||
g: 0.32,
|
||||
b: 0.32,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const ROW_HOVER: Color = Color {
|
||||
r: 0.24,
|
||||
g: 0.24,
|
||||
b: 0.24,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const CHECK_COLOR: Color = Color {
|
||||
r: 0.20,
|
||||
g: 0.75,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const ICON_COLOR: Color = Color {
|
||||
r: 0.25,
|
||||
g: 0.75,
|
||||
b: 0.45,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const LABEL_ON: Color = Color {
|
||||
r: 0.92,
|
||||
g: 0.92,
|
||||
b: 0.92,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const LABEL_OFF: Color = Color {
|
||||
r: 0.72,
|
||||
g: 0.72,
|
||||
b: 0.72,
|
||||
a: 1.0,
|
||||
};
|
||||
|
||||
// ── Style context (passed from Ribbon to render_large) ────────────────────
|
||||
|
||||
|
|
@ -86,18 +176,18 @@ pub(super) struct StyleContext {
|
|||
impl StyleContext {
|
||||
fn names_for(&self, key: StyleKey) -> &[String] {
|
||||
match key {
|
||||
StyleKey::TextStyle => &self.text_style_names,
|
||||
StyleKey::DimStyle => &self.dim_style_names,
|
||||
StyleKey::TextStyle => &self.text_style_names,
|
||||
StyleKey::DimStyle => &self.dim_style_names,
|
||||
StyleKey::MLeaderStyle => &self.mleader_style_names,
|
||||
StyleKey::TableStyle => &self.table_style_names,
|
||||
StyleKey::TableStyle => &self.table_style_names,
|
||||
}
|
||||
}
|
||||
fn active_for(&self, key: StyleKey) -> &str {
|
||||
match key {
|
||||
StyleKey::TextStyle => &self.active_text_style,
|
||||
StyleKey::DimStyle => &self.active_dim_style,
|
||||
StyleKey::TextStyle => &self.active_text_style,
|
||||
StyleKey::DimStyle => &self.active_dim_style,
|
||||
StyleKey::MLeaderStyle => &self.active_mleader_style,
|
||||
StyleKey::TableStyle => &self.active_table_style,
|
||||
StyleKey::TableStyle => &self.active_table_style,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,7 +267,12 @@ pub(super) fn tip_style(_theme: &Theme) -> container::Style {
|
|||
a: 0.97,
|
||||
})),
|
||||
border: Border {
|
||||
color: Color { r: 0.35, g: 0.35, b: 0.35, a: 1.0 },
|
||||
color: Color {
|
||||
r: 0.35,
|
||||
g: 0.35,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 3.0.into(),
|
||||
},
|
||||
|
|
@ -216,7 +311,13 @@ pub(super) fn render_small<'a>(
|
|||
.into()
|
||||
}
|
||||
|
||||
RibbonItem::Dropdown { id, icon, items, default, .. } => {
|
||||
RibbonItem::Dropdown {
|
||||
id,
|
||||
icon,
|
||||
items,
|
||||
default,
|
||||
..
|
||||
} => {
|
||||
let active = active_tool.as_deref() == Some(id)
|
||||
|| items
|
||||
.iter()
|
||||
|
|
@ -227,7 +328,10 @@ pub(super) fn render_small<'a>(
|
|||
.get(id)
|
||||
.copied()
|
||||
.and_then(|cmd| {
|
||||
items.iter().find(|(c, _, _)| *c == cmd).map(|(_, _, ik)| *ik)
|
||||
items
|
||||
.iter()
|
||||
.find(|(c, _, _)| *c == cmd)
|
||||
.map(|(_, _, ik)| *ik)
|
||||
})
|
||||
.or_else(|| items.first().map(|(_, _, ik)| *ik))
|
||||
.unwrap_or(icon);
|
||||
|
|
@ -236,7 +340,10 @@ pub(super) fn render_small<'a>(
|
|||
.get(id)
|
||||
.copied()
|
||||
.and_then(|cmd| {
|
||||
items.iter().find(|(c, _, _)| *c == cmd).map(|(_, lbl, _)| *lbl)
|
||||
items
|
||||
.iter()
|
||||
.find(|(c, _, _)| *c == cmd)
|
||||
.map(|(_, lbl, _)| *lbl)
|
||||
})
|
||||
.or_else(|| items.first().map(|(_, lbl, _)| *lbl))
|
||||
.unwrap_or(id);
|
||||
|
|
@ -267,7 +374,10 @@ pub(super) fn render_small<'a>(
|
|||
_ if dd_open => TOOL_ACTIVE,
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
border: Border { radius: 2.0.into(), ..Default::default() },
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(ARROW_W))
|
||||
|
|
@ -283,7 +393,10 @@ pub(super) fn render_small<'a>(
|
|||
.delay(Duration::from_millis(400))
|
||||
.style(tip_style);
|
||||
|
||||
row![icon_with_tip, arr_with_tip].spacing(0).height(ROW_H).into()
|
||||
row![icon_with_tip, arr_with_tip]
|
||||
.spacing(0)
|
||||
.height(ROW_H)
|
||||
.into()
|
||||
}
|
||||
|
||||
_ => text("").into(),
|
||||
|
|
@ -325,7 +438,12 @@ pub(super) fn render_large<'a>(
|
|||
.style(move |_: &Theme, status| tool_btn_style(active, status))
|
||||
.width(Length::Fixed(LARGE_W))
|
||||
.height(Fill)
|
||||
.padding(Padding { top: 6.0, right: 4.0, bottom: 4.0, left: 4.0 });
|
||||
.padding(Padding {
|
||||
top: 6.0,
|
||||
right: 4.0,
|
||||
bottom: 4.0,
|
||||
left: 4.0,
|
||||
});
|
||||
tooltip(btn, make_tip(tip_text), TipPos::Bottom)
|
||||
.gap(6.0)
|
||||
.delay(Duration::from_millis(400))
|
||||
|
|
@ -333,7 +451,13 @@ pub(super) fn render_large<'a>(
|
|||
.into()
|
||||
}
|
||||
|
||||
RibbonItem::LargeDropdown { id, label, icon, items, default } => {
|
||||
RibbonItem::LargeDropdown {
|
||||
id,
|
||||
label,
|
||||
icon,
|
||||
items,
|
||||
default,
|
||||
} => {
|
||||
let active = active_tool.as_deref() == Some(id)
|
||||
|| items
|
||||
.iter()
|
||||
|
|
@ -344,7 +468,10 @@ pub(super) fn render_large<'a>(
|
|||
.get(id)
|
||||
.copied()
|
||||
.and_then(|cmd| {
|
||||
items.iter().find(|(c, _, _)| *c == cmd).map(|(_, _, ik)| *ik)
|
||||
items
|
||||
.iter()
|
||||
.find(|(c, _, _)| *c == cmd)
|
||||
.map(|(_, _, ik)| *ik)
|
||||
})
|
||||
.or_else(|| items.first().map(|(_, _, ik)| *ik))
|
||||
.unwrap_or(icon);
|
||||
|
|
@ -353,7 +480,10 @@ pub(super) fn render_large<'a>(
|
|||
.get(id)
|
||||
.copied()
|
||||
.and_then(|cmd| {
|
||||
items.iter().find(|(c, _, _)| *c == cmd).map(|(_, lbl, _)| *lbl)
|
||||
items
|
||||
.iter()
|
||||
.find(|(c, _, _)| *c == cmd)
|
||||
.map(|(_, lbl, _)| *lbl)
|
||||
})
|
||||
.or_else(|| items.first().map(|(_, lbl, _)| *lbl))
|
||||
.unwrap_or(label);
|
||||
|
|
@ -375,7 +505,12 @@ pub(super) fn render_large<'a>(
|
|||
.style(move |_: &Theme, status| tool_btn_style(active, status))
|
||||
.width(Length::Fixed(LARGE_W))
|
||||
.height(Fill)
|
||||
.padding(Padding { top: 6.0, right: 4.0, bottom: 2.0, left: 4.0 });
|
||||
.padding(Padding {
|
||||
top: 6.0,
|
||||
right: 4.0,
|
||||
bottom: 2.0,
|
||||
left: 4.0,
|
||||
});
|
||||
|
||||
let arr_btn = button(
|
||||
container(text("▾").size(9).color(ARROW_COLOR))
|
||||
|
|
@ -391,7 +526,10 @@ pub(super) fn render_large<'a>(
|
|||
_ if dd_open => TOOL_ACTIVE,
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
border: Border { radius: 3.0.into(), ..Default::default() },
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(LARGE_W))
|
||||
|
|
@ -424,23 +562,61 @@ pub(super) fn render_large<'a>(
|
|||
let ll = info.map(|l| l.locked).unwrap_or(false);
|
||||
let is_open = open_dd.as_deref() == Some(LAYER_COMBO_ID);
|
||||
|
||||
let vis_icon = text(if lv { "●" } else { "○" }).size(10).color(
|
||||
if lv { Color { r: 0.95, g: 0.85, b: 0.20, a: 1.0 } }
|
||||
else { Color { r: 0.45, g: 0.45, b: 0.45, a: 1.0 } },
|
||||
);
|
||||
let freeze_icon = text("✱").size(10).color(
|
||||
if lf { Color { r: 0.40, g: 0.80, b: 1.00, a: 1.0 } }
|
||||
else { Color { r: 0.95, g: 0.85, b: 0.20, a: 1.0 } },
|
||||
);
|
||||
let lock_icon = text(if ll { "🔒" } else { "🔓" }).size(10).color(
|
||||
if ll { Color { r: 0.95, g: 0.70, b: 0.20, a: 1.0 } }
|
||||
else { Color { r: 0.65, g: 0.65, b: 0.65, a: 1.0 } },
|
||||
);
|
||||
let vis_icon = text(if lv { "●" } else { "○" }).size(10).color(if lv {
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.85,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color {
|
||||
r: 0.45,
|
||||
g: 0.45,
|
||||
b: 0.45,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let freeze_icon = text("✱").size(10).color(if lf {
|
||||
Color {
|
||||
r: 0.40,
|
||||
g: 0.80,
|
||||
b: 1.00,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.85,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let lock_icon = text(if ll { "🔒" } else { "🔓" }).size(10).color(if ll {
|
||||
Color {
|
||||
r: 0.95,
|
||||
g: 0.70,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color {
|
||||
r: 0.65,
|
||||
g: 0.65,
|
||||
b: 0.65,
|
||||
a: 1.0,
|
||||
}
|
||||
});
|
||||
let swatch = container(text(""))
|
||||
.style(move |_: &Theme| container::Style {
|
||||
background: Some(Background::Color(lc)),
|
||||
border: Border {
|
||||
color: Color { r: 0.0, g: 0.0, b: 0.0, a: 0.5 },
|
||||
color: Color {
|
||||
r: 0.0,
|
||||
g: 0.0,
|
||||
b: 0.0,
|
||||
a: 0.5,
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
|
|
@ -454,10 +630,19 @@ pub(super) fn render_large<'a>(
|
|||
|
||||
let combo_btn = button(
|
||||
row![
|
||||
vis_icon, freeze_icon, lock_icon, swatch,
|
||||
vis_icon,
|
||||
freeze_icon,
|
||||
lock_icon,
|
||||
swatch,
|
||||
container(text(active_layer).size(11).color(Color::WHITE))
|
||||
.width(name_w).clip(true),
|
||||
text("▾").size(9).color(Color { r: 0.7, g: 0.7, b: 0.7, a: 1.0 }),
|
||||
.width(name_w)
|
||||
.clip(true),
|
||||
text("▾").size(9).color(Color {
|
||||
r: 0.7,
|
||||
g: 0.7,
|
||||
b: 0.7,
|
||||
a: 1.0
|
||||
}),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
|
|
@ -465,14 +650,34 @@ pub(super) fn render_large<'a>(
|
|||
.on_press(Message::ToggleRibbonDropdown(LAYER_COMBO_ID.to_string()))
|
||||
.style(move |_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match (is_open, status) {
|
||||
(true, _) => Color { r: 0.14, g: 0.14, b: 0.14, a: 1.0 },
|
||||
(_, button::Status::Hovered) => Color { r: 0.26, g: 0.26, b: 0.26, a: 1.0 },
|
||||
_ => Color { r: 0.18, g: 0.18, b: 0.18, a: 1.0 },
|
||||
(true, _) => Color {
|
||||
r: 0.14,
|
||||
g: 0.14,
|
||||
b: 0.14,
|
||||
a: 1.0,
|
||||
},
|
||||
(_, button::Status::Hovered) => Color {
|
||||
r: 0.26,
|
||||
g: 0.26,
|
||||
b: 0.26,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color {
|
||||
r: 0.18,
|
||||
g: 0.18,
|
||||
b: 0.18,
|
||||
a: 1.0,
|
||||
},
|
||||
})),
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
width: 1.0,
|
||||
color: Color { r: 0.35, g: 0.35, b: 0.35, a: 1.0 },
|
||||
color: Color {
|
||||
r: 0.35,
|
||||
g: 0.35,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
},
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
|
|
@ -488,12 +693,12 @@ pub(super) fn render_large<'a>(
|
|||
let event = t.event.clone();
|
||||
let icon_el: Element<Message> = match t.icon {
|
||||
IconKind::Glyph(g) => text(g).size(13).color(Color::WHITE).into(),
|
||||
IconKind::Svg(bytes) => iced::widget::svg(
|
||||
iced::widget::svg::Handle::from_memory(bytes),
|
||||
)
|
||||
.width(16)
|
||||
.height(16)
|
||||
.into(),
|
||||
IconKind::Svg(bytes) => {
|
||||
iced::widget::svg(iced::widget::svg::Handle::from_memory(bytes))
|
||||
.width(16)
|
||||
.height(16)
|
||||
.into()
|
||||
}
|
||||
};
|
||||
let msg = module_event_to_message(event);
|
||||
tooltip(
|
||||
|
|
@ -524,7 +729,12 @@ pub(super) fn render_large<'a>(
|
|||
.width(Length::Fixed(COMBO_W))
|
||||
.height(Fill)
|
||||
.align_y(iced::Center)
|
||||
.padding(Padding { top: 4.0, bottom: 4.0, left: 4.0, right: 4.0 })
|
||||
.padding(Padding {
|
||||
top: 4.0,
|
||||
bottom: 4.0,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -541,11 +751,19 @@ pub(super) fn render_large<'a>(
|
|||
.align_x(iced::Center)
|
||||
.spacing(3),
|
||||
)
|
||||
.on_press(Message::RibbonToolClick { tool_id: mp_id, event: mp_event })
|
||||
.on_press(Message::RibbonToolClick {
|
||||
tool_id: mp_id,
|
||||
event: mp_event,
|
||||
})
|
||||
.style(move |_: &Theme, status| tool_btn_style(mp_active, status))
|
||||
.width(Length::Fixed(LARGE_W))
|
||||
.height(Fill)
|
||||
.padding(Padding { top: 6.0, right: 4.0, bottom: 4.0, left: 4.0 });
|
||||
.padding(Padding {
|
||||
top: 6.0,
|
||||
right: 4.0,
|
||||
bottom: 4.0,
|
||||
left: 4.0,
|
||||
});
|
||||
let mp_el = tooltip(mp_btn, make_tip(mp_tip), TipPos::Bottom)
|
||||
.gap(6.0)
|
||||
.delay(Duration::from_millis(400))
|
||||
|
|
@ -560,7 +778,12 @@ pub(super) fn render_large<'a>(
|
|||
.style(move |_: &Theme| container::Style {
|
||||
background: Some(Background::Color(c)),
|
||||
border: Border {
|
||||
color: Color { r: 0.0, g: 0.0, b: 0.0, a: 0.5 },
|
||||
color: Color {
|
||||
r: 0.0,
|
||||
g: 0.0,
|
||||
b: 0.0,
|
||||
a: 0.5,
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 1.0.into(),
|
||||
},
|
||||
|
|
@ -578,9 +801,12 @@ pub(super) fn render_large<'a>(
|
|||
container(text(label).size(10).color(Color::WHITE))
|
||||
.width(Fill)
|
||||
.clip(true),
|
||||
text(if is_open { "▲" } else { "▼" })
|
||||
.size(7)
|
||||
.color(Color { r: 0.6, g: 0.6, b: 0.6, a: 1.0 }),
|
||||
text(if is_open { "▲" } else { "▼" }).size(7).color(Color {
|
||||
r: 0.6,
|
||||
g: 0.6,
|
||||
b: 0.6,
|
||||
a: 1.0
|
||||
}),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
|
|
@ -588,19 +814,42 @@ pub(super) fn render_large<'a>(
|
|||
.on_press(Message::ToggleRibbonDropdown(dd_id.to_string()))
|
||||
.style(move |_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match (is_open, status) {
|
||||
(true, _) => Color { r: 0.14, g: 0.14, b: 0.14, a: 1.0 },
|
||||
(_, button::Status::Hovered) => {
|
||||
Color { r: 0.26, g: 0.26, b: 0.26, a: 1.0 }
|
||||
}
|
||||
_ => Color { r: 0.18, g: 0.18, b: 0.18, a: 1.0 },
|
||||
(true, _) => Color {
|
||||
r: 0.14,
|
||||
g: 0.14,
|
||||
b: 0.14,
|
||||
a: 1.0,
|
||||
},
|
||||
(_, button::Status::Hovered) => Color {
|
||||
r: 0.26,
|
||||
g: 0.26,
|
||||
b: 0.26,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color {
|
||||
r: 0.18,
|
||||
g: 0.18,
|
||||
b: 0.18,
|
||||
a: 1.0,
|
||||
},
|
||||
})),
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
width: 1.0,
|
||||
color: if is_open {
|
||||
Color { r: 0.45, g: 0.65, b: 0.90, a: 1.0 }
|
||||
Color {
|
||||
r: 0.45,
|
||||
g: 0.65,
|
||||
b: 0.90,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color { r: 0.35, g: 0.35, b: 0.35, a: 1.0 }
|
||||
Color {
|
||||
r: 0.35,
|
||||
g: 0.35,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
}
|
||||
},
|
||||
},
|
||||
..Default::default()
|
||||
|
|
@ -615,11 +864,18 @@ pub(super) fn render_large<'a>(
|
|||
let lw_row = prop_row(LwItem(active_lineweight).to_string(), PROP_LW_ID, None);
|
||||
|
||||
let combos = container(
|
||||
column![color_row, lt_row, lw_row].spacing(2).align_x(iced::Left),
|
||||
column![color_row, lt_row, lw_row]
|
||||
.spacing(2)
|
||||
.align_x(iced::Left),
|
||||
)
|
||||
.height(Fill)
|
||||
.align_y(iced::Center)
|
||||
.padding(Padding { top: 4.0, bottom: 4.0, left: 0.0, right: 4.0 });
|
||||
.padding(Padding {
|
||||
top: 4.0,
|
||||
bottom: 4.0,
|
||||
left: 0.0,
|
||||
right: 4.0,
|
||||
});
|
||||
|
||||
row![mp_el, combos]
|
||||
.spacing(4)
|
||||
|
|
@ -628,7 +884,12 @@ pub(super) fn render_large<'a>(
|
|||
.into()
|
||||
}
|
||||
|
||||
RibbonItem::StyleComboGroup { style_key, combo_id, manager_cmd, rows } => {
|
||||
RibbonItem::StyleComboGroup {
|
||||
style_key,
|
||||
combo_id,
|
||||
manager_cmd,
|
||||
rows,
|
||||
} => {
|
||||
const STYLE_COMBO_W: f32 = LARGE_W * 2.3;
|
||||
let names: Vec<String> = style_ctx.names_for(style_key).to_vec();
|
||||
let active: String = style_ctx.active_for(style_key).to_string();
|
||||
|
|
@ -640,9 +901,12 @@ pub(super) fn render_large<'a>(
|
|||
container(text(active.clone()).size(11).color(Color::WHITE))
|
||||
.width(Fill)
|
||||
.clip(true),
|
||||
text(if is_open { "▲" } else { "▾" })
|
||||
.size(9)
|
||||
.color(Color { r: 0.7, g: 0.7, b: 0.7, a: 1.0 }),
|
||||
text(if is_open { "▲" } else { "▾" }).size(9).color(Color {
|
||||
r: 0.7,
|
||||
g: 0.7,
|
||||
b: 0.7,
|
||||
a: 1.0
|
||||
}),
|
||||
]
|
||||
.spacing(4)
|
||||
.align_y(iced::Center),
|
||||
|
|
@ -650,17 +914,42 @@ pub(super) fn render_large<'a>(
|
|||
.on_press(Message::ToggleRibbonDropdown(combo_id.to_string()))
|
||||
.style(move |_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match (is_open, status) {
|
||||
(true, _) => Color { r: 0.14, g: 0.14, b: 0.14, a: 1.0 },
|
||||
(_, button::Status::Hovered) => Color { r: 0.26, g: 0.26, b: 0.26, a: 1.0 },
|
||||
_ => Color { r: 0.18, g: 0.18, b: 0.18, a: 1.0 },
|
||||
(true, _) => Color {
|
||||
r: 0.14,
|
||||
g: 0.14,
|
||||
b: 0.14,
|
||||
a: 1.0,
|
||||
},
|
||||
(_, button::Status::Hovered) => Color {
|
||||
r: 0.26,
|
||||
g: 0.26,
|
||||
b: 0.26,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color {
|
||||
r: 0.18,
|
||||
g: 0.18,
|
||||
b: 0.18,
|
||||
a: 1.0,
|
||||
},
|
||||
})),
|
||||
border: Border {
|
||||
radius: 3.0.into(),
|
||||
width: 1.0,
|
||||
color: if is_open {
|
||||
Color { r: 0.45, g: 0.65, b: 0.90, a: 1.0 }
|
||||
Color {
|
||||
r: 0.45,
|
||||
g: 0.65,
|
||||
b: 0.90,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color { r: 0.35, g: 0.35, b: 0.35, a: 1.0 }
|
||||
Color {
|
||||
r: 0.35,
|
||||
g: 0.35,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
}
|
||||
},
|
||||
},
|
||||
..Default::default()
|
||||
|
|
@ -681,7 +970,12 @@ pub(super) fn render_large<'a>(
|
|||
text(if is_sel { "✓" } else { " " })
|
||||
.size(10)
|
||||
.color(if is_sel {
|
||||
Color { r: 0.2, g: 0.8, b: 0.4, a: 1.0 }
|
||||
Color {
|
||||
r: 0.2,
|
||||
g: 0.8,
|
||||
b: 0.4,
|
||||
a: 1.0,
|
||||
}
|
||||
} else {
|
||||
Color::TRANSPARENT
|
||||
}),
|
||||
|
|
@ -693,11 +987,24 @@ pub(super) fn render_large<'a>(
|
|||
.on_press(Message::RibbonStyleChanged { key, name: n })
|
||||
.style(move |_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered | button::Status::Pressed => {
|
||||
Color { r: 0.28, g: 0.28, b: 0.28, a: 1.0 }
|
||||
}
|
||||
_ if is_sel => Color { r: 0.20, g: 0.35, b: 0.55, a: 1.0 },
|
||||
_ => Color { r: 0.16, g: 0.16, b: 0.16, a: 1.0 },
|
||||
button::Status::Hovered | button::Status::Pressed => Color {
|
||||
r: 0.28,
|
||||
g: 0.28,
|
||||
b: 0.28,
|
||||
a: 1.0,
|
||||
},
|
||||
_ if is_sel => Color {
|
||||
r: 0.20,
|
||||
g: 0.35,
|
||||
b: 0.55,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color {
|
||||
r: 0.16,
|
||||
g: 0.16,
|
||||
b: 0.16,
|
||||
a: 1.0,
|
||||
},
|
||||
})),
|
||||
..Default::default()
|
||||
})
|
||||
|
|
@ -711,15 +1018,27 @@ pub(super) fn render_large<'a>(
|
|||
let mut full_col = items_col;
|
||||
if let Some(mgr_cmd) = manager_cmd {
|
||||
full_col.push(
|
||||
button(
|
||||
text(format!("Manage…")).size(10)
|
||||
.color(Color { r: 0.5, g: 0.8, b: 1.0, a: 1.0 }),
|
||||
)
|
||||
button(text(format!("Manage…")).size(10).color(Color {
|
||||
r: 0.5,
|
||||
g: 0.8,
|
||||
b: 1.0,
|
||||
a: 1.0,
|
||||
}))
|
||||
.on_press(Message::Command(mgr_cmd.to_string()))
|
||||
.style(|_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered => Color { r: 0.24, g: 0.24, b: 0.24, a: 1.0 },
|
||||
_ => Color { r: 0.13, g: 0.13, b: 0.13, a: 1.0 },
|
||||
button::Status::Hovered => Color {
|
||||
r: 0.24,
|
||||
g: 0.24,
|
||||
b: 0.24,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color {
|
||||
r: 0.13,
|
||||
g: 0.13,
|
||||
b: 0.13,
|
||||
a: 1.0,
|
||||
},
|
||||
})),
|
||||
..Default::default()
|
||||
})
|
||||
|
|
@ -740,11 +1059,19 @@ pub(super) fn render_large<'a>(
|
|||
.max_height(180.0)
|
||||
.width(Length::Fixed(STYLE_COMBO_W))
|
||||
.style(|_: &Theme| container::Style {
|
||||
background: Some(Background::Color(
|
||||
Color { r: 0.14, g: 0.14, b: 0.14, a: 0.98 },
|
||||
)),
|
||||
background: Some(Background::Color(Color {
|
||||
r: 0.14,
|
||||
g: 0.14,
|
||||
b: 0.14,
|
||||
a: 0.98,
|
||||
})),
|
||||
border: Border {
|
||||
color: Color { r: 0.35, g: 0.35, b: 0.35, a: 1.0 },
|
||||
color: Color {
|
||||
r: 0.35,
|
||||
g: 0.35,
|
||||
b: 0.35,
|
||||
a: 1.0,
|
||||
},
|
||||
width: 1.0,
|
||||
radius: 4.0.into(),
|
||||
},
|
||||
|
|
@ -765,12 +1092,12 @@ pub(super) fn render_large<'a>(
|
|||
let event = t.event.clone();
|
||||
let icon_el: Element<Message> = match t.icon {
|
||||
IconKind::Glyph(g) => text(g).size(13).color(Color::WHITE).into(),
|
||||
IconKind::Svg(bytes) => iced::widget::svg(
|
||||
iced::widget::svg::Handle::from_memory(bytes),
|
||||
)
|
||||
.width(16)
|
||||
.height(16)
|
||||
.into(),
|
||||
IconKind::Svg(bytes) => {
|
||||
iced::widget::svg(iced::widget::svg::Handle::from_memory(bytes))
|
||||
.width(16)
|
||||
.height(16)
|
||||
.into()
|
||||
}
|
||||
};
|
||||
let msg = module_event_to_message(event);
|
||||
tooltip(
|
||||
|
|
@ -790,11 +1117,10 @@ pub(super) fn render_large<'a>(
|
|||
row(btns).spacing(2).align_y(iced::Center).into()
|
||||
};
|
||||
|
||||
let mut col_items: Vec<Element<Message>> = vec![
|
||||
container(row![combo_btn, items_panel].spacing(0))
|
||||
let mut col_items: Vec<Element<Message>> =
|
||||
vec![container(row![combo_btn, items_panel].spacing(0))
|
||||
.width(Fill)
|
||||
.into(),
|
||||
];
|
||||
.into()];
|
||||
for row_tools in rows {
|
||||
col_items.push(make_tool_row(row_tools));
|
||||
}
|
||||
|
|
@ -803,7 +1129,12 @@ pub(super) fn render_large<'a>(
|
|||
.width(Length::Fixed(STYLE_COMBO_W))
|
||||
.height(Fill)
|
||||
.align_y(iced::Center)
|
||||
.padding(Padding { top: 4.0, bottom: 4.0, left: 4.0, right: 4.0 })
|
||||
.padding(Padding {
|
||||
top: 4.0,
|
||||
bottom: 4.0,
|
||||
left: 4.0,
|
||||
right: 4.0,
|
||||
})
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -814,10 +1145,7 @@ pub(super) fn render_large<'a>(
|
|||
// ── Dropdown position helpers ──────────────────────────────────────────────
|
||||
|
||||
/// Calculate the left pixel offset of a dropdown button inside the ribbon tool area.
|
||||
pub(super) fn compute_dropdown_left(
|
||||
groups: &[RibbonGroup],
|
||||
open_id: &str,
|
||||
) -> f32 {
|
||||
pub(super) fn compute_dropdown_left(groups: &[RibbonGroup], open_id: &str) -> f32 {
|
||||
let sum_with_spacing = |widths: &[f32]| -> f32 {
|
||||
widths
|
||||
.iter()
|
||||
|
|
@ -826,7 +1154,11 @@ pub(super) fn compute_dropdown_left(
|
|||
.sum::<f32>()
|
||||
};
|
||||
let next_item_x = |widths: &[f32]| -> f32 {
|
||||
if widths.is_empty() { 0.0 } else { sum_with_spacing(widths) + 2.0 }
|
||||
if widths.is_empty() {
|
||||
0.0
|
||||
} else {
|
||||
sum_with_spacing(widths) + 2.0
|
||||
}
|
||||
};
|
||||
|
||||
let mut x = 0.0f32;
|
||||
|
|
@ -950,7 +1282,9 @@ pub(super) fn render_history_control<'a>(
|
|||
|
||||
let main_btn = {
|
||||
let btn = button(
|
||||
text(glyph).size(14).color(if active { Color::WHITE } else { LABEL_OFF }),
|
||||
text(glyph)
|
||||
.size(14)
|
||||
.color(if active { Color::WHITE } else { LABEL_OFF }),
|
||||
)
|
||||
.style(move |_: &Theme, status| top_hist_btn_style(active, dd_open, status))
|
||||
.width(Length::Fixed(TOP_HIST_W))
|
||||
|
|
@ -978,7 +1312,9 @@ pub(super) fn render_history_control<'a>(
|
|||
let arrow_btn = {
|
||||
let btn = button(
|
||||
container(
|
||||
text("▾").size(7).color(if active { ARROW_COLOR } else { LABEL_OFF }),
|
||||
text("▾")
|
||||
.size(7)
|
||||
.color(if active { ARROW_COLOR } else { LABEL_OFF }),
|
||||
)
|
||||
.width(Fill)
|
||||
.height(Fill)
|
||||
|
|
@ -1014,7 +1350,12 @@ pub(super) fn top_hist_btn_style(
|
|||
) -> button::Style {
|
||||
button::Style {
|
||||
background: Some(Background::Color(match (active, open, status) {
|
||||
(false, _, _) => Color { r: 0.20, g: 0.20, b: 0.20, a: 1.0 },
|
||||
(false, _, _) => Color {
|
||||
r: 0.20,
|
||||
g: 0.20,
|
||||
b: 0.20,
|
||||
a: 1.0,
|
||||
},
|
||||
(_, true, _) => TOOL_ACTIVE,
|
||||
(_, _, button::Status::Hovered) => TOOL_HOVER,
|
||||
(_, _, button::Status::Pressed) => TOOL_ACTIVE,
|
||||
|
|
|
|||
Loading…
Reference in a new issue