|
|
|
02-20-2023, 04:13 AM
|
#801
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by FeedTheCat
Uups, that works So it's some sort of tiling, very cool!
|
Yes, for ReaImGui windows. Not sure whether it will tile with other windows.
|
|
|
02-21-2023, 05:03 AM
|
#802
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
ReaImGui just showcased on ReaLinks.net, include two minimal starter template ⭐
|
|
|
02-21-2023, 06:20 PM
|
#803
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by X-Raym
ReaImGui just showcased on ReaLinks.net, include two minimal starter template ⭐
|
Nice, thanks! Didn't realize it's already been 2 years!
Some improvements suggestions for the examples:
1. The first frame should wait until the next defer cycle. Otherwise it gets twice the contents: https://forum.cockos.com/showthread.php?p=2638717.
Code:
-Run()
+reaper.defer(Run)
2. Windows virtual key codes are deprecated. Support will go away if (when?) dear imgui removes support of what it calls "legacy keys".
3. DestroyContext is no longer required nor recommended. It's a leftover from the very early days. I should have removed it in v0.5 when it lost its usefulness. Now I'm stuck with it because it used to be a core function used in every script (including non-Lua)... Scripts can just stop and ReaImGui will gracefully cleanup all resources it used (as you've suggested back in the v0.1 days ). EDIT: To be precise, the issue it solved wasn't cleanup but rather a delay before the window would close. That went away with v0.5's multi-window support.)
Code:
-if process or not imgui_open or reaper.ImGui_IsKeyPressed(ctx, 27) then -- 27 is escaped key
- reaper.ImGui_DestroyContext(ctx)
-else
+if imgui_open and not reaper.ImGui_IsKeyPressed(ctx, reaper.ImGui_Key_Escape()) then
reaper.defer(Run)
end
4. SetNextWindowBgAlpha is a simpler way to set the background opaque
5. That's a scary amount of code for a "minimal" or "simple" example. Far from the absolute minimum which is:
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local function loop()
reaper.ImGui_Text(ctx, 'Hello world!')
reaper.defer(loop)
end
reaper.defer(loop)
(Although a minimal example meant to be reused as a starting point for real scripts should at least create one proper window with Begin/End, like the 12 lines Example #1 in the first post of this thread.)
Last edited by cfillion; 02-21-2023 at 07:11 PM.
|
|
|
02-22-2023, 02:19 AM
|
#804
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by cfillion
3. DestroyContext is no longer required nor recommended.
4. SetNextWindowBgAlpha is a simpler way to set the background opaque
|
3. Thanks.
4. It won't help if you want to get different color.
@X-Raym, you can place this alpha thing just before begin, so it will look like:
Code:
reaper.ImGui_SetNextWindowBgAlpha(ctx, 1)
local imgui_visible, imgui_open = reaper.ImGui_Begin(ctx, input_title, true, reaper.ImGui_WindowFlags_NoCollapse())
|
|
|
03-07-2023, 12:47 PM
|
#805
|
Human being with feelings
Join Date: Jun 2021
Location: Moscow, Russia
Posts: 280
|
No problem at all, just informing that "Graphic renderer: OpenGL" option crashes Reaper when I close Color Palette script or Item Sampler. Direct3D behaves ok. I have installed last Microsoft VC redist. Reaper v6.77, ReaImGui v0.8.4.
|
|
|
03-07-2023, 02:58 PM
|
#806
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Thanks for reporting that! It's an important bug if it crashes REAPER.
EDIT: Bug was introduced in 0.8.4's rework of how it loads OpenGL on Windows. 0.8.3 should work fine.
Last edited by cfillion; 03-07-2023 at 03:38 PM.
|
|
|
03-08-2023, 07:09 PM
|
#807
|
Human being with feelings
Join Date: Dec 2015
Posts: 172
|
Hi, cfillion!
Is it possible to dock ImGui window in MIDI Editor, like track list or media item lane docked?
|
|
|
03-09-2023, 12:23 AM
|
#808
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by kartalex
Hi, cfillion!
Is it possible to dock ImGui window in MIDI Editor, like track list or media item lane docked?
|
No, it is Reaper's limitation.
|
|
|
03-17-2023, 10:15 AM
|
#809
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Is there a way to manage the default font size? like imgui.setfontsize?
|
|
|
03-17-2023, 10:24 AM
|
#810
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Code:
local my_font = reaper.ImGui_CreateFont('sans-serif', pixelHeight)
reaper.ImGui_Attach(ctx, my_font)
local function frame()
reaper.ImGui_PushFont(ctx, my_font)
-- anything here will use my_font (from entire windows to one fragment of text)
reaper.ImGui_PopFont(ctx)
end
Changing the size of the default font is not exposed because it's a bitmap font (wouldn't be pretty).
|
|
|
03-18-2023, 11:05 AM
|
#811
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by cfillion
Code:
local my_font = reaper.ImGui_CreateFont('sans-serif', pixelHeight)
reaper.ImGui_Attach(ctx, my_font)
local function frame()
reaper.ImGui_PushFont(ctx, my_font)
-- anything here will use my_font (from entire windows to one fragment of text)
reaper.ImGui_PopFont(ctx)
end
Changing the size of the default font is not exposed because it's a bitmap font (wouldn't be pretty).
|
Great! thanks so much! understand about the pixel font uglyness , that would imply loading a different font for every size...
|
|
|
03-18-2023, 11:32 AM
|
#812
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
The process would be the same with the default bitmap font: its glyph would have to be re-rasterized at the new size like any other font.
Unused fonts should be detached to free resources.
Code:
local ImGui = {}
for name, func in pairs(reaper) do
name = name:match('^ImGui_(.+)$')
if name then ImGui[name] = func end
end
local ctx = ImGui.CreateContext('My script')
local zoomLevel, fontSize, font = 1
local function setFontSize(newSize)
if newSize == fontSize then return end
if font then ImGui.Detach(ctx, font) end
font, fontSize = ImGui.CreateFont('sans-serif', newSize), newSize
ImGui.Attach(ctx, font)
end
local function frame()
setFontSize(13 * zoomLevel // 1)
ImGui.PushFont(ctx, font)
ImGui.Text(ctx, 'Hello, World!')
ImGui.PopFont(ctx)
zoomLevel = zoomLevel + ImGui.GetMouseWheel(ctx)
zoomLevel = math.max(0.3, math.min(5, zoomLevel))
reaper.defer(frame)
end
reaper.defer(frame)
(Currently attaching a font rasterizes the entire Latin character set which is expensive. In the future it should become possible for dear imgui and ReaImGui to only do that for characters that are used. At that point font creation will become cheap without changing the API beyond lifting timing and attachment restrictions.)
Last edited by cfillion; 03-18-2023 at 11:47 AM.
|
|
|
03-22-2023, 07:51 PM
|
#813
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Released version 0.8.5:
Code:
• Add a new API for running EEL programs
• Collect all errors in a single report window
• Disable ConfigVar_InputTrickleEventQueue by default
• Fix duplicate error reports when failing to end a frame
• Remove global object count limit (limit context attachments instead)
• Update to dear imgui v1.89.4 (release notes)
• macOS: fix stuck keys when undocking while a key is down
• macOS: follow the "Control+left-click emulates right-click" setting [t=277197]
• Windows: fix a regression in the OpenGL renderer causing crashes [p=2656531]
Documentation:
• Add a table of contents of the entire category tree
• Insert links for references with trailing wildcards (eg. StyleVar_*)
gfx2imgui:
• Add REAPER v6.75's gfx.getchar second return value
• Implement (partial) blit rotation
• More compatibility improvements and performance optimizations
API changes:
• Add 'callback' parameter to InputText* and SetNextWindowSizeConstraints
• Add a boolean return value to BeginTooltip
• Add ConfigVar_DebugBeginReturnValue{Once,Loop}
• Add CreateFunctionFromEEL and Function_*
• Add InputTextFlags_Callback{Always,CharFilter,Completion,Edit,History}
• Rename {Push,Pop}AllowKeyboardFocus to {Push,Pop}TabStop
EEL functions and callbacks
This new API allows creating EEL programs from any ReaScripting language. They can be given to ReaImGui functions such as InputText and SetNextWindowSizeConstraints to implement custom character filters, query or modify edit state (cursor & selection position, change text during edition) and custom window size limit logic.
- Demo > Widgets > Text Input > Filtered Text Input
- Demo > Widgets > Text Input > Completion, History, Edit Callbacks
- Demo > Examples > Console
- Demo > Examples > Constrained-resizing window
They can also be used completely standalone even in scripts otherwise not using ReaImGui. This can be useful as EEL is often a lot faster than Lua.
An example extracted from gfx2imgui:
Code:
local sort2d = ImGui.CreateFunctionFromEEL([[
i = 0;
while(i < n_points) (
x = points[i]; y = points[i + 1]; j = i - 2;
angle = atan2(y - center.y, x - center.x);
while(j >= 0 &&
atan2(points[j + 1] - center.y, points[j] - center.x) > angle) (
points[j + 2] = points[j]; points[j + 3] = points[j + 1];
j = j - 2;
);
points[j + 2] = x; points[j + 3] = y;
i += 2;
);
]])
Code:
local points = reaper.new_array({ ... })
local center_x, center_y = ...
ImGui.Function_SetValue(sort2d, 'center.x', center_x)
ImGui.Function_SetValue(sort2d, 'center.y', center_y)
ImGui.Function_SetValue(sort2d, 'n_points', #points)
ImGui.Function_SetValue_Array(sort2d, 'points', points)
ImGui.Function_Execute(sort2d)
ImGui.Function_GetValue_Array(sort2d, 'points', points)
-- points are now sorted ~8x faster than the previous implementation in Lua
Rotation in gfx2imgui's gfx.blit
Partially implemented: missing in text, gradients and the clipping region when blitting (it's auto-disabled when blitting to another offscreen buffer as a workaround).
BeginTooltip's return value
Version 1.89.4 of dear imgui added a boolean return value to BeginTooltip for consistency with the other Begin* functions. EndTooltip should only be called when it returns true. (Although, for the time being, it always does.)
Quote:
Originally Posted by dear imgui 1.89.4 release notes
Tooltips: Added 'bool' return value to BeginTooltip() for API consistency. Please only submit contents and call EndTooltip() if BeginTooltip() returns true. In reality the function will currently always return true, but further changes down the line may change this, best to clarify API sooner. Updated demo code accordingly.
|
Last edited by cfillion; 03-22-2023 at 09:04 PM.
|
|
|
03-24-2023, 09:21 PM
|
#814
|
Human being with feelings
Join Date: Jan 2023
Posts: 57
|
Brilliant! I'm really glad that I found this during my search for GUI creation tools and for providing a slick approach for GUI development in the DAW (instead of the limited "bring music to the IDE" approach.)
I don't know anything about GUI development, btw; haven't ever made one and found it frustratingly complex on all sorts of levels, but this bypasses all of the problems I was running into and I* can finally make what I've been cooking up in my head for a long time.
*Not just me -- I have the ambition to morph the accepted norm in a certain discussion group from [number and math discussions but no sound] to [audio_example.ogg], [number and math explanation], and a DAW integrated, Python-enabled (!) workflow is way better suited to the task than anything I could have imagined being possible (much less already existing).
|
|
|
03-26-2023, 07:55 PM
|
#815
|
Human being with feelings
Join Date: Jan 2019
Location: China
Posts: 654
|
Loading images can cause the reaper software to crash.
Code:
local ctx = reaper.ImGui_CreateContext('My script')
function loop2()
local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
if visible then
ImGui_Image = reaper.ImGui_CreateImage('\\REAPER\\test.JPG')
reaper.ImGui_Image(ctx, ImGui_Image,70,50)
reaper.ImGui_End(ctx)
end
if open then
reaper.defer(loop2)
end
end
reaper.defer(loop2)
|
|
|
03-26-2023, 09:43 PM
|
#816
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Thanks! Will investigate and fix the crash.
The script should not create a new image every frame (even without the crash bug, it's still very inefficient):
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local img = reaper.ImGui_CreateImage([[\REAPER\test.JPG]])
function loop()
local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
if visible then
reaper.ImGui_Image(ctx, img, reaper.ImGui_Image_GetSize(img))
reaper.ImGui_End(ctx)
end
if open then
reaper.defer(loop)
end
end
reaper.defer(loop)
|
|
|
03-27-2023, 01:46 AM
|
#817
|
Human being with feelings
Join Date: Jan 2019
Location: China
Posts: 654
|
Quote:
Originally Posted by cfillion
Thanks! Will investigate and fix the crash.
The script should not create a new image every frame (even without the crash bug, it's still very inefficient):
|
It's normal now. Thank you for your help!
|
|
|
03-29-2023, 08:19 AM
|
#818
|
Human being with feelings
Join Date: Jan 2019
Location: China
Posts: 654
|
An error will be reported when opening after folding:
C:\Reaper Dev\Scripts\TEST 2.lua:7: ImGui_Image_GetSize: expected a valid ImGui_Image*, got 000000000C91E140
|
|
|
03-29-2023, 08:23 AM
|
#819
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,597
|
Quote:
Originally Posted by dangguidan
An error will be reported when opening after folding:
C:\Reaper Dev\Scripts\TEST 2.lua:7: ImGui_Image_GetSize: expected a valid ImGui_Image*, got 000000000C91E140
|
Code:
reaper.ImGui_Attach( ctx, img )
after CreateImage, to extend its lifetime to scripts lifetime (it is discarded by garbage collector after not using it).
(I seem smart but its just I had similar issue and got answer )
Last edited by Sexan; 03-29-2023 at 08:29 AM.
|
|
|
03-29-2023, 07:12 PM
|
#820
|
Human being with feelings
Join Date: Jan 2019
Location: China
Posts: 654
|
Quote:
Originally Posted by Sexan
Code:
reaper.ImGui_Attach( ctx, img )
after CreateImage, to extend its lifetime to scripts lifetime (it is discarded by garbage collector after not using it).
(I seem smart but its just I had similar issue and got answer )
|
It's all right now, thank you!
|
|
|
03-30-2023, 06:17 PM
|
#821
|
Human being with feelings
Join Date: Sep 2019
Location: Austria
Posts: 443
|
Is the disabled "tap to click" on MacBook's Trackpad with 0.8.5 intended?
With 0.8.4 it works.
|
|
|
03-30-2023, 06:37 PM
|
#822
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by OLSHALOM
Is the disabled "tap to click" on MacBook's Trackpad with 0.8.5 intended?
|
Not intended, does it comes back in the demo script if you enable "ConfigVar_InputTrickleEventQueue" under Configuration > Configuration > General?
|
|
|
03-31-2023, 12:11 AM
|
#823
|
Human being with feelings
Join Date: Sep 2019
Location: Austria
Posts: 443
|
Quote:
Originally Posted by cfillion
Not intended, does it comes back in the demo script if you enable "ConfigVar_InputTrickleEventQueue" under Configuration > Configuration > General?
|
Yes, it comes back when I enable it in the Demo.
Is this the way to do it properly inside another script?:
reaper.ImGui_SetConfigVar(ctx, reaper.ImGui_ConfigVar_InputTrickleEventQueue(), 1)
I put it here:
Code:
local function loop()
reaper.ImGui_PushFont(ctx, sans_serif)
reaper.ImGui_SetConfigVar(ctx, reaper.ImGui_ConfigVar_InputTrickleEventQueue(), 1)
local window_flags = reaper.ImGui_WindowFlags_None() | reaper.ImGui_WindowFlags_MenuBar()
local style_color_n = push_style_color()
local style_var_m = push_style_var()
reaper.ImGui_SetNextWindowSize(ctx, 400, 140, reaper.ImGui_Cond_FirstUseEver())
visible, open = reaper.ImGui_Begin(ctx, 'ColorPalette', true, window_flags)
etc....
|
|
|
03-31-2023, 12:17 AM
|
#824
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by OLSHALOM
Yes, it comes back when I enable it in the Demo.
|
Thanks for reporting that regression! I'll think about it and either revert that change or add some logic to not lose clicks shorter than 30ms (used to be the case until v0.6)...
Quote:
Originally Posted by OLSHALOM
Is this the way to do it properly inside another script?:
|
Yes, that's fine. It can also be done once, after CreateContext.
|
|
|
03-31-2023, 12:41 AM
|
#825
|
Human being with feelings
Join Date: Sep 2019
Location: Austria
Posts: 443
|
Quote:
Originally Posted by cfillion
Yes, that's fine. It can also be done once, after CreateContext.
|
Ah, that's the way to go. Works fine over here. Thank you very much.
|
|
|
03-31-2023, 12:19 PM
|
#826
|
Human being with feelings
Join Date: Jan 2023
Posts: 57
|
I'm trying to get the whole Lua demo script into Python, though maybe I'm making it harder than it should be! I tried using py-lua-parser on the Lua script, (...starting from "I didn't know what a parser was a few days ago, or any other relevant stuff"), found a bug with the parser, hopefully now getting back down to business.
But if I'm duplicating something that's already been done or that you're working on still, that would probably be good to know about (and visa versa; if I do get this working I'll of course post the translated Python demo script for review).
Thanks!
Star
|
|
|
04-06-2023, 01:26 PM
|
#827
|
Human being with feelings
Join Date: Jan 2023
Posts: 57
|
Quote:
Originally Posted by cfillion
Released version 0.8.5:
Code:
• Add a new API for running EEL programs
An example extracted from gfx2imgui:
Code:
local sort2d = ImGui.CreateFunctionFromEEL([[
i = 0;
while(i < n_points) (
x = points[i]; y = points[i + 1]; j = i - 2;
angle = atan2(y - center.y, x - center.x);
while(j >= 0 &&
atan2(points[j + 1] - center.y, points[j] - center.x) > angle) (
points[j + 2] = points[j]; points[j + 3] = points[j + 1];
j = j - 2;
);
points[j + 2] = x; points[j + 3] = y;
i += 2;
);
]])
Code:
local points = reaper.new_array({ ... })
local center_x, center_y = ...
ImGui.Function_SetValue(sort2d, 'center.x', center_x)
ImGui.Function_SetValue(sort2d, 'center.y', center_y)
ImGui.Function_SetValue(sort2d, 'n_points', #points)
ImGui.Function_SetValue_Array(sort2d, 'points', points)
ImGui.Function_Execute(sort2d)
ImGui.Function_GetValue_Array(sort2d, 'points', points)
-- points are now sorted ~8x faster than the previous implementation in Lua
|
Is it possible to do this from Python?
Do I just wrap like """code""" (instead of the [[ code ]] used in Lua)?
Can the wrapped function also call ReaScript API funcs, or do those need to be encapsulated separately? I know that sounds dumb; the particular functions I'm trying to use don't seem to work in Python. (RPR_MIDI_GetAllEvts, which I can find exactly zero Python examples of)
|
|
|
04-06-2023, 06:22 PM
|
#828
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by Starshine
Is it possible to do this from Python?
Do I just wrap like """code""" (instead of the [[ code ]] used in Lua)?
|
Yes, it's available in all ReaScript/extension languages (Lua/EEL/Python/C++).
Quote:
Originally Posted by Starshine
Can the wrapped function also call ReaScript API funcs
|
No, only EEL's basic math and string functions plus a few ReaImGui-specific ones can be used.
|
|
|
04-15-2023, 09:07 PM
|
#829
|
Human being with feelings
Join Date: Jan 2015
Posts: 225
|
Quote:
Originally Posted by dangguidan
Loading images can cause the reaper software to crash.
Code:
local ctx = reaper.ImGui_CreateContext('My script')
function loop2()
local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
if visible then
ImGui_Image = reaper.ImGui_CreateImage('\\REAPER\\test.JPG')
reaper.ImGui_Image(ctx, ImGui_Image,70,50)
reaper.ImGui_End(ctx)
end
if open then
reaper.defer(loop2)
end
end
reaper.defer(loop2)
|
Can confirm same bug. Seems like the image definition needs to be outside of the window section?
|
|
|
04-15-2023, 10:14 PM
|
#830
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by mazegeek999
Can confirm same bug. Seems like the image definition needs to be outside of the window section?
|
Next version will have the fix for that crash (GPU texture manager gets confused in some cases when it needs to add+remove multiple textures in the same frame).
However the snippet is also incorrect as creating a whole new image every frame is slow. Objects instantiated with a CreateXYZ function should be reused as long as possible. As a general rule of thumb:
If the image is used all the time (for demonstration purpose only, in real scripts images would always be conditionally used, eg. between a window's Begin/End):
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local img = reaper.ImGui_CreateImage('test.png')
local function loop()
reaper.ImGui_Image(ctx, img, reaper.ImGui_Image_GetSize(img))
reaper.defer(loop)
end
reaper.defer(loop)
If used often (keep loaded in RAM even when unused):
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local img = reaper.ImGui_CreateImage('test.png')
reaper.ImGui_Attach(ctx, img) -- link the lifetime of the image with the context
-- can use Detach() later to unlink if condition becomes less likely and allowing the image to unload is wanted
local function loop()
if blue_sky then
reaper.ImGui_Image(ctx, img, reaper.ImGui_Image_GetSize(img))
end
reaper.defer(loop)
end
reaper.defer(loop)
If used only sometimes (reload when necessary):
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local img
local function loop()
if blue_moon then
if not reaper.ImGui_ValidatePtr(img, 'ImGui_Image*') then
-- create the image on first use or re-create it after it has been garbage-collected due to unuse
img = reaper.ImGui_CreateImage('test.png')
end
reaper.ImGui_Image(ctx, img, reaper.ImGui_Image_GetSize(img))
end
reaper.defer(loop)
end
reaper.defer(loop)
Last edited by cfillion; 04-16-2023 at 07:23 AM.
|
|
|
04-16-2023, 01:19 AM
|
#831
|
Human being with feelings
Join Date: Jan 2015
Posts: 225
|
Solid advice. Makes sense, thanks!
|
|
|
04-16-2023, 10:37 AM
|
#832
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
addline vs polyline
addline
polyline
Polyline API has a less significant impact on the CPU compared to building a spectrum with jointed lines, but it looks pretty weird and I'm guessing it's because of antialiasing . Is there a way to make polyline look better for an application like this?
thanks
|
|
|
04-16-2023, 09:56 PM
|
#833
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Seems to be a known issue with sharp angles (slightly improved in v1.83):
https://github.com/ocornut/imgui/issues/3366
https://github.com/ocornut/imgui/pull/2964
A workaround proposed in this comment is to split the calls to AddPolyline at acute angles.
(Regarding the CPU usage of separate AddLine calls and if iterating over the same reaper_array of points: converting to a Lua table should be faster. Indexing a reaper_array in Lua has a lot of overhead.)
EDIT: PlotLines() should render a graph like that correctly (given an array of linearly spaced values). (And with some styling can also look the same as the manually-drawn lines.)
Last edited by cfillion; 04-17-2023 at 03:36 AM.
|
|
|
04-17-2023, 02:49 AM
|
#834
|
Human being with feelings
Join Date: Mar 2016
Location: Italy
Posts: 322
|
Quote:
Originally Posted by cfillion
Seems to be a known issue with sharp angles (slightly improved in v1.83):
https://github.com/ocornut/imgui/issues/3366
https://github.com/ocornut/imgui/pull/2964
A workaround proposed in this comment is to split the calls to AddPolyline at acute angles.
(Regarding the CPU usage of separate AddLine calls and if iterating over the same reaper_array of points: converting to a Lua table should be faster. Indexing a reaper_array in Lua has a lot of overhead.)
EDIT: PlotLines() should render a graph like that correctly (given an array of linearly spaced points). (And with some styling can also look the same as the manually-drawn lines.)
|
Cool, I never tried plotlines function, I need to check it out.
I might try that first instead of using more math to correct polyline
thanks so much
|
|
|
04-23-2023, 01:39 AM
|
#835
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Released version 0.8.6:
Code:
• Add a button to restore default settings in the preferences page
• Don't give focus to the first setting when opening the preferences page [t=277729]
• Enable docking by default (ConfigFlags_DockingEnable) and expose a user setting
• Fix 1-frame flicker after uploading a new texture
• Fix a use-after-free when calling an EEL function after an assertion failure
• Fix crashes when removing/uploading textures every frame [p=2663379]
• Fix name conflict between the ImGui_Image type and function in the C++ header
• Revert "disable ConfigVar_InputTrickleEventQueue by default" [p=2664743]
• Update to dear imgui v1.89.5 (release notes)
API changes:
• Move the C++ API functions to a ImGui namespace
v0.8.6.1 hotfix:
Code:
• macOS: restore accidentally disabled clipboard I/O
Last edited by cfillion; 04-23-2023 at 09:38 AM.
|
|
|
05-06-2023, 03:40 AM
|
#836
|
Human being with feelings
Join Date: Sep 2019
Location: Austria
Posts: 443
|
Is it possible to prevent a popup from being closed when I have mouseinput inside the "Main window"?
Last edited by OLSHALOM; 05-06-2023 at 03:53 AM.
|
|
|
05-06-2023, 04:05 AM
|
#837
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by OLSHALOM
Is it possible to prevent a popup from being closed when I have mouseinput inside the "Main window"?
|
Use popup modal:
Code:
boolean retval, boolean p_open = reaper.ImGui_BeginPopupModal(ImGui_Context ctx, string name, boolean p_open = nil, number flags = WindowFlags_None)
Block every interaction behind the window, cannot be closed by user, add a dimming background, has a title bar. Return true if the modal is open, and you can start outputting to it.
|
|
|
05-06-2023, 04:14 AM
|
#838
|
Human being with feelings
Join Date: Sep 2019
Location: Austria
Posts: 443
|
Quote:
Originally Posted by vitalker
Use popup modal:
Code:
boolean retval, boolean p_open = reaper.ImGui_BeginPopupModal(ImGui_Context ctx, string name, boolean p_open = nil, number flags = WindowFlags_None)
Block every interaction behind the window, cannot be closed by user, add a dimming background, has a title bar. Return true if the modal is open, and you can start outputting to it.
|
But using PopupModal prevent mouse input for all other windows, right?
|
|
|
05-06-2023, 04:16 AM
|
#839
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,333
|
Quote:
Originally Posted by OLSHALOM
But using PopupModal prevent mouse input for all other windows, right?
|
Yes. It's for windows where action is demanded and can't be skipped.
|
|
|
05-06-2023, 04:43 AM
|
#840
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Or have two regular windows to allow mouse input everywhere.
Code:
local ctx = reaper.ImGui_CreateContext('My script')
local openSecondWnd = false
local function loop()
local visible, open = reaper.ImGui_Begin(ctx, 'My window', true)
if visible then
local rv
rv, openSecondWnd = reaper.ImGui_Checkbox(ctx, 'Show second window', openSecondWnd)
reaper.ImGui_End(ctx)
end
if not open then return end
if openSecondWnd then
visible, openSecondWnd = reaper.ImGui_Begin(ctx, 'My second window', true)
if visible then
reaper.ImGui_Text(ctx, 'Hello from the second window!')
reaper.ImGui_End(ctx)
end
end
reaper.defer(loop)
end
reaper.defer(loop)
Last edited by cfillion; 05-07-2023 at 03:44 AM.
Reason: typo
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 10:51 PM.
|