Old 05-22-2021, 05:47 AM   #201
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Rodilab View Post
In order to create a custom widget (setting several color values in one widget), I would like to draw this :
Draw two gradients: white to color (left to right) + transparent black to opaque black (top to bottom). This is what Dear ImGui's picker code does:

Code:
local white = 0xffffffff
local black = 0x000000ff
local color = 0xff0000ff
r.ImGui_DrawList_AddRectFilledMultiColor(draw_list,
  pos[1], pos[2], pos[1] + size, pos[2] + size, white, color, color, white)
r.ImGui_DrawList_AddRectFilledMultiColor(draw_list,
  pos[1], pos[2], pos[1] + size, pos[2] + size, 0, 0, black, black)


A (perhaps simpler) alternative would be to overlay the extra draggable buttons over the native color picker.

Last edited by cfillion; 05-22-2021 at 05:57 AM.
cfillion is offline   Reply With Quote
Old 05-22-2021, 07:03 AM   #202
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Nice !
Thank you (again)
Rodilab is offline   Reply With Quote
Old 05-25-2021, 11:47 AM   #203
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Hi! Is there any minimal Reaper C++ extension IMGui template available?
kartalex is offline   Reply With Quote
Old 05-25-2021, 12:48 PM   #204
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by kartalex View Post
Hi! Is there any minimal Reaper C++ extension IMGui template available?
Now there is one at https://github.com/cfillion/reaimgui...ello_world.cpp.

v0.4's reaper_imgui_functions.h is missing a declaration for ImGui_Font: fixed in https://ci.appveyor.com/api/buildjob...ui_functions.h.

Last edited by cfillion; 05-25-2021 at 12:57 PM.
cfillion is offline   Reply With Quote
Old 05-25-2021, 11:27 PM   #205
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Quote:
Originally Posted by cfillion View Post
Cool! Thanks!
kartalex is offline   Reply With Quote
Old 06-02-2021, 12:38 AM   #206
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Hi

Since 0.4.0 it is possible to save the position, size and dock of the context.
Is there a way to save only some of these parameters?
For example, save the position but not the size.

Thanks

Last edited by Rodilab; 06-02-2021 at 09:56 AM.
Rodilab is offline   Reply With Quote
Old 06-02-2021, 03:35 AM   #207
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Hi,

I found a bug in keyboard keycodes.
The keycodes of the number keys are wrong for me.

For example :
When I press "1" key, ImGui_IsKeyDown(ctx,38) return true. And ImGui_IsKeyDown(ctx,49) return false.
The key code should be 49. 38 is the up arrow. By the way, the top arrow also returns true with keycode 38.
The same with all key numbers.

Tested with macOS 10.15, ReaImGui 0.4, Reaper 6.29
Rodilab is offline   Reply With Quote
Old 06-04-2021, 03:04 PM   #208
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Released verson 0.4.1:

Code:
• Add a C++ extension example [p=2447754]
• C++ binding: add missing ImGui_Font declaration
• Demo: fix 'Scroll Offset' and 'Scroll To Pos' buttons in Layout & Scrolling->Scrolling
• Document CreateFont's supported generic font families
• macOS: improve keycode compatibility across various keyboard layouts [p=2450237]
• Update Dear ImGui to v1.83 (release notes at https://github.com/ocornut/imgui/releases/tag/v1.83)
• Workaround a possible race condition when detecting the splash screen [p=2450259]
• Windows: fix a crash when dragging files from some sources [p=2445786]

API changes:
• Add ConfigFlags_NoRestoreSize [p=2450209]
• Add TableSetColumnEnabled

Last edited by cfillion; 06-04-2021 at 04:00 PM.
cfillion is offline   Reply With Quote
Old 06-05-2021, 03:22 AM   #209
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thank you! I've got to try the new font feature!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 06-10-2021, 09:04 AM   #210
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Do I get this right, ImGui supports GPU hardware acceleration and therefore the GUI will be rendered entirely on the GPU?
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-10-2021, 10:09 AM   #211
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by _Stevie_ View Post
Do I get this right, ImGui supports GPU hardware acceleration and therefore the GUI will be rendered entirely on the GPU?
Yes. The CPU produces a list of textured triangles and sends them to the GPU for rendering into pixels on the screen.

(For the curious: See Tools -> Metrics/Debugger -> DrawLists in the demo or call ImGui_ShowMetricsWindow in your script. https://i.imgur.com/l1ei6Hy.png)

Last edited by cfillion; 06-10-2021 at 10:19 AM.
cfillion is offline   Reply With Quote
Old 06-10-2021, 11:54 PM   #212
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Amazing, so in essence this means: ImGui is reducing the CPU load and puts it on the GPU and is therefore more efficient than using native Reaper gfx functions.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 06-11-2021, 12:06 AM   #213
Daodan
Human being with feelings
 
Join Date: Jan 2011
Posts: 1,167
Default

Hi. Thank you so much cfillion. For all.
I already asked in Rodilab Color palette thread but anyway:
is it possible to hide script title bar?
Daodan is offline   Reply With Quote
Old 06-11-2021, 10:04 AM   #214
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Daodan View Post
Hi. Thank you so much cfillion. For all.
I already asked in Rodilab Color palette thread but anyway:
is it possible to hide script title bar?
Currently it should be possible using JS_ReaScript API hackery to modify the window's styles (I haven't tested).

In the future: yes*. It's part of the windowing improvements I'm working on for v0.5:



* = Unless major unexpected problems arises during development. https://www.monkeyuser.com/assets/im...root-cause.png

Last edited by cfillion; 06-11-2021 at 12:47 PM.
cfillion is offline   Reply With Quote
Old 06-11-2021, 02:04 PM   #215
Daodan
Human being with feelings
 
Join Date: Jan 2011
Posts: 1,167
Default

Quote:
Originally Posted by cfillion View Post
Currently it should be possible using JS_ReaScript API hackery to modify the window's styles (I haven't tested).

In the future: yes*. It's part of the windowing improvements I'm working on for v0.5:
Nice! Thank you.
Daodan is offline   Reply With Quote
Old 06-13-2021, 10:08 AM   #216
jbradbury
Human being with feelings
 
jbradbury's Avatar
 
Join Date: Sep 2019
Location: Berlin
Posts: 61
Default Debouncing

Is there a sensible way to debounce inside the frame() loop? Does rv return false if nothing changed for example or does it require some state management?
jbradbury is offline   Reply With Quote
Old 06-13-2021, 10:16 AM   #217
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Depends on what you're having a bouncing problem with. Can you elaborate?
cfillion is offline   Reply With Quote
Old 06-18-2021, 02:08 AM   #218
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Released version v0.5-beta! Summary of the changes:
  • Each Dear ImGui 'virtual window' (Begin/End) open in their own dedicated window
  • Tooltips, popups and menus are visible even outside of their parent canvas boundaries
  • ImGui windows can be docked into each other (in addition to into REAPER's dockers)
These improvements come at the cost of backward compatibility breakage (upgrade tips below). Because of this, v0.5 is marked as "beta" in ReaPack. It must be manually selected for installation in ReaPack's package browser. I'm currently planning on marking it as "stable" for automatic updates in a week.

Code:
• Create a dedicated platform window for each ImGui virtual window
• Demo: fix the size preset buttons in Examples->Constrained-resizing window
• Demo: move docking example to 'Window options'
• Fix removing focus using SetWindowFocusEx
• macOS: count vertical coordinates from the top of the primary monitor
• Switch to Dear ImGui v1.83's 'docking' branch
• Re-implement docking into REAPER using ImGui's docking branch's beta API
• Update the Lua, EEL2, Python and C++ examples
• Windows: detect HiDPI scaling changes when docked in REAPER (Per-Monitor v2 mode)
• Windows: fix positioning of the system's Input Method Editor (IME) on HiDPI monitors

API changes:
• Add Col_DockingPreview, Col_DockingEmptyBg
• Add ConfigFlags_DockingEnable, WindowFlags_NoDocking
• Add IsWindowDocked, GetWindowDockID, SetNextWindowDockID
• Add SetWindow* functions without a window name argument (renamed existing functions to SetWindow*Ex)
• C++ binding: allow omitting optional arguments (C++17 or newer required)
• CollapsingHeader: treat p_visible=false the same as p_visible=nil (= disable the close button)
• Make Begin/End consistent with the rest of the API (call End only if Begin returned true)
• Mark 'p_*' arguments as output values in the documentation
• Remove BeginPopupContextVoid, BeginMainMenuBar and EndMainMenuBar
• Remove ConfigFlags_NoRestoreSize, GetDisplaySize
• Remove GetNativeHwnd, IsCloseRequested, GetDock, SetDock
• Remove size/position/dock arguments of CreateContext
• Treat 'p_open=false' as input the same as 'p_open=nil' for compatibility with EEL2
New CreateContext

CreateContext no longer opens a window. The size, position and dock arguments have been removed. The 'label' parameter is used for state persistence and when docking into REAPER.

Code:
ctx = reaper.ImGui_CreateContext('My script', reaper.ImGui_ConfigFlags_DockingEnable())
Begin/End changes

Begin/End, BeginChild/EndChild and BeginChildFrame/EndChildFrame were the only three pair of functions for which End had to always be called even if the corresponding Begin returned false.

They now match the rest of Dear ImGui's functions. (This change is likely to be made in Dear ImGui in a future 1.8x release. I have emulated it in ReaImGui now to avoid breaking scripts again later.)

Code:
if reaper.ImGui_Begin(...) then
  reaper.ImGui_End(...)
end
Removal of IsCloseRequested

The second return value of ImGui_Begin becomes false when the window was requested to be closed.

Code:
function loop()
  local visible, open = reaper.ImGui_Begin(ctx, 'Window name', true)
  if visible then
    reaper.ImGui_Text(ctx, 'Lorem ipsum dolor sit amet...')
    reaper.ImGui_End(ctx)
  end

  if open then
    reaper.defer(loop)
  else
    reaper.ImGui_DestroyContext(ctx)
  end
end
New docking API (again)

GetDock and SetDock have been replaced by (part of) Dear ImGui's beta docking API: GetWindowDockID, SetNextWindowDockID and IsWindowDocked.

These new functions are used for both Dear ImGui internal docking (ID > 0) and REAPER docking (ID < 0). See Demo -> Window options.

Code:
-- dock into REAPER's first docker on first use
reaper.SetNextWindowDockID(ctx, -1, reaper.ImGui_Cond_FirstUseEver())
if reaper.ImGui_Begin(...) then
Removal of ConfigFlags_NoRestoreSize

Use SetNextWindowSize instead (or SetNextWindowSizeConstraints for defining minimum/maximum sizes).

Last edited by cfillion; 06-18-2021 at 11:18 AM.
cfillion is offline   Reply With Quote
Old 06-18-2021, 10:15 AM   #219
mtk
Human being with feelings
 
Join Date: Sep 2019
Posts: 85
Default

This is awesome!

Do you have in plans to add support for images?
mtk is offline   Reply With Quote
Old 06-19-2021, 04:36 AM   #220
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Nice !

Big changes. I hope to find time to modify my scripts before the release of the stable v0.5.
Why remove GetNativeHwnd ?
Rodilab is offline   Reply With Quote
Old 06-19-2021, 01:41 PM   #221
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 755
Default

Quote:
Originally Posted by Rodilab View Post
Why remove GetNativeHwnd ?
I was also wondering this. I've been using GetNativeHwnd and comparing it to JS_Window_GetFocus to check if my ImGui context has focus, so I can visually indicate that. Is there a different/better way of doing this?

(Edit: to be clear, this is a fairly minor issue for me... Visually indicating focus isn't really something I can't live without. But it's a neat little feature to have, especially when your script has keyboard shortcuts and you want to know where your input is going...)

Last edited by elcalen; 06-19-2021 at 01:51 PM.
elcalen is online now   Reply With Quote
Old 06-19-2021, 01:59 PM   #222
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by mtk View Post
Do you have in plans to add support for images?
Yes. I don't know yet when it will happen though (v0.6? v0.7?).

Quote:
Originally Posted by Rodilab View Post
Why remove GetNativeHwnd ?
Because each Begin() open a window, there is no longer a single window HWND per context for GetNativeHwnd to return. I haven't added a replacement because it isn't necessary anymore (I might add one if there's a good use-case).

The reasons for its existence were originally to allow manual external docking and using js_ReaScriptAPI for filling ReaImGui's lack of a window management API. External docking turned out to be buggy. And now Dear ImGui's window management API work on the real windows (rather than on pre-v0.5's "virtual windows").

Quote:
Originally Posted by elcalen View Post
I was also wondering this. I've been using GetNativeHwnd and comparing it to JS_Window_GetFocus to check if my ImGui context has focus, so I can visually indicate that. Is there a different/better way of doing this?
ImGui_IsWindowFocused returns whether the current window has focus. See Demo->Widgets->Querying Status.

Last edited by cfillion; 06-19-2021 at 02:18 PM.
cfillion is offline   Reply With Quote
Old 06-19-2021, 02:23 PM   #223
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 755
Default

Quote:
Originally Posted by cfillion View Post
ImGui_IsWindowFocused returns whether the current window has focus. See Demo->Widgets->Querying Status.
Last I checked, that didn't work. It works for windows *within* an ImGui context, but if I click in Reaper *outside* the demo context, the IsWindowFocused() line still reads 'true'... Has this changed in 0.5 (I haven't updated yet)?
elcalen is online now   Reply With Quote
Old 06-19-2021, 02:27 PM   #224
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by elcalen View Post
Has this changed in 0.5 (I haven't updated yet)?
Yes.

cfillion is offline   Reply With Quote
Old 06-19-2021, 02:34 PM   #225
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 755
Default

Ah, well, that should work then. I hope I'll manage to get around to updating my script next week...
elcalen is online now   Reply With Quote
Old 06-21-2021, 09:03 AM   #226
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by cfillion View Post
Released version v0.5-beta! Summary of the changes:


These improvements come at the cost of backward compatibility breakage (upgrade tips below). Because of this, v0.5 is marked as "beta" in ReaPack. It must be manually selected for installation in ReaPack's package browser. I'm currently planning on marking it as "stable" for automatic updates in a week.
Does this mean, that previous api-docs for it has become outdated and I should base my docs on the 0.5er api-docs instead from now on? Or does it stay the same and just some workflows change?
And shall I better wait for the actual release for a docs-update?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 06-21-2021 at 09:13 AM.
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-21-2021, 12:13 PM   #227
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Does this mean, that previous api-docs for it has become outdated and I should base my docs on the 0.5er api-docs instead from now on? Or does it stay the same and just some workflows change?
And shall I better wait for the actual release for a docs-update?
New work should use the v0.5 API. The backward-incompatible API changes are few but they affect core functions. It's beta only in name for disabling ReaPack auto-update, giving time for scripts to be updated.

Last edited by cfillion; 06-21-2021 at 12:31 PM.
cfillion is offline   Reply With Quote
Old 06-22-2021, 02:35 AM   #228
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Some questions I can't figure out on my own:
  1. Why when I dock this window it loses its background color?

    Code:
    r = reaper
    script_name = 'Test ImGui'
    
    function ImGuiBody()
      r.ImGui_Text(ctx, 'Hello World !')
      if r.ImGui_Button(ctx, 'Dock') then
        change_dock = true
      end
    end
    
    function loop()
      if change_dock then
        dock = ~dock
        r.ImGui_SetNextWindowDockID(ctx, dock)
        change_dock = nil
      end
    
      r.ImGui_PushStyleColor(ctx, r.ImGui_Col_WindowBg(), 0x333333ff)
      local visible, open = r.ImGui_Begin(ctx, script_name, true, r.ImGui_WindowFlags_NoCollapse())
      r.ImGui_PopStyleColor(ctx)
    
      dock = r.ImGui_GetWindowDockID(ctx)
      
      if visible then
        ImGuiBody()
        if not dock or change_dock then dock = r.ImGui_GetWindowDockID(ctx) end
        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)

  2. How to proceed to open correctly the window on the mouse cursor with Mac? The vertical coordinates are reversed.
    Code:
    r = reaper
    script_name = 'Test ImGui'
    
    function ImGuiBody()
      r.ImGui_Text(ctx, 'Hello World !')
    end
    
    function loop()
    
      local pos = {r.GetMousePosition()}
      r.ImGui_SetNextWindowPos(ctx, pos[1], pos[2], r.ImGui_Cond_Once(), 0.5, 0.5)
    
      local visible, open = r.ImGui_Begin(ctx, script_name, true, r.ImGui_WindowFlags_NoCollapse())
      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)
  3. Where is the .ini data of ReaImGui?

Thank you
Rodilab is offline   Reply With Quote
Old 06-22-2021, 02:56 AM   #229
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Rodilab View Post
Why when I dock this window it loses its background color?
Docking in Dear ImGui embeds the window inside of another one. Because of this docked windows use the ChildBg color (same as a BeginChild() subwindow would). Try setting both WindowBg and ChildBg.

Quote:
Originally Posted by Rodilab View Post
How to proceed to open correctly the window on the mouse cursor with Mac? The vertical coordinates are reversed.
This should work to convert the native macOS bottom-based Y to cross-platform top-based Y:

Code:
local cur_x, cur_y = r.GetMousePosition()
local primary_monitor_height = ({reaper.BR_Win32_GetMonitorRectFromRect(false, 0, 0, 0, 0)})[4]
cur_y = primary_monitor_height - cur_y
...however I'll look into adding a function to ReaImGui for this kind of coordinate conversion. I think it will be useful not only for flipping Y macOS but also for HiDPI scaling on Windows/Linux.

Quote:
Originally Posted by Rodilab View Post
Where is the .ini data of ReaImGui?
<resource path>/ReaImGui. The .ini's filename is derived from the label given to CreateContext.

Last edited by cfillion; 06-22-2021 at 03:17 AM.
cfillion is offline   Reply With Quote
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
Old 06-23-2021, 11:29 AM   #231
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Rodilab View Post
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.
Was the script restarted (eg. from the IDE) less than 5 seconds after docking? ImGui waits 5 seconds after a change was made before saving the settings to disk (or until DestroyContext is used).

(Demo -> Tools -> Metrics/Debugger (or ImGui_ShowMetricsDialog) -> Settings -> SettingsDirtyTimer)

Last edited by cfillion; 06-23-2021 at 11:58 AM.
cfillion is offline   Reply With Quote
Old 06-25-2021, 12:45 AM   #232
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Indeed, that was my problem. Thanks

Another thing about the DockID :
All positive DockIDs seem to save themselves with the value 0.
This prevents me from knowing which was the last preferred dock position.

Exemple :
  • Window is docked on the top (DockID = -2)
  • I undock the window, so DockID = ~DockID = 1
  • I close the script, reopen it
  • The window is indeed floating, but with DockID = 0
  • When I dock again, the user expects the window to dock at the top, like last time. But DockID = ~0 = -1 so it dock on the right

I hope I am clear
Rodilab is offline   Reply With Quote
Old 06-25-2021, 03:02 AM   #233
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Rodilab View Post
All positive DockIDs seem to save themselves with the value 0.
This prevents me from knowing which was the last preferred dock position.
It's reset to 0 (undocked) when the dock ID doesn't exist. The previous dock ID should be stored separately, or the user presented with a choice of which REAPER docker to dock into (eg. menu or dropdown).

The dock ID represent a Dear ImGui dock space. Dock spaces are created (counting up from 1) when docking a window inside of another one in the same context by dragging their title bar. -1 to -16 are "special" as they are reserved by ReaImGui to correspond to a REAPER docker.

(Dear ImGui has an API for adding/managing custom dock spaces inside of windows, but it is still in beta and subject to change, so I haven't exposed it in ReaImGui yet.)
cfillion is offline   Reply With Quote
Old 06-26-2021, 12:32 AM   #234
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Quote:
Originally Posted by cfillion View Post
The previous dock ID should be stored separately
Ok, I will. Thanks.
My scripts are ready now.
This v0.5 is very interesting, thanks for your work
Rodilab is offline   Reply With Quote
Old 06-28-2021, 10:16 PM   #235
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Released v0.5.1:

Code:
• Add a HTML documentation page (accessible from the demo: Tools->Documentation)
• Cleanup the documentation of many functions (proofread, add hyperlinks...)
• Demo: fix even/odd detection in Tabs->Advanced & Close Button

API changes:
• Add PointConvertNative [p=2456542]
• Remove redundant return values in the Python binding
• Rename wrongly named function PathFillConvex to DrawList_PathFillConvex
(REAPER's built-in documentation now lists incorrect return values in the Python signatures.)

Last edited by cfillion; 06-29-2021 at 11:52 AM.
cfillion is offline   Reply With Quote
Old 07-01-2021, 02:02 PM   #236
jbradbury
Human being with feelings
 
jbradbury's Avatar
 
Join Date: Sep 2019
Location: Berlin
Posts: 61
Default Demo script does not work anymore

Hi Cfillion,

This is really great work and very commendable for your documentation and efforts. Truly superb.

I was working on a big overhaul of the ReaCoMa package using ReaImGui once I saw it. I was retooling things using 0.4.1 which worked a charm, but now updating to 0.5.1 no windows seem to be drawing or created at runtime. I thought it might be my fault converting things over to the new APIs that emerged between these two versions, however, when I run the demo example this has the same problem. I'm on an M1 Mac using the arm64 build of the library (as provided by ReaPack). Any ideas on how I can help you debug this (or where I might be going wrong?)

EDIT:

Just to further rule out any of my meat-ware issues I tried the most basic script:

Code:
local ctx = reaper.ImGui_CreateContext('My script')

function loop()
  local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
  if visible then
    reaper.ImGui_Text(ctx, 'Hello World!')
    reaper.ImGui_End(ctx)
  end
  
  if open then
    reaper.defer(loop)
  else
    reaper.ImGui_DestroyContext(ctx)
  end
end

reaper.defer(loop)
Which has the same issue.

EDIT2:

Just to confirm that I think this is an ARM/MAC issue - the demo scripts all work on my windows machine running 0.5.1.

Last edited by jbradbury; 07-01-2021 at 02:11 PM. Reason: More info
jbradbury is offline   Reply With Quote
Old 07-01-2021, 02:46 PM   #237
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by jbradbury View Post
Just to confirm that I think this is an ARM/MAC issue - the demo scripts all work on my windows machine running 0.5.1.
I think so too. Or at least, it could be an issue happening only with specific versions of macOS (I primarily test on 10.14.6 and occasionally on 10.15.7). What is the exact macOS version number you are using? I can try installing that on a x86 virtual machine & debug from there.

(I hope the bug isn't unique to ARM because I don't have the means to debug on that.)

EDIT: Try adding this before the ImGui_Begin call to dock into REAPER (instead of opening a floating window):
Code:
reaper.ImGui_SetNextWindowDockID(ctx, -1)
...and add ConfigFlags_DockingEnable to the CreateContext line:
Code:
local ctx = reaper.ImGui_CreateContext('My script', reaper.ImGui_ConfigFlags_DockingEnable())
Does that show up?

EDIT2: I assume there aren't any ReaImGui error messages in the ReaScript console when the problem happens?

Last edited by cfillion; 07-01-2021 at 03:42 PM.
cfillion is offline   Reply With Quote
Old 07-01-2021, 04:49 PM   #238
jbradbury
Human being with feelings
 
jbradbury's Avatar
 
Join Date: Sep 2019
Location: Berlin
Posts: 61
Default

No errors in the window at all. There might be a single frame flicker but its honestly so perceptually hard to discern I'm not sure if anything happens.

I'm going to go through your suggested steps tomorrow and let you know how I go

Happy to be debug for you if you can point me to parts of the code where it might be fixed or at least explored in some detail.

EDIT:

I am on 11.4 which might be part of the issue, although 0.4.1 worked without a hitch.

Last edited by jbradbury; 07-01-2021 at 04:51 PM. Reason: OS
jbradbury is offline   Reply With Quote
Old 07-01-2021, 04:58 PM   #239
jbradbury
Human being with feelings
 
jbradbury's Avatar
 
Join Date: Sep 2019
Location: Berlin
Posts: 61
Default

Code:
reaper.ImGui_SetNextWindowDockID(ctx, -1)
...and add ConfigFlags_DockingEnable to the CreateContext line:
Code:
local ctx = reaper.ImGui_CreateContext('My script', 
reaper.ImGui_ConfigFlags_DockingEnable())
Does that show up?

No luck trying these two things either — it produces the same behaviour as I described earlier. Here is a video just to contextualise it a bit.

http://permashare.jb.imap.cc/ReaCoMa/reaimgui.mp4
jbradbury is offline   Reply With Quote
Old 07-01-2021, 05:13 PM   #240
jbradbury
Human being with feelings
 
jbradbury's Avatar
 
Join Date: Sep 2019
Location: Berlin
Posts: 61
Default

I have just made a DEBUG build on my system (your instructions are really good by the way! A rarity).

I was able to get something to appear by following your advice, however, I cannot close this black window in the dock and if I run the script without the docking code in there, then modify the code to work with the docking API the old behaviour takes over again and nothing happens.

http://permashare.jb.imap.cc/ReaCoMa...d-reaimgui.png
jbradbury is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.