Old 10-05-2021, 06:53 AM   #361
Lopez
Human being with feelings
 
Join Date: Aug 2011
Location: Germany
Posts: 241
Default

Quote:
Originally Posted by cfillion View Post
Released version 0.5.7:

Code:
• Demo: fix crash in the Querying Status section [p=2480715]
• Fix visibility of popups and menus opened directly over REAPER's main window
• Support WindowFlags_TopMost in BeginPopup and BeginPopupModal
Well, I updated ReaImGui to 0.5.7 and now Reaper is closing right after starting up without error. Over and over again. It also appears with running as admin.

So, I delete reaper_imgui-x64.dll and it works again.
However, I get a popup now to install ReaImGui, I pinned it to v0.5.6 and now it works as before.

So: v0.5.7 is broken (at least on win)

Win 10 x64, 21H1, fully patched.
__________________
Lopez is offline   Reply With Quote
Old 10-05-2021, 08:05 AM   #362
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 863
Default

I'm on Linux, and it is *mostly* working for me, but there's definitely something wrong: whenever I click on the background of my script window, the window vanishes.
elcalen is online now   Reply With Quote
Old 10-05-2021, 01:29 PM   #363
YuriOl
Human being with feelings
 
Join Date: Sep 2018
Location: lugansk
Posts: 153
Default

After the last update, some scripts such as Script: Amagalma_reaimgui Color Theme Creator.lua and Script: CFillion_apply Render Preset.lua that use ReaimGui stopped working and сrashing Reaper.
(Windows 10)
YuriOl is offline   Reply With Quote
Old 10-05-2021, 03:14 PM   #364
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Released version 0.5.8, should fix both regressions.
Code:
• Font: downgrade FreeType to 2.10.4 as workaround for a crash in 2.11.0 on Windows [p=2486019][p=2486079]
• Linux: fix window visibility when dragging them over REAPER's main window [p=2486034]
cfillion is offline   Reply With Quote
Old 10-05-2021, 11:00 PM   #365
YuriOl
Human being with feelings
 
Join Date: Sep 2018
Location: lugansk
Posts: 153
Default

Quote:
Originally Posted by cfillion View Post
Released version 0.5.8, should fix both regressions.
Code:
• Font: downgrade FreeType to 2.10.4 as workaround for a crash in 2.11.0 on Windows [p=2486019][p=2486079]
• Linux: fix window visibility when dragging them over REAPER's main window [p=2486034]
It's okay now.
YuriOl is offline   Reply With Quote
Old 10-06-2021, 12:32 AM   #366
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 863
Default

Yup, my issue would appear to be fixed as well. Thank you.
elcalen is online now   Reply With Quote
Old 10-06-2021, 10:39 PM   #367
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default

Quote:
Originally Posted by cfillion View Post
I don't think I'll have enough free time to implement bitmaps in the near future.


understand, thanks for info
inframan is offline   Reply With Quote
Old 10-09-2021, 08:41 AM   #368
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Just an idea, not sure if it's working..

Is it possible to draw images in ImGui window with Reaper's gfx methods?
kartalex is offline   Reply With Quote
Old 11-13-2021, 08:03 PM   #369
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default ImGui possible bug with combo

not fatal, by any means, but might be a place where a little edit of the underlying code could avoid problems...

I had several radio button widgets in a large ImGui-based script, and decided to switch to combo boxes to save GUI real estate.The GUI has ImGui text boxes here and there explaining the selection choices, so on the combos I first put in a nil string ( '' ) or a blank ( ' ' ) for the label parameter.

If more than one combo in a script, this use breaks the combo box. The first combo still sorta works but some list items from subsequent combos bleed into the first one. Later ones don't work at all. Same behavior with the one-liner and the full 'begin..end' version. The test code below will show the problem and, by commenting-uncommenting revised lines, the fix.

This is easily fixed by having non-space text in the label parameter, so no biggie. But while fiddling around to find the fix, at one point I think the same problem occurred even with non-space text as the labels, so there may be other factors involved.

So, maybe a fix in the combo underlying code would resolve, or at minimum, a mention in the ImGui combo documentation could help others.

Code:
local r = reaper  -- r used to abreviate reaper.xxx calls to Reaper API
local ctx = r.ImGui_CreateContext('Combo Test') -- setup context for script GUI
local Combo1idx = 1
local Combo2idx = 2
local Combo3idx = 0

function Combo1Ctrl()  -- long version combo
  local items1 = { "this", "that", "the other" }
  local preview1 = items1[Combo1idx] -- Pass in the preview value visible before opening the combo (it could be anything)
  r.ImGui_SetNextItemWidth(ctx, 80.0)
  if r.ImGui_BeginCombo(ctx, ' ', preview1) then
  --if r.ImGui_BeginCombo(ctx, 'Combo1', preview1) then
    for i,v in ipairs(items1) do
      local is_selected = Combo1idx == i
      if r.ImGui_Selectable(ctx, items1[i], is_selected) then
        Combo1idx = i
      end
      -- Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
      if is_selected then
        r.ImGui_SetItemDefaultFocus(ctx)
      end
    end
    r.ImGui_EndCombo(ctx)
  end
end  --Combo1Ctrl()

function Combo2Ctrl() -- long version combo
  local items2 = { "  One  ", " Two ", " Three " }
  local preview2 = items2[Combo2idx] -- Pass in the preview value visible before opening the combo (it could be anything)
  r.ImGui_SetNextItemWidth(ctx, 80.0)
  if r.ImGui_BeginCombo(ctx, ' ', preview1) then
  --if r.ImGui_BeginCombo(ctx, 'Combo2', preview2 ) then
    for i,v in ipairs(items2) do
      local is_selected = Combo2idx == i
      if r.ImGui_Selectable(ctx, items2[i], is_selected) then
        Combo2idx = i
      end
      -- Set the initial focus when opening the combo (scrolling + keyboard navigation focus)
      if is_selected then
        r.ImGui_SetItemDefaultFocus(ctx)
      end
    end
    r.ImGui_EndCombo(ctx)
  end
end  --Combo2Ctrl()

function Combo3Ctrl()  -- one liner, from demo
  local items = "AAAA\31BBBB\31CCCC\31DDDD\31EEEE\31FFFF\31GGGG\31HHHH\31IIIIIII\31JJJJ\31KKKKKKK\31"
  local testvar
  r.ImGui_SetNextItemWidth(ctx, 80.0)
  rv, Combo3idx = r.ImGui_Combo(ctx, ' ', Combo3idx, items)
  --rv, testvar = r.ImGui_Combo(ctx, 'combo', testvar, items)
end  --Combo3Ctrl()

function ShowMainWindow()
  Combo1Ctrl()

  -- if you comment out the following calls, the blank label on the first one no longer breaks it
  Combo2Ctrl() 
  Combo3Ctrl()
end   --ShowMainWindow()

function main()
  r.ImGui_SetNextWindowPos(ctx, 300, 200, r.ImGui_Cond_FirstUseEver())
  r.ImGui_SetNextWindowSize(ctx, 300, 200, r.ImGui_Cond_FirstUseEver())

  local visible, open = r.ImGui_Begin(ctx, 'TestCombo', true)
  if visible then
      ShowMainWindow()
    r.ImGui_End(ctx)
  end

  if open then
    r.defer(main)
  else
    r.ImGui_DestroyContext(ctx)
  end
end

main()
inframan is offline   Reply With Quote
Old 11-13-2021, 08:21 PM   #370
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

All interactive items (not limited to combo boxes) must have a unique identifier. A space is technically fine as long as it's only used once in the same window/scope. This is documented in the FAQ: https://github.com/ocornut/imgui/blo...d-stack-system.

The unique labels can be hidden from view by prefixing them with ## (see link above for more details):

Code:
r.ImGui_BeginCombo(ctx, '##some_unique_id_for_this_item_here', preview1)
...and/or by using ImGui_PushID / PopID around it.
cfillion is offline   Reply With Quote
Old 11-13-2021, 10:30 PM   #371
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default

thanks cfillion,

that explains it. so the label is not just a label for display bin GUI, it is also the widget's unique identifier.

as a friend used to tell me, "when all else fails, read the documentation..."
inframan is offline   Reply With Quote
Old 11-16-2021, 09:48 AM   #372
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default PopupModal with focused textbox and cancel button

I'm trying to use a PopupModal with textbox and cancel button.

I want the textbox to have focus when popup opens so user can just start typing, then hit return key to save the changes, so I added ImGui_SetKeyboardFocusHere above the ImGui_InputText line and the EnterReturnsTrue flag to the textbox, and it works great!

Problem is, the cancel button doesn't work. The only way to close the popup is to press the return key.

Can someone show me how to fix this please?

Code:
local ctx = reaper.ImGui_CreateContext('Test Popup', reaper.ImGui_ConfigFlags_NoSavedSettings())
local cur_name = "Current Name"

function loop()
  local visible, open = reaper.ImGui_Begin(ctx, 'My window', true) 
  if visible then
    reaper.ImGui_Text(ctx, 'Press F2 key for modal popup window!')
    
    -- F2 key pressed ?
    if reaper.ImGui_IsKeyPressed(ctx, 0x71, nil) then reaper.ImGui_OpenPopup(ctx, "Rename Selected Preset") end 
    -- show popup ? 
    if reaper.ImGui_BeginPopupModal(ctx, "Rename Selected Preset", nil, reaper.ImGui_WindowFlags_AlwaysAutoResize()) then
      reaper.ImGui_Text(ctx, "Enter new name for selected preset")  
      reaper.ImGui_SetKeyboardFocusHere(ctx, 0) -- Sets focus on text so user can start typing when popup opens
      local rv, new_name = reaper.ImGui_InputText(ctx, '##text1', cur_name, reaper.ImGui_InputTextFlags_EnterReturnsTrue()) 
      if rv then
        cur_name = new_name
        reaper.ImGui_CloseCurrentPopup(ctx) 
      end  
      -- cancel button DOES NOT WORK when using ImGui_SetKeyboardFocusHere above ????
      if reaper.ImGui_Button(ctx, " Cancel ") then reaper.ImGui_CloseCurrentPopup(ctx) end 
      reaper.ImGui_EndPopup(ctx)
    end
    
    reaper.ImGui_End(ctx)
  end 
  if open then
    reaper.defer(loop)
  else
    reaper.ImGui_DestroyContext(ctx)
  end
end

reaper.defer(loop)
Edgemeal is offline   Reply With Quote
Old 11-16-2021, 12:09 PM   #373
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

The problem is the InputText is given focus at every frame, so the button never has a chance to take it. It should be called only once after opening the popup. Using IsWindowAppearing to check for this:

Code:
if reaper.ImGui_IsWindowAppearing(ctx) then
  reaper.ImGui_SetKeyboardFocusHere(ctx)
end
EDIT: However, due to EnterReturnsTrue, the InputText will forget the user's entered value if they remove focus from it (eg. press on an empty area of the popup, press escape...).

Code:
    -- show popup ? 
    if reaper.ImGui_BeginPopupModal(ctx, "Rename Selected Preset", nil, reaper.ImGui_WindowFlags_AlwaysAutoResize()) then
      local rv
      reaper.ImGui_Text(ctx, "Enter new name for selected preset:")  
      if reaper.ImGui_IsWindowAppearing(ctx) then
        reaper.ImGui_SetKeyboardFocusHere(ctx) -- Sets focus on text so user can start typing when popup opens
        edit_name = cur_name
      end

      local FLT_MIN, FLT_MAX = reaper.ImGui_NumericLimits_Float()
      reaper.ImGui_SetNextItemWidth(ctx, -FLT_MIN)
      rv, edit_name = reaper.ImGui_InputText(ctx, '##text1', edit_name) 
      
      -- extra spacing in the buttons (font-independent)
      reaper.ImGui_PushStyleVar(ctx, reaper.ImGui_StyleVar_FramePadding(), 10, 3)
      if reaper.ImGui_Button(ctx, "OK") or reaper.ImGui_IsKeyPressed(ctx, 0x0D) then
        -- click or Enter
        cur_name = edit_name
        reaper.ImGui_CloseCurrentPopup(ctx) 
      end  
      reaper.ImGui_SameLine(ctx)
      if reaper.ImGui_Button(ctx, "Cancel") or reaper.ImGui_IsKeyPressed(ctx, 0x1B) then
        -- click or Escape
        reaper.ImGui_CloseCurrentPopup(ctx)
      end
      reaper.ImGui_PopStyleVar(ctx)

      reaper.ImGui_EndPopup(ctx)
    elseif reaper.ImGui_IsKeyPressed(ctx, 0x71) then
      -- F2 key pressed when the popup is closed
      reaper.ImGui_OpenPopup(ctx, "Rename Selected Preset")
    end

Last edited by cfillion; 11-16-2021 at 12:38 PM.
cfillion is offline   Reply With Quote
Old 11-16-2021, 02:41 PM   #374
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by cfillion View Post

EDIT: However, due to EnterReturnsTrue, the InputText will forget the user's entered value if they remove focus from it (eg. press on an empty area of the popup, press escape...).
Hmmm, the textbox doesn't have focus when the popup opens here (Win10 x64), need to press Tab key once.

If nothing else, I may just go with this (don't really need buttons).
Focus is on the textbox when open and I can just use Return and Esc keys to control it.

Code:
   -- show popup ? 
   if reaper.ImGui_BeginPopupModal(ctx, "Rename Selected Preset", nil, reaper.ImGui_WindowFlags_AlwaysAutoResize()) then 
     reaper.ImGui_Text(ctx, "Enter new name for selected preset:")  
     reaper.ImGui_SetKeyboardFocusHere(ctx) -- Sets focus on text so user can start typing when popup opens 
     local rv, edit_name = reaper.ImGui_InputText(ctx, '##text1', cur_name)
     
     if reaper.ImGui_IsKeyPressed(ctx, 0x0D) then -- Enter
       cur_name = edit_name
       reaper.ImGui_CloseCurrentPopup(ctx) 
     end 
     
     -- Esc
     if reaper.ImGui_IsKeyPressed(ctx, 0x1B) then reaper.ImGui_CloseCurrentPopup(ctx) end 
     reaper.ImGui_EndPopup(ctx)
   elseif reaper.ImGui_IsKeyPressed(ctx, 0x71) then -- F2 key pressed when the popup is closed
     reaper.ImGui_OpenPopup(ctx, "Rename Selected Preset")
   end
Edgemeal is offline   Reply With Quote
Old 11-16-2021, 07:45 PM   #375
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by Edgemeal View Post
Hmmm, the textbox doesn't have focus when the popup opens here (Win10 x64), need to press Tab key once.
Ah right, I was using a development build of the next version. For now, using "not IsAnyItemActive" instead of IsWindowAppearing should to the trick.
cfillion is offline   Reply With Quote
Old 11-16-2021, 09:42 PM   #376
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by cfillion View Post
Ah right, I was using a development build of the next version. For now, using "not IsAnyItemActive" instead of IsWindowAppearing should to the trick.
Yep that does the trick! Thanks!

Maybe already known, but Viewport_GetCenter seems broken here, returning 0,0, like in demo...
Code:
    -- Always center this window when appearing
    local center = {r.ImGui_Viewport_GetCenter(r.ImGui_GetMainViewport(ctx))}
    r.ImGui_SetNextWindowPos(ctx, center[1], center[2], r.ImGui_Cond_Appearing(), 0.5, 0.5)
    if r.ImGui_BeginPopupModal(ctx, 'Delete?',...
That popup window is almost completely off desktop area at far top-left (SPY++ rect x,y was showing something like (-127, -35).
Otherwise SetNextWindowPos seems fine, using ScreenWidth/2, ScreenHeight/2 centers window on screen.

Then to center popup over main window I do this, not sure if there is better way, but seems to be working OK.
Code:
    -- center rename preset popup in center of main window
    local x,y = reaper.ImGui_GetWindowPos(ctx) w,h = reaper.ImGui_GetWindowSize(ctx)
    reaper.ImGui_SetNextWindowPos(ctx, (w/2)+x, (h/2)+y, reaper.ImGui_Cond_Appearing(), 0.5, 0.5)
    if reaper.ImGui_BeginPopupModal(ctx, "Rename Selected Preset",...
Win10/x64, REAPER v6.41/x64, reaimgui (imgui-x64) v0.5.8

Last edited by Edgemeal; 11-16-2021 at 09:47 PM.
Edgemeal is offline   Reply With Quote
Old 11-22-2021, 07:34 AM   #377
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

I use reaper. Imgui_ Button creates a button. Can I make the button respond to right-click? How to achieve it?
dangguidan is offline   Reply With Quote
Old 11-22-2021, 03:36 PM   #378
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by dangguidan View Post
I use reaper. Imgui_ Button creates a button. Can I make the button respond to right-click? How to achieve it?
Code:
local ctx = reaper.ImGui_CreateContext('My script')

function loop()
  local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
  if visible then
    if reaper.ImGui_Button(ctx, "Button") then
      reaper.ShowConsoleMsg("left-click\n")
    end
    if reaper.ImGui_IsItemClicked(ctx, reaper.ImGui_MouseButton_Right()) then
      reaper.ShowConsoleMsg("right-click\n")
    end
    reaper.ImGui_End(ctx)
  end
  
  if open then
    reaper.defer(loop)
  else
    reaper.ImGui_DestroyContext(ctx)
  end
end

reaper.defer(loop)
Perhaps there is a better way..
__________________
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 11-22-2021, 07:40 PM   #379
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

Quote:
Originally Posted by amagalma View Post
Code:
local ctx = reaper.ImGui_CreateContext('My script')

function loop()
  local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
  if visible then
    if reaper.ImGui_Button(ctx, "Button") then
      reaper.ShowConsoleMsg("left-click\n")
    end
    if reaper.ImGui_IsItemClicked(ctx, reaper.ImGui_MouseButton_Right()) then
      reaper.ShowConsoleMsg("right-click\n")
    end
    reaper.ImGui_End(ctx)
  end
  
  if open then
    reaper.defer(loop)
  else
    reaper.ImGui_DestroyContext(ctx)
  end
end

reaper.defer(loop)
Perhaps there is a better way..
Thank you. This looks good!
dangguidan is offline   Reply With Quote
Old 12-05-2021, 09:29 PM   #380
MisterLevy
Human being with feelings
 
Join Date: Sep 2020
Posts: 20
Default

Does anyone know if it possible to change the default colors so that all ReaImGui scripts will be affected?
MisterLevy is offline   Reply With Quote
Old 12-05-2021, 10:56 PM   #381
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

There's no global user-configurable theming support in ReaImGui. Could be a good feature idea...

Right now the default theme can be changed globally by rebuilding the extension. (Relevant code lines are here. Was originally intended to automatically change the colors to follow the active REAPER theme, but I couldn't get it to be reliably nice-looking.)
cfillion is offline   Reply With Quote
Old 01-03-2022, 09:40 PM   #382
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Released version 0.5.9:

Code:
• Docker: fix no rendering on macOS if opened within the first 3 frames of the context
• Docker: obey WindowFlags_NoFocusOnAppearing if set on any hosted windows
• Fix the main viewport having a zero position and size [p=2498028]
• Fix WindowFlags_NoFocusOnAppearing not having an effect within the first 3 frames
• Update to Dear ImGui v1.85 (release notes)

API changes:
• Add DockHierarchy and NoPopupHierarchy in both FocusedFlags and HoveredFlags
• Add ShowStackToolWindow (also Demo->Tools->Stack Tool)
• Remove GetWindowContentRegionWidth

Last edited by cfillion; 01-03-2022 at 10:36 PM.
cfillion is offline   Reply With Quote
Old 01-03-2022, 10:01 PM   #383
en5ca
Human being with feelings
 
Join Date: Dec 2018
Posts: 394
Default

Quote:
Originally Posted by cfillion View Post
Released version 0.5.9: ...
Thank you for your work! Is it possible to somehow 'check' if ReaImGui API is loaded properly? E.g something like
Code:
REAPERAPI_LoadAPI(rec->GetFunc))
?
en5ca is offline   Reply With Quote
Old 01-03-2022, 10:07 PM   #384
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

For a C++ extension using reaper_imgui_functions.h:

Code:
// ReaImGuiFunc instances are convertible to bool
if(ImGui_GetVersion) // could be any function, preferably one that is used later
  ; // ReaImGui is loaded
(Extensions are loaded in filesystem-defined order so this won't work reliably at startup.)

Last edited by cfillion; 01-03-2022 at 10:16 PM.
cfillion is offline   Reply With Quote
Old 01-03-2022, 10:14 PM   #385
en5ca
Human being with feelings
 
Join Date: Dec 2018
Posts: 394
Default

Quote:
Originally Posted by cfillion View Post
From another C++ extension, if you're using reaper_imgui_functions.h:

Code:
// ReaImGuiFunc instances are convertible to bool
if(ImGui_GetVersion) // could be any function, preferably one that is used later
  ; // ReaImGui is loaded
Thank you. I will try this.

EDIT:

Got compiler error after trying this. MSVC Compiler Error C2662 error to be precise.

Modified ReaImGuiFunc class declaration in reaper_imgui_functions.h:
Code:
operator bool() const { return proc() != nullptr; }
into
Code:
operator bool() { return proc() != nullptr; }
and got it to compile. Did I also break something in the most horrible way imaginable?

Last edited by en5ca; 01-03-2022 at 10:37 PM.
en5ca is offline   Reply With Quote
Old 01-04-2022, 02:27 AM   #386
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by en5ca View Post
Got compiler error after trying this. MSVC Compiler Error C2662 error to be precise.
Good catch, that extra const is a leftover from an earlier version. Fixing!
cfillion is offline   Reply With Quote
Old 01-04-2022, 03:49 AM   #387
en5ca
Human being with feelings
 
Join Date: Dec 2018
Posts: 394
Default

Quote:
Originally Posted by cfillion View Post
Good catch, that extra const is a leftover from an earlier version. Fixing!
Ok, great! Thank you.
en5ca is offline   Reply With Quote
Old 01-11-2022, 07:37 AM   #388
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by cfillion View Post
Ah right, I was using a development build of the next version. For now, using "not IsAnyItemActive" instead of IsWindowAppearing should to the trick.
Updated from v0.5.8 to v0.5.9 and had to change my code from IsAnyItemActive to IsWindowAppearing, and is working as expected again.
Thanks!

Win10/x64, REAPER v6.45/x64, reaimgui (imgui-x64) v0.5.9
Edgemeal is offline   Reply With Quote
Old 01-17-2022, 05:33 PM   #389
Mavriq
Human being with feelings
 
Mavriq's Avatar
 
Join Date: Aug 2016
Location: Thunder Bay, Canada
Posts: 297
Default

Quote:
Originally Posted by amagalma View Post
I think this may come in handy to people using ReaImGui:

amagalma_ReaImGui Color Theme Creator
Wow very handy indeed. Thanks!
Mavriq is offline   Reply With Quote
Old 01-19-2022, 03:56 PM   #390
Mavriq
Human being with feelings
 
Mavriq's Avatar
 
Join Date: Aug 2016
Location: Thunder Bay, Canada
Posts: 297
Default

Found what I think is a bug. I have 2 buttons with the same label. The second one never seems to "fire". IE always returns false when clicked.


Code:
  if r.ImGui_Button(ctx, "Set",60,20) then
      data =  return_something()
  end

.... later in same ctx

  if r.ImGui_Button(ctx, "Set",60,20) then
      data =  return_something()
  end
Is that by design, or should you be able to have the same labels?
Mavriq is offline   Reply With Quote
Old 01-20-2022, 01:22 AM   #391
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Each UI elements need a unique ID to identify them. See https://github.com/ocornut/imgui/blo...d-stack-system.

TL;DR, there are two ways to give unique IDs to those buttons sharing the same parent element/window:

Code:
-- using '##' to pass a complement to the ID invisible to the user
r.ImGui_Button(ctx, "Set##1", 60, 20)
r.ImGui_Button(ctx, "Set##2", 60, 20)
Code:
-- using PushID to simulate a parent element with a unique ID
r.ImGui_PushID(ctx, 1)
r.ImGui_Button(ctx, "Set", 60, 20)
-- possibly more elements here...
r.ImGui_PopID(ctx)

r.ImGui_PushID(ctx, 2)
r.ImGui_Button(ctx, "Set", 60, 20)
r.ImGui_PopID(ctx)
cfillion is offline   Reply With Quote
Old 01-20-2022, 05:08 PM   #392
Mavriq
Human being with feelings
 
Mavriq's Avatar
 
Join Date: Aug 2016
Location: Thunder Bay, Canada
Posts: 297
Default

Ah. I knew there had to some way of doing it. Incidentally there is a third way, which is the "hack" I did before you replied:

You can use spaces in the labels. IE "Set", " Set ", " Set ".
Mavriq is offline   Reply With Quote
Old 01-28-2022, 12:26 AM   #393
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

If the system text of windows is enlarged, especially some small notebooks, Then there will be a deviation in the pop-up position of imgui.And the enlarged interface looks very rough. How can we make correct compensation?
Code:
local ctx = reaper.ImGui_CreateContext('My script')
 x, y = reaper.GetMousePosition()
 reaper.ImGui_SetNextWindowPos(ctx, x, y)
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)
dangguidan is offline   Reply With Quote
Old 01-28-2022, 05:56 AM   #394
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by dangguidan View Post
If the system text of windows is enlarged, especially some small notebooks, Then there will be a deviation in the pop-up position of imgui.And the enlarged interface looks very rough. How can we make correct compensation?
Use ImGui_PointConvertNative to translate native HiDPI coordinates to ReaImGui global coordinates:

Code:
x, y = reaper.GetMousePosition()
x, y = reaper.ImGui_PointConvertNative(ctx, x, y)
As for the interface looking rough when scaled, can you share a screenshot? And which HiDPI mode is REAPER set to? "Multimonitor aware v2" should yield the best results. https://reaperblog.net/2020/07/multimonitor-v2-hidpi/
cfillion is offline   Reply With Quote
Old 01-28-2022, 07:16 PM   #395
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

Quote:
Originally Posted by cfillion View Post
Use ImGui_PointConvertNative to translate native HiDPI coordinates to ReaImGui global coordinates:

Code:
x, y = reaper.GetMousePosition()
x, y = reaper.ImGui_PointConvertNative(ctx, x, y)
As for the interface looking rough when scaled, can you share a screenshot? And which HiDPI mode is REAPER set to? "Multimonitor aware v2" should yield the best results. https://reaperblog.net/2020/07/multimonitor-v2-hidpi/
The position is completely correct now. Thank you for your guidance!
The enlarged imgui text looks a little blurred. Is it convenient for you to provide email? I'll send you the screenshot.
dangguidan is offline   Reply With Quote
Old 01-29-2022, 05:00 AM   #396
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

<EDIT: removed email>, but you can also use online image hosters like imgur and embed them here on the forum:
Code:
[img]https://url.to.the/uploaded-image/here.png[/img]
It is normal for the default font to look pixelated when scaled up as in the image below. This is because the built-in font uses 13px bitmap glyphs.



Vector fonts loaded with CreateFont, PushFont and PopFont (usage example in the first post) should render smoothly even at higher DPI settings:


Last edited by cfillion; 02-03-2022 at 08:41 PM.
cfillion is offline   Reply With Quote
Old 01-29-2022, 06:57 AM   #397
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 662
Default

The email has been sent, please check it.
dangguidan is offline   Reply With Quote
Old 01-30-2022, 11:17 AM   #398
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Ah yes, that's probably because the scaling factor isn't an integer (eg. 1.25x). Not sure if that can be improved. Try loading a vector font instead of using the built-in bitmap font.
cfillion is offline   Reply With Quote
Old 02-11-2022, 02:27 PM   #399
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Released version 0.5.10:

Code:
• Update to Dear ImGui v1.86 (release notes)

API changes:
• Add GetMouseClickedCount
• Add ListClipper_ForceDisplayRangeByIndices
cfillion is offline   Reply With Quote
Old 02-12-2022, 03:38 PM   #400
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

I found an issue in the docs:

ImGui_FocusedFlags_AnyWindow claims, that it returns true if any window is focused.
However, the retval is integer...

Edit:
Same goes for ImGui_FocusedFlags_ChildWindows
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...

Last edited by Meo-Ada Mespotine; 02-12-2022 at 03:51 PM.
Meo-Ada Mespotine 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 11:27 AM.


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