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

WIP Tooltips #266

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

WIP Tooltips #266

wants to merge 3 commits into from

Conversation

matyalatte
Copy link
Contributor

#256 has many problems because it's hard coded for my apps.
This PR is an updated version of the old one.
I fixed some issues and supported more controls.

Tooltip API

/**
 * Sets the control tooltip.
 *
 * @param c uiControl instance.
 * @param tooltip Control tooltip.\n
 *             A valid, `NULL` terminated UTF-8 string.\n
 *             Data is copied internally. Ownership is not transferred.
 * @note Setting `NULL` resets the tooltip to the default value.
 * @memberof uiControl
 */
_UI_EXTERN void uiControlSetTooltip(uiControl *c, const char *tooltip);

@matyalatte
Copy link
Contributor Author

I opened this PR as a draft because I don't plan to update it anymore.
But you can use my commits if you are working on the tooltip API.

@matyalatte matyalatte mentioned this pull request Jan 27, 2024
@cody271
Copy link
Contributor

cody271 commented Jan 29, 2024

I opened this PR as a draft because I don't plan to update it anymore.

What's left to be done here?

@matyalatte
Copy link
Contributor Author

What's left to be done here?

First, we need to find out which controls are supported.
I tested some of the data entry controls (uiCheckbox, uiEntry, uiSpinbox, uiCombobox, uiEditableCombobox, and uiRadioButtons) but idk how it works with other controls.

Second, there should be assertions and comments about the unsupported controls if we use the current implementation.

Third, there might be better solutions.
I'm too novice at winapi to tell if my implementation is appropriate.

@cody271
Copy link
Contributor

cody271 commented Feb 1, 2024

Third, there might be better solutions.
I'm too novice at winapi to tell if my implementation is appropriate.

No unfortunately you have it correct: Win32 builtin support for tooltips is just really complex.

@rubyFeedback
Copy link

If this is too complex, could we perhaps just pick one entry for tooltips? For instance,
working with GUIs (ruby-gtk3) I typically use tooltips by far the most for a button,
to describe what this button does (clicking on it, that is); and the other one is
gtk-entry (e. g. to allow for user input, other toolkits call this single line input or
entry, as opposed to multiline entry, which sometimes is also called just a
text view widget). So perhaps a tooltip on buttons? Anything else could be implemented
at a later time, if tooltip on buttons work.

@cody271
Copy link
Contributor

cody271 commented Feb 5, 2024

If this is too complex, could we perhaps just pick one entry for tooltips?
So perhaps a tooltip on buttons? Anything else could be implemented at a later time, if tooltip on buttons work.

Support for all the controls you list here already implemented in this PR.

@rubyFeedback Give tooltips with this PR a try, testers on Windows especially needed!

@petabyt
Copy link

petabyt commented Feb 11, 2024

Tested the control gallery Windows 11, ran in Visual Studio and got a __debugbreak

 	KernelBase.dll!00007ffb0f59cd82()	Unknown
 	ex.exe!_logLastError(wchar_t * file, wchar_t * line, wchar_t * func, wchar_t * s) Line 32	C++
>	ex.exe!uiWindowsEnsureSetParentHWND(HWND__ * hwnd, HWND__ * parent) Line 16	C++
 	ex.exe!uiWindowSetParentHWND(uiWindowsControl * c, HWND__ * parent) Line 257	C++
 	ex.exe!uiWindowsControlMinimumSize(uiWindowsControl * c, int * width, int * height) Line 17	C++
 	ex.exe!windowWndProc(HWND__ * hwnd, unsigned int uMsg, unsigned __int64 wParam, __int64 lParam) Line 121	C++
 	user32.dll!00007ffb10578241()	Unknown
 	user32.dll!00007ffb10577efc()	Unknown
 	user32.dll!00007ffb105876fc()	Unknown
 	ntdll.dll!00007ffb11b933b4()	Unknown
 	win32u.dll!00007ffb0eed1554()	Unknown
 	user32.dll!00007ffb10576655()	Unknown
 	user32.dll!00007ffb105762b9()	Unknown
 	ex.exe!windowWndProc(HWND__ * hwnd, unsigned int uMsg, unsigned __int64 wParam, __int64 lParam) Line 137	C++
 	user32.dll!00007ffb10578241()	Unknown
 	user32.dll!00007ffb10577efc()	Unknown
 	user32.dll!00007ffb1058564c()	Unknown
 	ntdll.dll!00007ffb11b933b4()	Unknown
 	win32u.dll!00007ffb0eed18d4()	Unknown
 	ex.exe!setClientSize(uiWindow * w, int width, int height, int hasMenubar, unsigned int style, unsigned int exstyle) Line 519	C++
 	ex.exe!uiNewWindow(volatile char * title, int width, int height, int hasMenubar) Line 563	C++
 	ex.exe!main() Line 353	C++
 	ex.exe!__tmainCRTStartup()	C++
 	ex.exe!mainCRTStartup() Line 214	C++
 	kernel32.dll!00007ffb10d7257d()	Unknown
 	ntdll.dll!00007ffb11b4aa58()	Unknown

For some reason I couldn't get any error message (compiling with MinGW) but it's clear it's this line:
https://github.com/matyalatte/libui-ng/blob/ac1c0d55f8da2dcacb6bc7a4da7702176d0de2da/windows/winpublic.cpp#L15C3-L15C48

Used this code: https://github.com/matyalatte/libui-ng/blob/1fe3dfff5b643c3314f6cd65915939202e52b923/examples/controlgallery/main.c

@matyalatte
Copy link
Contributor Author

matyalatte commented Feb 11, 2024

Hmm, I use mingw-w64 on Windows10 but it works fine.

ex.exe!uiNewWindow(volatile char * title, int width, int height, int hasMenubar) Line 563
ex.exe!main() Line 353

It's weird that uiNewWindow causes an error. It has no tooltips when it's called.
Can you test the control gallery with the master branch? It might also get the __debugbreak.

Used this code: https://github.com/matyalatte/libui-ng/blob/1fe3dfff5b643c3314f6cd65915939202e52b923/examples/controlgallery/main.c

Is it true? The line 353 is not the main function at the commit.

@petabyt
Copy link

petabyt commented Feb 11, 2024

Is it true? The line 353 is not the main function at the commit.

I had been doing a few experiments on the old file, but your code had the exact same error.

It's weird that uiNewWindow causes an error. It has no tooltips when it's called. Can you test the control gallery with the master branch? It might also get the __debugbreak.

Same thing. It might be a compiler issue on my end? I'm compiling libui with a custom Makefile into a standalone binary with the control gallery. But the current libui-ng/libui-ng codebase compiles fine with the same makefile.

@petabyt
Copy link

petabyt commented Feb 11, 2024

Ok, I cleaned and it's working on the control gallery now. I'm sure it was some goof on my end. But uiControlSetTooltip isn't working. Look like it's breaking here now: https://github.com/matyalatte/libui-ng/blob/df7edf3473c9abb10eeba887ab49a34aef4ebfb3/windows/tooltip.cpp#L28

EDIT: Looks like my old tooltips implementation isn't working either. So might be some bizarre issue on my end.

@matyalatte
Copy link
Contributor Author

matyalatte commented Feb 12, 2024

I'm compiling libui with a custom Makefile into a standalone binary with the control gallery.

The only way to get support here is to use meson (even if the cause is my PR.)
And I think meson supports the standalone binary with --default-library=static.

I built standalone binaries with mingw-w64 like this.

meson setup build --default-library=static
meson compile -C build

Then, the control gallery worked on clean installed Windows 10 without DLLs.

@petabyt
Copy link

petabyt commented Feb 12, 2024

The only way to get support here is to use meson (even if the cause is my PR.) And I think meson supports the standalone binary with --default-library=static.

Well, I'd sure hope meson isn't doing any compilation magic to make libui work 😆 Anyway, it's my issue now looks like.

EDIT: it's working now, I had copied the wrong resource file.

Tooltips are working well, no errors or crashes running in visual studio debugger in Windows 11.

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.

None yet

4 participants