PDA

View Full Version : mini slider with distances?



spud_q
10-10-2004, 05:25 PM
Hello,

I知 trying to recreate the set value tool with Lscripting. I want to add some more features without taking any of the original functionality. The original set value tool is a real plug-in not an Lscript, so here is my question. In Lscripting is there any way to make a mini slider that holds distances? The original tool has a distance mini slider and if I知 going to do this right I would need to recreate the same.

Thanks

GregMalick
10-10-2004, 08:17 PM
I think you'll have to cheat by using both a ctlminislider() and a ctldistance().
Yes, it will be a coding hack. You'll need to hide that ctlminislider "value box".
I wish we had all the standard controls. I've actually asked H2MW to try to get this one in the next LScript version.

spud_q
10-10-2004, 09:11 PM
Man, you made that sound easy! :)

Here is my requester so far. Is there any way to make the slider values floating point? When I pull the slider to not get integers?

For example get values such as 500mm and not 20m.


Oh and thanks for the reply. That reply was a great help.


__________________________________________________ ____


@warnings
@version 2.3




length;
value;


main
{
axisVar = 2;
hardValue = 1;

reqbegin("My Requester");
reqsize(256,150);



slider = ctlminislider("Value",hardValue,-500,500);
ctlposition(slider,21,37,108,19);

length = ctldistance("leangth",hardValue);
ctlposition(length,20,70);

ctlrefresh(slider,"refresh");



return if !reqpost();

requpdate();

axisVar = getvalue(slider);
hardValue = getvalue(length);

reqend();
}


refresh: value {
setvalue(length, value);
}

spud_q
10-10-2004, 09:17 PM
Oh I got it! Thank you Gregory for your reply. I would have never figured that out on my own. Thank you very much.

GregMalick
10-10-2004, 09:56 PM
Hi spud,
Looks like you must have solved it while I was away. The trick is to size the minislider "box" so it is small enough to easily obscure and strategically place the ctldistance so that it looks like it's actually part of the minislider. Why don't you post your completed code so other newbies can benefit. :)


p.s. won't it be nice when we don't have to "workaround" these simple things?

spud_q
10-10-2004, 10:31 PM
I sure will. I値l post the final code when I have my plug finished. I知 sure it will be useful for someone, but I tell you its awfully unorganized.

I have to say that it surprises me that this hack is the only way to solve this problem. There are only about a billion projects that you would want to use a mini slider with distances. :)

Thanks again for your help,

Patrick

GregMalick
10-10-2004, 11:08 PM
Actually, I only meant the code regarding the Distance miniSlider. Just so other LScripters that search on this topic can benefit. :D

spud_q
10-10-2004, 11:58 PM
Well thats awfully boring don't you think :) Well beacuse you ask for it, here it is. This code snipet is a requester that has a hacked minislider with distances.

At this point it just says it's a set value tool, It doesn't do anything.




__________________________________________________ _______
@warnings
@version 2.3


c1;
c2;


main
{
slider = 0;
distance = 0;
axisVar = 2;

reqbegin("Set Value");
reqsize(305,123);

c1 = ctlminislider(" ",slider,-50000,50000); ctlposition(c1,143,40,10,19);

c2 = ctldistance("Value",distance); ctlposition(c2,59,40);

c3 = ctlchoice("Axis",axisVar,@"X","Y","Z"@); ctlposition(c3,59,14,172,19);

ctlrefresh(c1,"refresh1");

return if !reqpost();

slider = getvalue(c1);
distance = getvalue(c2);
axisVar = getvalue(c3);

reqend();
}


refresh1: value {

setvalue(c2, value*.01);

}

GregMalick
10-11-2004, 01:06 AM
Booring... well yes. ;) But in a few months some newbie will be posting a "Thank You" reply for the pain you saved them.

So spud... thanks and welcome to the community.


p.s. I grew up and graduated HS in Griffith, IN.

spud_q
10-11-2004, 04:14 AM
Thank you for the warm welcome.

I'm afraid I can't say I have visited Griffith. That痴 way up there for me. I live way down in Columbus. It痴 always great to hear from anybody from Indiana. There doesn稚 seem to be enough people getting into the 3D business here.

I sure will be posting more often. I'm trying to make myself more available to the LW community as well as the general 3D industry.

I really appreciate your help and can't wait to get my first completed plug-in posted.

-Patrick

Malorie
12-22-2005, 06:32 AM
Well, it's been more than a few months, but THANK YOU!!! That's exactly what I was looking for. ;)

GregMalick
12-22-2005, 08:52 AM
OMG!
my family vacationed in paw paw, Michigan when I was a child.
a trillion years ago in a galaxy far far away....


And glad this helped :thumbsup:

Malorie
12-22-2005, 09:19 AM
I hadn't quite gotten to tackling this problem yet, but it was coming up quick in my current project. I knew it was going to be somthing like that. In fact, I had quickly splashed some code about while pondering this problem and I came up with something very similar. Of course syntax was a real problem with mine. ;)

Anyway, Paw Paw!? What on earth would they come here for. ;)
Malorie

evenflcw
12-22-2005, 09:07 PM
Clever stuff! Thanks! I found myself needing a distance minislider too. Just featured requested it yesterday!

I modified the previous code example abit. Why use ctlminislider() which enforces a limited range!? Use ctlpercent() or ctlangle() instead which don't require you to specify a range!

I also added in a second refresh so they update eachother. The if case is needed to prevent them going into an endless loop updating eachother. I don't know, but maybe the simple comparison will fail on really long numbers when precision go out the window.

This works out great. Only problem is that the stepping when sliding is different (more precise) from what a proper implementation of a distance minislider would provide. This can probably be fixed aswell. But now I'm gonna go sleep :)


c1;
c2;


main
{
val = 0;

reqbegin("CtlDistance");
reqsize(305,123);

c1 = ctlpercent("", val);
c2 = ctldistance("Value", val);

ctlposition(c2, 5, 5, 97);
ctlposition(c1, 89, 5, 10, 19);

ctlrefresh(c1,"refresh_c2");
ctlrefresh(c2,"refresh_c1");

return if !reqpost();

val = getvalue(c2);

reqend();
}


refresh_c2: value
{
if( value != getvalue(c2) )
setvalue(c2, value);
}

refresh_c1: value
{
if( value != getvalue(c1) )
setvalue(c1, value);
}

Malorie
12-23-2005, 05:33 AM
Did I miss something?

You use the minislider to get the minislider control, right?

I don't think the percent or angle controls have a minislider, do they?

evenflcw
12-23-2005, 05:54 AM
I did not use theminislider control for reaons mentioned above (it only works within a limited range). Percent and angle controls both have minislider and support their respective units (% and コ). Reading the lscript release notes, those two got added in v2.1 but recieved a minislider only in v2.5.1. Why the distance controller didn't also recieve a slider is beyond me. *irritated*

Malorie
12-24-2005, 12:47 AM
Well, that would be what I missed then. I have V2.4 with no minisliders other than the ctlminislider.

That would probably be why nobody has responded to this thread for a year. ;)

Malorie
12-26-2005, 10:20 AM
I finally got what I was looking for out of this hack. I now have a minislider with no limit and decimal values.

The minislider is now being used for sort of an amount of change variable and gets reset to zero whenever not being updated. Now you can enter any value in the number box and it stays there and is updated by the minislider.

By increasing or decreasing the number range in the minislider, you can increase or decrease the sensativity to the speed of the mouse to some extent. Higher numbers give greater possible changes, while smaller numbers give only single step changes.

And of course the decimal value in the refresh routine sets the number of decimal places in the control.

If you want a distance value or angle or whateve, you would just replace the cltnumber with the correct value control.

Here's what I came up with...


c1,c2;

options
{
var1 = 0;
var2 = 0;

reqbegin("My Requester");
reqsize(300,200);

c1 = ctlminislider(" ",var1,-100,100);
ctlposition(c1,200,10,10,19);

c2 = ctlnumber("Decimal Number Slider",var2);
ctlposition(c2,14,10,197,19);

ctlrefresh(c1,"refresh1");

return if !reqpost();

var2 = getvalue(c2);

reqend();
}

refresh1:value
{
setvalue(c2,getvalue(c2)+value*.001);
setvalue(c1,0);
}


Enjoy,
Malorie

evenflcw
12-26-2005, 10:28 AM
Very nice and neat solution, Malorie! Thanks!

Malorie
12-26-2005, 12:42 PM
You are most welcome.

PrintF
02-20-2007, 05:06 PM
how about now with LW 8.5 - ctldistance + minislider, inside lscript in one control element?

nickdigital
06-30-2011, 08:22 PM
Booring... well yes. ;) But in a few months some newbie will be posting a "Thank You" reply for the pain you saved them.


Thanks!

spud_q
08-05-2011, 05:21 AM
woh, haha, hardly a few months have gone by.