Guest User

xToolBar v1.5

a guest
Mar 19th, 2012
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.78 KB | None | 0 0
  1. --------------### xToolBar ###------------
  2. xToolBar = {};
  3. xToolBar.Version = "1.5.0.0""\\btn_xToolBar.btn") then
  4.     for x=1, 4 do
  5.         Crypto.Base64DecodeFromString(xToolBar.Buttons[x], xToolBarButtons_Path.."\\btn_xToolBar"..((x>1) and x or "")..".btn");
  6.     end
  7. end
  8.  
  9. --Animations--
  10. xMODESTRAIGHT = 1;
  11. xMODEUP = 2;
  12. xMODEDOWN = 3;
  13. xMODESTRAIGHTUP = 4;
  14. xMODESTRAIGHTDOWN = 5;
  15. xMODESHAKEME = 6;
  16. xMODEFISHEYE_UP = 7;
  17. xMODEFISHEYE_DOWN = 8;
  18. xMODEFISHEYE_MIDDLE = 9;
  19. xMODESHAKEME_UD = 10;
  20. xMODESHAKEME_LR = 11;
  21. xMODESTRAIGHTALL = 12;
  22.  
  23. --ORCONSTANTS--
  24. x_ORIENTATION_HOR = 1;
  25. x_ORIENTATION_VER = 2;
  26. x_SIDE_LEFT = 1;
  27. x_SIDE_RIGHT = 2;
  28.  
  29. --xToolBar_Globals--
  30. xToolBar.nMaxSize = 1.5;
  31. xToolBar.nShakes = 50;
  32. xToolBar.nSide = 1;--1=left, 2=right
  33.  
  34. --xToolBar functions--
  35. xToolBar.AddItem = function(sObject, tContainer)
  36.     xToolBar.CheckValue(tContainer, "table", "xToolBar table");
  37.     for each, image in pairs(tContainer.tItems) do
  38.         if image.id == sObject then
  39.             Application.ExitScript();
  40.         end
  41.     end
  42.     Application.SetRedraw(false);
  43.     local nK = Page.GetObjectType(sObject);
  44.     local tD = xToolBar.Objects[nK+1];
  45.     local n = #tContainer.tItems;
  46.     local step = tContainer.nSize+tContainer.nSpace;
  47.     tD.SetSize(sObject, tContainer.nSize, tContainer.nSize);
  48.     if n == 0 then
  49.         tD.SetPos(sObject, tContainer.nLeft-(tContainer.nSize/2), tContainer.nTop-(tContainer.nSize/2));
  50.     else
  51.         if tContainer.nOr == 1 then
  52.             local mintotal = tContainer.nLeft - ((((n+1) * tContainer.nSize) + (n * tContainer.nSpace))/2);
  53.             for each, image in pairs(tContainer.tItems) do
  54.                 local tDe =  xToolBar.Objects[image.kind+1];
  55.                 image.left = mintotal+(step*(each-1));
  56.                 image.right = image.left + tContainer.nSize;
  57.                 image.lm_x = image.left + (tContainer.nSize/2);
  58.                 tDe.SetPos(image.id, image.left , tContainer.nTop-(tContainer.nSize/2));
  59.             end
  60.             tD.SetPos(sObject, (mintotal+(step*n)), tContainer.nTop-(tContainer.nSize/2));
  61.         else
  62.             local mintotal = tContainer.nTop - ((((n+1) * tContainer.nSize) + (n * tContainer.nSpace))/2);
  63.             for each, image in pairs(tContainer.tItems) do
  64.                 local tDe =  xToolBar.Objects[image.kind+1];
  65.                 image.top = mintotal+(step*(each-1));
  66.                 image.bottom = image.top + tContainer.nSize;
  67.                 image.lm_y = image.top + (tContainer.nSize/2);
  68.                 tDe.SetPos(image.id, tContainer.nLeft-(tContainer.nSize/2), image.top);
  69.             end
  70.             tD.SetPos(sObject, tContainer.nLeft-(tContainer.nSize/2), (mintotal+(step*n)));
  71.         end
  72.     end
  73.     local tPos = tD.GetPos(sObject);
  74.     local tool = "";
  75.     if tContainer.bTool and nK ~= 40 then
  76.         local tProps = tD.GetProperties(sObject);
  77.         tool = tProps.TooltipText
  78.         tProps.TooltipText = "";
  79.         tD.SetProperties(sObject, tProps);
  80.     end
  81.     if nK==3 and tContainer.nTrans~=-1 then
  82.         Image.SetOpacity(sObject, tContainer.nTrans);
  83.     end
  84.     table.insert(tContainer.tItems, #tContainer.tItems+1, {id=sObject, tooltip=tool, kind=nK, left=tPos.X, top=tPos.Y, right=tPos.X+tContainer.nSize, lm_x=tPos.X+(tContainer.nSize/2), bottom=tPos.Y+tContainer.nSize, lm_y=tPos.Y+(tContainer.nSize/2)})
  85.     Application.SetRedraw(true);
  86.     return true;
  87. end
  88.  
  89. xToolBar.Animate = function (e_X, e_Y, toolbar)
  90.     if toolbar then
  91.         local xbtn = "";
  92.         if toolbar.nOr == 1 then
  93.             xbtn = (toolbar.nMode==3 or toolbar.nMode==5 or toolbar.nMode==8) and "btn_xToolBar2" or "btn_xToolBar";
  94.         else
  95.             xbtn = (xToolBar.nSide==1) and "btn_xToolBar3" or "btn_xToolBar4";
  96.         end
  97.         if e_Y >= (toolbar.tItems[1].top-(toolbar.nSize/2)) and e_Y <= (toolbar.tItems[table.maxn(toolbar.tItems)].bottom+(toolbar.nSize/2)) and e_X > (toolbar.tItems[1].left-(toolbar.nSize/2)) and e_X < (toolbar.tItems[table.maxn(toolbar.tItems)].right+(toolbar.nSize/2)) then
  98.             if toolbar.nMode <= 11 then
  99.                 for x, item in pairs(toolbar.tItems) do
  100.                     if e_X >= item.left-(toolbar.nSpace/2) and e_X <= item.right+(toolbar.nSpace/2) and e_Y >= item.top-(toolbar.nSpace/2) and e_Y <= item.bottom+(toolbar.nSpace/2) then
  101.                         if toolbar.nOr == 1 then
  102.                             local dif = item.lm_x-e_X;
  103.                             local factor = (toolbar.nMode==1 or toolbar.nMode==6 or toolbar.nMode==10 or toolbar.nMode==11) and 0 or (toolbar.nMode==2 or toolbar.nMode==4) and ((toolbar.nSize/2)-math.abs(dif))*.5 or -(((toolbar.nSize/2)-math.abs(dif))*.5);--Vertical % to increase
  104.                             local tDe = xToolBar.Objects[item.kind+1];
  105.                             if item.kind==3 and toolbar.nTrans~=-1 then
  106.                                 tDe.SetOpacity(item.id, 100-(math.abs(dif)*2));
  107.                             end
  108.                             if toolbar.nMode >= 7 and toolbar.nMode <= 9 then --fisheye_up, down, middle
  109.                                 local newDiff = xToolBar.nMaxSize-(math.abs(dif)*2*.01);
  110.                                 newDiff = (newDiff<1) and 1 or newDiff;
  111.                                 local newSize = toolbar.nSize*newDiff;
  112.                                 local newPos = (newSize-toolbar.nSize)/2;
  113.                                 tDe.SetPos(item.id, item.left-newPos, (toolbar.nMode==7) and item.top-(newPos*2) or (toolbar.nMode==8) and item.top or item.top-newPos)
  114.                                 tDe.SetSize(item.id, newSize, newSize);
  115.                                 if toolbar.bTool then
  116.                                     if item.tooltip== "" then
  117.                                         Button.SetVisible(xbtn, false)
  118.                                     else
  119.                                         Button.SetText(xbtn, item.tooltip);
  120.                                         Button.SetPos(xbtn, item.lm_x-46.5, (toolbar.nMode==7) and item.top-((newSize/2)+32) or (toolbar.nMode==8) and item.top+(newSize+2) or item.top-((newSize/2)+16));
  121.                                         if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  122.                                     end
  123.                                 end
  124.                                 for each, other in pairs(toolbar.tItems) do
  125.                                     if other.id ~= item.id then
  126.                                         local tDf = xToolBar.Objects[other.kind+1];
  127.                                         tDf.SetPos(other.id, (other.left<item.left) and other.left-newPos or other.left+newPos, other.top)
  128.                                         tDf.SetSize(other.id, toolbar.nSize, toolbar.nSize);
  129.                                     end
  130.                                 end
  131.                             else
  132.                                 if toolbar.bTool then
  133.                                     if item.tooltip== "" then
  134.                                         Button.SetVisible(xbtn, false)
  135.                                     else
  136.                                         local res = (toolbar.nMode==3 or toolbar.nMode==5) and -(toolbar.nSize+2) or 32
  137.                                         Button.SetText(xbtn, item.tooltip);
  138.                                         Button.SetPos(xbtn, item.lm_x-46.5, item.top-factor-res);
  139.                                         if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  140.                                     end
  141.                                 end
  142.                                 if toolbar.nMode==6  or toolbar.nMode==10 or toolbar.nMode==11 then--shakes
  143.                                     Math.RandomSeed(999)
  144.                                     for x=1, xToolBar.nShakes do
  145.                                         local rangeX = Math.Random(-4,4);
  146.                                         local rangeY = Math.Random(-4,4);
  147.                                         tDe.SetPos(item.id, (toolbar.nMode==6 or toolbar.nMode==11) and item.left+rangeX or item.left, (toolbar.nMode==6 or toolbar.nMode==10) and item.top+rangeY or item.top)
  148.                                     end
  149.                                     tDe.SetPos(item.id, item.left, item.top)
  150.                                 else
  151.                                     tDe.SetPos(item.id, (toolbar.nMode<=3) and item.left+dif or item.left, item.top-factor);
  152.                                 end
  153.                             end
  154.                             break;
  155.                         else
  156.                             local dif = item.lm_y-e_Y;
  157.                             local factor = (toolbar.nMode==1 or toolbar.nMode==6 or toolbar.nMode==10 or toolbar.nMode==11) and 0 or (toolbar.nMode==2 or toolbar.nMode==4) and ((toolbar.nSize/2)-math.abs(dif))*.5 or -(((toolbar.nSize/2)-math.abs(dif))*.5);
  158.                             local tDe = xToolBar.Objects[item.kind+1];
  159.                             if item.kind==3 and toolbar.nTrans~=-1 then
  160.                                 tDe.SetOpacity(item.id, 100-(math.abs(dif)*2));
  161.                             end
  162.                             if toolbar.nMode >= 7 and toolbar.nMode <= 9 then --fisheye_up, down, middle
  163.                                 local newDiff = xToolBar.nMaxSize-(math.abs(dif)*2*.01);
  164.                                 newDiff = (newDiff<1) and 1 or newDiff;
  165.                                 local newSize = toolbar.nSize*newDiff;
  166.                                 local newPos = (newSize-toolbar.nSize)/2;
  167.                                 tDe.SetPos(item.id, item.left-newPos, (toolbar.nMode==7) and item.top-(newPos*2) or (toolbar.nMode==8) and item.top or item.top-newPos)
  168.                                 tDe.SetSize(item.id, newSize, newSize);
  169.                                 if toolbar.bTool then
  170.                                     if item.tooltip== "" then
  171.                                         Button.SetVisible(xbtn, false)
  172.                                     else
  173.                                         Button.SetText(xbtn, item.tooltip);
  174.                                         Button.SetPos(xbtn,(xToolBar.nSide==1) and item.left-((newSize/2)+80) or item.left+newSize+2, item.lm_y-15);
  175.                                         if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  176.                                     end
  177.                                 end
  178.                                 for each, other in pairs(toolbar.tItems) do
  179.                                     if other.id ~= item.id then
  180.                                         local tDf = xToolBar.Objects[other.kind+1];
  181.                                         if toolbar.nMode==9 then
  182.                                             tDf.SetPos(other.id, item.left, (other.top<item.top) and other.top-newPos or other.top+newPos)
  183.                                         elseif toolbar.nMode == 7 then
  184.                                             tDf.SetPos(other.id, item.left, (other.top<item.top) and other.top-(newPos*2) or other.top)
  185.                                         else
  186.                                             tDf.SetPos(other.id, item.left, (other.top<item.top) and other.top or other.top+(newPos*2))
  187.                                         end
  188.                                         tDf.SetSize(other.id, toolbar.nSize, toolbar.nSize);
  189.                                     end
  190.                                 end
  191.                             else
  192.                                 if toolbar.bTool then
  193.                                     if item.tooltip== "" then
  194.                                         Button.SetVisible(xbtn, false)
  195.                                     else
  196.                                         local res = (toolbar.nMode==3 or toolbar.nMode==5) and -(toolbar.nSize+2) or 95
  197.                                         Button.SetText(xbtn, item.tooltip);
  198.                                         Button.SetPos(xbtn,(xToolBar.nSide==1) and item.left-factor-res or item.right-factor+2, item.lm_y-15);
  199.                                         if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  200.                                     end
  201.                                 end
  202.                                 if toolbar.nMode==6  or toolbar.nMode==10 or toolbar.nMode==11 then--shakes
  203.                                     Math.RandomSeed(999)
  204.                                     for x=1, xToolBar.nShakes do
  205.                                         local rangeX = Math.Random(-4,4);
  206.                                         local rangeY = Math.Random(-4,4);
  207.                                         tDe.SetPos(item.id, (toolbar.nMode==6 or toolbar.nMode==11) and item.left+rangeX or item.left, (toolbar.nMode==6 or toolbar.nMode==10) and item.top+rangeY or item.top)
  208.                                     end
  209.                                     tDe.SetPos(item.id, item.left, item.top)
  210.                                 else
  211.                                     tDe.SetPos(item.id, item.left-factor, (toolbar.nMode<=3) and item.top+dif or item.top);
  212.                                 end
  213.                             end
  214.                             break;
  215.                         end
  216.                     end
  217.                 end
  218.             elseif toolbar.nMode == 12 then--xMODEAUTOMOVE
  219.                 if toolbar.nOr == 1 then
  220.                     local dif = toolbar.nLeft-e_X;
  221.                     for each, item in pairs(toolbar.tItems) do
  222.                         local tDf = xToolBar.Objects[item.kind+1];
  223.                         tDf.SetPos(item.id, item.left+(dif/#toolbar.tItems), item.top)
  224.                         if toolbar.bTool and e_X > item.left+(dif/#toolbar.tItems) and e_X < item.left+(dif/#toolbar.tItems)+toolbar.nSize then
  225.                             if item.tooltip== "" then
  226.                                 Button.SetVisible(xbtn, false)
  227.                             else
  228.                                 Button.SetText(xbtn, item.tooltip);
  229.                                 Button.SetPos(xbtn, (item.left+(dif/#toolbar.tItems)+(toolbar.nSize/2))-46.5, item.top-32);
  230.                                 if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  231.                             end
  232.                         end
  233.                     end
  234.                 else
  235.                     local dif = toolbar.nTop-e_Y;
  236.                     for each, item in pairs(toolbar.tItems) do
  237.                         local tDf = xToolBar.Objects[item.kind+1];
  238.                         tDf.SetPos(item.id, item.left, item.top+(dif/#toolbar.tItems))
  239.                         if toolbar.bTool and e_Y > (item.top+(dif/#toolbar.tItems)) and e_Y < (item.top+(dif/#toolbar.tItems)+toolbar.nSize) then
  240.                             if item.tooltip== "" then
  241.                                 Button.SetVisible(xbtn, false)
  242.                             else
  243.                                 Button.SetText(xbtn, item.tooltip);
  244.                                 Button.SetPos(xbtn,(xToolBar.nSide==1) and item.left-101 or item.right+2, (item.top+(dif/#toolbar.tItems)+(toolbar.nSize/2))-15);
  245.                                 if not Button.IsVisible(xbtn) then Button.SetVisible(xbtn, true) end
  246.                             end
  247.                         end
  248.                     end
  249.                 end
  250.             end
  251.             Application.ExitScript();
  252.         else
  253.             for x, item in pairs(toolbar.tItems) do
  254.                 local tDe = xToolBar.Objects[item.kind+1];
  255.                 if item.kind==3 and toolbar.nTrans~=-1 then
  256.                     tDe.SetOpacity(item.id, toolbar.nTrans)
  257.                 end
  258.                 tDe.SetPos(item.id, item.left, item.top);
  259.                 tDe.SetSize(item.id, toolbar.nSize, toolbar.nSize);
  260.                 if toolbar.bTool then
  261.                     Button.SetVisible(xbtn, false);
  262.                 end
  263.             end
  264.         end
  265.     end
  266. end
  267.  
  268. xToolBar.CheckValue = function(...)
  269.     if arg[2] == "button" then
  270.         if Page.GetObjectType(arg[1]) == -1 then
  271.             local xToolBarButtons_Path=_TempFolder;
  272.             for x=1, 4 do
  273.                 if Page.GetObjectType(arg[1]..((x==1) and "" or x)) == -1 then
  274.                     local tProps = {Visible=false, FontSize=8, LeftMargin=0, ColorDown=16777215, HighlightSound=1,HighlightSoundFile="", ResizeTop=false, Width=((x<=2) and 93 or 101), Alignment=1,ClickSoundFile="", ResizeLeft=false,FontUnderline=false,ResizeRight=false,XOffset=0, ColorNormal=16777215, Cursor=1, YOffset=0,ButtonFile=xToolBarButtons_Path.."\\"..arg[1]..((x==1) and "" or x)..".btn",FontItalic=false,FontStrikeout=false,ToggleState=0, FontAntiAlias=true, Enabled=true, ResizeBottom=false, ClickSound=1, FontScript=0, Text="", FontName="Arial", TooltipText="", Y=0, X=0, Style=0, RightMargin=0, Height=((x<=2) and 30 or 22), ColorHighlight=16777215, FontWeight=700, ColorDisabled=16777215}
  275.                     Page.CreateObject(OBJECT_BUTTON, arg[1]..((x==1) and "" or x), tProps);
  276.                 end
  277.             end
  278.         end
  279.     else
  280.         if type(arg[1]) ~= arg[2] then
  281.             Dialog.Message("Error @ "..arg[3], "Submited argument is a "..type(arg[1]).." value instead of "..arg[2].." value\r\nExecution cancelled");
  282.             Application.ExitScript();
  283.         end
  284.     end
  285. end
  286.  
  287. xToolBar.CreateToolbar = function(sToolbarName, nCenterLeft, nTopPos, nSizePerIcon, nSpacePerItem, nAnimation, bShowTooltip, nTransp, nOrientation)
  288.     xToolBar.CheckValue("btn_xToolBar", "button");
  289.     xToolBar.CheckValue(sToolbarName, "string", "xToolBar Name");
  290.     xToolBar.CheckValue(nCenterLeft, "number", "X Center");
  291.     xToolBar.CheckValue(nTopPos, "number", "Y Center");
  292.     xToolBar.CheckValue(nSizePerIcon, "number", "Size/Icon");
  293.     xToolBar.CheckValue(nSpacePerItem, "number", "Space");
  294.     xToolBar.CheckValue(nAnimation, "number", "Animation");
  295.     xToolBar.CheckValue(bShowTooltip, "boolean", "Show tooltip");
  296.     xToolBar.CheckValue(nTransp, "number", "Opacity");
  297.     xToolBar.CheckValue(nOrientation, "number", "Orientation");
  298.     if not xToolBar.Toolbars[sToolbarName] then
  299.         local nT = (nTransp==100) and -1 or nTransp;
  300.         xToolBar.Toolbars[sToolbarName] = {nSize=nSizePerIcon, nTop=nTopPos, nLeft=nCenterLeft, nSpace=nSpacePerItem, tItems={}, nMode=nAnimation, bTool=bShowTooltip, nTrans=nT, nOr=nOrientation};
  301.         return xToolBar.Toolbars[sToolbarName];
  302.     else
  303.  
  304.         return xToolBar.Toolbars[sToolbarName];
  305.     end
  306. end
  307.  
  308. xToolBar.GetAnimation = function(toolbar)
  309.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  310.     return toolbar.nMode;
  311. end
  312.  
  313. xToolBar.GetIconsSize = function(toolbar)
  314.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  315.     return toolbar.nSize;
  316. end
  317.  
  318. xToolBar.GetnMaxSize = function()
  319.     return (xToolBar.nMaxSize-1)*100;
  320. end
  321.  
  322. xToolBar.GetnShakes = function()
  323.     return xToolBar.nShakes;
  324. end
  325.  
  326. xToolBar.GetOpacity = function(toolbar)
  327.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  328.     return toolbar.nTrans;
  329. end
  330.  
  331. xToolBar.GetPos = function(toolbar)
  332.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  333.     return {X = toolbar.nLeft, Y = toolbar.nTop};
  334. end
  335.  
  336. xToolBar.HideTooltip = function(toolbar)
  337.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  338.     toolbar.bTool = false;
  339. end
  340.  
  341. xToolBar.Reorder = function (toolbar)
  342.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  343.     local n = #toolbar.tItems;
  344.     local step = toolbar.nSize+toolbar.nSpace;
  345.     if toolbar.nOr == 1 then
  346.         local mintotal = toolbar.nLeft - (((n * toolbar.nSize) + ((n-1) * toolbar.nSpace))/2);
  347.         for each, image in pairs(toolbar.tItems) do
  348.             local tDe =  xToolBar.Objects[image.kind+1];
  349.             image.left = mintotal+(step*(each-1));
  350.             image.right = image.left + toolbar.nSize;
  351.             image.lm_x = image.left + (toolbar.nSize/2);
  352.             image.top = toolbar.nTop-(toolbar.nSize/2);
  353.             image.bottom = image.top + toolbar.nSize;
  354.             image.lm_y = image.top + (toolbar.nSize/2);
  355.             tDe.SetPos(image.id, image.left , toolbar.nTop-(toolbar.nSize/2));
  356.         end
  357.     else
  358.         local mintotal = toolbar.nTop - (((n * toolbar.nSize) + ((n-1) * toolbar.nSpace))/2);
  359.         for each, image in pairs(toolbar.tItems) do
  360.             local tDe =  xToolBar.Objects[image.kind+1];
  361.             image.top = mintotal+(step*(each-1));
  362.             image.bottom = image.top + toolbar.nSize;
  363.             image.lm_y = image.top + (toolbar.nSize/2);
  364.             image.left = toolbar.nLeft-(toolbar.nSize/2);
  365.             image.right = image.left+toolbar.nSize;
  366.             image.lm_x = image.left + (toolbar.nSize/2);
  367.             tDe.SetPos(image.id, toolbar.nLeft-(toolbar.nSize/2), image.top);
  368.         end
  369.     end
  370. end
  371.  
  372. xToolBar.SetAnimation = function(toolbar, n)
  373.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  374.     xToolBar.CheckValue(n,"number", "Animation");
  375.     toolbar.nMode=n;
  376. end
  377.  
  378. xToolBar.SetIconsSize = function(toolbar, n)
  379.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  380.     xToolBar.CheckValue(n,"number", "IconsSize");
  381.     toolbar.nSize = n;
  382.     xToolBar.Reorder(toolbar);
  383. end
  384.  
  385. xToolBar.SetnMaxSize = function(n)--Fish Eye animations
  386.     xToolBar.CheckValue(n, "number", "nMaxSize");
  387.     xToolBar.nMaxSize = 1+(n*.01)
  388. end
  389.  
  390. xToolBar.SetnShakes = function(n)--Shake animations
  391.     xToolBar.CheckValue(n,"number", "nShakes");
  392.     xToolBar.nShakes = n;
  393. end
  394. xToolBar.SetnSpace = function(toolbar, n)
  395.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  396.     xToolBar.CheckValue(n, "number", "nSpace");
  397.     xToolBar.nSpace = n;
  398.     xToolBar.Reorder(toolbar);
  399. end
  400.  
  401. xToolBar.SetOpacity = function(toolbar, n)
  402.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  403.     xToolBar.CheckValue(n, "number", "Opacity");
  404.     toolbar.nTrans = (n==100) and -1 or n;
  405. end
  406.  
  407. xToolBar.SetPos = function(toolbar, x, y)
  408.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  409.     xToolBar.CheckValue(x,"number", "X Pos");
  410.     xToolBar.CheckValue(y,"number", "Y Pos");
  411.     toolbar.nLeft = x;
  412.     toolbar.nTop = y;
  413.     xToolBar.Reorder(toolbar);
  414. end
  415.  
  416. xToolBar.SetTooltipSide= function(n)--Vertical oriented toolbars
  417.     xToolBar.CheckValue(n,"number", "Tooltip side");
  418.     xToolBar.nSide = n;
  419. end
  420.  
  421. xToolBar.ShowTooltip = function(toolbar)
  422.     xToolBar.CheckValue(toolbar,"table", "xToolBar table");
  423.     toolbar.bTool = true;
  424. end
  425.  
  426. xToolBar.SwitchOrientation = function(toolbar)
  427.     toolbar.nOr = xToolBar.xChange(toolbar.nOr)
  428.     xToolBar.Reorder(toolbar);
  429. end
  430.  
  431. xToolBar.xChange = function(...)
  432.     xToolBar.CheckValue(arg[1],"number", "xChange arg[1]");
  433.     if #arg == 1 then
  434.         return (arg[1]==1) and 2 or 1;
  435.     else
  436.         xToolBar.CheckValue(arg[2],"number", "xChange arg[2]");
  437.         return arg[2], arg[1];
  438.     end
  439. end
  440.  
  441. --------------### xToolBar New Functions ###------------
  442.  
  443. xToolBar.slideUpShow = function(sObj)--Hides an object
  444.     local cp = Application.GetCurrentPage();
  445.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  446.     local u = cp.."_"..sObj;
  447.     if not xToolBar.Animating[u] then
  448.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true};
  449.     elseif not xToolBar.Animating[u].Visible then
  450.         Dialog.Message("Error", "Object already hidden");
  451.         Application.ExitScript();
  452.     elseif xToolBar.Animating[u].Animating then
  453.         --Dialog.Message("Error", "Object is been animated");
  454.         Application.ExitScript();
  455.     end
  456.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  457.     if tObj and xToolBar.Animating[u].Kind ~= 1 then
  458.         if tObj.IsVisible(sObj) then
  459.             local t = tObj.GetSize(sObj);
  460.             xToolBar.Animating[u].Width = t.Width;
  461.             xToolBar.Animating[u].Height = t.Height;
  462.             if t then
  463.                 xToolBar.Animating[u].Animating = true;
  464.                 local step = -((t.Height/50)*(t.Height/100));
  465.                 for x=t.Height, 0, step do
  466.                     tObj.SetSize(sObj, t.Width, x);
  467.                 end
  468.                 tObj.SetVisible(sObj, false);
  469.                 xToolBar.Animating[u].Visible = false;
  470.                 xToolBar.Animating[u].Animating = false;
  471.             end
  472.         else
  473.             Dialog.Message("Error", "Object is not visible");
  474.             xToolBar.Animating[u].Visible = false;
  475.             Application.ExitScript();
  476.         end
  477.     else
  478.         Dialog.Message("Error", "Unsupported object");
  479.         Application.ExitScript();
  480.     end
  481. end
  482.  
  483. xToolBar.slideDownShow = function(sObj)--Shows an object
  484.     local cp = Application.GetCurrentPage();
  485.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  486.     local u = cp.."_"..sObj;
  487.     if not xToolBar.Animating[u] then
  488.         Dialog.Message("Error", "Object can't be showed");
  489.         Application.ExitScript();
  490.     elseif xToolBar.Animating[u].Visible then
  491.         Dialog.Message("Error", "Object is visible");
  492.         Application.ExitScript();
  493.     elseif xToolBar.Animating[u].Animating then
  494.         --Dialog.Message("Error", "Object is been animated");
  495.         Application.ExitScript();
  496.     end
  497.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  498.     if tObj and xToolBar.Animating[u].Kind ~= 1 then
  499.         tObj.SetVisible(sObj, true);
  500.         xToolBar.Animating[u].Visible = true;
  501.         xToolBar.Animating[u].Animating = true;
  502.         local step = ((xToolBar.Animating[u].Height/50)*(xToolBar.Animating[u].Height/100));
  503.         for x=0, xToolBar.Animating[u].Height, step do
  504.             tObj.SetSize(sObj, xToolBar.Animating[u].Width, x);
  505.         end
  506.         xToolBar.Animating[u].Animating = false;
  507.     else
  508.         Dialog.Message("Error", "Unsupported object");
  509.         Application.ExitScript();
  510.     end
  511. end
  512.  
  513. xToolBar.slideUDToggleShow = function(sObj)--Switch between hide and show
  514.     local cp = Application.GetCurrentPage();
  515.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  516.     local u = cp.."_"..sObj;
  517.     if not xToolBar.Animating[u] then
  518.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true};
  519.     elseif xToolBar.Animating[u].Animating then
  520.         --Dialog.Message("Error", "Object is been animated");
  521.         Application.ExitScript();
  522.     end
  523.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  524.     if tObj and xToolBar.Animating[u].Kind ~= 1 then
  525.         xToolBar.Animating[u].Animating = true;
  526.         if xToolBar.Animating[u].Visible then
  527.             if tObj.IsVisible(sObj) then
  528.                 local t = tObj.GetSize(sObj);
  529.                 xToolBar.Animating[u].Width = t.Width;
  530.                 xToolBar.Animating[u].Height = t.Height;
  531.                 if t then
  532.                     local step = -((t.Height/50)*(t.Height/100));
  533.                     for x=t.Height, 0, step do
  534.                         tObj.SetSize(sObj, t.Width, x);
  535.                     end
  536.                     tObj.SetVisible(sObj, false);
  537.                     xToolBar.Animating[u].Visible = false;
  538.                 end
  539.             else
  540.                 Dialog.Message("Error", "Object is not visible");
  541.                 xToolBar.Animating[u].Visible = false;
  542.                 Application.ExitScript();
  543.             end
  544.         else
  545.             if not tObj.IsVisible(sObj) then
  546.                 tObj.SetVisible(sObj, true);
  547.                 xToolBar.Animating[u].Visible = true;
  548.                 if xToolBar.Animating[u].Height then
  549.                     local step = ((xToolBar.Animating[u].Height/50)*(xToolBar.Animating[u].Height/100));
  550.                     for x=0, xToolBar.Animating[u].Height, step do
  551.                         tObj.SetSize(sObj, xToolBar.Animating[u].Width, x);
  552.                     end
  553.                 else
  554.                     Dialog.Message("Error", "Object can't be animated");
  555.                     xToolBar.Animating[u].Visible = false;
  556.                     Application.ExitScript();
  557.                 end
  558.             else
  559.                 Dialog.Message("Error", "Object is already visible");
  560.                 xToolBar.Animating[u].Visible = true;
  561.                 Application.ExitScript();
  562.             end
  563.         end
  564.         xToolBar.Animating[u].Animating = false;
  565.     else
  566.         Dialog.Message("Error", "Unsupported object");
  567.         Application.ExitScript();
  568.     end
  569. end
  570.  
  571. xToolBar.slideLeft = function(sObj, np, ...)--Moves an object
  572.     local orientation = (arg[1] ~= nil) and -1 or 1
  573.     local cp = Application.GetCurrentPage();
  574.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  575.     local u = cp.."_"..sObj;
  576.     if not xToolBar.Animating[u] then
  577.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true};
  578.     elseif xToolBar.Animating[u].Animating then
  579.         --Dialog.Message("Error", "Object is been animated");
  580.         Application.ExitScript();
  581.     end
  582.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  583.     if tObj then
  584.         if tObj.IsVisible(sObj) then
  585.             local t = tObj.GetPos(sObj);
  586.             if t then
  587.                 xToolBar.Animating[u].Animating = true;
  588.                 local ntx = 0;
  589.                 for x=.05, np do
  590.                     ntx = t.X-(x*orientation);
  591.                     tObj.SetPos(sObj, ntx, t.Y);
  592.                 end
  593.                 xToolBar.Animating[u].Animating = false;
  594.             end
  595.         else
  596.             xToolBar.Animating[u].Visible = false;
  597.             Dialog.Message("Error", "Can't animate a hidden object");
  598.             Application.ExitScript();
  599.         end
  600.     else
  601.         Dialog.Message("Error", "Unsupported object");
  602.         Application.ExitScript();
  603.     end
  604. end
  605.  
  606. xToolBar.slideRight = function(sObj, np)--Moves an object
  607.     xToolBar.slideLeft(sObj, np, -1);--lol
  608. end
  609.  
  610. xToolBar.slideLR = function(sObj, np, start, ...)--Moves and backs an object
  611.     local orientation = (arg[1] ~= nil) and true or false;
  612.     start = tonumber(start);
  613.     start = (start~=nil) and (start==-1) and -1 or 1 or 1;
  614.     local cp = Application.GetCurrentPage();
  615.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  616.     local u = cp.."_"..sObj;
  617.     if not xToolBar.Animating[u] then
  618.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true};
  619.     elseif xToolBar.Animating[u].Animating then
  620.         --Dialog.Message("Error", "Object is been animated");
  621.         Application.ExitScript();
  622.     end
  623.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  624.     if tObj then
  625.         if tObj.IsVisible(sObj) then
  626.             local t = tObj.GetPos(sObj);
  627.             if t then
  628.                 local Xor = (orientation == false) and t.X or t.Y;
  629.                 xToolBar.Animating[u].Animating = true;
  630.                 local ntx, ntx2 = 0, 0;
  631.                 for x=.05, np do
  632.                     ntx = Xor +(x*start);
  633.                     tObj.SetPos(sObj, (orientation == false) and ntx or t.X, (orientation == false) and t.Y or ntx);
  634.                 end
  635.                 for x=.05, np do
  636.                     ntx2 = ntx-(x*start);
  637.                     tObj.SetPos(sObj, (orientation == false) and ntx2 or t.X, (orientation == false) and t.Y or ntx2);
  638.                 end
  639.                 xToolBar.Animating[u].Animating = false;
  640.             end
  641.         else
  642.             xToolBar.Animating[u].Visible = false;
  643.             Dialog.Message("Error", "Can't animate a hidden object");
  644.             Application.ExitScript();
  645.         end
  646.     else
  647.         Dialog.Message("Error", "Unsupported object");
  648.         Application.ExitScript();
  649.     end
  650. end
  651.  
  652. xToolBar.slideLRToggle = function(sObj, np, start, ...)
  653.     local orientation = (arg[1] ~= nil) and true or false;
  654.     start = tonumber(start);
  655.     start = (start~=nil) and (start==-1) and -1 or 1 or 1;
  656.     local cp, tObj = Application.GetCurrentPage();
  657.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  658.     local u = cp.."_"..sObj;
  659.     if not xToolBar.Animating[u] then
  660.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true, Switch = false};
  661.     elseif xToolBar.Animating[u].Animating then
  662.         --Dialog.Message("Error", "Object is been animated");
  663.         Application.ExitScript();
  664.     end
  665.     tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  666.     if not tObj then
  667.         Dialog.Message("Error", "Unsupported object");
  668.         Application.ExitScript();
  669.     else
  670.         if not tObj.IsVisible(sObj) then
  671.             xToolBar.Animating[u].Visible = false;
  672.             Dialog.Message("Error", "Can't animate a hidden object");
  673.             Application.ExitScript();
  674.         end
  675.     end
  676.     local t = tObj.GetPos(sObj);
  677.     if t then
  678.         local Xor = (orientation == false) and t.X or t.Y;
  679.         xToolBar.Animating[u].Animating = true;
  680.         if not xToolBar.Animating[u].Switch then
  681.             local ntx = 0;
  682.             for x=.05, np do
  683.                 ntx = Xor+(x*start);
  684.                 tObj.SetPos(sObj, (orientation == false) and ntx or t.X, (orientation == false) and t.Y or ntx);
  685.             end
  686.             xToolBar.Animating[u].Switch = true;
  687.         else
  688.             local ntx = 0;
  689.             for x=.05, np do
  690.                 ntx = Xor-(x*start);
  691.                 tObj.SetPos(sObj, (orientation == false) and ntx or t.X, (orientation == false) and t.Y or ntx);
  692.             end
  693.             xToolBar.Animating[u].Switch = false;
  694.         end
  695.         xToolBar.Animating[u].Animating = false;
  696.     end
  697. end
  698.  
  699. xToolBar.slideUp = function(sObj, np, ...)
  700.     local orientation = (arg[1] ~= nil) and -1 or 1
  701.     local cp = Application.GetCurrentPage();
  702.     cp = (cp == "") and Application.GetCurrentDialog() or cp;
  703.     local u = cp.."_"..sObj;
  704.     if not xToolBar.Animating[u] then
  705.         xToolBar.Animating[u] = {Kind = Page.GetObjectType(sObj), Visible = true};
  706.     elseif xToolBar.Animating[u].Animating then
  707.         --Dialog.Message("Error", "Object is been animated");
  708.         Application.ExitScript();
  709.     end
  710.     local tObj = xToolBar.Objects[xToolBar.Animating[u].Kind+1];
  711.     if tObj then
  712.         if not tObj.IsVisible(sObj) then
  713.             xToolBar.Animating[u].Visible = false;
  714.             Dialog.Message("Error", "Can't animate a hidden object");
  715.             Application.ExitScript();
  716.         end
  717.         local t = tObj.GetPos(sObj);
  718.         if t then
  719.             xToolBar.Animating[u].Animating = true;
  720.             local ntx = 0;
  721.             for x=.05, np do
  722.                 ntx = t.Y-(x*orientation);
  723.                 tObj.SetPos(sObj, t.X, ntx);
  724.             end
  725.             xToolBar.Animating[u].Animating = false;
  726.         end
  727.     else
  728.         Dialog.Message("Error", "Unsupported object");
  729.         Application.ExitScript();
  730.     end
  731. end
  732.  
  733. xToolBar.slideDown = function(sObj, np)
  734.     xToolBar.slideUp(sObj, np,-1);--lol
  735. end
  736.  
  737. xToolBar.slideUDToggle = function(sObj, np, start)
  738.     xToolBar.slideLRToggle(sObj, np, start, true);--lol
  739. end
  740.  
  741. xToolBar.slideUD = function(sObj, np, start)
  742.     xToolBar.slideLR(sObj, np, start, true);--lol
  743. end
  744. ------------### by WeBuLtRa ###-----------
  745.  
  746. --[[Example calls for new functions:
  747.  
  748. xToolBar.slideUp("Image1", 50);
  749. xToolBar.slideDown("Image1", 50);
  750. xToolBar.slideLeft("Image1", 50);
  751. xToolBar.slideRight("Image1", 50);
  752.  
  753. xToolBar.slideLR("Image1", 100);
  754. xToolBar.slideLR("Image1", 100, -1);
  755.  
  756. xToolBar.slideUD("Image1", 100);
  757. xToolBar.slideUD("Image1", 100, -1);
  758.  
  759. xToolBar.slideLRToggle("Image1", 100);
  760. xToolBar.slideLRToggle("Image1", 100, -1);
  761. xToolBar.slideUDToggle("Image1", 100);
  762. xToolBar.slideUDToggle("Image1", 100, -1);
  763.  
  764. xToolBar.slideUpShow("Image1");
  765. xToolBar.slideDownShow("Image1");
  766. xToolBar.slideUDToggleShow("Image1");
  767.  
  768. ]]--
Add Comment
Please, Sign In to add comment