Old 05-20-2019, 12:38 PM   #521
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Edit... my bad

Last edited by Sexan; 05-20-2019 at 12:47 PM.
Sexan is offline   Reply With Quote
Old 05-20-2019, 12:52 PM   #522
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,353
Default

Quote:
Originally Posted by mespotine View Post
If manage to do that completely, could you write a small tutorial on that one into the Reaper-Internals-thread? We might have use for touch-stuff in our Ultraschall-extension
I will! At the moment I don't have high hopes for that, though.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 05-20-2019, 01:11 PM   #523
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
how do you revert bitmap to its original state/color?
I'm trying JS_LICE_AlterBitmapHSV
Besides the obvious solution of just saving the original bitmap and switching between them, you can use any invertible transformation. AFAIK, in the case of HSV, saturation and value aren't reversible, since they can bump against max and min values. Hue, on the other hand, is a continuous ring that will wrap around when it reaches the maximum, so if you use AlterHSV with any +hue, just use -hue to revert the change.

Another option is to use ProcessRect in XOR mode, since XOR is invertible. Just XOR with any number (0x00FFFFFF will nicely invert the colors without changing alpha) and then XOR again to revert.
juliansader is offline   Reply With Quote
Old 05-20-2019, 01:27 PM   #524
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Quote:
Originally Posted by juliansader View Post
Besides the obvious solution of just saving the original bitmap and switching between them, you can use any invertible transformation. AFAIK, in the case of HSV, saturation and value aren't reversible, since they can bump against max and min values. Hue, on the other hand, is a continuous ring that will wrap around when it reaches the maximum, so if you use AlterHSV with any +hue, just use -hue to revert the change.

Another option is to use ProcessRect in XOR mode, since XOR is invertible. Just XOR with any number (0x00FFFFFF will nicely invert the colors without changing alpha) and then XOR again to revert.
Yeah thats what I did, but used wrong numbers...sorry, thats why I've edited the post
Sexan is offline   Reply With Quote
Old 05-20-2019, 01:52 PM   #525
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Anyway something I've noticed after playing with LICE,GDI etc last 20 days.

Sometimes one bitmap renders over others and sometimes below. I'm not sure why is that happening. You can see that in my last post here regarding touchscreen:
You can see that "menu" highlight bitmap is behind main one, but one of 30 times it will get rendered above it. Is there any control over it or the code just needs to be:
first - second - last regarding drawing?

EDIT: Just as I've try to test something it appeared

You can see that last one menu highlight is rendered above everything along with its background

Last edited by Sexan; 05-20-2019 at 01:59 PM.
Sexan is offline   Reply With Quote
Old 05-20-2019, 02:10 PM   #526
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Sexan View Post
Is there any control over it or the code just needs to be:
first - second - last regarding drawing?
ATM there is no control over the order in which linked bitmaps get drawn on the screen.
juliansader is offline   Reply With Quote
Old 05-21-2019, 05:30 AM   #527
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,202
Default

Quote:
Originally Posted by nofish View Post
Since above one probably got a bit outdated meanwhile, here's one generated fron v0.987:
https://stash.reaper.fm/v/36404/js_ReaScriptAPI.py

(Btw. the Python function wrappers file can be created rather easily using the Pearl scripts SWS is also using.)
How hard would it be to port it over to Lua?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 05-21-2019, 05:57 AM   #528
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,041
Default

Hey Julian,

Something in the latest dev build 521 - causes reaper to hard crash when I run some of my scripts which use your API.

I remove your extension dll - and although my scripts lose some functionality - they work ok again.

I'm generally using Mouse and Window functions - some GDI functions (and load mouse cursor - but still crashed when I removed this).

Trying to narrow down the problem...

EDIT:

Strangely - it seems to be your JS_ReaScriptAPI_Version() function which is crashing Reaper.
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal

Last edited by lb0; 05-21-2019 at 06:15 AM.
lb0 is offline   Reply With Quote
Old 05-21-2019, 06:05 AM   #529
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,080
Default

Would it be to much to ask for an API to set global project startup actions. It would work similar to SWS/S&M: Set global startup action but it would get called on every project load.

I know we can create project templates with SWS/S&M: Set project startup action, but that doesn't always really work
Breeder is offline   Reply With Quote
Old 05-21-2019, 06:35 AM   #530
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by lb0 View Post
Strangely - it seems to be your JS_ReaScriptAPI_Version() function which is crashing Reaper.
This is indeed strange. What OS and REAPER version are you using?

Does even a single-line script "v = reaper.JS_ReaScript_Version()" crash your system?
juliansader is offline   Reply With Quote
Old 05-21-2019, 06:43 AM   #531
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,041
Default

Quote:
Originally Posted by juliansader View Post
This is indeed strange. What OS and REAPER version are you using?

Does even a single-line script "v = reaper.JS_ReaScript_Version()" crash your system?
Yeah- I went through all the commands I use in Stripper in a separate Lua file - and the version API was the cause.

I'm on windows 10 64bit - latest dev build of Reaper - dev521

This crash was reported to me by Stevie - so it's not just me.

The latest dev build has this:

Code:
+ API: support optional arguments in extension-supplied functions when called from ReaScript/Lua [t=219455]
which might be the cause?
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 05-21-2019, 11:05 AM   #532
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Julian I have small issue that i cannot figure out how to fix so if you can please assist:
Image of the item is not shrinking/stretching it just reveal its content and disappears when its off the original.



Drawing code
Code:
for j = 1, #tbl.info[i].items do
            local as_item = tbl.info[i].items[j]
            local item_bm = item_ghosts[as_item].bm
            local item_start, item_lenght = item_blit(as_item, tbl.time_start, tbl.time_end, pos)
            reaper.JS_Composite(track_window, 
                      math.ceil(item_start * zoom_lvl) - Arr_pixel, -- X
                      item_t - y_view_start + item_bar,             -- Y
                      math.ceil(item_lenght * zoom_lvl),            -- W
                      item_h,                                       -- H
                      item_bm,                                      
                       0,                                           --x
                       0,                                           --y
                       math.ceil((item_lenght * zoom_lvl)),         --w
                       item_h)                                      --h
          end
grabbing code
Code:
for j = 1, #tbl.info[i].items do
        
        local as_tr, as_item  = tbl.info[i].track, tbl.info[i].items[j]
        local item_t, item_h, item_b = TBH[as_tr].t, TBH[as_tr].h, TBH[as_tr].b
        local item_bar = (item_h > 42) and 15 or 0
        local item_start, item_lenght = item_blit(as_item, tbl.time_start, tbl.time_end)
        
        local bm = reaper.JS_LICE_CreateBitmap(true, math.ceil(item_lenght * zoom_lvl), item_h)
        local dc = reaper.JS_LICE_GetDC(bm)
        
        reaper.JS_GDI_Blit(dc, 0, 0, track_window_dc,                                -- SOURCE - DESTINATION
                            math.floor(item_start    * zoom_lvl) - Arr_pixel,        -- X
                                      ((item_t       + item_bar) - y_view_start),    -- Y
                            math.ceil(item_lenght   * zoom_lvl),                    -- W
                                       item_h - 19)                                  -- H (-19 TO COMPENSATE ITEM BAR REMOVING)
      
        item_ghosts[as_item] =  {bm =  bm , dc = dc }
      end

Last edited by Sexan; 05-21-2019 at 11:13 AM.
Sexan is offline   Reply With Quote
Old 05-21-2019, 11:36 AM   #533
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

At first glance, this drawing code might be the problem:
Code:
            reaper.JS_Composite(track_window, 
                      math.ceil(item_start * zoom_lvl) - Arr_pixel, -- X
                      item_t - y_view_start + item_bar,             -- Y
                      math.ceil(item_lenght * zoom_lvl),            -- W
                      item_h,                                       -- H
                      item_bm,                                      
                       0,                                           --x
                       0,                                           --y
                       math.ceil((item_lenght * zoom_lvl)),         --w
                       item_h)                                      --h
          end
The last --w and --h lines probably cut off part of the bitmap. To shrink and expand the ghost, the entire source bitmap must be composited, so (source w and h remain constant), and only the image size W and H in the track window changes.
juliansader is offline   Reply With Quote
Old 05-21-2019, 11:51 AM   #534
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Yeah thats whats happening, so the last two should be zero or I need to store original sizes also ? Probably second one

Last edited by Sexan; 05-21-2019 at 11:59 AM.
Sexan is offline   Reply With Quote
Old 05-21-2019, 11:58 AM   #535
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Sexan View Post
Yeah thats whats happening, so the last two should be zero or I need to store original sizes also ?
You will need to store the original size.
juliansader is offline   Reply With Quote
Old 05-21-2019, 12:07 PM   #536
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Yes, now it works thank you

Last edited by Sexan; 05-21-2019 at 12:14 PM.
Sexan is offline   Reply With Quote
Old 05-22-2019, 01:48 AM   #537
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Breeder View Post
Would it be to much to ask for an API to set global project startup actions. It would work similar to SWS/S&M: Set global startup action but it would get called on every project load.
I would be happy to - if I knew how. Is there a C++ function to set such startup actions, or do you know some alternative trick? I took a look at SnM's code, and they seem to use "plugin_register("timer"", but I couldn't find any reference to "timer" in reaper_plugin_functions.h or reaper_plugin.h.


Quote:
I know we can create project templates with SWS/S&M: Set project startup action, but that doesn't always really work
Oops. If SnM's trick doesn't always work, I'm not sure that I can do better...

(BTW, anyone can contribute to this extension, so if you have any API code that you would like me to include, you are welcome to send it to me or make a pull request on github.)
juliansader is offline   Reply With Quote
Old 05-22-2019, 02:45 AM   #538
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Sexan View Post
Awesome thank you! If its not too much trouble can you please help me with that VK_Key cutoff (2 posts above you)? Not sure how the code should look like
The code from my own scripts above is probably the best example I can give.

Depending on exactly which keys you would like to include or exclude, you may need a combination of GetState and GetDown or GetUp:

In case of "press and hold" functions that run as long as the key is held down, use GetState to get the currently active keys. To include the shortcut keys that were used to call the scripts, use GetState(startTimeOfScript-1).

To get keys that were newly pressed, I use a combination of GetState and GetDown: GetDown(prevCycleTime) gets KEYDOWNs since the last defer cycle, and then compares it against GetState(startTime-1) from the *previous* defer cycle (which was called at prevCycleTime), to exclude repeated KEYDOWNs that are being sent by keys that were already down in the previous cycle.
juliansader is offline   Reply With Quote
Old 05-22-2019, 04:54 AM   #539
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,080
Default

Quote:
Originally Posted by juliansader View Post
I would be happy to - if I knew how. Is there a C++ function to set such startup actions, or do you know some alternative trick? I took a look at SnM's code, and they seem to use "plugin_register("timer"", but I couldn't find any reference to "timer" in reaper_plugin_functions.h or reaper_plugin.h.
Hey, thanks man!

He firsts creates this static variable:
https://github.com/reaper-oss/sws/bl....cpp#L421-L422

The he registers it on reaper startup:
https://github.com/reaper-oss/sws/bl....cpp#L430-L431

And then during every project save/load these 3 functions get called by REAPER:
https://github.com/reaper-oss/sws/bl....cpp#L391-L419

And in those functions you check if there's anything you would like to run during that time. In global project action case, you simply read the action in question during extension load and run it in ProcessExtensionLine.

The timer he is using is just to postpone running the action until the whole project loads (at least I think...I do remember these updates and I remember we had some trouble until we used the timer trick...I think it's the same thing as doing defer() from .lua script )

So instead of just doing Main_OnCommand(cmdId, 0) - he registers a timer:
https://github.com/reaper-oss/sws/bl....cpp#L401-L402

And then deregisters that same timer from itself and calls Main_OnCommand(cmdId, 0) there:
https://github.com/reaper-oss/sws/bl....cpp#L224-L236

And also makes sure timer gets deregistered properly on REAPER exit (not sure if this actually might be necessary because timer deregisters itself, but it's good practice anyway and we always strived to make sure everything deregistered properly during REAPER exit):
https://github.com/reaper-oss/sws/bl....cpp#L436-L437

If you got any specific question, feel free to ask. While working on SWS, both Jeffos and myself met with a lot of small quirks like this one (registering a timer like this)...SWS is like a small encyclopedia on how to deal with a lot of small idiosyncrasies inherent to REAPER This is the exact reason I was always for unification of C++ extensions and was afraid SWS will go to hell if people start doing their own extensions instead of contributing directly to SWS...


Regarding contributing - I actually wouldn't mind contributing but I just can't find the time to go through the whole visual studio setup etc...I had a lot of work on setting things up since I got back to REAPER and now I'm in the middle of writing an album.

I must confess that after writing countless scripts these days, I do miss C++. Who knows, when I finish this period of life, I just might give it another round. No promises, lol - who knows where this music making will take me ;D

Quote:
Originally Posted by juliansader View Post
Oops. If SnM's trick doesn't always work, I'm not sure that I can do better...
No, no...it works! But the problem is that you have to set up project action for every project you want it to use. There's currently no known way to have REAPER run something on EVERY project load without setting the project up.

That's why I tried to differentiate between PROJECT action and GLOBAL PROJECT action when describing the issue. I remember actually wanting to add that, but that being Jeffos part of code, I just hoped he would add it. And then he abruptly left and I had a breakdown and switched to Cubase and then abandoned music all together until now

Last edited by Breeder; 05-22-2019 at 05:09 AM.
Breeder is offline   Reply With Quote
Old 05-22-2019, 07:33 AM   #540
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

osX users have trouble with

Code:
local _, scroll, _, _, _ = reaper.JS_Window_GetScrollInfo(track_window, "SB_VERT")
SInce by API it expects string what can I do about this?

And while we are at it I also have

Code:
local mixer_wnd = reaper.JS_Window_Find("mixer", true)   -- DONT KNOW ITS ID

local track = reaper.JS_Window_GetLongPtr(handl, "USER") -- DONT KNOW HOW OTHER PLATFORMS SEE THIS

local window = reaper.JS_Window_GetRelated(track_window, "NEXT")

reaper.JS_Window_GetRelated(window, "CHILD")

reaper.JS_Window_GetLongPtr(window, "USERDATA")
I know mixer will be a problem with other platforms but do not know how to convert it to ID. This other strings also I'm not sure if they will pass on other platforms but I dont know how to fix it
Sexan is offline   Reply With Quote
Old 05-22-2019, 08:09 AM   #541
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Sexan View Post
osX users have trouble with

Code:
local _, scroll, _, _, _ = reaper.JS_Window_GetScrollInfo(track_window, "SB_VERT")
SInce by API it expects string what can I do about this?
deeb's error report refers to argument 1, the void*. This is because the line to get track_window uses Window_Find:
Code:
local track_window = reaper.JS_Window_Find("trackview", true) -- GET TRACK VIEW
For cross-platform usage, you should rather use ID (check out Mespotine's long list above):
Code:
local track_window = reaper.JS_Window_FindChildByID(main_wnd, 1000)

Quote:
And while we are at it I also have
I would recommend caution when using GetRelated(hwnd, "NEXT"), since it might not always get the same sequence of windows. Even stuff such as presence of docks or other child windows may change the sequence.

Regarding cross-platform testing, please see PM.
juliansader is offline   Reply With Quote
Old 05-22-2019, 12:26 PM   #542
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

function with "NEXT" is the most important function in the script I do not know how to refactor this if its problematic, but I did not encountered any problem with it yet

Code:
local function GetTrackFromMouseRange(t, b)
  if l_r_t ~= t or l_r_b ~= b then                                                  -- GET TRACKS ONLY IF MOUSE RANGE CHANGED
    local range_tracks = {}
    local trackview_window
    local _, _, arr_top = reaper.JS_Window_GetRect(track_window)
    local window = reaper.JS_Window_GetRelated(track_window, "NEXT")
    while window do
      local _, _, top = reaper.JS_Window_GetRect(window)
      if top == arr_top then trackview_window = reaper.JS_Window_GetRelated(window, "CHILD") end
      window = reaper.JS_Window_GetRelated(window, "NEXT")
    end 
      -- loop over track and envelope windows 
    local window = reaper.JS_Window_GetRelated(trackview_window, "CHILD")
    while window do
      if reaper.JS_Window_IsVisible(window) then
        -- windows visible in arrange view only
        local _, _, top, _, bottom = reaper.JS_Window_GetRect(window)
        if top >= t and bottom <= b then -- IF TRACK IS IN THE MOUSE ZONE RANGE 
          local pointer = reaper.JS_Window_GetLongPtr(window, "USERDATA")
          if reaper.ValidatePtr(pointer, "MediaTrack*") then
            if not Has_val(range_tracks, pointer) then range_tracks[#range_tracks+1] = {track = pointer} end -- ADD TRACKS TO TABLE IF THEY ARE NOT ALREADY THERE
          elseif  reaper.ValidatePtr(pointer, "TrackEnvelope*") then
            if not Has_val(range_tracks, pointer) then range_tracks[#range_tracks+1] = {track = pointer} end
          end
        end
      end
    window = reaper.JS_Window_GetRelated(window, "NEXT")
    end
    l_r_t, l_r_b, last_tracks = t, b, range_tracks
    return range_tracks
  else
    return last_tracks                                                          -- IF MOUSE RANGE IS SAME AS LAST RETURN SAVED TRACKS
  end
end
Is there any other approach to it?
This is the ONLY way to get both tracks and envelopes, I've tried other methods many times before but non did it as it should. It is also CPU hungry but I've managed that to only check when actual track changed

I give it Y range and it gives me all the tracks AND envelopes in that range

Last edited by Sexan; 05-22-2019 at 12:32 PM.
Sexan is offline   Reply With Quote
Old 05-22-2019, 03:33 PM   #543
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Your function avoids the problem with GetRelated and "NEXT" that I referred to above, since it finds trackview_window by checking "if top == arr_top", instead of assuming that trackview_window will always be the Xth (fourth, for example) child window returned by GetRelated.
juliansader is offline   Reply With Quote
Old 05-24-2019, 08:16 PM   #544
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 5,941
Default

Update on the window pinning issue - it was partly on my side. I mistyped the variable name I was passing in, so I was giving nil as the HWND argument to JS_Window_Find. Working fine now on Windows 8 and 10.

I would have expected that to cause an error from the extension though, but it returns a UserData pointer without complaining.
Lokasenna is online now   Reply With Quote
Old 06-03-2019, 07:08 AM   #545
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,202
Default

While looking into that thread: https://forum.cockos.com/showthread.php?t=221481
I wondered, if it would be any useful, if you could add CreateWindowExW and such to JS-extension-plugin as well.
This could allow us to add system-ui-elements into windows. Would be helpful for lokasenna as well, as he's currently refactoring his Gui-Lib. If he could add also system-ui-elements, it would be fantastic and help making guis look more like system-stuff.


In other news:
You request as work in progress...

__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 06-03-2019, 08:34 AM   #546
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,041
Default

Quote:
Originally Posted by mespotine View Post
While looking into that thread: https://forum.cockos.com/showthread.php?t=221481
I wondered, if it would be any useful, if you could add CreateWindowExW and such to JS-extension-plugin as well.
This could allow us to add system-ui-elements into windows. Would be helpful for lokasenna as well, as he's currently refactoring his Gui-Lib. If he could add also system-ui-elements, it would be fantastic and help making guis look more like system-stuff.


In other news:
You request as work in progress...

+1

Interestingly - I was thinking along similar lines regarding adding create window api.

My thought's were to intercept multitouch messages in a transparent overlay window - store the data somewhere - in order to get multitouch into script GUI's.

However - so far - it's just thoughts going round my head and may not even be feasible...
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 06-04-2019, 06:42 AM   #547
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,353
Default

Damn lb0, that would be fantastic, if that was possible!
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-04-2019, 02:48 PM   #548
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Julian is there some function which returns screen resolution? I have some problems with track heights:

Code:
function GetTrackTBH(tbl)
  local total_h = 0
  local t, b, h, nt
  
  for i = #tbl , 1, -1 do                                            -- NEEDS TO BE REVERSED OR IT DRAWS WEIRD
    local track = tbl[i].track
    t, b, h = TBH[track].t, TBH[track].b, TBH[track].h
    total_h = total_h + h
    if t ~= 2344 then nt = t else total_h = total_h - h end          -- NEED TO FIX THIS,RESOLUTION DEPENDANT        -- FIX FOR WHEN THE TOP OF AS IS OUT PROJECT TOP IT WOULD EXPAND THE BOTTOM WHEN THE TOP TRACK IS OUT OF VIEW
  end
  
  if total_h == 0 then nt = 0 end
  
  return nt, total_h, b
end
Code:
if t ~= 2344 then nt = t else total_h = total_h - h end
If track is off the screen it returns in screen resolution, in my case I own QHD monitor so I need to set 2344 or it gets broken, if its 1080p then it needs to be around 1860-70 something in that range (need to check whats returned). Spotted this issue while was working on notebook

Last edited by Sexan; 06-04-2019 at 02:54 PM.
Sexan is offline   Reply With Quote
Old 06-04-2019, 03:35 PM   #549
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Indeed there is: JS_Window_GetViewportFromRect
juliansader is offline   Reply With Quote
Old 06-05-2019, 12:45 AM   #550
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

hm.... not sure how to calculate this

Code:
Resolution 2560 x 1440 

TOP OFFSET - 2344
Code:
Resolution 1920 X 1080

TOP OFFSET - 1984
Do not know what it takes into account when calculating this offset (track height when track is not in the view any more)?

Edit: nvm, added track visibility parameter to main tbl

Last edited by Sexan; 06-05-2019 at 01:13 AM.
Sexan is offline   Reply With Quote
Old 06-09-2019, 11:56 PM   #551
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Julian does JS_destroy_bitmap releases dc or I need to manually delete it?

second question:
Is it possible to get what is the current mouse cursor (want to track elements when cursor changes)?

and third, Julian take a look at PM

Last edited by Sexan; 06-10-2019 at 11:55 AM.
Sexan is offline   Reply With Quote
Old 06-10-2019, 06:32 PM   #552
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 142
Default

Question about JS_Window_Find

If I use JS_Window_Find to get the HWND from a window that doesn't exist, like:

Code:
reaper.JS_Window_Find ("Render to File", True)
If the Render to File window is closed and I run this script, then Reaper hang.
dsyrock is offline   Reply With Quote
Old 06-10-2019, 07:13 PM   #553
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 5,941
Default

Quote:
Originally Posted by dsyrock View Post
Question about JS_Window_Find

If I use JS_Window_Find to get the HWND from a window that doesn't exist, like:

Code:
reaper.JS_Window_Find ("Render to File", True)
If the Render to File window is closed and I run this script, then Reaper hang.
What does the rest of your code look like? It just returns nil for me on Linux and W10.
Lokasenna is online now   Reply With Quote
Old 06-10-2019, 08:28 PM   #554
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 142
Default

Quote:
Originally Posted by Lokasenna View Post
What does the rest of your code look like? It just returns nil for me on Linux and W10.
Wait maybe I did something wrong, I'll try it again, thanks.
dsyrock is offline   Reply With Quote
Old 06-11-2019, 01:39 PM   #555
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

Quote:
Originally Posted by Sexan View Post
Julian does JS_destroy_bitmap releases dc or I need to manually delete it?
I am not aware of a function to release LICE bitmap dc's, so I think the dc is destroyed along with the bitmap.


Quote:
Originally Posted by Sexan View Post
Is it possible to get what is the current mouse cursor (want to track elements when cursor changes)?
This is an excellent idea for getting a more detailed cursor context. I quickly tested it, and it seems to work well. I will soon upload a new version with a Mouse_GetCursor function (and perhaps some window creation functions).
juliansader is offline   Reply With Quote
Old 06-12-2019, 05:42 AM   #556
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

Julian I cannot reuse same bitmap do draw it again but on other place? I need to blit it to new bitmap?

If its the second part what would be the most simplest code to duplicate it?

Use case : Draw it multiple times on different coordinates

Last edited by Sexan; 06-12-2019 at 05:50 AM.
Sexan is offline   Reply With Quote
Old 06-12-2019, 01:13 PM   #557
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,796
Default Q; How to refresh media explorer after scroll via API ?

Hi,


I'm tryong to scroll Media Explorer to a certain arbitrary pos,
the code works but the display isn't refreshed,
we can see the scrollbar scrolled a little to the bottom,
but the File List isn't refreshed, even when JS_Window_SetScrollPos return true.


Code:
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end  

local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)
a = reaper.JS_Window_SetScrollPos( file_LV, "v", 80 )
reaper.JS_Window_Update( hWnd )
reaper.JS_Window_Update( container )
reaper.JS_Window_Update( file_LV )

I tried to push various Window Update without success.


What do I miss ?
X-Raym is offline   Reply With Quote
Old 06-12-2019, 01:42 PM   #558
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,576
Default

v0.988 uploaded with GetCursor.

Quote:
Originally Posted by Sexan View Post
Julian I cannot reuse same bitmap do draw it again but on other place? I need to blit it to new bitmap?

If its the second part what would be the most simplest code to duplicate it?
Yes, you need to blit to a new bitmap: simply create a new bitmap of the same size, and LICE_Blit in "COPY" mode.
juliansader is offline   Reply With Quote
Old 06-12-2019, 02:18 PM   #559
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,176
Default

Quote:
Originally Posted by X-Raym View Post
I'm tryong to scroll Media Explorer to a certain arbitrary pos,
If all else fails maybe send "WM_VSCROLL" msgs?

Code:
local SB_LINEUP = 0
local SB_LINEDOWN = 1
local SB_TOP = 6
local SB_BOTTOM = 7

-- go to top
reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_TOP, 0,0,0)
-- scroll down to line #
for n = 1, 7 do
  reaper.JS_WindowMessage_Send(file_LV, "WM_VSCROLL", SB_LINEDOWN, 0,0,0)
end
Edgemeal is offline   Reply With Quote
Old 06-12-2019, 02:19 PM   #560
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,405
Default

GetCursor works EXTREMELY well for what I wanted! Thank you!


Last edited by Sexan; 06-12-2019 at 02:26 PM.
Sexan 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 07:12 AM.


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