Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
ImGui new thread - Page 22 — Gideros Forum

ImGui new thread

1161718192022»

Comments

  • piepie Member
    @MoKaLux thank you, this might be related, but I am not using Texture directly.
    I guess that ImGui does something similar when it builds the FontAtlas, unfortunately I didn't see an exposed setting to extend its texture to a power of two (or to not do it)
  • keszeghkeszegh Member
    better here:

    @rrraptor why was the padding option removed from imageButton?

    "Changed ImGui:imageButton(texture, w, h [, padding = -1, tint_color = 0xffffff, tint_alpha = 1, border_color = 0xffffff, border_alpha = 0]) to ImGui:imageButton(str_id, texture, w, h [, tint_color = 0xffffff, tint_alpha = 1, border_color = 0xffffff, border_alpha = 0])"

    for all my imagebuttons padding was set to 0 but now it is impossible or much more complicated to set it with pushstyle before each of them (if that works, i did not check).
  • keszeghkeszegh Member
    edited May 2023
    setting bg color does not work for me in imageButtonScaled, can you check it?
    never mind, my args where on the wrong place.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited May 2023
    keszegh said:

    better here:

    @rrraptor why was the padding option removed from imageButton?

    "Changed ImGui:imageButton(texture, w, h [, padding = -1, tint_color = 0xffffff, tint_alpha = 1, border_color = 0xffffff, border_alpha = 0]) to ImGui:imageButton(str_id, texture, w, h [, tint_color = 0xffffff, tint_alpha = 1, border_color = 0xffffff, border_alpha = 0])"

    for all my imagebuttons padding was set to 0 but now it is impossible or much more complicated to set it with pushstyle before each of them (if that works, i did not check).

    I have no idea, devs changed it in 1.89
    https://github.com/ocornut/imgui/releases/tag/v1.89
    Maybe I can bring it back...?
  • keszegh said:

    it would be great to have freetype rendering option in gideros imgui, see
    https://github.com/ocornut/imgui/tree/master/misc/freetype

    It cant be an option. Its either freetype or truetype.
  • keszeghkeszegh Member
    rrraptor said:


    I have no idea, devs changed it in 1.89
    https://github.com/ocornut/imgui/releases/tag/v1.89
    Maybe I can bring it back...?

    i've replaced all occurrence with my padded variant of scaledimagebutton, yet it takes like 10 more arguments so much less clean (i could remove them from my variant though, as i anyway don't use them). all in all for me it does not matter much anymore.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    rrraptor said:

    keszegh said:

    it would be great to have freetype rendering option in gideros imgui, see
    https://github.com/ocornut/imgui/tree/master/misc/freetype

    It cant be an option. Its either freetype or truetype.
    you mean it has to be set when gideros is built?
  • rrraptorrrraptor Member
    edited May 2023
    keszegh said:

    rrraptor said:

    keszegh said:

    it would be great to have freetype rendering option in gideros imgui, see
    https://github.com/ocornut/imgui/tree/master/misc/freetype

    It cant be an option. Its either freetype or truetype.
    you mean it has to be set when gideros is built?
    Yes. Maybe we can have 2 versions of imgui and in plugin options (inside gideros) choose what you need. But I dont know how to implement this feature... @hgy29 can tell us :)
    keszegh said:

    rrraptor said:


    I have no idea, devs changed it in 1.89
    https://github.com/ocornut/imgui/releases/tag/v1.89
    Maybe I can bring it back...?

    i've replaced all occurrence with my padded variant of scaledimagebutton, yet it takes like 10 more arguments so much less clean (i could remove them from my variant though, as i anyway don't use them). all in all for me it does not matter much anymore.

    I am also thinking of changing custom "scaledImageButton" functions the same way. What do you think?)
  • keszeghkeszegh Member
    what do you mean by same? can you share old syntax vs proposed syntax?
  • rrraptorrrraptor Member
    edited May 2023
    keszegh said:

    what do you mean by same? can you share old syntax vs proposed syntax?

    Add str_id as first argument.
    Before:
    ImGui:scaledImage(texture, w, h ...)
    ImGui:scaledImageButton(texture, w, h ...)
    After:
    ImGui:scaledImage(str_id, texture, w, h ...)
    ImGui:scaledImageButton(str_id, texture, w, h ...)
  • keszeghkeszegh Member
    ah yes, sure, that's useful, so far i needed to push/pop id's all the time.
  • piepie Member
    @rrraptor is it possibile to wrap this workaround to scroll on touch in imgui gideros without breaking everything else? I think it is a nice feature for mobile, but I am not sure about its implications o:)

    https://github.com/ocornut/imgui/issues/3379

    Thank you
  • rrraptorrrraptor Member
    edited May 2023
    pie said:

    @rrraptor is it possibile to wrap this workaround to scroll on touch in imgui gideros without breaking everything else? I think it is a nice feature for mobile, but I am not sure about its implications o:)

    https://github.com/ocornut/imgui/issues/3379

    Thank you

    Since its just a function, I can add this.
    Edit:
    Or you want to add this into "endWindow"/"endChild" functions?

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    Thank you, I have no preferences on that matter, I would stick to the easiest approach that makes it usable when needeed :)
  • @rrraptor ,probably for consistency ImGui:scaledImageButtonWithText should also be starting with an id, no?
  • rrraptorrrraptor Member
    Accepted Answer
    keszegh said:

    @rrraptor ,probably for consistency ImGui:scaledImageButtonWithText should also be starting with an id, no?

    Label is your ID, you can add anything after "##" and it wont be displayed. So you can do this:
    for i = 1, 3 do
       ui:scaledImageButtonWithText(myTexture, `Name##{i}`, ...)
    end

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • keszeghkeszegh Member
    edited June 2023
    i see, won't it be more consistent in this case with the rest of the function syntaxes to exchange first two parameters?
    (checkboxes are like that too i think, where their label is also shown and is the first parameter)
  • piepie Member
    edited July 2023
    Hi @rrraptor I am trying ImGuiTextFilter for the first time, and I wonder how (if it's possible) to avoid fuzzy search and approach the filter as "beginning of word"+wildcard (or the word itself).
    ie. search for "ti" should get: time, timing, timetable, titan, tito... but shouldn't get: monotime, pathetic, antithetic ... do I make sense? :smile:
    thank you

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited July 2023
    pie said:

    Hi @rrraptor I am trying ImGuiTextFilter for the first time, and I wonder how (if it's possible) to avoid fuzzy search and approach the filter as "beginning of word"+wildcard (or the word itself).
    ie. search for "ti" should get: time, timing, timetable, titan, tito... but shouldn't get: monotime, pathetic, antithetic ... do I make sense? :smile:
    thank you

    I dont think it is possible by default

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    rrraptor said:

    pie said:

    @rrraptor is it possibile to wrap this workaround to scroll on touch in imgui gideros without breaking everything else? I think it is a nice feature for mobile, but I am not sure about its implications o:)

    https://github.com/ocornut/imgui/issues/3379

    Thank you

    Since its just a function, I can add this.
    Edit:
    Or you want to add this into "endWindow"/"endChild" functions?
    I finally managed to try it and I have a question:
    I am writing this inside a beginWindow, before EndWindow
    local mouse_delta_x, mouse_delta_y = IO:getMouseDelta()
    ui:scrollWhenDragging(0, -mouse_delta_y) --the first is 0 because I want only vertical scrolling
    based on the documentation I should put only 2 parameters (x, y) but as soon as my app reach that point I get this error:

    missing argument #4 to 'scrollWhenDragging' (number expected)
    which number should I give it?
    Thank you again @rrraptor :smile:
  • MoKaLuxMoKaLux Member
    edited August 2023
    pie according to GH:
    https://github.com/gideros/gideros/blob/6265acd33ab1163b13dbce06bed91bfa0b74904c/plugins/imgui/source/Common/imgui_user.h#L71
    IMGUI_API void ScrollWhenDragging(float dx, float dy, ImGuiMouseButton mouse_button);
    and
    https://github.com/gideros/gideros/blob/6265acd33ab1163b13dbce06bed91bfa0b74904c/plugins/imgui/source/Common/imgui_user.cpp#L547
    	void ScrollWhenDragging(float dx, float dy, ImGuiMouseButton mouse_button)
    I don't know if mouse_button is optional or not, plus I don't know which value it should be :(

    Sorry I cannot help further :(

    Likes: pie

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • piepie Member
    @MoKaLux thank you might have helped:I tried hardcoding some mouse button values but without success so far :smile:
  • hope sir rrraptor will be around soon o:)
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • rrraptorrrraptor Member
    edited August 2023
    @pie
    ui:beginChild('as') -- any begin state
    for i = 1, 100 do 
    	ui:text(`Item #{i}`)
    end
    -- 0: horizontal speed
    -- -1: vertical speed (+1 to reverse scrolling)
    -- 1: LMB (2 for RMB and I guess 4 for MMB, I dont have enums for these in ImGui for some reason...)
    ui:scrollWhenDragging(0, -1, 1)
    ui:endChild() -- any end state

    Likes: MoKaLux, pie

    +1 -1 (+2 / -0 )Share on Facebook
  • piepie Member
    edited September 2023
    rrraptor said:

    @pie

    ui:beginChild('as') -- any begin state
    for i = 1, 100 do 
    	ui:text(`Item #{i}`)
    end
    -- 0: horizontal speed
    -- -1: vertical speed (+1 to reverse scrolling)
    -- 1: LMB (2 for RMB and I guess 4 for MMB, I dont have enums for these in ImGui for some reason...)
    ui:scrollWhenDragging(0, -1, 1)
    ui:endChild() -- any end state
    Thank you a lot @rrraptor ! :)

    While it works perfectly on pc I have a small issue on android, like as if it won't take the current screen offset, and reset the screen scroll-position on every new touch.

    See this in action on android player: I've added a big scrollbar to see it better.

    Thank you again!

    EDIT: I guess this is the same issue: https://github.com/ocornut/imgui/issues/3379#issuecomment-879900513
    application:setBackgroundColor(0x323232)
     
    require "ImGui"
     
     
     
     
    local ui = ImGui.new(nil, false, true, false) 
    local IO = ui:getIO()
     
     
     
     
     
    function onWindowResize(rt)
    	local minX, minY, maxX, maxY = application:getLogicalBounds()
     
    	local sx = application:getLogicalScaleX()
    	local sy = application:getLogicalScaleY()
     
    	ui:setScale(1 / sx, 1 / sy)
    	-- move UI to top left corner
    	ui:setPosition(minX, minY)
    	-- resize display area
    	IO:setDisplaySize((maxX - minX) * sx, (maxY - minY) * sy)
     
    	if rt then
    		rt = {
    			x  = minX,
    			X  = maxX,
    			y  = minY,
    			Y  = maxY,
    			Sx = sx,
    			Sy = sy,
    			w  = (maxX - minX) * sx,
    			h  = (maxY - minY) * sy
    		}
    		return rt
    	end
    end
     
    ss = onWindowResize(true)
     
     
    function DrawWindow(ui)
    		ui:pushStyleVar(ImGui.StyleVar_ScrollbarSize, ss.w/10)
    		ui:setNextWindowSize(ss.w, ss.h)
    		ui:setNextWindowPos(ss.x, ss.y)
    		local container = ui:beginWindow(
    			"Window02", --title
    			nil,  -- no close button
    			ImGui.WindowFlags_NoCollapse | ImGui.WindowFlags_NoResize | ImGui.WindowFlags_NoBringToFrontOnFocus | ImGui.WindowFlags_NoMove |ImGui.WindowFlags_AlwaysVerticalScrollbar
    			)
     
     
     
    			for i = 1, 1000 do 
    				ui:text(`Item #{i}`)
    			end
    			-- 0: horizontal speed
    			-- -1: vertical speed (+1 to reverse scrolling)
    			-- 1: LMB (2 for RMB and I guess 4 for MMB, I dont have enums for these in ImGui for some reason...)
    			ui:scrollWhenDragging(0, -1, 1)
     
     
    		ui:endWindow()
    		ui:popStyleVar()
     
    end
     
    local function onDrawGui(e)
    	ui:newFrame(e.deltaTime)
     
    	DrawWindow(ui)
     
    	print("test")
    	ui:updateCursor()
    	ui:render()
    	ui:endFrame()
    end
     
     
    onWindowResize()
     
     
     
     
    function onTouch(event)               
      local IO=IO    
    	if event.type=="mouseWheel" then      
        IO:setMouseWheel(event.wheel/300)
        IO:setMousePos(event.x,event.y)            
        return    
      end
      if event.type=="mouseHover" then      
        IO:setMousePos(event.x,event.y)        
        return    
      end
      local xGui=event.touch.x
      local yGui=event.touch.y
      IO:setMousePos(xGui,yGui) 
      guiHasMouse=IO:wantCaptureMouse()   
    if event.type=="touchesBegin" then           
    	if event.touch.mouseButton==0 then event.touch.mouseButton=1 end	 --workaround
        IO:setMouseDown(event.touch.mouseButton, true)                       
      end
      if event.type=="touchesMove" then           
      end
      if event.type=="touchesEnd" then        
    	  if event.touch.mouseButton==0 then event.touch.mouseButton=1 end     --workaround
        IO:setMouseDown(event.touch.mouseButton, false)           
        IO:setMouseDown(2, false)  --for safety, sometimes right-click got `stuck' 
      end     
     
      guiHasMouse=IO:wantCaptureMouse()  
      if guiHasMouse then return end
     end
     
    stage:addEventListener(Event.TOUCHES_BEGIN, onTouch,self)
    stage:addEventListener(Event.TOUCHES_MOVE, onTouch,self)  
    stage:addEventListener(Event.TOUCHES_END, onTouch,self)
    stage:addEventListener(Event.TOUCHES_CANCEL, onTouch,self)
    stage:addEventListener(Event.MOUSE_HOVER, onTouch,self)
    stage:addEventListener(Event.MOUSE_WHEEL, onTouch,self)
     
     
    stage:addEventListener("enterFrame", onDrawGui)
    stage:addEventListener("applicationResize", onWindowResize)
     
     
    stage:addChild(ui)

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • dear all,
    using imgui i want to send a table as a payload on drag'n'drop. is that possible? as far as i see one can send a single number or a string (am i right? can we send multiple values for example?), so some lua way to convert a table to a number and back would also be fine.
  • keszegh said:

    dear all,
    using imgui i want to send a table as a payload on drag'n'drop. is that possible? as far as i see one can send a single number or a string (am i right? can we send multiple values for example?), so some lua way to convert a table to a number and back would also be fine.

    I tried to make it accept any data, but no luck. It is possible, I just dont know how to do it from C++ side...
  • @rrraptor , thanks, at the end i've rewritten my code so that the relevant tables can be referred to by an id as well and then i'm sending the id only and looking up the respective table by its id when needed.

    but overall it is strange that one can only send one number or string, even if sending tables is obviously only a lua specific possibility, so it is not that surprising that imgui does not handle it by default.

    gideros+imgui is still amazing. i just spent 2 days on doing drag'n'drop reordering of lists and at the end i gave up on putting something 'between' to other things, as apparently imgui can do that only in a messy way. but still i'm happy with how i managed to do it.
Sign In or Register to comment.