andlabs / libui Goto Github PK
View Code? Open in Web Editor NEWSimple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
License: Other
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
License: Other
10.7 has Auto Layout bugs and some missing features, and the people on various OS X dev channels are suggesting I should drop it. Would anyone miss it?
seems like there is no way to access the edited value of an EditableCombobox? Maybe a get/setvalue pair for comboboxes would be good, that would return whatever string is visible to the user (edited or not)
migrated from andlabs/ui#36
There's some code for this in old ui already. It's not very elegant, and it's not themed, and it's still based on XP.
If I want this on GTK+ we either need to bump the version up or reimplement it ourselves. We can't use the official GtkPopover code because of LGPL.
There's code in various places, especially in the Windows backend, that assumes that a toplevel is a window. That will need to be fixed.
I am currently writing a library for C# wrapping libui for .NET Core. I have generally found the library structured very well for being wrapped for usage in another language. One issue I have come across is the usage of intmax_t
and uintmax_t
. C# has no equivalent for these types (and I suspect other languages also have this limitation), and as such I am currently assuming that they are 64 bit integers, but this could not be true. If the API could instead expose these as some fixed width integer then this would be much easier to deal with, especially when wanting to target any Windows, Linux or OS X system.
How can I build this project on windows? Do I use "nmake.exe"? I already took a look at "buildnotes" it says to run "make" but as far as I know theirs no make for windows.
It would be nice to support iOS and Android devices as well.
I know that this is still early, but I would like to suggest to use something like a semantic versioning system, as it allows potential upstream developers to target specific versions. For instance, I will check if a python wrapper is feasible, and it is important to target a specific version instead of the latest commits.
the example crashes when you hit enter in the entry box:
...
entry = uiNewEntry();
...
at least on osx that does not happen
i understand that a few menu items have special locations on some systems and have to be handled differently.
but i wonder why uiMenuAppendQuitItem() is the only function that seems to be doing an action on top of adding the entry to the right place.
i would prefer having to add an onClicked() action there, too.
When I searched through the repository using keyword Tree, I found that
// On GTK+, uiTableModel is a GtkTreeModel.
But what about on Windows? Are there any alternatives?
Lets'go
go get github.com/andlabs/ui
github.com/andlabs/ui
/usr/bin/ld: cannot find -lui
collect2: error: ld returned 1 exit status
Hey everyone, show some love here :) https://github.com/mavenave/libui.js very little done so far
I'm trying to tear down an hierarchy of uiControls by recursively unparenting and destroying the child controls, all the way up to the window.
uiLabel *l = uiNewLabel("foo");
uiWindow *w = uiNewWindow("win", 320, 200, 0);
uiWindowSetChild(w, uiControl(l));
uiControlSetParent(uiControl(l), NULL);
uiControlDestroy(uiControl(l));
uiControlDestroy(uiControl(w));
This results in the following abort:
** (lua:20378): CRITICAL **: [libui] common/control.c:94:uiControlVerifySetParent() POSSIBLE IMPLEMENTATION BUG; CONTACT ANDLABS:
attempt to double unparent uiControl 0x1309c60
Trace/breakpoint trap
What is the proper way to handle this?
Thank you,
concerns (for now) these functions:
_UI_EXTERN char *uiOpenFile(uiWindow *parent);
_UI_EXTERN char *uiSaveFile(uiWindow *parent);
_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description);
_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description);
can the parent parameter be NULL, i.e. parentless dialogs?
As opposed to using uiMain, a function we can call that would poll events, etc, would be nice so we can have multiple things on the main thread as well.
So I ran:
make install
I am trying to use the library to run a program. Please help. I really love this project.
Even the simplest setup:
gcc -L. -l:libui.so pkg-config --cflags --libs gtk+-3.0
-o a.out main.c
gives:
/tmp/ccXi6gxB.o: In function onClosing': main.c:(.text+0x1b): undefined reference to
uiControlDestroy'
main.c:(.text+0x20): undefined reference to uiQuit' /tmp/ccXi6gxB.o: In function
shouldQuit':
main.c:(.text+0x42): undefined reference to uiControlDestroy' /tmp/ccXi6gxB.o: In function
openClicked':
main.c:(.text+0x6c): undefined reference to uiOpenFile' main.c:(.text+0x90): undefined reference to
uiMsgBoxError'
main.c:(.text+0xaa): undefined reference to uiMsgBox' main.c:(.text+0xb6): undefined reference to
uiFreeText'
/tmp/ccXi6gxB.o: In function saveClicked': main.c:(.text+0xdb): undefined reference to
uiSaveFile'
main.c:(.text+0xff): undefined reference to uiMsgBoxError' main.c:(.text+0x119): undefined reference to
uiMsgBox'
main.c:(.text+0x125): undefined reference to uiFreeText' /tmp/ccXi6gxB.o: In function
update':
main.c:(.text+0x149): undefined reference to uiSpinboxSetValue' main.c:(.text+0x15f): undefined reference to
uiSliderSetValue'
main.c:(.text+0x176): undefined reference to uiProgressBarSetValue' /tmp/ccXi6gxB.o: In function
onSpinboxChanged':
main.c:(.text+0x197): undefined reference to uiSpinboxValue' /tmp/ccXi6gxB.o: In function
onSliderChanged':
main.c:(.text+0x1c0): undefined reference to uiSliderValue' /tmp/ccXi6gxB.o: In function
main':
main.c:(.text+0x1f4): undefined reference to uiInit' main.c:(.text+0x228): undefined reference to
uiFreeInitError'
main.c:(.text+0x23c): undefined reference to uiNewMenu' main.c:(.text+0x251): undefined reference to
uiMenuAppendItem'
main.c:(.text+0x26b): undefined reference to uiMenuItemOnClicked' main.c:(.text+0x27c): undefined reference to
uiMenuAppendItem'
main.c:(.text+0x296): undefined reference to uiMenuItemOnClicked' main.c:(.text+0x2a2): undefined reference to
uiMenuAppendQuitItem'
main.c:(.text+0x2b5): undefined reference to uiOnShouldQuit' main.c:(.text+0x2bf): undefined reference to
uiNewMenu'
main.c:(.text+0x2d4): undefined reference to uiMenuAppendCheckItem' main.c:(.text+0x2e4): undefined reference to
uiMenuAppendSeparator'
main.c:(.text+0x2f5): undefined reference to uiMenuAppendItem' main.c:(.text+0x305): undefined reference to
uiMenuItemDisable'
main.c:(.text+0x311): undefined reference to uiMenuAppendPreferencesItem' main.c:(.text+0x31f): undefined reference to
uiNewMenu'
main.c:(.text+0x334): undefined reference to uiMenuAppendItem' main.c:(.text+0x344): undefined reference to
uiMenuAppendAboutItem'
main.c:(.text+0x361): undefined reference to uiNewWindow' main.c:(.text+0x37c): undefined reference to
uiWindowSetMargined'
main.c:(.text+0x395): undefined reference to uiWindowOnClosing' main.c:(.text+0x39a): undefined reference to
uiNewVerticalBox'
main.c:(.text+0x3af): undefined reference to uiBoxSetPadded' main.c:(.text+0x3c5): undefined reference to
uiWindowSetChild'
main.c:(.text+0x3ca): undefined reference to uiNewHorizontalBox' main.c:(.text+0x3df): undefined reference to
uiBoxSetPadded'
main.c:(.text+0x3f7): undefined reference to uiBoxAppend' main.c:(.text+0x401): undefined reference to
uiNewGroup'
main.c:(.text+0x416): undefined reference to uiGroupSetMargined' main.c:(.text+0x42e): undefined reference to
uiBoxAppend'
main.c:(.text+0x433): undefined reference to uiNewVerticalBox' main.c:(.text+0x448): undefined reference to
uiBoxSetPadded'
main.c:(.text+0x45b): undefined reference to uiGroupSetChild' main.c:(.text+0x465): undefined reference to
uiNewButton'
main.c:(.text+0x47c): undefined reference to uiBoxAppend' main.c:(.text+0x486): undefined reference to
uiNewCheckbox'
main.c:(.text+0x49d): undefined reference to uiBoxAppend' main.c:(.text+0x4a2): undefined reference to
uiNewEntry'
main.c:(.text+0x4b7): undefined reference to uiEntrySetText' main.c:(.text+0x4cf): undefined reference to
uiBoxAppend'
main.c:(.text+0x4d9): undefined reference to uiNewLabel' main.c:(.text+0x4f0): undefined reference to
uiBoxAppend'
main.c:(.text+0x4f5): undefined reference to uiNewHorizontalSeparator' main.c:(.text+0x50c): undefined reference to
uiBoxAppend'
main.c:(.text+0x511): undefined reference to uiNewDatePicker' main.c:(.text+0x528): undefined reference to
uiBoxAppend'
main.c:(.text+0x52d): undefined reference to uiNewTimePicker' main.c:(.text+0x544): undefined reference to
uiBoxAppend'
main.c:(.text+0x549): undefined reference to uiNewDateTimePicker' main.c:(.text+0x560): undefined reference to
uiBoxAppend'
main.c:(.text+0x565): undefined reference to uiNewFontButton' main.c:(.text+0x57c): undefined reference to
uiBoxAppend'
main.c:(.text+0x581): undefined reference to uiNewVerticalBox' main.c:(.text+0x596): undefined reference to
uiBoxSetPadded'
main.c:(.text+0x5ae): undefined reference to uiBoxAppend' main.c:(.text+0x5b8): undefined reference to
uiNewGroup'
main.c:(.text+0x5cd): undefined reference to uiGroupSetMargined' main.c:(.text+0x5e5): undefined reference to
uiBoxAppend'
main.c:(.text+0x5ea): undefined reference to uiNewVerticalBox' main.c:(.text+0x5ff): undefined reference to
uiBoxSetPadded'
main.c:(.text+0x612): undefined reference to uiGroupSetChild' main.c:(.text+0x621): undefined reference to
uiNewSpinbox'
main.c:(.text+0x641): undefined reference to uiSpinboxOnChanged' main.c:(.text+0x65c): undefined reference to
uiBoxAppend'
main.c:(.text+0x66b): undefined reference to uiNewSlider' main.c:(.text+0x68b): undefined reference to
uiSliderOnChanged'
main.c:(.text+0x6a6): undefined reference to uiBoxAppend' main.c:(.text+0x6ab): undefined reference to
uiNewProgressBar'
main.c:(.text+0x6cd): undefined reference to uiBoxAppend' main.c:(.text+0x6d7): undefined reference to
uiNewGroup'
main.c:(.text+0x6ec): undefined reference to uiGroupSetMargined' main.c:(.text+0x704): undefined reference to
uiBoxAppend'
main.c:(.text+0x709): undefined reference to uiNewVerticalBox' main.c:(.text+0x71e): undefined reference to
uiBoxSetPadded'
main.c:(.text+0x731): undefined reference to uiGroupSetChild' main.c:(.text+0x736): undefined reference to
uiNewCombobox'
main.c:(.text+0x74b): undefined reference to uiComboboxAppend' main.c:(.text+0x75c): undefined reference to
uiComboboxAppend'
main.c:(.text+0x76d): undefined reference to uiComboboxAppend' main.c:(.text+0x785): undefined reference to
uiBoxAppend'
main.c:(.text+0x78a): undefined reference to uiNewEditableCombobox' main.c:(.text+0x79f): undefined reference to
uiComboboxAppend'
main.c:(.text+0x7b0): undefined reference to uiComboboxAppend' main.c:(.text+0x7c1): undefined reference to
uiComboboxAppend'
main.c:(.text+0x7d9): undefined reference to uiBoxAppend' main.c:(.text+0x7de): undefined reference to
uiNewRadioButtons'
main.c:(.text+0x7f3): undefined reference to uiRadioButtonsAppend' main.c:(.text+0x804): undefined reference to
uiRadioButtonsAppend'
main.c:(.text+0x815): undefined reference to `uiRadioButtonsAppend'
migrated from andlabs/ui#33
Multi-line plain-text text fields. Already in old ui.
just like the other callbacks.
Rationale: again, scripting integration. Without such an element, the callbacks in the uiAreaHandler will not be able to find the interpreter, unless it is stored in a global variable, which one may not want to do.
I would like to point out that identifiers like "__LIBUI_UI_UNIX_H__
" and "_UI_EXTERN
" do eventually not fit to the expected naming convention of the C++ language standard.
Would you like to adjust your selection for unique names?
This is work is so great and it makes it easy to create c UI application on all platform. Good job.
I build and run the histogram example on my MAC OS X, but it crashes when I clicked the close button.
It will be nice to fix it. Thanks a lot. Please keep going.
putting this here because I keep forgetting about it; also migrated from andlabs/ui#13
https://blogs.msdn.microsoft.com/oldnewthing/20140521-00/?p=943
https://blogs.msdn.microsoft.com/oldnewthing/20140522-00/?p=933
Not really an issue, more of a note: I've started writing a Lua binding to libui, if I find the time and discipline to get something working I'll point to the branch here and/or put up a pull request.
Such a feature would be useful
migrated from andlabs/ui#100
Simple image-displaying widget.
Need to figure out scaling, scrolling, etc.
Need to figure out image loading.
uiArea might obviate the need for this, but putting it up anyway.
I had four reasons for choosing flat makefiles:
.obj
and out
directories (obviating the need for #13 in my opinion, at least)However it seems that this decision is causing problems for lots of people, mostly on Windows where the command-line Visual Studio tools either behave unpredictably or require special handling depending on the configuration. @kainjow in #15 makes a really good point: most Windows users are likely more familiar with an IDE than with the command-line build system, to the point that command-line systems like cmake are more accessible.
While it's true I originally resisted changing, thinking make would be simpler, the number of build issues keeps growing, especially on other platforms. So now I'm willing ot hear arguments for specific build systems.
I genuinely do not have a preference for any one build system over the other, so please make your case for one you prefer. As part of your case, you should demonstrate what a setup for libui, the test/ folder, and each example would look like, as well as (if possible) a rule to build all examples. Feel free to point out any other advantages or disadvantages.
Here is a page detailing what an ideal build system would be like: https://gist.github.com/andlabs/243d5d817d291fa62722c33a9c58c6ab
Right now the following are being considered:
I'll make my decision and switch build systems if one appeals to me more than the others.
Thanks for your feedback! I do appreciate it all, and I want to make sure libui works for everyone :)
Looks like this can be done with all supported platforms:
Are there any plans to add an OpenGL control?
GLFW is great for making a bare window and OpenGL context across platforms, but doesn't have the sweet cross-platform UI support that libui seems to offer.
Libui is an awesome project that makes it much easier to make natively accessible applications on various platforms.
Currently it's impossible to render a list of items in a list view.
There are two pieces of behavior that I see as important for a list view implementation (wx fails onthe second on Mac):
1: Displaying a fixed list of columnar data
2: Displaying a list of items dynamically fetched from a datasource
Here is documentation on the underlying UI controls:
On windows: https://msdn.microsoft.com/en-us/library/windows/desktop/bb774737%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
on my system, GTK isnโt the native toolkit
I don't know if I am missing something but I've looked at the go library too, and there appears to be no way to get the current selected radio button?
migrate from andlabs/ui#104
Add an event to uiEntry that is triggered when Enter is pressed.
Notes to self: http://blogs.msdn.com/b/oldnewthing/archive/2006/10/12/819674.aspx
I ran these
make EXAMPLE=controlgallery
out/libui.so
But I got segfaulted.
GNU Make 3.81.8.2
libgtk-3 3.10.8
On 10.11.5, when I run the controlgallery example and then close it via the window to quit, I get this:
$ ./out/controlgallery
2016-05-23 13:01:05.503 controlgallery[39763:203248] [libui] darwin/alloc.m:45:uninitAlloc() You have a bug: Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:
0x7fa60370cc40 struct mapTable
Illegal instruction: 4
Can't seem to find such a method in the library. It could return an array of child windows, widgets etc.
as the title sais. Otherwise you can set up fancy onshouldquit handlers, and they will not be called because the user closed the window instead of closing the app through File->Quit
This is related to #14 but I got it on Arch Linux
I ran the controlgallery and after it the following error happened:
(main:5406): GLib-GObject-CRITICAL **: g_object_set_qdata: assertion 'G_IS_OBJECT (object)' failed
(main:5406): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(main:5406): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
(main:5406): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer
(main:5406): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
** (main:5406): CRITICAL **: [libui] unix/alloc.c:42:uninitAlloc() You have a bug: Some data was leaked; either you left a uiControl lying around or there's a bug in libui itself. Leaked data:
0x16178a0 uiRadioButtons
Trace/breakpoint trap (core dumped)
see telegramdesktop/tdesktop#1112
TODO other sanitizers?
GTK+ isn't native. Some binding of X11 is. Why didn't you use that? Your description is:
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports
Sorry for the noob GNU make question, and this deserves to be closed right away, but I can't quite figure out how to link my own code against libui, using it as a library. Some updated documentation might be nice regarding this. I'm running on OS X.
Here is the result after closing controllgallery example on OS X El Capitan 10.11.2:
Process: controlgallery [37906]
Path: /Users/USER/*/controlgallery
Identifier: controlgallery
Version: 0
Code Type: X86-64 (Native)
Parent Process: bash [11297]
Responsible: Terminal [655]
User ID: 501
Date/Time: 2016-01-14 00:57:05.467 +0900
OS Version: Mac OS X 10.11.2 (15C50)
Report Version: 11
Anonymous UUID: A52CAB68-2320-9AF9-7DBD-6B10FD3B1494
Sleep/Wake UUID: EC6A834B-5FEE-4EDE-9513-84986A571F6A
Time Awake Since Boot: 1000000 seconds
Time Since Wake: 3100 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff95cc6002 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff938065c5 pthread_kill + 90
2 libsystem_c.dylib 0x00007fff9a8f76e7 abort + 129
3 libui.A.dylib 0x000000010ac4d563 complain + 435
4 libui.A.dylib 0x000000010ac3d5c8 uninitAlloc + 280 (alloc.m:44)
5 libui.A.dylib 0x000000010ac46ea1 uiUninit + 113 (main.m:104)
6 controlgallery 0x000000010ac337bc main + 2860 (main.c:217)
7 libdyld.dylib 0x00007fff918355ad start + 1
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff95cc6ff6 kevent_qos + 10
1 libdispatch.dylib 0x00007fff93884099 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff93883d01 _dispatch_mgr_thread + 52
Thread 2:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff95cc0386 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff95cbf7c7 mach_msg + 55
2 com.apple.CoreFoundation 0x00007fff96662624 __CFRunLoopServiceMachPort + 212
3 com.apple.CoreFoundation 0x00007fff96661aec __CFRunLoopRun + 1356
4 com.apple.CoreFoundation 0x00007fff96661338 CFRunLoopRunSpecific + 296
5 com.apple.AppKit 0x00007fff90d0d065 _NSEventThread + 149
6 libsystem_pthread.dylib 0x00007fff93804c13 _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff93804b90 _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff93802375 thread_start + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff95cc66de __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93804729 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff93802365 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff95cc66de __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93804729 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff93802365 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff95cc66de __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93804729 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff93802365 start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff95cc66de __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff93804729 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff93802365 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000006 rcx: 0x00007fff54fcd4a8 rdx: 0x0000000000000000
rdi: 0x000000000000050f rsi: 0x0000000000000006 rbp: 0x00007fff54fcd4d0 rsp: 0x00007fff54fcd4a8
r8: 0x0000000000000040 r9: 0x00007fff7bb331e0 r10: 0x0000000008000000 r11: 0x0000000000000206
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x00007fff7a6df000 r15: 0x0000000000000000
rip: 0x00007fff95cc6002 rfl: 0x0000000000000206 cr2: 0x00007fff7bb31008
Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133
Binary Images:
0x10ac32000 - 0x10ac33fff +controlgallery (0) <79582598-211E-3B39-989C-5029DF41AE7A> /Users/USER/*/controlgallery
0x10ac3b000 - 0x10ac58ff7 +libui.A.dylib (0) <8A46B2A4-9F51-3D8D-9BA7-776CD0355C66> /Users/USER/*/libui.A.dylib
0x10afd9000 - 0x10afedfe3 libCGInterfaces.dylib (317.9) <5079DE4F-3717-32FF-B76A-77F53236D17D> /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/Versions/A/Libraries/libCGInterfaces.dylib
0x110115000 - 0x11017afff com.apple.driver.AppleIntelHD5000GraphicsMTLDriver (10.12.13 - 10.1.2) <DBA88B2F-5AA2-3702-A269-5AB51497B22E> /System/Library/Extensions/AppleIntelHD5000GraphicsMTLDriver.bundle/Contents/MacOS/AppleIntelHD5000GraphicsMTLDriver
0x1120f2000 - 0x1120f2fe7 +cl_kernels (???) <F689C4A1-5565-4947-B5E2-81C2E58CDDB7> cl_kernels
0x7fff62804000 - 0x7fff6283afa7 dyld (360.18) <1A7F8274-FC32-3B86-9979-66B8F2B7B5E2> /usr/lib/dyld
0x7fff87b7e000 - 0x7fff87b80ff7 com.apple.xpc.ServiceManagement (1.0 - 1) <3777FD15-B6F3-32A2-A8E3-3E8CE3B8D5E7> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
0x7fff87b81000 - 0x7fff87befff7 com.apple.ApplicationServices.ATS (377 - 394.3) <66E581EE-67E2-39E9-97A7-0614F334B9B3> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x7fff87e75000 - 0x7fff87f0afff com.apple.ink.framework (10.9 - 214) <6B573126-A6E9-357F-B36A-AA5BDC0BEAF8> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x7fff87f0f000 - 0x7fff87f83fff com.apple.Heimdal (4.0 - 2.0) <009F223D-B89B-376B-94F5-6D982CBEF771> /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
0x7fff88043000 - 0x7fff8804eff7 libcommonCrypto.dylib (60075.20.1) <766BC3F5-41F3-3315-BABC-72718A98EA92> /usr/lib/system/libcommonCrypto.dylib
0x7fff8807d000 - 0x7fff880b5fff com.apple.RemoteViewServices (2.0 - 99) <596153FD-3CB9-3FED-9D63-1B73B01AC6DB> /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
0x7fff880b8000 - 0x7fff880e9fff com.apple.GSS (4.0 - 2.0) <25DECD44-0905-3E53-9480-DE7BEB84DB83> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
0x7fff8811c000 - 0x7fff88126fff com.apple.NetAuth (6.0 - 6.0) <19E44307-6F9F-3DEC-8C1A-4685BC252A35> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
0x7fff8819a000 - 0x7fff8819afff libOpenScriptingUtil.dylib (169) <5CE2080C-398C-34C2-8D65-B9C627AACA19> /usr/lib/libOpenScriptingUtil.dylib
0x7fff8819b000 - 0x7fff8819cfff libDiagnosticMessagesClient.dylib (100) <4243B6B4-21E9-355B-9C5A-95A216233B96> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff8819d000 - 0x7fff8836bffb com.apple.QuartzCore (1.11 - 410.14) <DB552FA2-D2D1-37F9-A1D4-C77D7EA82ECD> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x7fff8836c000 - 0x7fff8836dffb libremovefile.dylib (41) <B8D1A5FC-CFD5-3AAB-8A10-14DDC129710A> /usr/lib/system/libremovefile.dylib
0x7fff8836e000 - 0x7fff88371ff7 libCoreFSCache.dylib (119.5) <C7008E64-0AFB-3446-929E-BC3F76DEF049> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib
0x7fff88385000 - 0x7fff884ecfff libBLAS.dylib (1159) <8C24B8BC-E7D9-386D-97C8-929728AFE10B> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x7fff884ed000 - 0x7fff88516fff libsystem_info.dylib (477.20.1) <6513635B-4ADE-3B45-BF63-ED7AC565B0C9> /usr/lib/system/libsystem_info.dylib
...
I propose to create a function either globally:
uiOnDestroy(void (*ondestroy)(uiControl*, void*))
or per widget:
uiControlOnDestroy(uiControl*, void (*ondestroy)(uiControl*, void*))
The passed handler should be called when any widget / the widget it was registered for is destroyed.
Rationale: I am currently writing a binding for this to lua, which is a language with a garbage collector. When I destroy a toplevel control (like a window), all of the contained controls are destroyed, too. But lua has no way of knowing about this, so when there is still a reference to a control that was used in the window, the next time when the garbage collector comes around, controls may be free()d a second time, which leads to a crash.
It looks like, even on some of the simplest examples, libui inherently leaks around 1.5MiB of memory. See the following:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ui.h>
static uiWindow * w;
static signed
shouldQuit (void * data) {
(void )data;
uiControlDestroy(uiControl(w));
return 1;
}
static signed
onClosing (uiWindow * win, void * data) {
(void )win;
shouldQuit(data);
uiQuit();
return 0;
}
signed
main (void) {
uiInitOptions o;
memset(&o, 0, sizeof(uiInitOptions));
const char * err = uiInit(&o);
if ( err ) {
fprintf(stderr, "libui test: error initializing UI: %s\n", err);
uiFreeInitError(err);
return EXIT_FAILURE;
}
w = uiNewWindow("Hello, World!", 800, 600, 1);
uiWindowOnClosing(w, onClosing, NULL);
uiLabel * l = uiNewLabel("Hello, World!");
uiWindowSetChild(w, uiControl(l));
uiControlShow(uiControl(w));
uiMain();
uiUninit();
return EXIT_FAILURE;
}
Given the above code snippet, which only spawns a window with a text label, I get the following output from valgrind
:
$ valgrind ./a.out
==17778== Memcheck, a memory error detector
==17778== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17778== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==17778== Command: ./a.out
==17778==
==17778== HEAP SUMMARY:
==17778== in use at exit: 1,574,098 bytes in 17,720 blocks
==17778== total heap usage: 165,359 allocs, 147,639 frees, 10,457,187 bytes allocated
==17778==
==17778== LEAK SUMMARY:
==17778== definitely lost: 1,280 bytes in 2 blocks
==17778== indirectly lost: 6,629 bytes in 272 blocks
==17778== possibly lost: 3,428 bytes in 45 blocks
==17778== still reachable: 1,493,033 bytes in 16,843 blocks
==17778== of which reachable via heuristic:
==17778== length64 : 3,320 bytes in 59 blocks
==17778== newarray : 2,032 bytes in 47 blocks
==17778== suppressed: 0 bytes in 0 blocks
==17778== Rerun with --leak-check=full to see details of leaked memory
==17778==
==17778== For counts of detected and suppressed errors, rerun with: -v
==17778== ERROR SUMMARY: 43 errors from 24 contexts (suppressed: 0 from 0)
On OSX Mavericks, I got some warnings and errors while compiling libui:
$ cc -v
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix
$ make
...
darwin/multilineentry.m:224:17: error: passing 'id' to parameter of incompatible
type 'NSEdgeInsets'
edgeInsetsStr([self.sv contentInsets]));
...
darwin/multilineentry.m:226:17: error: passing 'id' to parameter of incompatible
type 'NSEdgeInsets'
edgeInsetsStr([self.sv scrollerInsets]));
If I delete these lines, it compiles fine..
Build initiated with make
.
Full output:
====== Compiled common/areaevents.c
====== Compiled common/control.c
====== Compiled common/debug.c
====== Compiled common/matrix.c
====== Compiled common/shouldquit.c
====== Compiled darwin/alloc.m
====== Compiled darwin/area.m
====== Compiled darwin/areaevents.m
====== Compiled darwin/autolayout.m
====== Compiled darwin/box.m
====== Compiled darwin/button.m
====== Compiled darwin/checkbox.m
darwin/colorbutton.m:103:26: warning: class method
'+colorWithRed:green:blue:alpha:' not found (return type defaults to 'id')
[-Wobjc-method-access]
[self setColor:[NSColor colorWithRed:r green:g blue:b alpha:a]];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
====== Compiled darwin/colorbutton.m
====== Compiled darwin/combobox.m
====== Compiled darwin/control.m
====== Compiled darwin/datetimepicker.m
====== Compiled darwin/debug.m
====== Compiled darwin/draw.m
====== Compiled darwin/drawtext.m
====== Compiled darwin/entry.m
====== Compiled darwin/fontbutton.m
====== Compiled darwin/group.m
====== Compiled darwin/label.m
====== Compiled darwin/main.m
====== Compiled darwin/map.m
====== Compiled darwin/menu.m
darwin/multilineentry.m:222:12: warning: instance method
'-automaticallyAdjustsContentInsets' not found (return type defaults to
'id') [-Wobjc-method-access]
[self.sv automaticallyAdjustsContentInsets]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:77:12: note:
receiver is instance of class declared here
@interface NSScrollView : NSView <NSTextFinderBarContainer>
^
darwin/multilineentry.m:224:26: warning: instance method '-contentInsets' not
found (return type defaults to 'id') [-Wobjc-method-access]
edgeInsetsStr([self.sv contentInsets]));
^~~~~~~~~~~~~
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:77:12: note:
receiver is instance of class declared here
@interface NSScrollView : NSView <NSTextFinderBarContainer>
^
darwin/multilineentry.m:224:17: error: passing 'id' to parameter of incompatible
type 'NSEdgeInsets'
edgeInsetsStr([self.sv contentInsets]));
^~~~~~~~~~~~~~~~~~~~~~~
darwin/multilineentry.m:191:45: note: passing argument to parameter 'i' here
static NSString *edgeInsetsStr(NSEdgeInsets i)
^
darwin/multilineentry.m:226:26: warning: instance method '-scrollerInsets' not
found (return type defaults to 'id') [-Wobjc-method-access]
edgeInsetsStr([self.sv scrollerInsets]));
^~~~~~~~~~~~~~
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:77:12: note:
receiver is instance of class declared here
@interface NSScrollView : NSView <NSTextFinderBarContainer>
^
darwin/multilineentry.m:226:17: error: passing 'id' to parameter of incompatible
type 'NSEdgeInsets'
edgeInsetsStr([self.sv scrollerInsets]));
^~~~~~~~~~~~~~~~~~~~~~~~
darwin/multilineentry.m:191:45: note: passing argument to parameter 'i' here
static NSString *edgeInsetsStr(NSEdgeInsets i)
^
darwin/multilineentry.m:243:42: error: 'allowsMagnification' is unavailable
add(" allowsMagnification %d", [self.sv allowsMagnification]);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:184:16: note:
property 'allowsMagnification' is declared unavailable here
@property BOOL allowsMagnification NS_AVAILABLE_MAC(10_8);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:184:16: note:
declaration has been explicitly marked unavailable here
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:184:16: note:
property 'allowsMagnification' is declared unavailable here
darwin/multilineentry.m:244:36: error: 'magnification' is unavailable
add(" magnification %g", [self.sv magnification]);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:187:19: note:
property 'magnification' is declared unavailable here
@property CGFloat magnification NS_AVAILABLE_MAC(10_8);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:187:19: note:
declaration has been explicitly marked unavailable here
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:187:19: note:
property 'magnification' is declared unavailable here
darwin/multilineentry.m:245:39: error: 'maxMagnification' is unavailable
add(" maxMagnification %g", [self.sv maxMagnification]);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:191:19: note:
property 'maxMagnification' is declared unavailable here
@property CGFloat maxMagnification NS_AVAILABLE_MAC(10_8);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:191:19: note:
declaration has been explicitly marked unavailable here
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:191:19: note:
property 'maxMagnification' is declared unavailable here
darwin/multilineentry.m:246:39: error: 'minMagnification' is unavailable
add(" minMagnification %g", [self.sv minMagnification]);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:195:19: note:
property 'minMagnification' is declared unavailable here
@property CGFloat minMagnification NS_AVAILABLE_MAC(10_8);
^
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:195:19: note:
declaration has been explicitly marked unavailable here
/System/Library/Frameworks/AppKit.framework/Headers/NSScrollView.h:195:19: note:
property 'minMagnification' is declared unavailable here
3 warnings and 6 errors generated.
make[1]: *** [.obj/darwin_multilineentry.m.o] Error 1
make: *** [libui] Error 2
Compiler version:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
I'm on ubuntu with dual monitors and I would expect that my program would be created on my primary monitor initially whereas it seems to pick one or the other.
C:\libui>mingw32-make -f GNUmakefile example EXAMPLE=controlgallery
mingw32-make[1]: 'out/libui.dll' is up to date.
main.c
examples/controlgallery/main.c(25): error C2198: 'uiOpenFile': too few arguments for call
examples/controlgallery/main.c(27): warning C4133: 'function': incompatible types - from 'char [17]' to 'uiWindow '
examples/controlgallery/main.c(27): error C2198: 'uiMsgBoxError': too few arguments for call
examples/controlgallery/main.c(30): warning C4133: 'function': incompatible types - from 'char [14]' to 'uiWindow *'
examples/controlgallery/main.c(30): error C2198: 'uiMsgBox': too few arguments for call
examples/controlgallery/main.c(38): error C2198: 'uiSaveFile': too few arguments for call
examples/controlgallery/main.c(40): warning C4133: 'function': incompatible types - from 'char [17]' to 'uiWindow *'
examples/controlgallery/main.c(40): error C2198: 'uiMsgBoxError': too few arguments for call
examples/controlgallery/main.c(43): warning C4133: 'function': incompatible types - from 'char [46]' to 'uiWindow *'
examples/controlgallery/main.c(43): error C2198: 'uiMsgBox': too few arguments for call
examples/controlgallery/main.c(55): warning C4244: 'function': conversion from 'intmax_t' to 'int', possible loss of data
build/GNUbasemsvc.mk:64: recipe for target '.obj/examples_controlgallery_main.c.o' failed
mingw32-make[1]: ** [.obj/examples_controlgallery_main.c.o] Error 2
GNUmakefile:58: recipe for target 'example' failed
mingw32-make: *** [example] Error 2
I've been working on C# bindings for this. However, if I try to set a window's child, (even if you don't read C# well, you can see where I am calling the library from my code) I get:
Exception thrown: read access violation.
c was 0x7569436F.
If there is a handler for this exception, the program may be safely continued.
Continuing causes memory corruption and the flow will stop into ntdll.
Debugger backtrace:
> libui.dll!uiControlSetParent(uiControl * c, uiControl * parent) Line 22 C
libui.dll!uiWindowSetChild(uiWindow * w, uiControl * child) Line 279 C++
[External Code]
LibUI.Binding.dll!LibUI.Window.Child.set(LibUI.Control value) Line 81 C#
LibUI.Demo.exe!LibUI.Demo.Program.Main(string[] args) Line 29 C#
Am I using the library wrong? I've compiled the library with VS 2015, and I'm running on Windows 10 64-bit. I've tried with the library compiled with gcc 5.3.1 on Ubuntu 64-bit, and running my little demo on Mono, but I also seem to fail at this as well,. (The error output is different, due to the different UI library backend.) The built-in demos work fine. My struct sizes match.
Impossible for me to build (MVSC 2010):
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9024 : unrecognized source file type 'C:\Users\username\AppData\Local\Programs\Git\Fo;.obj\common_areaevents.c.o', object file assum
ed
cl : Command line warning D9024 : unrecognized source file type 'C:/', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'D:/', object file assumed
cl : Command line warning D9024 : unrecognized source file type '_UI_EXTERN=__declspec(dllexport) extern', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/W4', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/wd4100', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/TC', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/bigobj', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/nologo', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTC1', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCc', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCs', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCu', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/Zi', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/Fd.obj/common_areaevents.c.o.pdb', object file as
sumed
areaevents.c
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:common_areaevents.c.exe
C:\Users\username\AppData\Local\Programs\Git\Fo;.obj\common_areaevents.c.o
C:/
areaevents.obj
D:/
"_UI_EXTERN=__declspec(dllexport) extern"
C:/Users/username/AppData/Local/Programs/Git/W4
C:/Users/username/AppData/Local/Programs/Git/wd4100
C:/Users/username/AppData/Local/Programs/Git/TC
C:/Users/username/AppData/Local/Programs/Git/bigobj
C:/Users/username/AppData/Local/Programs/Git/nologo
C:/Users/username/AppData/Local/Programs/Git/RTC1
C:/Users/username/AppData/Local/Programs/Git/RTCc
C:/Users/username/AppData/Local/Programs/Git/RTCs
C:/Users/username/AppData/Local/Programs/Git/RTCu
C:/Users/username/AppData/Local/Programs/Git/Zi
C:/Users/username/AppData/Local/Programs/Git/Fd.obj/common_areaevents.c.o.pdb
LINK : fatal error LNK1181: cannot open input file 'C:\Users\username\AppData\Local\Programs\Git\Fo;.obj\common_areaevents.c.o'
make[1]: *** [.obj/common_areaevents.c.o] Erreur 2
make: *** [libui] Erreur 2
C:\Users\username\libui-master>make > log
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9024 : unrecognized source file type 'C:\Users\username\AppData\Local\Programs\Git\Fo;.obj\common_areaevents.c.o', object file assum
ed
cl : Command line warning D9024 : unrecognized source file type 'C:/', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'D:/', object file assumed
cl : Command line warning D9024 : unrecognized source file type '_UI_EXTERN=__declspec(dllexport) extern', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/W4', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/wd4100', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/TC', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/bigobj', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/nologo', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTC1', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCc', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCs', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/RTCu', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/Zi', object file assumed
cl : Command line warning D9024 : unrecognized source file type 'C:/Users/username/AppData/Local/Programs/Git/Fd.obj/common_areaevents.c.o.pdb', object file as
sumed
make[1]: *** [.obj/common_areaevents.c.o] Erreur 2
make: *** [libui] Erreur 2
Containers that allow only one child โ uiWindow, uiGroup, and the individual pages of a uiTab โ have this weird intermediary state when you first create them: the state of having no child; the value of the child uiControl
pointer is NULL
. This creates a bunch of weird edge cases for determining what the preferred size of these containers should be and certain grandparent-parent-child relationships.
There are three things I can do to resolve this:
NULL
children explicitly where passing NULL
to a SetChild()
will simply produce an empty container.NULL
initially, but not afterward where creating a container has a NULL
child but that's the only time NULL
is allowedNULL
entirely meaning that every constructor function would need you to pass a child in, even a temporary one like an empty box (I could provide a spacer control too)What do you all think? I'm genuinely not sure which I should do; all the options require relatively the same amount of code effort on my part.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.