View Single Post
Old 06-23-2021, 05:03 AM   #230
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Thanks a lot

One more question:
Why in the following example, the dock/undock works fine but is not saved for the next opening?
It always reopens with a DockID of 0.

Code:
r = reaper
script_name = 'Test ImGui'

function ImGuiBody()
  r.ImGui_Text(ctx, 'DockID = '..dock)
  if r.ImGui_Button(ctx, 'Dock') then
    change_dock = true
  end
end

function loop()
  
  if change_dock then
    r.ImGui_SetNextWindowDockID(ctx, ~dock)
    change_dock = nil
  end
  
  local visible, open = r.ImGui_Begin(ctx, script_name, true)
  dock = r.ImGui_GetWindowDockID(ctx)
  if visible then
    ImGuiBody()
    r.ImGui_End(ctx)
  end
  
  if not open or r.ImGui_IsKeyDown(ctx,27) then
    r.ImGui_DestroyContext(ctx)
  else
    r.defer(loop)
  end
end

ctx = r.ImGui_CreateContext(script_name, r.ImGui_ConfigFlags_DockingEnable())
r.defer(loop)
Rodilab is offline   Reply With Quote