nakst / luigi Goto Github PK
View Code? Open in Web Editor NEWA barebones single-header GUI library for Win32, X11 and Essence.
License: Other
A barebones single-header GUI library for Win32, X11 and Essence.
License: Other
In _UIPanelLayout
,
int width = ((child->flags & UI_ELEMENT_H_FILL) || expand) ? hSpace : UIElementMessage(child, UI_MSG_GET_WIDTH, 0, 0);
should be replaced with
int width = ((child->flags & UI_ELEMENT_H_FILL) || expand) ? hSpace : UIElementMessage(child, MSG_GET_WIDTH, (child->flags & ELEMENT_V_FILL) ? perFill : 0, 0);
since the height is known in the case where V_FILL
is set.
Similar in the horizontal
branch.
In this case, deallocating elements in _UIUpdate
not in the dialog itself should be delayed until the modal exits.
You have several function whose names start with an underscore followed by a capital letter (specifically _UI
), which is undefined behavior according to the C and C++ standards.
Compiling with
cl -Od -Z7 -nologo -TC ./luigi_example.c -link User32.lib Gdi32.lib Shell32.lib
Results in
luigi.h(3678): error C2143: syntax error: missing ')' before '*'
luigi.h(3678): error C2059: syntax error: ')'
luigi.h(3678): error C2100: illegal indirection
luigi.h(3678): error C2143: syntax error: missing ')' before ';'
The line it's complaining about is
void (*callback)(UIElement *) = va_arg(arguments, void (*)(UIElement *));
MSVC doesn't seem to understand a function pointer type without a typedef. I tried changing compiler flags - removing -TC
adding -std:c11
, -std:c17
. It didn't help.
Beyond that, the other problem is that
_UIInitialiseCommon();
runs before
ui.heap = GetProcessHeap();
But there is a font allocation in _UIInitialiseCommon
which just crashes since it tries to access ui.heap
Good day.
Thank you for your generous contribution to open source community.
For OCR training and asian fonts development we need implement editable base SVG shapes on base of luigi. Reslts we will be happy to share.
After page OCR in training mode it is need edit about thousand of restangles on every OCR page - need to know size and position after element edition with mouse and set unicode name of element. HTML just freeze on this task.
Which UI_Element you think may give us a correct start?
UIMDIClientCreate look most suitable but it will be need make it more light - close active element by keyboard and common button for example. No need close button on small shape.
Will be happy to any advice.
Alexander
Hi,
first off, congrats for the effort put into this single header lib. I am honestly amazed at some of the tricks i see in here.
Getting to the point, the library works flawlessly on my x86-64 machine, but i noticed it segfaults on ARM (32 bit) . Note : i replaced some of the x86 specific SIMD instructions with standard functions in order to compile for arm and i recompiled and tested them on x86 and i confirm they still work the same.
I have also statically compiled a binary to run some tests using qemu on my workstation, getting the same segfault.
Anyways, do you plan on supporting the ARM arch? I know theres a lot of low level stuff going on in the header, so the fact that im running this on 32 bit is causing it to segfault, and im honestly at a loss.
Sorry for bothering
On linux, command
gcc luigi_example.c -lX11 -lm -o luigi
Produces
luigi_example.c: In function ‘ThemeEditorTableMessage’:
luigi_example.c:59:64: error: ‘UITheme’ {aka ‘struct UITheme’} has no member named ‘colors’
59 | return snprintf(m->buffer, m->bufferBytes, "#%.6x", ui.theme.colors[m->index]);
| ^
luigi_example.c:63:24: error: ‘UITheme’ {aka ‘struct UITheme’} has no member named ‘colors’
63 | UIColorToHSV(ui.theme.colors[themeEditorSelectedColor],
| ^
luigi_example.c: In function ‘ThemeEditorColorPickerMessage’:
luigi_example.c:75:13: error: ‘UITheme’ {aka ‘struct UITheme’} has no member named ‘colors’
75 | &ui.theme.colors[themeEditorSelectedColor]);
| ^
Seems like it's expecting colors
array in UITheme
? I fixed it like this just to run it
typedef union UITheme {
struct {
uint32_t panel1, panel2, selected, border;
uint32_t text, textDisabled, textSelected;
uint32_t buttonNormal, buttonHovered, buttonPressed, buttonDisabled;
uint32_t textboxNormal, textboxFocused;
uint32_t codeFocused, codeBackground, codeDefault, codeComment, codeString, codeNumber, codeOperator, codePreprocessor;
};
uint32_t colors[20];
} UITheme;
Which works but is there some other intended way to access those colors as an array? Also, themeItems
appears to be out of date. Replacing it with
const char *themeItems[] = {
"panel1",
"panel2",
"selected",
"border",
"text",
"textDisabled",
"textSelected",
"buttonNormal",
"buttonHovered",
"buttonPressed",
"buttonDisabled",
"textboxNormal",
"textboxFocused",
"codeFocused",
"codeBackground",
"codeDefault",
"codeComment",
"codeString",
"codeNumber",
"codeOperator",
"codePreprocessor",
};
Appears to make the example work as intended.
gcc -O2 luigi_example.c -lX11 -lm -lfreetype -DUI_FREETYPE `pkg-config --cflags freetype2` -DUI_FONT_PATH=./luculent.ttf -DUI_FONT_SIZE=24
The command compiles fine, but the font is the same as without the freetype flags.
Its possible to change the font size of the default X11 (no freetype) font ?
Thanks and cool project.
Hi nakst
Currently when you use a UITable, the vertical scrollbar extends into the table header background area.
The screenshot showing your Config Editor demonstrates this scrollbar behaviour, as does the luigi/luigi2 example.
For your consideration, a two-line patch which:
See pull request #15
Regards,
OzChris / ChrisDownUnder
Good day.
For benefit of Essence development will be useful to rename Luigi to essence_ui.h
The reason is:
Dear Nakst, which license you have in mind for whole Essence family?
Good day.
We have in progress Asian languages input for Luigi.
For now problem is it XLib input for multi-byte characters.
Inside Luigi we are just handle wchar_t instead of char by Freetype (or Pango).
This way we are able to read Xutf8LookupString input for first part of unicode – up to 0x0600 (Arabian) at last.
Problem is we can not fire KeyPeess XEvent by any keyboard driver upper then 0x0700.
Any advice or idea how handle KeyPress in 0x0f00 - 0xffff (tibetan, sanskrit, japan) ranges in XLib?
May we kindly ask you test Xutf8LookupString and XwcLookupString on your computer for upper unicode ranges?
// in
//bool _UIProcessEvent(XEvent *event)
m.textBytes = Xutf8LookupString(window->xic, &event->xkey, text, sizeof(text) - 1, &symbol, &status);
printf("input utf8:");
for(int i=0;i<m.textBytes;i++){
printf("%x ",text[i]);
}
printf("\n");
wchar_t textw[32];
int wlen=XwcLookupString(window->xic, &event->xkey, textw, sizeof(textw) - 1, &symbol, &status);
printf("input utf16:");
for(int i=0;i<wlen;i++){
printf("%x ",textw[i]);
}
printf("\n");
I get this error when compiling with -DWIN32_LEAN_AND_MEAN
:
In file included from luigi_example.c:7:
luigi.h: In function '_UIWindowProcedure':
luigi.h:5497:17: error: unknown type name 'HDROP'
5497 | HDROP drop = (HDROP) wParam;
5497 | HDROP drop = (HDROP) wParam;
| ^~~~~
luigi.h:5497:31: note: each undeclared identifier is reported only once for each function it appears in
luigi.h:5497:38: error: expected ',' or ';' before 'wParam'
5497 | HDROP drop = (HDROP) wParam;
| ^~~~~~
luigi.h:5498:29: warning: implicit declaration of function 'DragQueryFil
' [-Wimplicit-function-declaration]
5498 | int count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
| ^~~~~~~~~~~~~
luigi.h:5511:17: warning: implicit declaration of function 'DragFinish'
-Wimplicit-function-declaration]
5511 | DragFinish(drop);
| ^~~~~~~~~~
This is an issue mainly because Nim std uses -DWIN32_LEAN_AND_MEAN
.
I believe this can be fixed by explicitly including shellapi.h
.
Hi nakst
I've made some enhancements to Gauge and Slider elements in my personal fork. Would you be interested in merging these changes?
(See my 'luigi vs luigi2' issue for further discussion on the new example file.)
I tried to keep the approach in line with your existing code. If you would implement these features in a different manner, I would be interested to know how, so that I can keep further updates I make in line with your approach.
If you are happy to merge these changes (pull request Luigi2 - gauge and slider improvements), you're welcome to create the initial luigi2_example.c file in your own repository before merging my changes, if you would like to keep an accurate version history (i.e., so it registers that you wrote the original file and I only contributed the few lines of changed code).
Regards,
OzChris / ChrisDownUnder
Good day
What was your inspiration for genious Luigi core messaging system?
https://en.m.wikipedia.org/wiki/Message_Passing_Interface
This system may work as core IPC for OCR training.
May I ask our advice where to read more?
With best regards
Open Source Buddhism Library
Alexander Stroganov
Hi nakst
With luigi2 being the actively developed version of this library, I was wondering:
The reason I ask is to do with incompatibilities (or just new APIs) between luigi2 and luigi + it's examples.
The current luigi examples do not compile with luigi2 for two main reasons that I can see:
If you are planning to keep luigi and luigi2 coexisting, could I suggest adding a 'luigi2_example.c' file to the repository to compile against luigi2? This would also allow further updates to the example to showcase luigi2 improvements without breaking the luigi example.
If you are keeping both versions of the library, see my Luigi1 - backport luigi2 fixes pull request with a few small quality of life improvements in case anyone uses the luigi1 header and examples -- for your consideration.
Note: See my other raised issue/pull request, which includes proposed luigi2 element updates along with an updated version of 'luigi2_example.c' demonstrating those features.
Regards,
OzChris / ChrisDownUnder
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.