forked from 1b-agent/opencadstudio-upstream
feat(ui): replace app-menu logo with a quick-access file toolbar
Remove the OCS-logo button and the dropdown menu it opened; the top strip now shows direct New / Open / Save / Save As / Print buttons ahead of the undo/redo controls. Drop the HELP and OPTIONS commands (HELP dumped text to the command line, OPTIONS aliased the drafting-settings popup). The app-menu overlay is gone, so its rendering code, MENU_ITEMS, four dead messages, and the LOGO_RED / GEAR / HELP assets are removed. The recents list it held is the only survivor — moved into OpenCADStudio.recent_files via a new app/recent.rs, backing the Start page's Recent Documents panel. Quick-access icons are redrawn in a cleaner style (file-plus, folder-open, device-floppy, file-export, printer) and tinted light so they read on the dark strip; FOLDER / DOC keep their old glyphs for the file browser. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bc5c2a686
commit
7bab7c7b8d
17 files changed
+154
-643
No files matched your search
+11
-27
@@ -217,32 +217,16 @@ impl Ribbon {
|
||||
undo_count: usize,
|
||||
redo_count: usize,
|
||||
) -> Element<'_, Message> {
|
||||
// ── Logo ──────────────────────────────────────────────────────────
|
||||
let logo_svg = {
|
||||
let handle = svg::Handle::from_memory(include_bytes!("../../../assets/logo.svg"));
|
||||
svg(handle).width(30).height(28)
|
||||
};
|
||||
let logo = button(logo_svg)
|
||||
.on_press(Message::ToggleAppMenu)
|
||||
.style(|_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered | button::Status::Pressed => Color {
|
||||
r: 0.80,
|
||||
g: 0.25,
|
||||
b: 0.15,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => LOGO_RED,
|
||||
})),
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
..Default::default()
|
||||
},
|
||||
shadow: iced::Shadow::default(),
|
||||
snap: false,
|
||||
..Default::default()
|
||||
})
|
||||
.padding([0, 4]);
|
||||
// ── Quick-access file commands ─────────────────────────────────────
|
||||
let quick_access = row![
|
||||
quick_access_btn(crate::ui::icons::DOC_NEW, "New", "NEW"),
|
||||
quick_access_btn(crate::ui::icons::FOLDER_OPEN, "Open", "OPEN"),
|
||||
quick_access_btn(crate::ui::icons::SAVE, "Save", "SAVE"),
|
||||
quick_access_btn(crate::ui::icons::FILE_EXPORT, "Save As", "SAVEAS"),
|
||||
quick_access_btn(crate::ui::icons::PRINT, "Print", "PRINT"),
|
||||
]
|
||||
.spacing(TOP_HIST_GAP)
|
||||
.align_y(iced::Center);
|
||||
|
||||
// ── Tab buttons ───────────────────────────────────────────────────
|
||||
let history_controls = row![
|
||||
@@ -253,7 +237,7 @@ impl Ribbon {
|
||||
.align_y(iced::Center);
|
||||
|
||||
let tab_buttons = self.modules.iter().enumerate().fold(
|
||||
row![logo, history_controls]
|
||||
row![quick_access, history_controls]
|
||||
.align_y(iced::Center)
|
||||
.spacing(6),
|
||||
|row_acc, (i, module)| {
|
||||
|
||||
@@ -54,10 +54,11 @@ 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,
|
||||
/// Light chrome grey for the quick-access file-command icons on the top strip.
|
||||
pub(super) const QA_ICON_COLOR: Color = Color {
|
||||
r: 0.82,
|
||||
g: 0.83,
|
||||
b: 0.85,
|
||||
a: 1.0,
|
||||
};
|
||||
pub(super) const TOPBAR_BG: Color = Color {
|
||||
@@ -1082,6 +1083,50 @@ pub fn module_event_to_message(event: ModuleEvent) -> Message {
|
||||
|
||||
// ── History control ────────────────────────────────────────────────────────
|
||||
|
||||
/// Quick-access chrome button (New / Open / Save / Save As / Print) in the top
|
||||
/// strip: an SVG icon that dispatches a command string, with a hover tooltip.
|
||||
pub(super) fn quick_access_btn<'a>(
|
||||
icon_bytes: &'static [u8],
|
||||
label: &'static str,
|
||||
cmd: &'static str,
|
||||
) -> Element<'a, Message> {
|
||||
// The bundled UI SVGs are black-stroked; tint them to a light chrome grey so
|
||||
// they read on the dark top strip (raw black is invisible there).
|
||||
let icon = icons::tinted(icon_bytes, 16.0, QA_ICON_COLOR);
|
||||
let btn = button(
|
||||
container(icon)
|
||||
.width(Fill)
|
||||
.height(Fill)
|
||||
.align_x(iced::Center)
|
||||
.align_y(iced::Center),
|
||||
)
|
||||
.on_press(Message::Command(cmd.to_string()))
|
||||
.style(|_: &Theme, status| button::Style {
|
||||
background: Some(Background::Color(match status {
|
||||
button::Status::Hovered | button::Status::Pressed => Color {
|
||||
r: 0.30,
|
||||
g: 0.30,
|
||||
b: 0.30,
|
||||
a: 1.0,
|
||||
},
|
||||
_ => Color::TRANSPARENT,
|
||||
})),
|
||||
border: Border {
|
||||
radius: 2.0.into(),
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.width(Length::Fixed(TOP_HIST_W))
|
||||
.height(24)
|
||||
.padding([2, 0]);
|
||||
tooltip(btn, make_tip(label.to_string()), TipPos::Bottom)
|
||||
.gap(6.0)
|
||||
.delay(Duration::from_millis(400))
|
||||
.style(tip_style)
|
||||
.into()
|
||||
}
|
||||
|
||||
pub(super) fn render_history_control<'a>(
|
||||
label: &'static str,
|
||||
dropdown_id: &'static str,
|
||||
|
||||
Reference in new issue
Block a user