Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
imGui bindings - Page 5 - Gideros Forum

imGui bindings

1235712

Comments

  • keszegh said:

    @rrraptor if you share here or in pm your paypal friend account, then i'd be happy to donate some to show my gratitude. thanks for your work.

    I dont need it xd
  • rrraptor said:

    keszegh said:

    @rrraptor if you share here or in pm your paypal friend account, then i'd be happy to donate some to show my gratitude. thanks for your work.

    I dont need it xd
    As you wish, of course. A virtual beer sent then.
  • rrraptorrrraptor Member
    edited August 17
    keszegh said:

    i can't wait....

    :smiley:

    If you are on windows, put dll into "Plugins" folder:

    Example project is in archive. Keep in mind that some function might not work at all :D

    P.S. works ONLY on windows and in Gideros player. Cant be exported.

    Likes: MoKaLux, keszegh, antix

    zip
    zip
    imgui.zip
    869K
    zzx.png
    286 x 125 - 3K
    +1 -1 (+3 / -0 ) Share on Facebook
  • keszeghkeszegh Member
    edited August 17
    i still have to understand how it works.
    1. can you post an example of tabs?
    2. also i want sliders that look like progress bars (i.e. fill up from left side). how can i do that?
    EDIT: 3. also, what is the easiest way to make a button which contains a texture and text as well.
    EDIT: 4. how to make zero gap between two elements next to each other? (like two buttons to look like one)

    thanks
  • @rrraptor , i've managed to solve my question 4., sameLine(0) adds zero gap. i wanted to use this to solve question 3. but sadly even if two buttons 'look' to be as one (with zero gap), hovering on them only highlights one of them, so it's not an optimal solution to emulate 3.
  • rrraptorrrraptor Member
    edited August 17
    keszegh said:

    sliderInt seems to make a sliderInt4 for me.

    Oh, whoops :smiley:
    keszegh said:

    1. can you post an example of tabs?

    if (imgui:beginTabBar("MyTabBar")) then 
    	demoData.tabsOpen[1], demoData.tabsVisible[1] = imgui:beginTabItem("Image button", demoData.tabsOpen[1])
    	if (demoData.tabsVisible[1]) then 
    		...
    		imgui:endTabItem()
    	end
     
    	demoData.tabsOpen[2], demoData.tabsVisible[2] = imgui:beginTabItem("Sliders?", demoData.tabsOpen[2])
    	if (demoData.tabsVisible[2]) then 
    		...
    		imgui:endTabItem()
    	end
    	imgui:endTabBar()
    end
    Hmmm, I guess I need to swap return values? So it will look like:
    if (imgui:beginTabBar("MyTabBar")) then 
    	if (imgui:beginTabItem("Image button", demoData.tabsOpen[1])) then 
    		...
    		imgui:endTabItem()
    	end
    	imgui:endTabBar()
    end
    keszegh said:

    2. also i want sliders that look like progress bars (i.e. fill up from left side). how can i do that?

    The only way I can think of is to draw custom rect on top of "DragInt"/"DragFloat" widget:
    demoData.customSliderValue = imgui:dragInt("", demoData.customSliderValue, 0.5, -100, 100)
    local minx, miny = imgui:getItemRectMin()
    local maxx, maxy = imgui:getItemRectMax()
    local xx = map(demoData.customSliderValue, -100, 100, minx, maxx)
    imgui:drawListAddRectFilled(minx, miny, xx, maxy, 0xff0000, 0.4)
    But it overlaps the text.
    keszegh said:

    EDIT: 3. also, what is the easiest way to make a button which contains a texture and text as well.

    Ive added this:

    Code:
    imgui:imageButtonWithText(tex, "Hello", 50, 50)
    Arguments:
    ImGui:imageButtonWithText(texture, text, imageWidth, imageHeight, [framePadding = -1, bgColor = 0xffffff, 0, tintColor = 0xffffff, 1, uv1, uv0])
    keszegh said:

    EDIT: 4. how to make zero gap between two elements next to each other? (like two buttons to look like one)

    Play aound with "ImGui:indent()" and "ImGui:unindent()"
    Indeed, sameLine(0) works :)

    Likes: keszegh, MoKaLux

    slider.png
    574 x 253 - 13K
    imgb.png
    135 x 91 - 2K
    zip
    zip
    imgui_2.zip
    860K
    +1 -1 (+2 / -0 ) Share on Facebook
  • rrraptorrrraptor Member
    edited August 17
    Actually, there is a bug in "ImGui:sameLine([offsetX = 0, spacing = -1])", I messed up arguments numbers, so that "offsetX" is completely ignored. Now, instead of "sameLine(0)" it should be "sameLine(0,0)" :D

    Added fixed dll to GitHub page:
    https://github.com/MultiPain/Gideros_ImGui

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • progressbar slider - " But it overlaps the text. " - that's an issue.
  • btw will this be cross-platform?

    another note that in general it's a bit risky to move to a gui system that i cannot tweak. of course i could add/change the source code but then i'd need to compile the plugin myself. if there is a tutorial for that which i can repeat, i'd be happy if you'd share that (i tried once or twice to compile gideros from source on windows but never succeeded).
  • about sliderInt, it seems that it's now:
    imgui:sliderInt(label,value,min, max, value)
    (note that i have value twice so that it works - perhaps one is the value where the slider is set and other is the value written on the slider?)
    instead of
    ImGui:sliderInt(label, value, [incStep = 1, min = 0, max = 0, formatString = "%d"])
  • keszeghkeszegh Member
    edited August 17
    - ImGui:isItemClicked() seems to crash.

    -imgui:imageButtonWithText does not seem to return a true value.
  • rrraptorrrraptor Member
    edited August 18
    @keszegh so you want icons on buttons/tabs/other widgets, right? It can be done using fonts. BUT! Fonts API is not finished and it does not have antialiasing yet. Idk how to fix it, so I guess we need to wait for @hgy29 ... ?
    keszegh said:

    btw will this be cross-platform?

    It should be.
    keszegh said:

    another note that in general it's a bit risky to move to a gui system that i cannot tweak. of course i could add/change the source code but then i'd need to compile the plugin myself. if there is a tutorial for that which i can repeat, i'd be happy if you'd share that (i tried once or twice to compile gideros from source on windows but never succeeded).

    Idk how to make it exportable, so maybe @hgy29 can help you.
    keszegh said:

    about sliderInt, it seems that it's now:
    imgui:sliderInt(label,value,min, max, value)
    (note that i have value twice so that it works - perhaps one is the value where the slider is set and other is the value written on the slider?)
    instead of
    ImGui:sliderInt(label, value, [incStep = 1, min = 0, max = 0, formatString = "%d"])

    Weird, I can add typecheck.
  • keszegh said:

    - ImGui:isItemClicked() seems to crash.

    You need to pass KeyCode.MOUSE_LEFT (or whatever you need) as first arg.
    keszegh said:

    -imgui:imageButtonWithText does not seem to return a true value.

    Ok, Ill check.
  • keszeghkeszegh Member
    edited August 18
    imgui:imageButtonWithText does not seem to work... actually the issue seems to be when two buttons (even simple text buttons) with the same parameters (i.e., text) are created, then they are not distinguished and this messes up imgui. is there a way to make two buttons with the same text and so that they still work as expected? kind of adding a distinguishing label which is not visible on the button?

    this is which does not work:
    if imgui:button("butt") then print("a") end		
    if imgui:button("butt") then print("b") end
    in this case pressing second butt(on) does nothing (whereas i'd want it to print 'b').
  • rrraptorrrraptor Member
    edited August 18
    @keszegh
    Thats how ImGui works (I guess it takes button text as ID).
    if imgui:button("butt") then print("a") end
    imgui:pushSID("MyButton2", nil)
    if imgui:button("butt") then print("b") end
    imgui:popID()
    You need to give unique ID to you button. Currently you can use ImGui:pushSID(string, nil) or ImGui:pushNID(number), then create widget and call ImGui:popID()

    Originaly ImGui:pushID() have 4 overloads:
    void ImGui::PushID(const char* str_id);
    void ImGui::PushID(const char* str_id_begin, const char* str_id_end);
    void ImGui::PushID(const void* ptr_id);
    void ImGui::PushID(int int_id);
    IDK whats the difference between first and second implementation, so I just added a check for 2d arg :
    int ImGui_impl_PushID_string(lua_State *L)
    {
        if (lua_type(L, 3) == LUA_TNIL)
        {
            ImGui::PushID(luaL_checkstring(L, 2));
        }
        else
        {
            ImGui::PushID(luaL_checkstring(L, 2), luaL_checkstring(L, 3));
        }
        return 0;
    }
    But seems like it should be something like:
    int ImGui_impl_PushID_string(lua_State *L)
    {
        if (lua_gettop(L) == 2) // only 2 arguments passed
        {
            ImGui::PushID(luaL_checkstring(L, 2));
        }
        else
        {
            ImGui::PushID(luaL_checkstring(L, 2), luaL_checkstring(L, 3));
        }
        return 0;
    }

    Likes: keszegh

    +1 -1 (+1 / -0 ) Share on Facebook
  • rrraptorrrraptor Member
    edited August 18
    Ok, so I made it so it can accept any value as ID.
    ImGui:getID() should be also reworked.
  • imgui:imageButtonWithText(...)

    Works as expected, maybe it does not work for you because of ImGui ID system?)
  • keszeghkeszegh Member
    edited August 18
    @rrraptor , yes, sorry if i was not clear, the issue was with the id's, now that i use push/popid, it works fine.

    although i did not go through all my gui elements, i think most could be replaced by imgui (and be better for it), except for the slider-progressbar (and a horizontally mirrored counterpart), if you find a better solution for it, let me know.
    bit more generally, it would be great to add some rangeslider solution:
    https://github.com/ocornut/imgui/issues/76
  • rrraptorrrraptor Member
    edited August 18
    keszegh said:

    @rrraptor , yes, sorry if i was not clear, the issue was with the id's, now that i use push/popid, it works fine.

    Ive changed functions names. It is now
    ImGui:pushID(anyValue)
    or
    ImGui:pushID(string, string)
    New version: https://github.com/MultiPain/Gideros_ImGui/blob/master/imgui.dll
    keszegh said:

    except for the slider-progressbar (and a horizontally mirrored counterpart), if you find a better solution for it, let me know.

    Well, I could ask on ImGui github page about that :)
    keszegh said:

    bit more generally, it would be great to add some rangeslider solution:
    https://github.com/ocornut/imgui/issues/76

    Will see :)
    keszegh said:

    horizontally mirrored counterpart

    What does it mean?)) I dont understand.

    Likes: MoKaLux

    +1 -1 (+1 / -0 ) Share on Facebook
  • "horizontally mirrored counterpart" - i mean a progressbar looking slider which fills up from the right instead of from the left.
  • @keszegh
    Ok, I figured out how to make this type of sliders :)

    I have changed a single line in slider behavior function and it works. Hmm, I wonder how can I make is so I dont need to add new set of sliders cuz there is A LOT of them :D
    sliderz!.gif
    610 x 282 - 110K
  • @rrraptor , looks perfect. i think it does not matter if there are more types, at least from a user perspective.

    btw in the future i wanted to improve my 'timeline' slider in my animation app by add bars to places where there is a nonempty 'key'frame. i wonder if i will be able to do that (rects should work but they will again be above the number and the slider which is not so good).
  • rrraptorrrraptor Member
    edited August 18
    keszegh said:

    @rrraptor , looks perfect. i think it does not matter if there are more types, at least from a user perspective.

    But why not :D
    keszegh said:

    btw in the future i wanted to improve my 'timeline' slider in my animation app by add bars to places where there is a nonempty 'key'frame.

    Again, I understand :P

    P.S. Ive updated dll on github. It is now have new sliders:
    ImGui:filledSliderFloat(label, mirrorFlag, ...)
    ImGui:filledSliderFloat2(label, mirrorFlag, ...)
    ImGui:filledSliderFloat3(label, mirrorFlag, ...)
    ImGui:filledSliderFloat4(label, mirrorFlag, ...)
    ImGui:filledSliderAngle(label, mirrorFlag, ...)
    ImGui:filledSliderInt(label, mirrorFlag, ...)
    ImGui:filledSliderInt2(label, mirrorFlag, ...)
    ImGui:filledSliderInt3(label, mirrorFlag, ...)
    ImGui:filledSliderInt4(label, mirrorFlag, ...)
    ImGui:filledSliderScalar(label, mirrorFlag, ...)
    ImGui:vFilledSliderFloat(label, mirrorFlag, ...)
    ImGui:vFilledSliderInt(label, mirrorFlag, ...)
    ImGui:vFilledSliderScalar(label, mirrorFlag, ...)

    Likes: keszegh, MoKaLux

    zxczxc.png
    345 x 99 - 2K
    +1 -1 (+2 / -0 ) Share on Facebook
  • @rrraptor , for the mirrored filled slider i need that the values are also reversed (that is, it goes from 100 to 0). i can set the range to 100,0 but strangely then i cannot pull it to to 0, the filledslider stops at 1.
Sign In or Register to comment.