kotlin-graphics / imgui

Bloat-free Immediate Mode Graphical User interface for JVM with minimal dependencies (rewrite of dear imgui)
MIT License
594 stars 37 forks source link

Methods need unecessary parameters when used in java #172

Closed 03lenio closed 2 years ago

03lenio commented 2 years ago

This is probably a really basic issue and maybe even my own mistake, but I don't get why I need parameters for methods that don't need any in kotlin?

example:

`imgui.beginGroup(); for(ModCategory category : > ModCategory.values()) { if(imgui.button(category.name(), new Vec2(100f, 0))) {

        }
       imgui.sameLine(10, 0);
    }
    imgui.endGroup();
    imgui.separator();`

in this snippet extra parameters like spacing and x-offset are needed when in the demo it cleary shows only sameLine should work, now if I build this snippet all buttons are in the same line but they completly overlap so you basically see only one button, the same issue with tabs, specifically with tabbaritems, they require a string for the name, a kmuteable boolean, and a flag, now I really don't know why I need all this when in the demo it works without all these parameters, I know it probably is my mistake and I fail to understand something but help would be greatly appreciated.

zeroeightysix commented 2 years ago

This is unfortunately the only way to call those functions from java. Default parameters don't exist in java, and thus you do need to provide their values.

Maybe we can add the @JvmOverloads annotation to public API functions to fix this?

03lenio commented 2 years ago

oh thanks, yeah that makes sense, I was just wondering since I previously only used the c++ version of ImGui and didn't need any parameters so I thought maybe I did something wrong well the tabs work now, however I still have one problem with columns: for some reason a black bar is drawn over the tabs exactly where the borders of the columns are located, did I maybe mess something up with the flag parameters of the columns? this is how it looks now:

https://imgur.com/a/iAhz1vh

and this is my current code:

`

if(imgui.beginTabBar("Categories", 0)) {
            for (ModCategory category : ModCategory.values()) {
                if (imgui.beginTabItem(category.name(), null, 0)) {
                    imgui.beginColumns(category.name(), 3, 0);
                    for (Mod mod : Stark.modManager.getModsByCategory(category)) {
                        if (imgui.collapsingHeader(mod.getName(), 0)) {

                        }
                        imgui.nextColumn();
                    }
                    imgui.endTabItem();

                }
            }

            imgui.endTabBar();
        }`
03lenio commented 2 years ago

nvm. I forgot the endColumns() haha, thanks @zeroeightysix for explaining the system I think I kind of got it now :D