-
Notifications
You must be signed in to change notification settings - Fork 49
feat: add icon to submenu #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement functionality to set icons for menu items in the macOS platform. This enhancement allows for improved visual representation of menu items by utilizing the `menuitem_set_icon` function.
Added a `set_icon` method to the `Submenu` struct, allowing for changing or removing the icon of a menu item. This enhances the flexibility of menu customization in the user interface.
Introduce a new submenu within the "Window" menu, allowing for additional icon items. This enhances the user interface by providing more options directly accessible from the menu. The default menu option for macOS is commented out to allow for customization. Icons are now properly set for the new submenu and its items.
Enhances the menu item functionality by integrating native icons. The `menuitem_set_native_icon` function is now called to set the native icon for the menu item, improving the visual consistency with platform standards. This change enables better user experience on macOS applications.
Consolidate import statements for better readability and maintainability. Update submenu icon setting to use `NativeIcon::Add` for improved consistency across platforms. This change enhances the user interface by ensuring the correct icon is displayed for the submenu.
Introduce a new method `set_native_icon` to allow changing the menu item icon to a native image. This method currently supports macOS, while remaining unsupported on Windows and Linux platforms. The addition enhances the customization options for submenu items.
Reorganized the import statements in `src/items/submenu.rs` to enhance code readability. Each import is now on a separate line, following Rust's style guidelines for clarity and maintainability.
Enhances the menu system by allowing submenu items to display icons. This change introduces checks for `MenuItemType::Submenu`, and if an icon is present, it retrieves the bitmap and updates the menu item info accordingly. This provides a more visually consistent and informative user interface.
Refactor icon setting logic to ensure that native icons are set properly only if they are provided. This change improves the handling of menu item icons, preventing potential null references and ensuring that both native and regular icons are assigned correctly.
Reorganize `use` statements for better clarity and remove unnecessary whitespace. Adjust comments for consistency and clarity. This enhances the overall readability of the code without changing its functionality.
This commit introduces the `gtk` dependency for Linux targets in the `examples/windows-common-controls-v6/Cargo.toml` file, enabling cross-platform compatibility with GTK-based UI elements.
This commit introduces the `gtk` dependency for Linux targets in the `examples/windows-common-controls-v6/Cargo.toml` file, enabling cross-platform compatibility with GTK-based UI elements.
Included the `gtk::prelude::*` import conditionally for Linux platforms to ensure compatibility with GTK-based UI components. This change enhances the cross-platform functionality of the application by properly handling Linux-specific dependencies.
Add support for custom layout in menu items by introducing a new parameter `for_menu_bar`. This allows for specific styling when creating menu items for the menu bar. The layout now includes an image and label in a horizontal box, improving the visual appearance and usability of menu items. Adjustments to CSS styling are also included to better align items when not used in the menu bar.
|
Fully completed the implementation and tested it on macOS, Windows, and Linux. It seems there are no issues with how it runs. As an example, I added the ability to launch on Linux (there’s a warning that there’s no parent, but it doesn’t interfere with testing—this warning only appears in the example). The task is related to: |
|
@amrbashir Hi, can you take a look? |
|
@amrbashir @s00d Would absolutely love to see this 👍🏻 I assume the gtk4 migration will be quite huge and take a long time so maybe merge this for now? |
amrbashir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I left a few comments.
Also since the migration to gtk4 is taking quite a bit of time (that I don't have just yet), we could take this PR as an opportunity to also merge MenuItem and IconMenuItem into a single type (If you want, I can try to include it after this PR lands).
|
I think I fixed everything you mentioned. I tested it on macOS, Linux, and Windows — everything works fine on my side. |
Refactor long lines in `src/platform_impl/gtk/mod.rs` to improve readability. This change enhances code maintainability without altering functionality.
|
https://github.com/s00d/muda/actions/runs/15685668646 Fixed all the errors and formatting. |
|
@s00d thank you |
This PR introduces the ability to add icons to submenu items on macOS by providing a new
set_iconandset_native_iconmethod in theSubmenuAPI.What’s Changed
set_iconandset_native_iconmethod to change the icon after the submenu has been created.Thank you for reviewing this pull request!