Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: [JS] ScriptUI CS6

$
0
0

Hi all,

 

I made an easy to use scrollable panel function.

 

There is one significant change from the methodology used above.  That is the use of maximumSize, without using this the size of the inner panel is limited to the size of the screen.


Enjoy,

 

Trevor

 

// By Trevor http://forums.adobe.com/thread/1229123?tstart=0 
function addScrollablePanel (toTheParent,                                            locationX,                                            locationY,                                            outerPanelWidth,                                            outerPanelHeight,                                            innerPanelWidth /* leave blank if not scrolling horizontally*/,                                            innerPanelHeight /* leave blank if  not scrolling vertically*/,                                             barThickness /* optional */)    {        var  padding = 2, innerPanel, outerPanel, scrollbarH, scrollbarV;        innerPanelWidth || innerPanelWidth = outerPanelWidth; // if the optinal variables are not defined then define them        innerPanelHeight || innerPanelHeight = outerPanelHeight;        barThickness || barThickness = 15;        innerPanelWidth += padding;        innerPanelHeight += padding;        scrollbarH = (innerPanelWidth != outerPanelWidth + padding);        scrollbarV = (innerPanelHeight != outerPanelHeight + padding);        if ($.os.match(/Windows/i))            {                 scrollbarV && scrollbarV = toTheParent.add('scrollbar', [locationX + outerPanelWidth - barThickness -  padding, locationY + padding , locationX + outerPanelWidth  -  padding, locationY + outerPanelHeight  - padding - (scrollbarH && barThickness)]);                 scrollbarH && scrollbarH = toTheParent.add('scrollbar', [locationX + padding, locationY + outerPanelHeight - padding -barThickness,  locationX + outerPanelWidth - padding - (scrollbarV && barThickness), locationY + outerPanelHeight - padding]);                 scrollbarH && scrollbarV && toTheParent.add('statictext', [locationX + outerPanelWidth - barThickness - padding , locationY + outerPanelHeight - barThickness - padding, locationX + outerPanelWidth - padding, locationY + outerPanelHeight - padding]); // fill the gap between the scrollbarbuttons                 outerPanel = toTheParent.add('panel',[locationX, locationY, locationX + outerPanelWidth, locationY + outerPanelHeight]);            }        else// Mac            {                outerPanel = toTheParent.add('panel',[locationX, locationY, locationX + outerPanelWidth, locationY + outerPanelHeight]);                scrollbarV && scrollbarV = toTheParent.add('scrollbar', [locationX + outerPanelWidth - barThickness -  padding, locationY + padding , locationX + outerPanelWidth  -  padding, locationY + outerPanelHeight  - padding - (scrollbarH && barThickness)]);                scrollbarH && scrollbarH = toTheParent.add('scrollbar', [locationX + padding, locationY + outerPanelHeight - padding ,  locationX + outerPanelWidth - padding - (scrollbarV && barThickness), locationY + outerPanelHeight - padding - barThickness]);                scrollbarH && scrollbarV && toTheParent.add('statictext', [locationX + outerPanelWidth - barThickness - padding , locationY + outerPanelHeight - barThickness - padding, locationX + outerPanelWidth - padding, locationY + outerPanelHeight - padding]);                           }        innerPanel = outerPanel.add('panel'); // set the bounds after setting the maximumSize        innerPanel.maximumSize = [innerPanelWidth * 2, innerPanelHeight * 2]; // This needs to be set to at lest the required size otherwise the panel size is limmited to the screen size        innerPanel.bounds = [0, 0, innerPanelWidth, innerPanelHeight]; // now we can set the size :-)        scrollbarV && scrollbarV.jumpdelta = 100 * outerPanelHeight / innerPanelHeight; // Make size of bar whatdoyoucallit (drag thing) propotional to the size of the windows        scrollbarH && scrollbarH.jumpdelta = 100 * outerPanelWidth / innerPanelWidth; // Make size of bar whatdoyoucallit (drag thing) propotional to the size of the windows        scrollbarV && scrollbarV.onChanging = function () {innerPanel.location.y = scrollbarV.value*(outerPanelHeight)/100 - scrollbarV.value*(innerPanelHeight)/100 - padding *(1-scrollbarV.value/100) };        scrollbarH && scrollbarH.onChanging = function () {innerPanel.location.x = scrollbarH.value*(outerPanelWidth)/100 - scrollbarH.value*(innerPanelWidth)/100 - padding *(1-scrollbarH.value/100) };        innerPanel.location.x -= padding;        innerPanel.location.y -= padding;        return innerPanel;} 
function hiJareck (toTheParent, accross, down, n, nn)    {        accross || accross = 1;        down || down = 1;        /*        if (!accross >1) accross = 1;        if (!down >1) down = 1;*/        for (n = 0; n < down; n++) for (nn = 0; nn < accross; nn++) toTheParent.add('edittext',[20+nn * 140,15+n*30, 130 + nn * 140 ,35+n*30], "Hi Jareck #"+ (n+1) + " #"  + (nn+1) );    } /* ****************** USAGE ********************* */ 
var w = new Window ("dialog","My Horizontally Scrollable Panel",[100, 100, 900 , 600]);
horizontalScrollablePanel = addScrollablePanel (w, 20, 20, 250, 70, 3700, false, 20);
horizontalScrollablePanel2 = addScrollablePanel (w, 20, 100, 250, 70, 1000, false, 20);
verticalScrollablePanel = addScrollablePanel (w, 300, 20, 200, 150, false, 1000, 20);
verticalScrollablePanel2 = addScrollablePanel (w, 510, 20, 200, 150, false, 1000, 40);
vertAndHorzScrollablePanel = addScrollablePanel (w, 250, 190, 310, 210, 3520, 820);
hiJareck(horizontalScrollablePanel, 26, 1);
hiJareck(horizontalScrollablePanel2, 7, 1);
hiJareck(verticalScrollablePanel, 1, 30);
hiJareck(verticalScrollablePanel2, 1, 30);
hiJareck(vertAndHorzScrollablePanel, 25, 25);
w.show(); 

Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>