-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: add icon to submenu #277
Open
s00d
wants to merge
14
commits into
tauri-apps:dev
Choose a base branch
from
s00d:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+124
−31
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This was referenced Feb 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the ability to add icons to submenu items on macOS by providing a new
set_icon
andset_native_icon
method in theSubmenu
API.What’s Changed
set_icon
andset_native_icon
method to change the icon after the submenu has been created.Thank you for reviewing this pull request!