Old 03-29-2021, 03:21 AM   #81
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,797
Default

It would be really nice if someone could make an effects rack like ableton's midi macros, with parameter modulation/link and min-max for each parameter as shown in this video.

https://www.youtube.com/watch?v=NOufylM_AEA
Vagelis is offline   Reply With Quote
Old 03-29-2021, 03:27 AM   #82
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

I think with lbx stripper you can do. But Mpl build some scripts just for macros, have you checked it out?
daniellumertz is online now   Reply With Quote
Old 03-29-2021, 03:43 AM   #83
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,797
Default

Quote:
Originally Posted by daniellumertz View Post
I think with lbx stripper you can do. But Mpl build some scripts just for macros, have you checked it out?
I 've tried both of them, With lbx stripper it takes too much time, mpl's mapping panel is the closest to this idea, but i think the min-max sliders doesn't work the way they should and the macro knob is not changing the parameter.
I would expect to set a proper min-max range without moving the parameter and then with the macro knob to move the parameter between this range. (except if i'm doing something wrong here)
Now the min-max is moving the parameter and the macro knob doesn't do nothing.
The positive thing is that when showing the macro envelope it has a proper range between min-max.

EDIT: Made a gif:
The macro knob is not moving the parameter, and not sure if it's a true min-max range or moving both min-max at the same time as it is already possible with parameter link's scale.
I'd like to adjust separately min or max but not sure if it's possible


Last edited by Vagelis; 03-29-2021 at 03:57 AM.
Vagelis is offline   Reply With Quote
Old 03-29-2021, 10:16 AM   #84
SNJUK2
Human being with feelings
 
SNJUK2's Avatar
 
Join Date: Feb 2017
Location: Zhytomyr,Ukraine
Posts: 449
Default

Quote:
Originally Posted by Vagelis View Post

I make this example - all works fine
SNJUK2 is offline   Reply With Quote
Old 03-29-2021, 10:20 AM   #85
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Maybe let's focus on ReaImGUI here :P


@Vagelis
You may open a new thread fo this particular issue, it will have more visibility!
X-Raym is offline   Reply With Quote
Old 03-29-2021, 02:19 PM   #86
Vagelis
Human being with feelings
 
Vagelis's Avatar
 
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,797
Default

I apologize for going out of topic, it first started as an idea for a script relative to RealmGUI.
Vagelis is offline   Reply With Quote
Old 04-02-2021, 11:56 PM   #87
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

@mods : Please make this thread sticky!

I am having my go with this. Great tool!!


A couple of questions:
- Is there any way to define how much of the context's width will an item's label take?
- How can I make a tooltip appear only when I hover over the label of an item? I use this function directly after an item:
Code:
local function TooltipHelp( desc )
  if reaper.ImGui_IsItemHovered(ctx) then
    reaper.ImGui_BeginTooltip(ctx)
    reaper.ImGui_PushTextWrapPos(ctx, fontsize * 20)
    reaper.ImGui_Text(ctx, desc)
    reaper.ImGui_PopTextWrapPos(ctx)
    reaper.ImGui_EndTooltip(ctx)
  end
end
But it makes the tooltip appear over any part of the item (over the slider, or the combo etc)
__________________
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 04-03-2021, 01:24 AM   #88
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
- Is there any way to define how much of the context's width will an item's label take?
The trick would be the same for having label on the left: use a text element and then on sameline use your input but without label (just unique identifier starting with ## instead)
It may also help your tooltip case


Though on tootlip, if you need something basic, it would be best to choose reaper tooltip cause it can extend outside the script window boundaries in an elegant way.


Also according to a minimal poll on slack, tootltip on a question mark symbol after the input just like in the reaimgui demo script seems more elegant cause it make obvious that there is a tootltip available if needed.
X-Raym is offline   Reply With Quote
Old 04-03-2021, 10:05 AM   #89
Arthur McArthur
Human being with feelings
 
Arthur McArthur's Avatar
 
Join Date: Sep 2016
Location: Toronto
Posts: 744
Default

Quote:
Originally Posted by amagalma View Post
- Is there any way to define how much of the context's width will an item's label take?
You can use: reaper.ImGui_PushItemWidth(ctx, width) before the item to define the width

Here's a simple example of a tooltip on hover from Daniel's code:

Code:
r = reaper
local click_count, text = 0, ''
local ctx = reaper.ImGui_CreateContext('Tooltip', 211, 211)
layer = 1

function print(a)
    reaper.ShowConsoleMsg('\n'..tostring(a))
end

function HelpMarker(desc) -- Function to show a ?
    reaper.ImGui_TextDisabled(ctx, '(?)')
    if reaper.ImGui_IsItemHovered(ctx) then
      reaper.ImGui_BeginTooltip(ctx)
      reaper.ImGui_PushTextWrapPos(ctx, reaper.ImGui_GetFontSize(ctx) * 35.0)
      reaper.ImGui_Text(ctx, desc)
      reaper.ImGui_PopTextWrapPos(ctx)
      reaper.ImGui_EndTooltip(ctx)
    end
end

function ToolTip(text)
    if reaper.ImGui_IsItemHovered(ctx) then
        reaper.ImGui_BeginTooltip(ctx)
        reaper.ImGui_PushTextWrapPos(ctx, reaper.ImGui_GetFontSize(ctx) * 35.0)
        reaper.ImGui_Text(ctx, text)
        reaper.ImGui_PopTextWrapPos(ctx)
        reaper.ImGui_EndTooltip(ctx)
    end
end

function loop()
    local rv

    if reaper.ImGui_IsCloseRequested(ctx) then
        reaper.ImGui_DestroyContext(ctx)
        return
    end
    
    local window_flags = reaper.ImGui_WindowFlags_MenuBar() |
                     reaper.ImGui_WindowFlags_NoDecoration()
    reaper.ImGui_SetNextWindowPos(ctx, 0, 0)
    reaper.ImGui_SetNextWindowSize(ctx, reaper.ImGui_GetDisplaySize(ctx))
    reaper.ImGui_Begin(ctx, 'Window', nil, window_flags)


    ----------------------------------------
    ---------------------------------------²
    -----------------------------------------
    ---- GUI

    reaper.ImGui_SameLine(ctx)
    HelpMarker('Tooltip')

    --------------------------------------
    ---------------------------------------
    --------------------------------------
    reaper.ImGui_End(ctx)
    reaper.defer(loop)
    
end
loop()
Arthur McArthur is offline   Reply With Quote
Old 04-03-2021, 11:35 AM   #90
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

I forgot to tell here


but here is my first ReaImGui script


Script: XR Theme color tweaker (ReaImGui demo) - Beta


This can be considered as another demo of what we can do with it.
X-Raym is offline   Reply With Quote
Old 04-04-2021, 12:00 AM   #91
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

@X-Raym, Arthur McArthur: Thanks guys!

@cfillion: "ReaImGui_Hello World.eel" examples have reversed red and blue colors in Windows OS.
__________________
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 04-04-2021, 12:22 AM   #92
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Is there an equivalent to gfx.measurestr that will return the width of a text in pixels?
__________________
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 04-04-2021, 01:10 AM   #93
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
Is there an equivalent to gfx.measurestr that will return the width of a text in pixels?
Code:
number w, number h = reaper.ImGui_CalcTextSize(ImGui_Context ctx, string text, number w, number h, optional boolean hide_text_after_double_hashIn, optional number wrap_widthIn)
Quote:
Originally Posted by amagalma View Post
@cfillion: "ReaImGui_Hello World.eel" examples have reversed red and blue colors in Windows OS.
Fixing, thanks!
cfillion is offline   Reply With Quote
Old 04-04-2021, 03:40 PM   #94
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks! It seems that number w, number h arguments are optional too? What do they do?
__________________
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 04-04-2021, 05:38 PM   #95
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
Thanks! It seems that number w, number h arguments are optional too? What do they do?
They are the two return values. In EEL and internally in C++ it's done via pointer arguments. In Lua, REAPER hides those by making them optional (but not in the documentation for some reason?).
cfillion is offline   Reply With Quote
Old 04-05-2021, 02:01 AM   #96
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Ah, ok..

Another issue: but this may be a general ReaScript issue and not ReaImGui only?) : keys that are used as a shortcut with global scope do not work with text input ( I stumbled upon this while double-clicking or ctrl-clicking a drag item to enter manually the values and my NumPad Enter fired the action I have assigned to it rather than send an enter message).

And a couple of questions:
1) how to align an element to the center of a context? I use this function for a disabled text for example:
Code:
local function CenterAlignedText( ctx, text )
  local w = reaper.ImGui_CalcTextSize( ctx, text )
  reaper.ImGui_Spacing( ctx )
  reaper.ImGui_SameLine( ctx, nil, (ctx_w-w)/2 - 7 )
  -- 7 is the default padding and ctx_w is the width I passed when creating the context
  reaper.ImGui_TextDisabled( ctx, text )
end
Is there a better way? 7 is the default padding, but is there any function that returns this number in case it is different?

2) is there a better way to leave vertical space between elements than calling many times reaper.ImGui_Spacing( ctx )?

Thank you!

P.S. This is what I am working on:
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-05-2021 at 02:15 AM.
amagalma is offline   Reply With Quote
Old 04-05-2021, 02:13 AM   #97
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Another demo (work in progress):
A Get User Input made with ReaImGui





Compared to the regular GetUserInput window, here we have!

  • hints
  • helper question marks and tooltips
  • aligned input
  • flexible field size
Also, we have access there in other input types (like numbers, etc) which can prevent some sanitization steps.
X-Raym is offline   Reply With Quote
Old 04-05-2021, 06:08 AM   #98
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

I have no idea what you wizards are doing but I'm sure amazing things will come out of this too!
Pink Wool is offline   Reply With Quote
Old 04-05-2021, 09:37 AM   #99
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Hey X Raym I would Like to see it when you are done to know better the ImGUI! Nice using the REAPER tooltips! And adaptive width
daniellumertz is online now   Reply With Quote
Old 04-05-2021, 01:46 PM   #100
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
Another issue: but this may be a general ReaScript issue and not ReaImGui only?) : keys that are used as a shortcut with global scope do not work with text input ( I stumbled upon this while double-clicking or ctrl-clicking a drag item to enter manually the values and my NumPad Enter fired the action I have assigned to it rather than send an enter message).
I don't know know if/how this can be fixed from the extension's side. (Maybe if ReaImGui could somehow trick REAPER into believing a input text box is focused, or could disable the global shortcut processing for its window...)

Quote:
Originally Posted by amagalma View Post
1) how to align an element to the center of a context? Is there a better way?
Code:
local function CenterText(ctx, textFunc, text)
  local text_w   = reaper.ImGui_CalcTextSize(ctx, text)
  local avail_w  = reaper.ImGui_GetContentRegionAvail(ctx)
  local offset_x = (avail_w - text_w) / 2

  if offset_x > 0 then
    local cursor_x = reaper.ImGui_GetCursorPosX(ctx)
    reaper.ImGui_SetCursorPosX(ctx, cursor_x + offset_x)
  end

  textFunc(ctx, text)
end

CenterText(ctx, reaper.ImGui_TextDisabled, 'foo bar baz')
This handles the current ImGui window size not being full-context, compensates for scrollbar width, supports optionally being used in conjunction with SameLine, allows using any text displaying function and prevents overlapping over previous items on the line if there's not enough available space to fit the entire text.

Quote:
Originally Posted by amagalma View Post
7 is the default padding, but is there any function that returns this number in case it is different?
Code:
x, y = reaper.ImGui_GetStyleVar(ctx, reaper.ImGui_StyleVar_WindowPadding())
Quote:
Originally Posted by amagalma View Post
2) is there a better way to leave vertical space between elements than calling many times reaper.ImGui_Spacing( ctx )?
Code:
reaper.ImGui_PushStyleVar(ctx, reaper.ImGui_StyleVar_ItemSpacing(), 42, 42)
-- ...
reaper.ImGui_PopStyleVar(ctx)

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

Thanks for the functions! Maybe we should create a template in ReaPack with them!

Quote:
Originally Posted by cfillion View Post
I don't know know if/how this can be fixed from the extension's side. (Maybe if ReaImGui could somehow trick REAPER into believing a input text box is focused, or could disable the global shortcut processing for its window...)
I see.. Probably, it is better to ask Justin if he could provide such functionality.

Quote:
Code:
x, y = reaper.ImGui_GetStyleVar(ctx, reaper.ImGui_StyleVar_WindowPadding())
Hmm, this is strange as the value I measured is 7 but the one returned is 8.. If I use the one returned then the alignment is off.

A few more questions if I may:
1) I use the mouse wheel to change item values. By default the mouse wheel scrolls the window if it is smaller than the script's window. Is there any way to disable this window scrolling by the wheel?

2) is there any way to make text input items to appear as disabled? I use reaper.ImGui_InputTextFlags_ReadOnly(), so the user can't enter values, but it would be nice if it looked like it too.



3) How can I highlight a whole row in the table either by clicking it, or programmatically?

Thank you very much!

PS. To mods: thread sticky please!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-06-2021 at 05:54 AM.
amagalma is offline   Reply With Quote
Old 04-06-2021, 12:29 PM   #102
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
1) I use the mouse wheel to change item values. By default the mouse wheel scrolls the window if it is smaller than the script's window. Is there any way to disable this window scrolling by the wheel?
Set WindowFlags_NoScrollWithMouse when starting the window or child window.

Code:
local flags = reaper.ImGui_WindowFlags_NoDecoration() | -- NoTitleBar | NoResize | NoScrollbar | NoCollapse
              reaper.ImGui_WindowFlags_NoScrollWithMouse()
reaper.ImGui_Begin(ctx, 'Window title', nil, flags)
Quote:
Originally Posted by amagalma View Post
2) is there any way to make text input items to appear as disabled? I use reaper.ImGui_InputTextFlags_ReadOnly(), so the user can't enter values, but it would be nice if it looked like it too.
PushStyleColor to set the text color to the disabled text color. This is what the TextDisabled helper function does internally.



Code:
rv,fadePad = reaper.ImGui_Checkbox(ctx, 'Fade Pad', fadePad)
reaper.ImGui_SameLine(ctx, nil, 20)
local flags = 0
if not fadePad then
  flags = flags | reaper.ImGui_InputTextFlags_ReadOnly()

  local textDisabled = reaper.ImGui_GetStyleColor(ctx, reaper.ImGui_Col_TextDisabled())
  reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_Text(), textDisabled);
end
reaper.ImGui_PushItemWidth(ctx, 120)
reaper.ImGui_Text(ctx, 'Leading pad:')
reaper.ImGui_SameLine(ctx)
reaper.ImGui_InputDouble(ctx, '##leading', 10, 1, 0.1, '%.1f ms', flags)
reaper.ImGui_SameLine(ctx, nil, 20)
reaper.ImGui_Text(ctx, 'Trailing pad:')
reaper.ImGui_SameLine(ctx)
reaper.ImGui_InputDouble(ctx, '##trailing', 10, 1, 0.1, '%.1f ms', flags)
reaper.ImGui_PopItemWidth(ctx)
if not fadePad then
  reaper.ImGui_PopStyleColor(ctx)
end
Quote:
Originally Posted by amagalma View Post
3) How can I highlight a whole row in the table either by clicking it, or programmatically?
A Selectable with SelectableFlags_SpanAllColumns and SelectableFlags_AllowItemOverlap set. See Tables > Advanced in the demo.

(AllowItemOverlap for not breaking interaction with buttons and other input items in the row. It's not necessary if the row only contains text.)

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

Thanks cfillion!

I do something wrong with the selectable and I mess the table:

Here is the table code and its sorting function:
Code:
-- Sorting function
local keys = {"method", "bufsz", "overlap", "thres", "minioi", "silence"}
local function CompareTableItems( a, b )
  local next_id = 0
  while true do
    local ok, col_user_id, col_idx, sort_order, sort_direction = reaper.ImGui_TableGetColumnSortSpecs( ctx, next_id )
    if not ok then break end
    next_id = next_id + 1
    local key = keys[col_user_id]
    local is_ascending = sort_direction == reaper.ImGui_SortDirection_Ascending()
    if a[key] < b[key] then
      return is_ascending
    elseif a[key] > b[key] then
      return not is_ascending
    end
  end
end

-- table code inside loop()
  if reaper.ImGui_BeginTable(ctx, 'table_sorting', 6, table_flags, 0, text_base_height * 5, 0) then
    reaper.ImGui_TableSetupColumn(ctx, 'Method', def_sort_flag | stretch_width_flag, 2, 1)
    reaper.ImGui_TableSetupColumn(ctx, 'Buffer', stretch_width_flag, 0, 2)
    reaper.ImGui_TableSetupColumn(ctx, 'Overlap', stretch_width_flag, 0, 3)
    reaper.ImGui_TableSetupColumn(ctx, 'Threshold', stretch_width_flag, 0, 4)
    reaper.ImGui_TableSetupColumn(ctx, 'Inter-Onset', stretch_width_flag, 0, 5)
    reaper.ImGui_TableSetupColumn(ctx, 'Silence', stretch_width_flag, 0, 6)
    
    reaper.ImGui_TableSetupScrollFreeze(ctx, 0, 1) -- Make row always visible
    reaper.ImGui_TableHeadersRow(ctx)

    -- Sort data if sort specs have been changed
    if reaper.ImGui_TableNeedSort( ctx ) then
      table.sort(Previous_Settings, CompareTableItems)
    end

    local clipper = reaper.ImGui_CreateListClipper( ctx )
    reaper.ImGui_ListClipper_Begin( clipper, #Previous_Settings)
    while reaper.ImGui_ListClipper_Step( clipper ) do
      local display_start = reaper.ImGui_ListClipper_GetDisplayStart( clipper )
      local display_end = reaper.ImGui_ListClipper_GetDisplayEnd( clipper )
      for row_n = display_start, display_end - 1 do
        local item = Previous_Settings[row_n + 1]
        reaper.ImGui_PushID( ctx, item.id )
        if reaper.ImGui_Selectable(ctx, "##", selected_setting == row_n + 1, span_all_columns_flag ) then
          selected_setting = row_n + 1
        end
        reaper.ImGui_TableNextRow( ctx )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.method )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.bufsz )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.overlap )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.thres )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.minioi )
        reaper.ImGui_TableNextColumn( ctx )
        reaper.ImGui_Text( ctx, item.silence )
        reaper.ImGui_PopID( ctx )
      end
    end
    reaper.ImGui_EndTable( ctx )
  end

If I comment out the selectable code part (above in bold) then it displays correctly. What am I doing wrong?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-06-2021 at 08:31 PM.
amagalma is offline   Reply With Quote
Old 04-07-2021, 01:22 PM   #104
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Selectable is called before TableNextRow and TableNextColumn, so it's being put in the last column of the previous row. It should replace one of the row's Text:

Code:
reaper.ImGui_TableNextRow(ctx)
reaper.ImGui_TableNextColumn(ctx)
if reaper.ImGui_Selectable(ctx, item.method, selected_setting == row_n, span_all_columns_flag) then
  selected_setting = row_n
end
reaper.ImGui_TableNextColumn(ctx)
reaper.ImGui_Text(ctx, item.bufsz)
-- ...
(ListClipper is only useful if the data can grow much bigger than what the table's height can fit at once. The next version will merge ListClipper_GetDisplayStart and _GetDisplayEnd with a single start,end = _GetDisplayRange call.)

Last edited by cfillion; 04-07-2021 at 01:48 PM.
cfillion is offline   Reply With Quote
Old 04-07-2021, 01:53 PM   #105
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks for the explanation! I understood now how it works!
__________________
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 04-10-2021, 01:18 AM   #106
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

How to get the equivalent of gfx.x and gfx.y (the position of the script's window on the screen)?

Also, it would be nice to know the ReaImGui/Dear ImGui nomenclature. I mean for example: how should we call these? : DragDouble, SliderInt, InputText etc. Widgets? Items? Elements? How should the script's window be called, and how a window inside the script's window? Is this info available somewhere?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-10-2021 at 01:26 AM.
amagalma is offline   Reply With Quote
Old 04-10-2021, 01:32 PM   #107
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
How to get the equivalent of gfx.x and gfx.y (the position of the script's window on the screen)?
JS_Window_GetClientRect(ImGui_GetNativeHwnd(ctx))

Is this for state persistence or another usecase? ImGui has built-in support for state persistence and I'm planning to extend it to remember the context's platform window state when I'll implement the feature in ReaImGui.

Quote:
Originally Posted by amagalma View Post
Also, it would be nice to know the ReaImGui/Dear ImGui nomenclature. I mean for example: how should we call these? : DragDouble, SliderInt, InputText etc. Widgets? Items? Elements?
Dear ImGui calls them "items".

Quote:
Originally Posted by amagalma View Post
How should the script's window be called, and how a window inside the script's window?
Dear ImGui refers to real windows as "Platform Windows" and virtual windows as just "Windows". In ReaImGui, each context has its own platform window. A script can create multiple contexts.

From a script's perspective however, currently, ReaImGui's platform windows are meant more as an implementation detail than an exposed concept (hence the lack of an API for managing them). Is there really a "platform window" worth referring to when the context is docked, for instance?

It might be best to just refer to the ReaImGui context itself. And say that the context has a "main viewport", a region on the screen for drawing things into. It just happens to be a window most of the time.

Dear ImGui devs are working on a multiple viewport per context system.

Quote:
Originally Posted by amagalma View Post
Is this info available somewhere?
Not really, beside the function names and documentation (in the source code). The FAQ has some useful information though.

Last edited by cfillion; 04-10-2021 at 11:24 PM.
cfillion is offline   Reply With Quote
Old 04-10-2021, 10:56 PM   #108
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thank you very much for the detailed answer cfillion!

Quote:
Originally Posted by cfillion View Post
JS_Window_GetClientRect(ImGui_GetNativeHwnd(ctx))

Is this for state persistence or another usecase? ImGui has built-in support for state persistence and I'm planning to extend it to the remember the context's platform window state when I'll implement the feature in ReaImGui.
State persistence, but the work-around you posted will do for now

Also, is there any way to disable context resize or limit its range? ImGui_WindowFlags_NoResize() doesn't seem to do anything...
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 04-11-2021 at 01:12 AM.
amagalma is offline   Reply With Quote
Old 04-11-2021, 10:32 AM   #109
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 765
Default

CreateContext has optional pos x/y parameters, but they don't appear to do anything. No matter what I write there, my window always opens in the same place, near the top left of my screen. Am I misunderstanding something, or is this broken? (I'm on Linux/Gnome in case that's relevant...)

Also, is there a way to dock a ReaImGui context? I can't seem to figure that out...
elcalen is offline   Reply With Quote
Old 04-11-2021, 11:04 AM   #110
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by amagalma View Post
Is there any way to disable context resize or limit its range?
No, but I could add a min/max size (undocked only). ImGui_WindowFlags_NoResize only applies to the virtual windows inside the context.

Quote:
Originally Posted by elcalen View Post
CreateContext has optional pos x/y parameters, but they don't appear to do anything. No matter what I write there, my window always opens in the same place, near the top left of my screen. Am I misunderstanding something, or is this broken? (I'm on Linux/Gnome in case that's relevant...)
EDIT: Fixing! (It was GNOME-specific)

Quote:
Originally Posted by elcalen View Post
Also, is there a way to dock a ReaImGui context? I can't seem to figure that out...
Code:
EDIT: removed snippet. Next version (0.3) will add a better SetDock function.
(Try right-clicking on an empty area of the demo script.)

Last edited by cfillion; 04-15-2021 at 10:16 PM.
cfillion is offline   Reply With Quote
Old 04-11-2021, 01:48 PM   #111
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 765
Default

Quote:
Originally Posted by cfillion View Post
Code:
local hwnd = reaper.ImGui_GetNativeHwnd(ctx)
reaper.DockWindowAdd(hwnd, 'Tab Name', 0, true)
reaper.DockWindowActivate(hwnd)
(Try right-clicking on an empty area of the demo script.)
Thank you! That did the trick.
elcalen is offline   Reply With Quote
Old 04-11-2021, 06:34 PM   #112
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

noob question, how does ImGui_PushStyleColor get RGB values I have using it by converting from ImGui_ColorConvertHSVtoRGB. Is there a way to manually input RGB values? I tried HEX RGB and putting RGB values sidebyside like 255,255,100 = 255255100. I don't understand what is going on!


EDIT: also

Code:
 
reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_Button(),        reaper.ImGui_ColorConvertHSVtoRGB( 7.0, 0.6, 0.6, 1.0))
instead of
Code:
 
    local buttonColor  = reaper.ImGui_ColorConvertHSVtoRGB( 7.0, 0.6, 0.6, 1.0)
    reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_Button(),        buttonColor)
is giving me error saying that there is more than 3 variables in PushStyle. But I just putted ImGui_ColorConvertHSVtoRGB inside of it

Last edited by daniellumertz; 04-11-2021 at 07:13 PM.
daniellumertz is online now   Reply With Quote
Old 04-11-2021, 07:13 PM   #113
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

It's 1 byte per color component, RedGreenBlueAlpha. 255,255,100,255 = 0xFFFF64FF (in hexadecimal form because it's easier to read than 4294927615. 2 hex chars = 1 byte: 0xFF = 255, 0x64 = 100).

Quote:
Originally Posted by daniellumertz View Post
EDIT: also [...] instead of [...]

is giving me error saying that there is more than 3 variables in PushStyle. But I just putted ImGui_ColorConvertHSVtoRGB inside of it
This is because ImGui_ColorConvertHSVtoRGB has 4 return values, and Lua tries to add all of them to the called function. Extract only the first value:

Code:
reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_Button(),
  ({reaper.ImGui_ColorConvertHSVtoRGB(7.0, 0.6, 0.6, 1.0)})[1])

Last edited by cfillion; 04-11-2021 at 07:23 PM.
cfillion is offline   Reply With Quote
Old 04-11-2021, 07:29 PM   #114
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Thanks for the answers

wow cool trick putting the function in a table at the same line to get just one parameter didn't know about that. :O

I end up making a function to save some lines and for organization!

function:

Code:
 
function ChangeColor(H,S,V,A)
    reaper.ImGui_PushID(ctx, 3)
    local button = reaper.ImGui_ColorConvertHSVtoRGB( H, S, V, A)
    local hover =  reaper.ImGui_ColorConvertHSVtoRGB( H, S , (V+0.4 < 1) and V+0.4 or 1 , A)
    local active = reaper.ImGui_ColorConvertHSVtoRGB( H, S, (V+0.2 < 1) and V+0.2 or 1 , A)
    reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_Button(),  button)
    reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_ButtonHovered(), hover)
    reaper.ImGui_PushStyleColor(ctx, reaper.ImGui_Col_ButtonActive(),  active)
end
when adding button:
Code:
    ChangeColor(1,1,0.5,1)
    reaper.ImGui_Button(ctx, 'Get')
    reaper.ImGui_PopStyleColor(ctx, 3); reaper.ImGui_PopID(ctx)

EDIT: now I wonder if many PushID with the same parameter will cause problems
daniellumertz is online now   Reply With Quote
Old 04-11-2021, 07:40 PM   #115
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by daniellumertz View Post
EDIT: now I wonder if many PushID with the same parameter will cause problems
PushID/PopID's is for differentiating multiple items that would otherwise end up with the same ID (eg. multiple 'Get' buttons in a loop). Item IDs (= item's label/str_id + parents' IDs) must be unique otherwise interacting with one would interact with all.

More info about the ID stack here: https://github.com/ocornut/imgui/blo...-i-click-on-it.
cfillion is offline   Reply With Quote
Old 04-12-2021, 01:42 AM   #116
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 765
Default

Is there any way to determine if my script's context has focus, among all the different windows in Reaper? The reason I ask is, I've set up some key shortcuts in my script, but sometimes I click outside the script window and forget to switch back to it, so it would be nice to set up some kind of visual indication of whether the script window is the active window or not.
elcalen is offline   Reply With Quote
Old 04-12-2021, 10:19 AM   #117
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

I think with JS extension you can get the active/focus window and compare if is the same hwnd of your script . Not in pc right now to check after this function but search the js, probably will be there
daniellumertz is online now   Reply With Quote
Old 04-12-2021, 02:54 PM   #118
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 765
Default

Quote:
Originally Posted by daniellumertz View Post
I think with JS extension you can get the active/focus window and compare if is the same hwnd of your script . Not in pc right now to check after this function but search the js, probably will be there
Ah, JS_Window_GetFocus appears to be the function. That looks like it should work, at least in theory. Thanks.
elcalen is offline   Reply With Quote
Old 04-13-2021, 05:40 AM   #119
elcalen
Human being with feelings
 
elcalen's Avatar
 
Join Date: Sep 2019
Location: Finland
Posts: 765
Default

I've encountered a glitch while experimenting with docking my ReaImGui window. If I open a new Reaper instance, then open a script which immediately docks itself (after creating the context, before starting the main defer loop), large parts of the Reaper window suddenly turn black. Mousing over some of the black areas makes them visible again, and if I hide and re-open the docker, everything is fine again. As far as I can tell, this only happens the first time I open the script in a new Reaper session, and doesn't happen if I dock the script after it's been running for a while.

Relevant information: Linux (Debian testing), Gnome 3.38, Nvidia drivers (460.67).
elcalen is offline   Reply With Quote
Old 04-13-2021, 06:27 AM   #120
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

ImGui_InputTextFlags_CharsDecimal() allows 0123456789.+-*/

Is it possible to allow only 0123456789.-? (not allow +, *, / that is)
__________________
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
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 05:32 PM.


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