# Windows utilities

# Windows Utilities

  • ImGui.IsWindowAppearing()

  • ImGui.IsWindowCollapsed()

  • ImGui.IsWindowFocused(int flags)

gui.add_dx_layer("ImGui_DX_Layer", function()
    ImGui.SetNextWindowSize(200, 100, ImGuiCond.FirstUseEver)
    ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver)

    if (ImGui.IsWindowFocused(ImGuiFocusedFlags.AnyWindow)) then
        log.info("Focused on the window!")
    end

    if (ImGui.Begin("ImGui Window")) then

        ImGui.End() 
    end
end)
  • ImGui.IsWindowHovered(int flags)
gui.add_dx_layer("ImGui_DX_Layer", function()
    ImGui.SetNextWindowSize(200, 100, ImGuiCond.FirstUseEver)
    ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver)

    if (ImGui.IsWindowHovered(ImGuiHoveredFlags.AnyWindow)) then
        log.info("Hovering over the window!")
    end

    if (ImGui.Begin("ImGui Window")) then

        ImGui.End() 
    end
end)
  • ImGui.GetWindowDrawList()

  • ImGui.GetWindowPos()

gui.add_dx_layer("ImGui_DX_Layer", function()
    ImGui.SetNextWindowSize(200, 100, ImGuiCond.FirstUseEver)
    ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver)

    if (ImGui.Begin("ImGui Window")) then
        if (ImGui.Button("Button")) then
            local _posX, _posY = ImGui.GetWindowPos()
            log.info("X: " .. _posX .. ", Y: " .. _posY)
        end

        ImGui.End() 
    end
end)
  • ImGui.GetWindowSize()
gui.add_dx_layer("ImGui_DX_Layer", function()
    ImGui.SetNextWindowSize(200, 100, ImGuiCond.FirstUseEver)
    ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver)

    if (ImGui.Begin("ImGui Window")) then
        if (ImGui.Button("Button")) then
            local _sizeX, _sizeY = ImGui.GetWindowSize()
            log.info("X: " .. _sizeX .. ", Y: " .. _sizeY)
        end

        ImGui.End() 
    end
end)
  • ImGui.GetWindowWidth()

  • ImGui.GetWindowHeight()

# Window Position & Size Settings

  • ImGui.SetNextWindowPos(float posX, float posY, int cond, float pivotX, float pivotY)
ImGui.SetNextWindowPos(30, 30)

cond: ImGuiCond

ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver)

cond: ImGuiCond

ImGui.SetNextWindowPos(30, 30, ImGuiCond.FirstUseEver, 0.5, 0.5)
  • ImGui.SetNextWindowSize(float sizeX, float sizeY, int cond)
ImGui.SetNextWindowSize(30, 30)

cond: ImGuiCond

ImGui.SetNextWindowSize(30, 30, ImGuiCond.FirstUseEver)
  • ImGui.SetNextWindowSizeConstraints(float minX, float minY, float maxX, float maxY)
ImGui.SetNextWindowSizeConstraints(10, 10, 200, 200)
  • ImGui.SetNextWindowContentSize(float sizeX, float sizeY)
ImGui.SetNextWindowContentSize(100, 50)
  • ImGui.SetNextWindowCollapsed(bool collapsed, int cond)
ImGui.SetNextWindowCollapsed(true)

cond: ImGuiCond

ImGui.SetNextWindowCollapsed(true, ImGuiCond.Always)
  • ImGui.SetNextWindowFocus()

  • ImGui.SetNextWindowBgAlpha(float alpha)
    alpha: Working range 0.0 -> 1.0

ImGui.SetNextWindowBgAlpha(0.70)
  • ImGui.SetWindowPos(float posX, float posY, int cond)
ImGui.SetWindowPos(30, 30)

cond: ImGuiCond

ImGui.SetWindowPos(30, 30, ImGuiCond.Always)
  • ImGui.SetWindowSize(float sizeX, float sizeY, int cond)
ImGui.SetWindowSize(30, 30)

cond: ImGuiCond

ImGui.SetWindowSize(30, 30, ImGuiCond.Always)
  • ImGui.SetWindowCollapsed(bool collapsed, int cond)
ImGui.SetNextWindowCollapsed(true)

cond: ImGuiCond

ImGui.SetWindowCollapsed(true, ImGuiCond.Always)
  • ImGui.SetWindowFocus()

  • ImGui.SetWindowFontScale(float scale)

ImGui.SetWindowFontScale(1.0)
  • ImGui.SetWindowPos(string name, float posX, float posY, int cond)
ImGui.SetWindowPos("window_name", 30, 30)

cond: ImGuiCond

ImGui.SetWindowPos("window_name", 30, 30, ImGuiCond.Always)
  • ImGui.SetWindowSize(string name, float sizeX, float sizeY, int cond)
ImGui.SetWindowSize("window_name", 30, 30)

cond: ImGuiCond

ImGui.SetWindowSize("window_name", 30, 30, ImGuiCond.Always)
  • ImGui.SetWindowCollapsed(string name, bool collapsed, int cond)
ImGui.SetNextWindowCollapsed("window_name", true)

cond: ImGuiCond

ImGui.SetWindowCollapsed("window_name", true, ImGuiCond.Always)
  • ImGui.SetWindowFocus(string name)
ImGui.SetWindowFocus("window_name")

# Content Region

  • ImGui.GetContentRegionMax()
local _x, _y = ImGui.GetContentRegionMax()
  • ImGui.GetContentRegionAvail()
local _x, _y = ImGui.GetContentRegionAvail()
  • ImGui.GetWindowContentRegionMin()
local _x, _y = ImGui.GetWindowContentRegionMin()
  • ImGui.GetWindowContentRegionMax()
local _x, _y = ImGui.GetWindowContentRegionMax()

# Windows Scrolling

  • ImGui.GetScrollX()

  • ImGui.GetScrollY()

  • ImGui.GetScrollMaxX()

  • ImGui.GetScrollMaxY()

  • ImGui.SetScrollX(float scrollX)

  • ImGui.SetScrollY(float scrollY)

  • ImGui.SetScrollHereX(float centerXRatio)

ImGui.SetScrollHereX()

0.0: left/up, 0.5: center, 1.0: right/down

ImGui.SetScrollHereX(0.25)```
  • ImGui.SetScrollHereY(float centerYRatio)
ImGui.SetScrollHereY()

0.0: left/up, 0.5: center, 1.0: right/down

ImGui.SetScrollHereY(0.25)
  • ImGui.SetScrollFromPosX(float localX, float centerXRatio)
ImGui.SetScrollFromPosX(0.5)
ImGui.SetScrollFromPosX(0.5, 0.25)
  • ImGui.SetScrollFromPosY(float localY, float centerYRatio)
ImGui.SetScrollFromPosY(0.5)
ImGui.SetScrollFromPosY(0.5, 0.25)