Old 11-22-2014, 02:01 PM   #1
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default EEL: Simple "slider class"

NOTE: This code is likely to change

Latest slider functions (and an example):
https://stash.reaper.fm/22487/spk_sli...s_03122014.eel









Older slider class file: (Feel free to add improvements )
https://stash.reaper.fm/22401/spk_slider_class.eel
(Example in post#8)

Last edited by spk77; 12-03-2014 at 03:40 PM.
spk77 is offline   Reply With Quote
Old 11-22-2014, 02:25 PM   #2
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

Nice one spk. I haven't got my head round this reltive namespace thingy though.

I've been using a routine to vertically drag values on screen, did you see the example I posted? -works well on the Item Marker Tool.
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 11-22-2014, 03:14 PM   #3
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by planetnine View Post
Nice one spk. I haven't got my head round this reltive namespace thingy though.

I've been using a routine to vertically drag values on screen, did you see the example I posted? -works well on the Item Marker Tool.
Thanks planetnine
It took me days to make this simple "class", and there are still bugs , but now I think I understand the "relative namespace thingy" a little better. I'm going to check your "vertical drag" code.

The nice thing is that it's possible to update all slider values (knob positions) from "outside" - I'm going to post some examples soon. Also, now it's not necessary to write long functions for each slider separately:

Code:
// Function desc: slider(x_pos, y_pos, radius, val, range_start, range_end, draw_start_x, draw_end_x, slider_id)

//This line will add a slider:
red = r.slider(20, 150, 8, r.val, 0, 255, 30, gfx_w - 30, 3);
// (changing r.val would update the "knob" position)
spk77 is offline   Reply With Quote
Old 11-22-2014, 04:12 PM   #4
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

If it works the way I think it does, it might save a tone of code duplication in my scripting. I've been reading through your code and the bit in the JSFX reference, but it's not quite joining up. I'm tired though, I might have another go at it in the morning.



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 11-22-2014, 07:17 PM   #5
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

spk77 have you been able to solve the problem of not being able to have a slider value NOT change when you change presets? All I want to do is create a slider that controls how fast values change when you change presets. It works except that the slider that controls change changes based on the preset. I need to lock that baby down!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 11-23-2014, 07:48 AM   #6
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
spk77 have you been able to solve the problem of not being able to have a slider value NOT change when you change presets? All I want to do is create a slider that controls how fast values change when you change presets. It works except that the slider that controls change changes based on the preset. I need to lock that baby down!
Do you mean changing a preset in JSFX? I have no idea


Here's the current "slider class"
  • removed "draw_start_x" (it was actually the same value as "x_pos")
  • renamed "draw_end_x" to "slider_w"
  • added "clicked_outside" (=true if mouse clicked outside GUI)

(First two functions are helper funcs. Also, I forgot to change some global variables to local)
Code:
function scale_x_to_slider_val(range_start, range_end, x_coord, x_start_offs, x_end_offs) local (scaled_x)
(
  scaled_x = range_start + (range_end - range_start) * (x_coord - x_start_offs) / (gfx_w - x_end_offs - x_start_offs);
  scaled_x > range_end ? scaled_x = range_end;
  scaled_x < range_start ? scaled_x = range_start;
  scaled_x;
);

function scale_slider_val_to_x(range_start, range_end, slider_val, x_start_offs, x_end_offs) local (x)
(
  x = x_start_offs + (slider_val - range_start) * (x_end_offs - x_start_offs) / (range_end - range_start);
);

function slider(x_pos, y_pos, radius, val, range_start, range_end, slider_w, slider_id) local (m_x, s_w, s_h)
(
  mouse_cap == 0 ? clicked_outside = 0; this.drag_started == 0;
  mouse_cap > 0 && (mouse_x < 0 || mouse_x > gfx_w || mouse_y > gfx_h || mouse_y < 0) ? clicked_outside = 1;

  this.x_pos = x_pos;
  this.y_pos = y_pos;
  this.radius = radius;
  this.val = max(min(val, range_end), range_start);
  this.range_start = range_start;
  this.range_end = range_end;
  this.slider_w = slider_w;
  this.slider_id = slider_id;
 
  m_x = mouse_x;
 
  gfx_a = 0.7;
  gfx_r = 0.8;
  gfx_g = 0.8;
  gfx_b = 0.8;
  
  clicked_outside == 0 && lmb_down == 0 && (mouse_x >= this.x_pos - this.radius && mouse_x <= this.slider_w &&  mouse_y >= this.y_pos - this.radius && mouse_y <= this.y_pos + this.radius)
  || this.drag_started == 1 ? (
    last_slider_id = this.slider_id;
    gfx_a = 0.9;
    gfx_b += 0.1;
    this.fill = 1;
    mouse_cap == 1 ? (
      gfx_a = 1;
      this.drag_started = 1;
      lmb_down = 1;
      //gfx_b += 0.2;
      mouse_x > this.slider_w ? m_x = this.slider_w;
      mouse_x < this.x_pos ? m_x = this.x_pos;
      this.val = scale_x_to_slider_val(this.range_start, this.range_end, m_x, this.x_pos, gfx_w - this.slider_w);
      
      slider_last_x = m_x;
    ) : (
      this.fill = 0;
      this.drag_started = 0;
      lmb_down = 0;
    );
  );

  this.x_coord = scale_slider_val_to_x(this.range_start, this.range_end, this.val, this.x_pos, this.slider_w);
  this.x_coord < this.x_pos ? x_coord = this.x_pos;
  this.x_coord > this.slider_w ? x_coord = this.slider_w;
  
  gfx_roundrect(this.x_pos - this.radius, this.y_pos - this.radius, this.slider_w - this.x_pos + 2 * this.radius, 2 * this.radius, this.radius);
  gfx_circle(this.x_coord, this.y_pos, this.radius, this.fill);
  
  gfx_measurestr(sprintf(slider_val_str, "%0.1f", this.val), s_w, s_h);
  gfx_a = 1;
  gfx_x = this.x_coord - 0.5 * this.radius - 0.5 * s_w;
  gfx_y = this.y_pos - this.radius - gfx_texth;
  gfx_printf(slider_val_str);
 
  this.val;
);

JSFX example (it's easier to debug in JSFX editor)

(I'll post it later)

Last edited by spk77; 11-23-2014 at 09:48 AM. Reason: "this.r" to "this.radius"
spk77 is offline   Reply With Quote
Old 11-23-2014, 08:16 AM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default JSFX test/example:

JSFX test/example:
Code:
desc:Slider "objects"

slider1:0<-1,1,0.01>Slider1
slider2:0<-100,100,0.1>Slider2

@init

@slider
sl1.val=slider1;
sl2.val=slider2;

@gfx 300 200

function scale_x_to_slider_val(range_start, range_end, x_coord, x_start_offs, x_end_offs) local (scaled_x)
(
  scaled_x = range_start + (range_end - range_start) * (x_coord - x_start_offs) / (gfx_w - x_end_offs - x_start_offs);
  scaled_x > range_end ? scaled_x = range_end;
  scaled_x < range_start ? scaled_x = range_start;
  scaled_x;
);

function scale_slider_val_to_x(range_start, range_end, slider_val, x_start_offs, x_end_offs) local (x)
(
  x = x_start_offs + (slider_val - range_start) * (x_end_offs - x_start_offs) / (range_end - range_start);
);

function slider(x_pos, y_pos, radius, val, range_start, range_end, slider_w, slider_id) local (m_x, s_w, s_h)
(
  // It's necessary to set/check "clicked_outside" flag in ReaScript EEL, otherwise
  // the sliders would move when resizing or moving the gfx window (and even this doesn't work 100%)
  mouse_cap == 0 ? clicked_outside = 0; this.drag_started == 0; 
  mouse_cap > 0 && (mouse_x < 0 || mouse_x > gfx_w || mouse_y > gfx_h || mouse_y < 0) ? clicked_outside = 1;

  this.x_pos = x_pos;
  this.y_pos = y_pos;
  this.radius = radius;
  this.val = max(min(val, range_end), range_start);
  this.range_start = range_start;
  this.range_end = range_end;
  this.slider_w = slider_w;
  this.slider_id = slider_id;
 
  m_x = mouse_x;
 
  gfx_a = 0.7;
  gfx_r = 0.8;
  gfx_g = 0.8;
  gfx_b = 0.8;
   
  clicked_outside == 0 && lmb_down == 0 && (mouse_x >= this.x_pos - this.radius && mouse_x <= this.slider_w &&  mouse_y >= this.y_pos - this.radius && mouse_y <= this.y_pos + this.radius)
  || this.drag_started == 1 ? (
    last_slider_id = this.slider_id;
    gfx_a = 0.9;
    gfx_b += 0.1;
    this.fill = 1;
    mouse_cap == 1 ? (
      gfx_a = 1;
      this.drag_started = 1;
      lmb_down = 1;
      //gfx_b += 0.2;
      mouse_x > this.slider_w ? m_x = this.slider_w;
      mouse_x < this.x_pos ? m_x = this.x_pos;
      this.val = scale_x_to_slider_val(this.range_start, this.range_end, m_x, this.x_pos, gfx_w - this.slider_w);
      
      slider_last_x = m_x;
    ) : (
      this.fill = 0;
      this.drag_started = 0;
      lmb_down = 0;
    );
  );

  this.x_coord = scale_slider_val_to_x(this.range_start, this.range_end, this.val, this.x_pos, this.slider_w);
  this.x_coord < this.x_pos ? x_coord = this.x_pos;
  this.x_coord > this.slider_w ? x_coord = this.slider_w;
  
  gfx_roundrect(this.x_pos - this.radius, this.y_pos - this.radius, this.slider_w - this.x_pos + 2 * this.radius, 2 * this.radius, this.radius);
  gfx_circle(this.x_coord, this.y_pos, this.radius, this.fill);
  
  gfx_measurestr(sprintf(slider_val_str, "%0.1f", this.val), s_w, s_h);
  gfx_a = 1;
  gfx_x = this.x_coord - 0.5 * r - 0.5 * s_w;
  gfx_y = this.y_pos - this.radius - gfx_texth;
  gfx_printf(slider_val_str);
 
  this.val;
);


// EXAMPLE add sliders (with different ranges and sizes):
// desc:   slider(x_pos, y_pos, radius, val, range_start, range_end, slider_w, slider_id)

//         X   Y   R   value        range      slider    id
//                               start  end    width    
sl1.slider(50, 20, 10, sl1.val,  -1,    1,     gfx_w-100 ,0);
sl2.slider(20, 60, 8,  sl2.val,  -100,  100,   gfx_w-20  ,1);

slider1 = sl1.val;
slider2 = sl2.val;
spk77 is offline   Reply With Quote
Old 11-23-2014, 12:34 PM   #8
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default Very simple EEL example:

It's possible to use @import filename.eel in EEL:

Very simple example (spk_slider_class.eel has to be in the same folder):
Code:
@import spk_slider_class.eel

// init
function init()
(
  gfx_init("",200,200);
  gfx_setfont(1, "Verdana", 16);
  sl1.val = 0; // sl1 initial value
  sl2.val = 10; // sl2 initial value
);

function run()
(
  gfx_a = 1;
  gfx_r =1; gfx_g =1; gfx_b = 1;
 
  sl1 = sl1.slider(20, 20, 6, sl1.val, -100, 100, gfx_w - 30, 0);
  sl2 = sl2.slider(20, 20+30, 6, sl2.val, 0, 40, gfx_w - 30, 1);
  
  char = gfx_getchar();

  char >= 0 ? (
    defer("run();");
  );

  gfx_update();
);

init();
run();
Here's the slider code file: (link added to post#1 also)
https://stash.reaper.fm/22401/spk_slider_class.eel
spk77 is offline   Reply With Quote
Old 11-25-2014, 05:52 PM   #9
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

This seems to be possible:

(Adding sliders dynamically)
spk77 is offline   Reply With Quote
Old 11-25-2014, 05:55 PM   #10
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

omg spk77... someone needs to make a good replacement for GetUserInputs... you are inspiring me... a text field library anyone?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 11-25-2014, 06:04 PM   #11
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
omg spk77... someone needs to make a good replacement for GetUserInputs... you are inspiring me... a text field library anyone?
Yes!
"Edit box" (or text field) -widget/element (or whatever that is called) would be nice
spk77 is offline   Reply With Quote
Old 11-25-2014, 07:02 PM   #12
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

complete with ability to highlight text, copy, paste, etc. If I have time I'd love to get started on that,
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 11-25-2014, 07:58 PM   #13
Nixon
Human being with feelings
 
Nixon's Avatar
 
Join Date: Dec 2011
Posts: 406
Default

Is it possible to use those sliders for plugins too? Would be awesome.
Nixon is offline   Reply With Quote
Old 11-26-2014, 07:09 AM   #14
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Thank you spk77 for this sliders, used on scripts you wrote in the Takes Random Action - Pan and More thread :P

Is it possible to change to color to the Fill and to the Border of the elements ?
X-Raym is offline   Reply With Quote
Old 11-27-2014, 03:17 PM   #15
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Nixon View Post
Is it possible to use those sliders for plugins too? Would be awesome.
It's possible to use these slider functions in JSFXs, but I recommend using IXix's GUI-library (for JSFX). It's very good - I like the "mouse system".

http://forum.cockos.com/showthread.php?t=143857
http://forum.cockos.com/showthread.php?t=143485


I'm making (or trying to make) this simple library, because it's not possible to use the IXix's library in ReaScript EEL (at least not without modifications). Also, the GUI "objects" has to be(?) png files.

I'm just using EEL's gfx_draw_something() -functions to draw an object that possibly looks like a slider (for example )

Quote:
Originally Posted by X-Raym View Post
Thank you spk77 for this sliders, used on scripts you wrote in the Takes Random Action - Pan and More thread :P

Is it possible to change to color to the Fill and to the Border of the elements ?
It's possible, but might be that I didn't understand
These two lines draw a slider:
Code:
gfx_roundrect(this.x_pos - this.radius, this.y_pos - this.radius, this.slider_w - this.x_pos + 2 * this.radius, 2 * this.radius, this.radius);
gfx_circle(this.x_coord, this.y_pos, this.radius, this.fill);


...I'll rewrite the code in "slider function":

I have new ideas for this whole library thing (that is: tkinter like "managing"):
f.ex. "container frames" for GUI-elements (for sliders, knobs etc.). The "container frames" would be divided into rows and columns - then it should be easier to:
  • manage object positions (in gfx window)
  • handle "mouse events"/"mouse positions" etc.

It will take time - I'm not a programmer

Last edited by spk77; 11-27-2014 at 03:28 PM.
spk77 is offline   Reply With Quote
Old 11-27-2014, 03:27 PM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
Originally Posted by spk77 View Post
I'm not a programmer
You definitely are !

Quote:
Originally Posted by spk77 View Post
It's possible, but might be that I didn't understand
I retry, with a better English :
Can we change the slider color ? For it's border color and fill color (which is black per default) ?
X-Raym is offline   Reply With Quote
Old 11-27-2014, 03:35 PM   #17
Nixon
Human being with feelings
 
Nixon's Avatar
 
Join Date: Dec 2011
Posts: 406
Default

Thanks for the answer spk77. Reading my question again I wasn't very accurate though. I wanted to ask if it's possible to use these sliders as an dynamic remote (or overview) to control several plugin parameters (like you did with the pans but also with normal vsts from different tracks). So we can drag and drop the parameters we want to list and have them in one window. I know that reaper has build in some sort of this behavior but if i remember right it's kind of different.

Regards

Last edited by Nixon; 11-27-2014 at 03:42 PM.
Nixon is offline   Reply With Quote
Old 11-27-2014, 03:37 PM   #18
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by X-Raym View Post
You definitely are !


I retry, with a better English :
Can we change the slider color ? And the color of it's fill (which is black per default) ?
Graphics functions:
http://www.cockos.com/reaper/sdk/js/gfx.php#js_gfx

gfx_a (alpha: 0 to 1)
gfx_r (red: 0 to 1)
gfx_g (green: 0 to 1)
gfx_b (blue: 0 to 1)


I don't actually know how to fill a "roundrect object" (there's no "fill" option):

Code:
gfx_roundrect(x,y,w,h,radius[,antialias]) -- REAPER 4.60+
Draws a rectangle with rounded corners.
spk77 is offline   Reply With Quote
Old 11-27-2014, 03:42 PM   #19
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@spk77
Perfect, thank you for your help !
X-Raym is offline   Reply With Quote
Old 11-27-2014, 03:46 PM   #20
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Nixon View Post
Thanks for the answer spk77. Reading my question again I wasn't very accurate though. I wanted to ask if it's possible to use these sliders as an dynamic remote (or overview) to control several plugin parameters (like you did with the pans but also with normal vsts from different track). So we can drag and drop the parameters we want to list and have them in one window. I know that reaper has build in some sort of this behavior but if i remember right it's kind of different.

Regards
Might be possible, but I'm not sure if it's possible to get min/max values of a parameter in "correct format" (eg. 20hz-20000hz).
Usually TrackFX_GetXXXXX -functions return a value between 0 to 1, -1 to 1(pan), 0 to 2(vol) etc.

EDIT: Actually, I don't know how to scale/show the values.

Last edited by spk77; 11-27-2014 at 03:52 PM.
spk77 is offline   Reply With Quote
Old 11-27-2014, 03:53 PM   #21
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by X-Raym View Post
@spk77
Perfect, thank you for your help !
Glad I could help
spk77 is offline   Reply With Quote
Old 11-27-2014, 08:13 PM   #22
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,924
Default

I've taken to using: rgba(r, g, b, a); because it's easier to type


Code:
function rgba(r, g, b, a)
(
	a !=0 ? gfx_a = a; // a==0, don't change a
	gfx_r = r; gfx_g = g; gfx_b = b; // set r,g,b
);


>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 11-27-2014, 10:32 PM   #23
mwe
Human being with feelings
 
mwe's Avatar
 
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
Default

Quote:
Originally Posted by spk77 View Post
I don't actually know how to fill a "roundrect object" (there's no "fill" option):
I've been using this. It's admittedly a brute force approach and doesn't work well with gfx_a < 1.
Code:
function gfx_fill_rnd_rect(x, y, w, h, r, aa)
(
  gfx_circle(x + r, y + r, r, 1, aa);
  gfx_circle(x + w - r, y + r, r, 1, aa);  
  gfx_circle(x + w - r, y + h - r, r, 1, aa);
  gfx_circle(x + r, y + h - r, r, 1, aa);
  gfx_rect(x, y + r, r, h - r * 2);
  gfx_rect(x + r, y, w - r * 2, h + 1);
  gfx_rect(x + w - r, y + r, r + 1, h - r * 2);
);
mwe is offline   Reply With Quote
Old 11-28-2014, 01:04 AM   #24
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@planetnine
Nice trick ! RGBA is far more easy to use

@mwe
Any screenshot to show us ?
X-Raym is offline   Reply With Quote
Old 11-28-2014, 02:57 AM   #25
mwe
Human being with feelings
 
mwe's Avatar
 
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
Default

Quote:
Originally Posted by X-Raym View Post
@mwe
Any screenshot to show us ?
It's just a little snipet I did a few months ago for a JS I was playing with. It solved an immediate need and I didn't do much else with it. Somewhere I have a nice little doodad using gfx_gradrect, I'll try to find it if there's any interest.

mwe is offline   Reply With Quote
Old 11-28-2014, 03:20 AM   #26
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

That's nice

If you want to go further,
This should interest you : 3D realtime raytrace JS GFX
X-Raym is offline   Reply With Quote
Old 11-29-2014, 08:44 AM   #27
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by spk77 View Post
it's not possible to use the IXix's library in ReaScript EEL (at least not without modifications).
I haven't tried to use the library in an EEL script but I thought it would be compatible. What's the problem? Perhaps I can get it working for both...
IXix is offline   Reply With Quote
Old 11-29-2014, 10:29 AM   #28
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
I haven't tried to use the library in an EEL script but I thought it would be compatible. What's the problem? Perhaps I can get it working for both...
That would be great!


I don't know exactly what should be changed (not very many things, I hope), but at least these:

1)
"ReaScript/EEL can import functions from other reascripts using @import filename.eel -- note that only the file's functions will be imported, normal code in that file will not be executed."

I think something like this would work ("Misc constants" would be in "mouse.init_constants" function):

(ixmouse.eel)
Code:
function mouse.init_constants()
(
  // Misc constants
  mouse.TRUE = 1;
  mouse.FALSE = 0;
  mouse.CANCEL = -1;
);

(importing "ixmouse.eel" and initializing "Misc constants"):
Code:
@import ixmouse.eel

mouse.init_constants();

ShowConsoleMsg(sprintf(#, "%d\n", mouse.TRUE));
ShowConsoleMsg(sprintf(#, "%d\n", mouse.FALSE));
ShowConsoleMsg(sprintf(#, "%d\n", mouse.CANCEL));

2)
File functions seem to be different
spk77 is offline   Reply With Quote
Old 11-29-2014, 10:57 AM   #29
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Ah I see, subtle differences. I'll have a look at it when I get chance. I may have to make separate versions for JS and EEL.

Regarding all the elements needing to be image files, at some point I'd like to make loading images optional and set up a system for drawing the controls with gfx methods. It's one of the features I didn't have time to implement but I know roughly how it should work.
IXix is offline   Reply With Quote
Old 11-29-2014, 11:44 AM   #30
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by IXix View Post
Ah I see, subtle differences. I'll have a look at it when I get chance. I may have to make separate versions for JS and EEL.
Very nice

Quote:
Originally Posted by IXix View Post
Regarding all the elements needing to be image files, at some point I'd like to make loading images optional and set up a system for drawing the controls with gfx methods. It's one of the features I didn't have time to implement but I know roughly how it should work.
That would be great - then it should be easier to make/handle custom elements: edit/input boxes, scrollbars, knobs etc. Also, making more complex GUIs should be easier

Usually when testing EEL scripts, I need just a simple slider (or sliders) for passing different values to the ReaScript API functions.

("Edit box" would be nice...I'll try to make that next )
spk77 is offline   Reply With Quote
Old 11-29-2014, 11:53 AM   #31
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

In the post#9 (dynamically adding sliders), I was surprised that this worked:


(It doesn't look very nice or even safe)
Code:
function main()
( 
  i = 0;
  loop(CountSelectedTracks(0),
    i.val = GetMediaTrackInfo_Value(GetSelectedTrack(0, i), "D_PAN");
    //
    //               X       Y     H  value  min max     W      id
    i.val = i.slider(30, 20+ i*30, 5, i.val, -1, 1, gfx_w - 30, i);
    i += 1;
  );
  
  // Global variable "last_slider_id" is stored in the "slider" function:
  // 
  // mouse_is_on_slider && !mouse_cap ? last_slider_id = slider_id;
  
  mouse_cap == 1 ? (
    SetMediaTrackInfo_Value(GetSelectedTrack(0, last_slider_id), "D_PAN", last_val);
  );  

  gfx_update(); 
  gfx_getchar() >= 0 ? defer("main();");
);
spk77 is offline   Reply With Quote
Old 12-03-2014, 03:41 PM   #32
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Post#1 updated.
spk77 is offline   Reply With Quote
Old 12-03-2014, 03:43 PM   #33
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

It looks very nice ! Congratulations !
X-Raym is offline   Reply With Quote
Old 12-03-2014, 03:45 PM   #34
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by X-Raym View Post
It looks very nice ! Congratulations !
Thanks
spk77 is offline   Reply With Quote
Old 12-03-2014, 04:05 PM   #35
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Is this compatible with the scripts that use the first version ?

I got this error message :
Code:
Error: C:\Users\Anymord\AppData\Roaming\REAPER\Scripts\Create take pitch envelope (random points - with GUI).eel:204: 'm.slider' needs 9 parms: ', m.val, -12, 12, gfx_w - 30, 0 <!> ))'
Cheers !
X-Raym is offline   Reply With Quote
Old 12-03-2014, 04:14 PM   #36
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by X-Raym View Post
Is this compatible with the scripts that use the first version ?

Cheers !
No
I'll modify the "Create take pan envelope..." -script (as an example) and make it work with the new slider code.
spk77 is offline   Reply With Quote
Old 12-03-2014, 04:42 PM   #37
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Don't worry it works fine with the original one, and I started to develop other things based on this :P
I will send you a mp.
X-Raym is offline   Reply With Quote
Old 12-05-2014, 03:26 PM   #38
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

"Button-like elements"



(I'll try to post something tomorrow)
spk77 is offline   Reply With Quote
Old 12-05-2014, 05:08 PM   #39
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

It becomes serious what's next ?
X-Raym is offline   Reply With Quote
Old 12-07-2014, 06:38 AM   #40
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by X-Raym View Post
It becomes serious what's next ?
"Frame", "Input box", "Text/label" - elements would be nice .

I don't want to go much "deeper" with it, because IXix already has a working GUI system for JSFX (and as he said, later for EEL also ).
spk77 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 10:07 PM.


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