Old 05-08-2022, 08:54 AM   #481
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Quote:
Originally Posted by cfillion View Post
ConvertRGBtoHSV and HSVtoRGB expects floating point values between 0 and 1. Also REAPER returns optional arguments (alpha in this case).

Updating the documentation to reflect this.
Great! Thank you! Now it works)))
kartalex is offline   Reply With Quote
Old 05-08-2022, 10:13 AM   #482
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

And there's one more question, please)

Can we change text font size dynamically, or we must attach all sizes in the begining of the program, where ctx is created?
kartalex is offline   Reply With Quote
Old 05-08-2022, 10:30 AM   #483
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

New fonts can be created at any time and attached to a context at any defer cycle before other ImGui functions are used.

(Rasterizing a font is a heavy operation, shouldn't be done every frame (frame = defer cycle). Consider detaching unused font sizes to reduce GPU memory usage.)
cfillion is offline   Reply With Quote
Old 05-08-2022, 03:08 PM   #484
immortalx
Human being with feelings
 
Join Date: Dec 2009
Posts: 69
Default

cfillion, has the idea of bitmap support been abandoned? I can't be thankful enough for all the work you've done, so I'm just asking because I'm trying to make a decision for a script I'm working on.
I guess it requires a ton of work for you to implement.
immortalx is offline   Reply With Quote
Old 05-08-2022, 03:31 PM   #485
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Not abandoned, but didn't make visible progress on it either. TODO list for bitmaps is more or less:
  • Share/reuse GPU textures across all windows in the same context
  • Generalize code responsible for re-rasterizing fonts for each DPI currently in use to also support switching images from a set(/allow for rescaling if needed)
  • Research & choose decoder(s) for common (just png/jpg? gif/bmp/tiff/webp/avif/qoi? system-dependent?) bitmap formats (either cross-platform or for each platform) (malformed image files should not lead to crashes or bad memory accesses)
  • Write the actual API
  • Connect the previous steps together and with Dear ImGui
If anyone has experience with C/C++ image decoders, suggestions would be helpful. (stb_image seems simple&nice but unsafe with untrusted files, macOS/Windows/GDK's loaders might have undesired nuances in supported formats(?))

Last edited by cfillion; 05-08-2022 at 09:43 PM.
cfillion is offline   Reply With Quote
Old 05-08-2022, 06:21 PM   #486
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default

Even if number of supported formats is limited (for example - png, bmp) it would be super great.
kartalex is offline   Reply With Quote
Old 05-08-2022, 08:39 PM   #487
immortalx
Human being with feelings
 
Join Date: Dec 2009
Posts: 69
Default

Quote:
Originally Posted by cfillion View Post
stb_image seems simple&nice but unsafe with untrusted files
I've used stb_image when trying to learn OpenGL and it's indeed very simple. These days It's the goto library for people doing sprite-rendering engines, and I'm sure I've spotted a couple of cases in which it was used on professional software.
It (and the whole stb suite) has been recommended by the Handmade Network for years. That's all I know.
immortalx is offline   Reply With Quote
Old 05-10-2022, 10:26 AM   #488
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Released version 0.6.2:

Code:
• Fix a crash when destroying list clippers while a different context is active
• Fix empty points array crashing DrawList_Add{Polyline,ConvexPolyFilled}
• Linux: restore broken key up/down events when an IME is active
• macOS: allow OpenGL software renderering for wider compatibility
• macOS: fix keyboard input when holding down a mouse button and the "Allow keyboard commands when mouse-editing" setting is disabled [p=2552296]
• Windows: receive Alt key events when "Prevent ALT key from focusing main menu" is enabled

API changes:
• DrawList_PathArcTo: fix incorrect default value for 'num_segments' when omitted
• Revert "Fix DrawList_AddTextEx not using the default bitmap font when font == nil" from v0.6
GetKeyMods is going to be removed in the upcoming v0.7. The replacement API, available since v0.6.0, is IsKeyDown(Key_Mod*). https://forum.cockos.com/showthread.php?p=2544651

EDIT: v0.7 will come with a backward-compatibility Lua script allowing scripts to request a specific version of the API.

EDIT2: Re-considering the previously planned removal of GetKeyMods, if so only KeyMod_* will be renamed to Mod_*...

Last edited by cfillion; 05-20-2022 at 08:35 PM.
cfillion is offline   Reply With Quote
Old 05-14-2022, 11:41 PM   #489
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default ImGui_IsKeyPressed can't see BlueTooth kbd on MacOS

I have had great success building custom script tools using the wonderful reaper.ImGui. Scripting Reaper with ImGui is super powerful.

Sometimes, for GUI control buttons, I like to bind a keypress trigger to a GUI button, roughly: "if button press or key press then do something...". Generally this works as desired.

I have found a problem. The ImGui_IsKeyPressed function on macOS cannot see key presses from the (Apple) bluetooth keyboard that I prefer to use. The problem is BT-only - ImGui_IsKeyPressed has no problem seeing keyboard input from mac internal keyboard or attached USB keyboard

for testing I have experimented with various keyboard hardware on two different macs, using this bit of Lua:

Code:
if r.ImGui_IsKeyPressed(ctx, 0x42, false) then
        msgln("B key pressed")
end  -- test kbd input
Other ImGui text stuff, such as ImGui_TextInput, works fine with all kbd devices including BT. The problem only occurs with IsKeyPressed.

I suspect this involves interaction between the reaper.ImGui implementation code and weird stuff deep within macOS IOKit internals. IOKit, sadly is well beyond my depth of understanding.

I was hoping that there might be some OS parameter I can change to resolve this from the OS side, and so I have googled the heck out of this. So far am unable to find any info about differing OS handling of kbd input on BT vs non-BT keyboards.

Can anyone shed any light on this, or suggest a workaround which still uses my BT kbd ?

edit: sorry, should have mentioned, I am currently on ReaImGui 0.6.1

Last edited by inframan; 05-15-2022 at 02:20 AM.
inframan is offline   Reply With Quote
Old 05-15-2022, 06:15 AM   #490
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

I'll try with a Bluetooth keyboard on macOS as soon as I can (have a Logitech one). Key events are received if character input works, so key translation must be misbehaving. Can you check if it triggers the wrong keys in the demo script (with 0.6.2 preferably)? Inputs, Navigation & Focus -> Keyboard, Gamepad & Navigation State.

EDIT: Can't duplicate, it works here on macOS 10.14.

Side note: the new API (dear imgui v1.87+, ReaImGui v0.6+) for reading keys is:
Code:
if r.ImGui_IsKeyPressed(ctx, r.ImGui_Key_B()) then end
(Windows-like virtual key codes (0x42 for B) will remain supported for the foreseeable future.)

Last edited by cfillion; 05-15-2022 at 07:09 PM.
cfillion is offline   Reply With Quote
Old 05-15-2022, 11:29 PM   #491
BryanChi
Human being with feelings
 
Join Date: Jan 2019
Location: Taiwan
Posts: 436
Default Is Y axis inverted for "SetNextWindowPos"?

Hi,
The Y axis for "ImGui_SetNextWindowPos" seems to be the opposite of the native API's "reaper.GetMousePosition()"?
I'm trying to get the window to appear at the mouse position, but it seems like reaper.GetMousePosition() returns top of screen as 0, whereas ImGui_SetNextWindowPos interprets bottom of screen as 0.
I could do some math to make it correct but that would require knowing the screen resolution and just makes it more complex than needed. Just wondering if there's some easier way to resolve this?
Thank you!
BryanChi is offline   Reply With Quote
Old 05-16-2022, 06:59 AM   #492
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

ImGui_PointConvertNative()

ReaImGui's y coordinate is top to bottom on all systems, while macOS (and therefore GetMousePosition and other non-ReaImGui APIs) is bottom to top.

The function above also does DPI conversion on Windows/Linux and should always be used to convert back and forth between ReaImGui coordinates and the operating system's coordinates.

Last edited by cfillion; 05-16-2022 at 07:11 AM.
cfillion is offline   Reply With Quote
Old 05-16-2022, 11:16 PM   #493
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default

thanks for advice cfillion

Quote:
Originally Posted by cfillion View Post
Can you check if it triggers the wrong keys in the demo script (with 0.6.2 preferably)?
Simply upgrading to 0.6.2 seems to have resolved the no-response to BT kbd input, although a different problem has arisen. Under 0.6.2 IsKeyPressed now works fine in most situations, but I can't get it to work if called from within a modal window.

Previously, ReImGui_IsKeyPressed in the same script was handling BT kbd input ok even from within a modal window. Sorry, I didn't notice exactly when the non-response issue started or what I changed (OS update or ImGui update ?) that might have led to problem.

Anyway, for now I have implemented a workaround: in one or two situations where I had been using IsKeyPressed from within a modal window, I have instead just slightly redesigned my control scheme, by using custom shortcut keys to native Reaper actions that get me to the same desired end result. For other things where I do not really need kbd control, I still use ReaImGui mouse-driven control widgets, and these of course work fine. So original problem is effectively resolved/worked-around.

BTW, before these changes, per your advice I tested Inputs in Demo using Navigation & Focus -> Keyboard, Gamepad & Navigation State. Resulting KeyCodes with both BT and attached/internal kbds were normal even where I had the original issue under 0.6.1.

Quote:
Originally Posted by cfillion View Post
EDIT: Can't duplicate, it works here on macOS 10.14.
I am on Big Sur 11.6.5. The BT keypress misbehavior occurred on both an M1 Airbook and intel macMini. The Mini has two big attached displays and is my main DAW machine and that's mainly why using BT keyboard is preferred.

Quote:
Originally Posted by cfillion View Post
Code:
if r.ImGui_IsKeyPressed(ctx, r.ImGui_Key_B()) then end
Original problem behavior and current behavior were identical under both new API and older version using raw KeyCode parameter. The new one is definitely nicer - a bit more self-documenting.
inframan is offline   Reply With Quote
Old 05-17-2022, 12:39 AM   #494
aurelien
Human being with feelings
 
Join Date: Apr 2014
Posts: 96
Default

Hello and thanks again for this amazing feature cfillion.

I'm actually trying to erase an InputDoubleField after a specific action, it's not quite easy to explain but i'll do my best.

1.I'm entering a number in an InputDouble Field
2.I'm pressing a shortcut to do an action.
3.After the action is done, I would like to erase all the number in the current field(as if i was doing ctrl_a + del)

Is there some kind of buffer or something to erase to do so?

Thanks !
aurelien is offline   Reply With Quote
Old 05-17-2022, 01:55 AM   #495
immortalx
Human being with feelings
 
Join Date: Dec 2009
Posts: 69
Default

Quote:
Originally Posted by aurelien View Post
Hello and thanks again for this amazing feature cfillion.

I'm actually trying to erase an InputDoubleField after a specific action, it's not quite easy to explain but i'll do my best.

1.I'm entering a number in an InputDouble Field
2.I'm pressing a shortcut to do an action.
3.After the action is done, I would like to erase all the number in the current field(as if i was doing ctrl_a + del)

Is there some kind of buffer or something to erase to do so?

Thanks !
If I get what you want, then you can have a condition right before you call the InputDouble field, where you test if your action was completed in that frame. When that turns to true, inside that condition use reaper.ImGui_SetKeyboardFocusHere() to set the focus on the input field. That auto-selects the value in that field. It doesn't delete it though and I'm not sure if that's possible
__________________
https://pragmata.webflow.io/
immortalx is offline   Reply With Quote
Old 05-17-2022, 03:27 AM   #496
aurelien
Human being with feelings
 
Join Date: Apr 2014
Posts: 96
Default

Thanks immortalx for your answer.

I gave it a try and since i'm already typing in the field, the setKeyBoardFocus command doesn't select all the text in the field.
aurelien is offline   Reply With Quote
Old 05-17-2022, 03:50 AM   #497
immortalx
Human being with feelings
 
Join Date: Dec 2009
Posts: 69
Default

Quote:
Originally Posted by aurelien View Post
Thanks immortalx for your answer.

I gave it a try and since i'm already typing in the field, the setKeyBoardFocus command doesn't select all the text in the field.
Hmmm, since you're already typing it already has the focus, right. So maybe you can fake it by moving the focus to another widget (or a dummy or invisible button) and then set the focus back to the input field.
Not the best way of course, but I can't think of anything else
__________________
https://pragmata.webflow.io/
immortalx is offline   Reply With Quote
Old 05-17-2022, 08:14 AM   #498
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,009
Default

Quote:
Originally Posted by aurelien View Post
Hello and thanks again for this amazing feature cfillion.

I'm actually trying to erase an InputDoubleField after a specific action, it's not quite easy to explain but i'll do my best.

1.I'm entering a number in an InputDouble Field
2.I'm pressing a shortcut to do an action.
3.After the action is done, I would like to erase all the number in the current field(as if i was doing ctrl_a + del)

Is there some kind of buffer or something to erase to do so?

Thanks !
You will need to have a way to know when the action is finished. And then just make the inputdoable value variable equals to '' or 0
daniellumertz is online now   Reply With Quote
Old 05-17-2022, 09:34 AM   #499
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by inframan View Post
Under 0.6.2 IsKeyPressed now works fine in most situations, but I can't get it to work if called from within a modal window.

Previously, ReImGui_IsKeyPressed in the same script was handling BT kbd input ok even from within a modal window.
Mhh keyboard input should behave the same as long as a ImGui windows in the same context has focus, modal or modeless.

https://i.imgur.com/gU2bXc8.gif

If it works in the demo for you but not in your script, might be worth reducing it to a minimal snippet that duplicates the problem so I can investigate.

Quote:
Originally Posted by aurelien View Post
I gave it a try and since i'm already typing in the field, the setKeyBoardFocus command doesn't select all the text in the field.
Not sure if there's a better way, but something like this can reset & select everything while the field is active (by deactivating it for 1 frame):

Code:
local event = reaper.ImGui_IsKeyPressed(ctx, reaper.ImGui_Key_C())
if event then n = 0 end -- reset
reaper.ImGui_PushStyleVar(ctx, reaper.ImGui_StyleVar_DisabledAlpha(), 1.0)
reaper.ImGui_BeginDisabled(ctx, event)
if prev_event then reaper.ImGui_SetKeyboardFocusHere(ctx) end
rv, n = reaper.ImGui_InputDouble(ctx, 'foo', n)
reaper.ImGui_EndDisabled(ctx)
reaper.ImGui_PopStyleVar(ctx)
prev_event = event

Last edited by cfillion; 05-17-2022 at 10:39 AM.
cfillion is offline   Reply With Quote
Old 05-17-2022, 10:33 AM   #500
aurelien
Human being with feelings
 
Join Date: Apr 2014
Posts: 96
Default

Thanks cfillion, it's working perfectly !
aurelien is offline   Reply With Quote
Old 05-17-2022, 10:24 PM   #501
BryanChi
Human being with feelings
 
Join Date: Jan 2019
Location: Taiwan
Posts: 436
Default

Quote:
Originally Posted by cfillion View Post
ImGui_PointConvertNative()

ReaImGui's y coordinate is top to bottom on all systems, while macOS (and therefore GetMousePosition and other non-ReaImGui APIs) is bottom to top.

The function above also does DPI conversion on Windows/Linux and should always be used to convert back and forth between ReaImGui coordinates and the operating system's coordinates.
Got it! Thanks very much again!!
BryanChi is offline   Reply With Quote
Old 05-18-2022, 01:31 AM   #502
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default

Quote:
Originally Posted by cfillion View Post
If it works in the demo for you but not in your script, might be worth reducing it to a minimal snippet that duplicates the problem so I can investigate.
It does work from within the modal popup in ReaImGui demo:
Code:
 if r.ImGui_BeginPopupModal(ctx, 'Delete?', nil, r.ImGui_WindowFlags_AlwaysAutoResize()) then
      -- test line added here
      if r.ImGui_IsKeyPressed(ctx, r.ImGui_Key_B(), false) then r.ShowConsoleMsg("B key pressed") end
      
      r.ImGui_Text(ctx, 'All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n')
      r.ImGui_Separator(ctx)
--.... more
Have tried to make my use of r.ImGui_IsKeyPressed from within modal popup logically identical to the above, but I can't immediately see where my use in my script differs. I have confirmed that my modal popup where keypress fails is still focused, so something else is going on. Admittedly, the script with the problem is a 2000+ line monster.

Anyway, I will take your suggestion and try stripping back irrelevant stuff and get to a minimal script still showing the same problem, and share here. Quite possibly, by this process I will discover the problem on my own. In any case, will post an update back here.

Might be a day or 2-3 before I can get the time to do this. Meanwhile, much appreciate your attention and guidance.
inframan is offline   Reply With Quote
Old 05-20-2022, 05:44 AM   #503
smandrap
Human being with feelings
 
smandrap's Avatar
 
Join Date: Feb 2021
Location: Right here
Posts: 1,449
Default

Hello everyone,

could someone help me with trees? I'm making a searchbox for sends and receives (it currently supports only sends). It seems useless given we have awesome drag'n'drop functionality for routing in reaper, but with large templates it really helps.

Anyway:

https://imgur.com/a/e64Cq9s

I'm trying to replicate the folder structure of the project, but i can't get the trees to work. Not their fault obviously, i'm not so experienced and this is my first real attempt at scripting in reaper .

As you can see in the imgur link, if there's a folder in the equation the rest of the tracks are treated as childrens.
Here's the code:

Code:
-----------------------------------
--------------GLOBALS--------------
-----------------------------------
r = reaper

local user_input = ''

local first_frame = true
local run = true
local selection_made = false

local tracks = {}
local tracks_num = 0

local selected_track = r.GetSelectedTrack(0, 1)
local depth_idx = 0

local ctx = r.ImGui_CreateContext('MANUP TESTER')

base_flags = r.ImGui_TreeNodeFlags_OpenOnArrow() | r.ImGui_TreeNodeFlags_DefaultOpen()
leaf_flags = base_flags | r.ImGui_TreeNodeFlags_Leaf() | r.ImGui_TreeNodeFlags_NoTreePushOnOpen()

-------------------------------------
--------------FUNCTIONS--------------
-------------------------------------

function tablelength(T)
    local count = 0
    for _ in pairs(T) do
        count = count + 1
    end
    return count
end

function TrimString(str)
    return str:match '^%s*(.*%S)' or ''
end

function CreateSend(dest)
    sel_track_count = r.CountSelectedTracks(0)

    for i = 0, sel_track_count - 1 do
        current = r.GetSelectedTrack(0, i)
        r.CreateTrackSend(current, dest)
    end
end

-------------------------------
--------------GUI--------------
-------------------------------

function frame()

    r.ImGui_SetNextWindowSize(ctx, 300, 400)
    visible, open = r.ImGui_Begin(ctx, 'SendBox', true)

    if visible then
        local tree_stack = 0

        -- Give focus to the search bar on first frame
        if first_frame then
            r.ImGui_SetKeyboardFocusHere(ctx)
            first_frame = false
        end

        rv, user_input = r.ImGui_InputText(ctx, 'Search', user_input)

        node_flags = base_flags

        for i = 0, tracks_num - 1 do

            -- depth_idx = depth_idx + tracks[i].depth

            -- This happens every frame. It shouldn't. This sucks.
            if string.match(string.lower(tracks[i].name), "(" .. TrimString(user_input) .. ")") then

                if tracks[i].depth == 0 then
                    node_flags = leaf_flags
                end

                if tracks[i].depth > 0 then
                    node_flags = base_flags
                    tree_stack = tree_stack + 1
                end

                r.ImGui_TreeNode(ctx, tracks[i].name, node_flags)

                if tracks[i].depth < 0 then
                    node_flags = leaf_flags
                    r.ImGui_TreePop(ctx)
                end

                r.ImGui_SameLine(ctx)
                r.ImGui_SmallButton(ctx, 'send')

                if r.ImGui_IsItemActivated(ctx) and not selection_made then
                    destination_track = r.GetTrack(0, i)
                    CreateSend(destination_track)

                    selection_made = true
                    run = false
                end

            end

        end

        while tree_stack > 0 do
            r.ImGui_TreePop(ctx)
            tree_stack = tree_stack - 1
        end

        r.ImGui_End(ctx)
    end

    if run and open then
        r.defer(frame)
    else
        r.ImGui_DestroyContext(ctx)
    end

end

--------------------------------
--------------MAIN--------------
--------------------------------

r.Undo_BeginBlock()

for i = 0, r.CountTracks() - 1 do
    current = r.GetTrack(0, i)
    retval, cur_name = r.GetTrackName(current)

    tracks[i] = {
        name = cur_name,
        depth = r.GetMediaTrackInfo_Value(current, 'I_FOLDERDEPTH')
    }
end

tracks_num = tablelength(tracks)

r.defer(frame)

r.Undo_EndBlock("Manup-Create Track Sends", -1)
I clearly don't understand when and how to use TreePop()
Any advice on how to make this work?

Thank you in advance.

Last edited by smandrap; 05-20-2022 at 05:47 AM. Reason: Forgot to say thanks
smandrap is online now   Reply With Quote
Old 05-20-2022, 09:45 AM   #504
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Previously open folders (when TreeNode returns true) must be closed with TreePop before adding a node of the same/lower level:

Code:
local r = reaper
local ctx = r.ImGui_CreateContext('MANUP TESTER')
local BASE_FLAGS = r.ImGui_TreeNodeFlags_OpenOnArrow() | r.ImGui_TreeNodeFlags_DefaultOpen()
local LEAF_FLAGS = BASE_FLAGS | r.ImGui_TreeNodeFlags_Leaf() | r.ImGui_TreeNodeFlags_NoTreePushOnOpen()

local function frame()
  r.ImGui_SetNextWindowSize(ctx, 300, 400, r.ImGui_Cond_FirstUseEver())
  local visible, open = r.ImGui_Begin(ctx, 'SendBox', true)

  if visible then
    local parent_open, depth, open_depth = true, 0, 0

    for i = 0, r.GetNumTracks() - 1 do
      local track = r.GetTrack(nil, i)
      local rv, name = r.GetTrackName(track)
      local depth_delta = r.GetMediaTrackInfo_Value(track, 'I_FOLDERDEPTH')
      depth_delta = math.max(depth_delta, -depth) -- prevent depth + delta being < 0
      local is_folder = depth_delta > 0

      if parent_open or depth <= open_depth then
        -- close previously open deeper folders
        for level = depth, open_depth - 1 do
          r.ImGui_TreePop(ctx)
          open_depth = depth
        end

        r.ImGui_PushID(ctx, i) -- disambiguate if two tracks in the same level have the same name
        parent_open = r.ImGui_TreeNode(ctx, name, is_folder and BASE_FLAGS or LEAF_FLAGS)
        r.ImGui_PopID(ctx)
      end
      
      depth = depth + depth_delta
      if is_folder and parent_open then open_depth = depth end
    end

    for level = 0, open_depth - 1 do
      r.ImGui_TreePop(ctx)
    end

    r.ImGui_End(ctx)
  end

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

r.defer(frame)

Last edited by cfillion; 05-20-2022 at 10:39 AM.
cfillion is offline   Reply With Quote
Old 05-20-2022, 12:53 PM   #505
smandrap
Human being with feelings
 
smandrap's Avatar
 
Join Date: Feb 2021
Location: Right here
Posts: 1,449
Default

Quote:
Originally Posted by cfillion View Post
Previously open folders (when TreeNode returns true) must be closed with TreePop before adding a node of the same/lower level:
Yeah, i got that part in my peabrain, but i couldn't make it work. I took your code and copypasta'd sections of mine to add the send functionality, but i still don't get how it actually works. I don't know how to thank you. Maybe i'll get in touch again with more trouble when i understand how your solution works
smandrap is online now   Reply With Quote
Old 05-21-2022, 12:49 AM   #506
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default

Quote:
Originally Posted by cfillion View Post
keyboard input should behave the same as long as a ImGui windows in the same context has focus, modal or modeless.
I have resolved my issue with ImGui_IsKeyPressed in modal popup.

I discovered that a mouse click anywhere in the popup (titlebar, blank space surrounding ImGui widgets, etc) would then normalize the response to keyboard input. Testing various modifications of my script's code, I eventually isolated the cause to these two lines.
Code:
  local window = r.JS_Window_Find('ImGuiMainWindow', true)
  r.JS_Window_SetFocus(window)
An IMGui button-click in my main ImGui window was running a function which would first run these two lines, then later do the OpenPopup and BeginModal stuff. I had assumed that simply opening the Popup would fully over-ride any effect of this earlier focus assignment, but apparently not.

Once found, the solution was to simply move the offending two lines further back, so that they run before the IMGui button click in my main ImGui window which calls the OpenPopup and BeginModal. Apparently a mouse action within the parent ImGui window, if t occurs after the above and before calling OpenPopup and BeginModal, normalizes the keyboard focus in the subsequently created popup, removing any lingering effect of the earlier JS_Window_SetFocus. Maybe there are some subtle inconsistencies between how the ImGui windows and popups manage window focus and how JS_Window_SetFocus(window) does.

Of course ideally I probably should not be applying JS stuff to ImGui window objects. The use of those two lines was kind of a desperate solution to a different problem. Earlier in this script, I have some user settings gathered with ImGui widgets in the main ImGui window and use these to automatically set up the Reaper metronome/click. This was leaving the metronome dialog window opened, and I could only close it with an kbd escape key or a mouse click elsewhere. The JS_Window_SetFocus was just my clumsy way to get that metronome dialog closed by my script, without user intervention. There are probably better ways to do that.

Anyway, the script now behaves the way I want, and the popup responds to keypresses the way I want, so all's well. Thanks again cfillion !
inframan is offline   Reply With Quote
Old 05-25-2022, 10:27 AM   #507
edkashinsky
Human being with feelings
 
Join Date: Dec 2021
Posts: 61
Default Modal Popups over Reaper window

I've started to learn ImGui extension recently and I ran into a problem. Does the extension have opportunity to create window that blocks reaper window events behind? Good example is native renaming window in reaper - when it shows, you are not able to drop selection of items, move cursor, just can only zoom in/out current position. I would like to have the same or at least block any main window events until my window closes. Is it possible?
edkashinsky is offline   Reply With Quote
Old 05-25-2022, 10:58 AM   #508
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

All ReaImGui windows are modeless (in the traditional sense–imgui modals only block other imgui windows in the same context).

On Windows you could simulate a modal by disabling inputs on background windows (probably not a good idea anyway vs hardening the script to allow for changing project state while it's running):
Code:
reaper.JS_Window_Enable(reaper.GetMainHwnd(), false) // no effect on macOS, didn't check on Linux
cfillion is offline   Reply With Quote
Old 05-25-2022, 01:08 PM   #509
edkashinsky
Human being with feelings
 
Join Date: Dec 2021
Posts: 61
Default

Quote:
Originally Posted by cfillion View Post
All ReaImGui windows are modeless (in the traditional sense–imgui modals only block other imgui windows in the same context).

On Windows you could simulate a modal by disabling inputs on background windows (probably not a good idea anyway vs hardening the script to allow for changing project state while it's running):
Code:
reaper.JS_Window_Enable(reaper.GetMainHwnd(), false) // no effect on macOS, didn't check on Linux
Oh, I see, thank you! But what if I open fake-fullscreen window like background with opacity 0% and my window will be over it. Is it possible?
edkashinsky is offline   Reply With Quote
Old 05-25-2022, 01:18 PM   #510
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Yes, that will be also possible once ReaImGui v0.7 is released with transparency implemented (almost ready, waiting for dear imgui 1.88 to finalize some changes).

You can give it a try early if you want, here's the latest dev build fresh off the master branch: https://ci.appveyor.com/project/cfil...uilds/43636164 (pick your operating system then grab the dll/dylib/so in the Artifacts tab).

Last edited by cfillion; 05-25-2022 at 01:26 PM.
cfillion is offline   Reply With Quote
Old 05-26-2022, 06:29 AM   #511
edkashinsky
Human being with feelings
 
Join Date: Dec 2021
Posts: 61
Default

Quote:
Originally Posted by cfillion View Post
Yes, that will be also possible once ReaImGui v0.7 is released with transparency implemented (almost ready, waiting for dear imgui 1.88 to finalize some changes).

You can give it a try early if you want, here's the latest dev build fresh off the master branch: https://ci.appveyor.com/project/cfil...uilds/43636164 (pick your operating system then grab the dll/dylib/so in the Artifacts tab).
Wow, great news! I'm just in time) Sure, but where can I get documentation/examples about transparency stuff?
edkashinsky is offline   Reply With Quote
Old 05-26-2022, 08:47 AM   #512
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by edkashinsky View Post
Wow, great news! I'm just in time) Sure, but where can I get documentation/examples about transparency stuff?
Demo script > Window options > No background and Demo > Configuration > Style > Colors

(Dev build above requires the latest demo code: https://github.com/cfillion/reaimgui...mples/demo.lua)

cfillion is offline   Reply With Quote
Old 05-27-2022, 12:26 AM   #513
edkashinsky
Human being with feelings
 
Join Date: Dec 2021
Posts: 61
Default

Quote:
Originally Posted by cfillion View Post
Demo script > Window options > No background and Demo > Configuration > Style > Colors

(Dev build above requires the latest demo code: https://github.com/cfillion/reaimgui...mples/demo.lua)

That's amazing! Thanks a lot!
edkashinsky is offline   Reply With Quote
Old 06-02-2022, 06:54 AM   #514
kartalex
Human being with feelings
 
Join Date: Dec 2015
Posts: 172
Default


Last edited by kartalex; 06-02-2022 at 07:00 AM. Reason: Deleted question because of my own mistake
kartalex is offline   Reply With Quote
Old 06-13-2022, 10:58 AM   #515
McSound
Human being with feelings
 
McSound's Avatar
 
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 282
Default

Is there a little, a tiny chance that cyrillic(utf8) support would be added to ReaImGui? Or maybe there's a workaround?
McSound is offline   Reply With Quote
Old 06-13-2022, 11:17 AM   #516
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

UTF-8 is fully supported but font rendering is, for now, limited to the Basic Latin and Latin Supplement Unicode blocks. https://github.com/cfillion/reaimgui...ent-1023143021
cfillion is offline   Reply With Quote
Old 06-13-2022, 10:53 PM   #517
McSound
Human being with feelings
 
McSound's Avatar
 
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 282
Default

So, the only gui which could display text in full unicode is gfx functions?
McSound is offline   Reply With Quote
Old 06-14-2022, 08:53 AM   #518
nikolalkc
Human being with feelings
 
nikolalkc's Avatar
 
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 338
Default

Quote:
Originally Posted by cfillion View Post
Adding bitmap image support is on the list of things I want to do. No ETA since it's going to be a lot of work...

Currently, flat vector icons/images can be drawn using OpenType TT fonts (with color layers in COLR/CPAL format, v0.5.3+).



(At this time, ReaImGui rasterizes glyphs only from the Basic Latin and Latin Supplement Unicode blocks.)
How would one do this actually? Specifically, I have custom svg icons I want to display. Should I create a font? A small example would be much appreciated (or a link to it, cause I couldn't find one).

Thanks a lot.
__________________
Youtube | Website | Twitter
nikolalkc is offline   Reply With Quote
Old 06-14-2022, 09:02 AM   #519
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

I used the demo of this software to convert REAPER's svg logo into CPAL/COLR layers: https://glyphsapp.com/learn/creating...oft-color-font.
cfillion is offline   Reply With Quote
Old 06-14-2022, 03:31 PM   #520
McSound
Human being with feelings
 
McSound's Avatar
 
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 282
Default

Sorry, bump!
Quote:
Originally Posted by McSound View Post
So, the only gui which could display text in full unicode is gfx functions?
And another question: what if I use these custom glyphs and make my cirillic symbols of them with that utility? I know, it' absurd, but just in theory, could it work that way?
McSound 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 02:59 PM.


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