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

Enum values are hardcoded into builder #18

Open
ocornut opened this issue Jan 20, 2020 · 3 comments
Open

Enum values are hardcoded into builder #18

ocornut opened this issue Jan 20, 2020 · 3 comments

Comments

@ocornut
Copy link

ocornut commented Jan 20, 2020

Hello,

Suggestion: it feels like the code generating the .ash file could emit the value using the value defined in imgui.h rather than hardcoded power of two:

" enum ImGuiInputTextFlags \r\n"
" { \r\n"
" eImGuiInputTextFlags_None                = 0, \r\n"
" eImGuiInputTextFlags_CharsDecimal        = 1,   // Allow 0123456789.+-*/ \r\n"
" eImGuiInputTextFlags_CharsHexadecimal    = 2,   // Allow 0123456789ABCDEFabcdef \r\n"
" eImGuiInputTextFlags_CharsUppercase      = 4,   // Turn a..z into A..Z \r\n"
" eImGuiInputTextFlags_CharsNoBlank        = 8,   // Filter out spaces, tabs \r\n"
" eImGuiInputTextFlags_AutoSelectAll       = 16,   // Select entire text when first taking mouse focus \r\n"
" eImGuiInputTextFlags_EnterReturnsTrue    = 32,   // Return 'true' when Enter is pressed (as opposed to every time the value was modified). \r\n"

etc.

This will make the generator code a little less readable. But please note that dear imgui provide no binary forward compatibility and those values are expected to change (and regularly are changing).

Regards.

@ericoporto
Copy link
Owner

First, thanks for ImGui, it's amazing piece of technology, I started using it for a little while and am having genuine fun with it, also repurposed one of it's examples in an in development tool here as agsconfig. ImGui is awesome!

I will update it to use non-hardcoded values. For now the .ash is not used, and instead I am relying on a big string in agsimgui.cpp. I am manually writing everything because AGS Script doesn't support the & feature (and, for now, AGS Script also doesn't have pointers for primitive types). I too wanted to rewrite some parts of the API - BeginListBox instead of ListBoxHeader for example.

When I get the API done I will proceed to try to automate it, but this is not trivial too, because parsing C++ code requires using Clang AST as parser. I am already learning Clang AST for a different project though, so eventually can be done. When this is done I can move the project to use git submodules or CMake instead of having a static version of ImGui stored in a directory in the git repository.

@ocornut
Copy link
Author

ocornut commented Jan 20, 2020

Hello Eric,

You can and should use the cimgui metadata output (lua/json data) to get the enum and function data and then you can automate part of your output. While I believe cimgui is a little poorly written (it doesn't use Clang etc as you suggested) but the output works and so as a back-end creator that's the best thing to use today.

ListBoxHeader() will be refactored into BeginListBox() but api will change slightly so I would advise against doing that renaming yourself early because your version likely won't match how it will eventually appear in Dear ImGui's API. I realize I should have been working on this api for a while... maybe I can schedule it for the next version.

Cheers

@ericoporto
Copy link
Owner

ericoporto commented Jan 20, 2020

OK, I read the cimgui repository and it seems doable, I will try later this month and report back. 😄

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

No branches or pull requests

2 participants