Skip to content

Clean up the app menu bar code to send its TextButtons directly as a layout #3345

@Keavon

Description

@Keavon

Currently, the app menu bar ("File", "Edit", "View", etc.) is composed of TextButtons defined in a loop in the frontend Svelte code:

Image

All other layouts are sent directly from the backend using the regular layout system, where each of those TextButtons would be defined in the Rust code and given to the frontend as a Vec<WidgetDiff>. But instead, we send it as a Vec<MenuBarEntry> special case, which should be changed to use the regular system:

Image

Then we can avoid opting out of the regular layout system for the MenuBar:

Image

Inside fn diff_and_send_layout_to_frontend, we would then remove the special case handling for the Layout::MenuLayout(_) => { ... } arm of the match statement. And then we could probably remove the Layout enum entirely once we are only using WidgetLayout and no longer using the MenuLayout:

Image

This may require making the standard system for sending dropdown menus and menu lists, including nested levels of menus, more powerful if it's not currently capable of expressing the same things expressed by a MenuLayout.

Basically, the goal is to standardize this all so it fits into the layout system and nested menu lists can be part of any layout, not only the special opted-out case of the app's menu bar. This might be a prerequisite for #138, or at least for context menus with sub-menu levels.

Important: it's crucial to make sure that the diffing still works with all the menu list content, including in sub-menu levels. So if you toggle rulers by clicking the "View > Rulers" menu entry's or using its shortcut, the menu entry's checkbox icon should be updated to show that it is active or inactive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Short-Term

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions