Skip to content
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

[nuklear] Added command to enable cursors with default font. #1138

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

dlannan
Copy link
Contributor

@dlannan dlannan commented Oct 23, 2024

This adds the cursor to be available for use when using the default font.

To enable cursors in a sokol application:

  • First hide the native mouse: sapp_show_mouse(false);
  • Then show the nuklear mouse: nk_style_show_cursor(ctx);
    The nuklear show must be called with a valid context.

If not using the default font, then after a font is initialized and added manually call:
nk_style_load_all_cursors(ctx, &your_font_atlas);
And then use the above operations to show the nuklear cursor.

@floooh floooh changed the title Added command to enable cursors with default font. [nuklear] Added command to enable cursors with default font. Oct 23, 2024
@floooh
Copy link
Owner

floooh commented Oct 23, 2024

Looks like a nice simple fix (oh, CI fails though, can you look into that?):

MSVC warning:

sokol_nuklear.h(2156,55): warning C4047: 'function': 'nk_cursor *' differs in levels of indirection from 'nk_cursor (*)[7]'

GCC/Clang error:

sokol_nuklear.h:2156:55: error: incompatible pointer types passing 'struct nk_cursor (*)[7]' to parameter of type 'struct nk_cursor *' [-Werror,-Wincompatible-pointer-types]

@dlannan
Copy link
Contributor Author

dlannan commented Oct 24, 2024

@floooh - sorry. I just went through some of these. Will fix. Needs to be:
nk_style_load_all_cursors(&_snuklear.ctx, &_snuklear.atlas.cursors[0]);
Running multi-platform tests now to make sure. Will update as needed.

Fixed incorrect parameter passing.
@floooh
Copy link
Owner

floooh commented Oct 24, 2024

Thanks for the fixes! The CI error on Android is unrelated, currently investigating...

PS: ok, looks like it was just a hickup, not unusual unfortunately with GH Actions.

I'll test the PR locally a bit and then merge, one sec...

floooh added a commit that referenced this pull request Oct 24, 2024
@floooh floooh merged commit e46099f into floooh:master Oct 24, 2024
32 checks passed
@floooh
Copy link
Owner

floooh commented Oct 24, 2024

Ok merged. Thanks!

The software mouse cursor actually feels a lot better than expected :) I tested on a 120 Hz display though.

The sapp_show_mouse(false/true) should probably also be hooked up to the SAPP_EVENTTYPE_MOUSE_ENTER/LEAVE events because at least on macOS the system mouse cursor remains hidden when moving it outside the application window (I think that's one of those platform specific behaviour in different window systems).

@floooh floooh mentioned this pull request Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants