Add button_image_pos support for flat buttons#251
Add button_image_pos support for flat buttons#251idrassi wants to merge 8 commits intofrang75:mainfrom
Conversation
frang75
left a comment
There was a problem hiding this comment.
This implementation looks great. It's clear you have a firm grasp of the NAppGUI architecture. Before merging:
-
I have pending changes requested by sponsors that may conflict with these. I need to prioritize these changes.
-
Please correct the comments.
-
I need to take down the branch first to compile and test it in the NAppGUI CI/CD.
-
Once everything is OK, I will merge it and include it in the official NAppGUI documentation.
|
Thank you for the review and for the guidance on the gui/osgui boundary. I addressed the requested changes in follow-up commit. I also rechecked the updated branch on macOS, Windows and Linux after this change set. Concerning the NAppGUI architecture, I got help in the beginning from https://deepwiki.com/frang75/nappgui_src but I found some issues in it and so I ended up creating a more accurate documentation: https://idrassi.github.io/nappgui_src/site/index.html This documentation is in a dedicated branch in my fork: https://github.com/idrassi/nappgui_src/tree/docs_html_site/docs I can create a PR for it if you think it can be helpful to the project |
|
Incredible! I'm so glad to see the great work you're doing with the SDK. As you know, the NAppGUI documentation is currently only "user-level." The architecture isn't documented. I'll try to merge my changes as soon as possible to merge this pull request and make your implementation available to everyone. Thank you again for your cooperation. |
|
@idrassi I'm also working on customizing the flatbutton drawing for macOS. Cocoa's default routines paste the images to the button's border, ignoring the padding. Again, congratulations on your work. And thank you very much for the support you're providing to users in the issue section. I have very limited time and can't dedicate as much time to NAppGUI as I'd like.
|
|
@frang75 thank you for the update and for the ongoing refactoring work. For the GTK underline issue you reported, do you want me to tackle it in this PR branch or are you already planning to cover GTK as part of your current native refactoring pass? |
You can fix it in this PR branch. I'm working also in this branch. |
|
@frang75 The fix keeps the native GTK mnemonic path then applies a persistent PANGO_UNDERLINE_SINGLE attribute directly to the child GtkLabel for check/radio buttons. This keeps accelerator activation native while making the underline visible without requiring Alt. I also adjusted the GTK shortcut text conversion so the mnemonic position is tracked as a displayed-character index not as a GTK-escaped string offset. This avoids incorrect underline placement for cases like "File_&Open". Below is a screenshot. Let me know if this approach is acceptable.
|


Closes #226.
This adds the
button_image_pos()API proposed in #226 sobutton_flat()andbutton_flatgle()can optionally render text relative to their image, while preserving the current image-only behavior unless the new API is explicitly used.The change introduces the shared
gui_pos_tenum inguictx.hxxtogether with the publicbutton_image_pos()function, and updates the GTK, Windows, and macOS backends to render flat-button text at the requested image position. Flat-toggle alternate text and image handling stays synchronized with the toggle state.As requested in review, the image-position enum used by both
guiandosguinow lives inguictx.hxx, and the native backends no longer include high-levelguiheaders to access button-specific types.The macOS implementation also includes the AppKit type fix needed for the new image-position helper to build cleanly with Xcode.
The Windows implementation also includes follow-up fixes required by this feature: the Win32 flat-button text drawing path, tooltip clearing for image-only flat buttons, explicit redraw on flat-toggle state changes, and sizing hardening so flat toggles reserve enough space for both states under custom padding.
The
GuiHellodemos were updated to cover the new behavior. TheButtonspage now exercisesekGUI_POS_TOP, and theButton paddingpage now covers flat toggles withbutton_image_pos(), alternate text/image states, and zero/high padding.Below cross-platform
GuiHelloscreenshots for the updated behavior:macOS
Windows
Linux Ubuntu 24.04