Thread Tools Display Modes
03-25-12, 07:04 PM   #1
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Sliding Panel

Is it at all possible to script a kgpanel, that would 'slide', for want fo a better word, when you clicked or moused over it? Say I wanted to hide a panel under minimap, or off the side of the screen, but have it slide into view when I moused over or clicked it?
__________________
  Reply With Quote
03-25-12, 07:29 PM   #2
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Are you asking for it to appear/disappear instantly, or to actually "slide" as in an animation?

If you're looking for it to actually animate, I'd look at the Translation Animation provided in the default UI.

Last edited by Waky : 03-25-12 at 07:34 PM.
  Reply With Quote
03-25-12, 07:38 PM   #3
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Actually slide in...the Lightheaded panel gave me the idea. But looking at that link lets me know that it's waaaay over my head, lol. My thanks~
__________________
  Reply With Quote
03-25-12, 07:44 PM   #4
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
I just whipped this little bit of code up in game:

Code:
f = f or CreateFrame("Frame","animTest",UIParent);
f:SetSize(100,100);
f:SetBackdrop(GameTooltip:GetBackdrop());
f:SetPoint("CENTER",UIParent);

local g = f:CreateAnimationGroup("AnimationTest"); -- Create the group holding our animations

local t = g:CreateAnimation("Translation"); -- Create a new animation, "Translation" for a sliding effect
t:SetOrder(1); -- Set when it's played (not necessary in this case since there's only 1 animation)
t:SetOffset(50,0); -- Set how far to slide
t:SetDuration(3); -- Set how long it takes to slide 

g:Play(); -- Tell animation to start
Basically all this does it creates a 100x100 frame in the middle of the screen, then moves it over 50 pixels over 3 seconds.

Last edited by Waky : 03-25-12 at 07:49 PM.
  Reply With Quote
03-25-12, 07:54 PM   #5
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
That's pretty spectacular..but how would I apply that to a kgpanel? I know making just the frame like that is easier, in some ways, but I'm extremely lua illiterate. My basic idea was to have a panel parented to an action bar ( I use Bartender) and have it slide into view when I moused over or clicked a certain region. Thank you, by the way, for taking the time to answer my questions~
__________________
  Reply With Quote
03-25-12, 08:38 PM   #6
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
I threw this together real quick

Create a frame like you normally would, then put this in it's OnLoad script. Make sure you enable mouse clicks.

OnLoad:
Code:
local open = false; -- Don't change this
local xOffset = 50; -- How far to move left
local yOffset = 0; -- How far to move up
local animDuration = 2; -- How long should it take (in seconds)
local point, relTo, relPt, xOff, yOff; -- Don't change these

self.animGroup = self:CreateAnimationGroup("SlidingFrame");
self.anim = self.animGroup:CreateAnimation("Translation");
self.anim:SetDuration(animDuration);
self.animGroup:SetScript("OnFinished",function()
  point, relTo, relPt, xOff, yOff = self:GetPoint();
if (open==false) then
  self:ClearAllPoints();
  self:SetPoint(point, relTo, relPt, xOff+xOffset, yOff);
else
  self:ClearAllPoints();
  self:SetPoint(point, relTo, relPt, xOff-xOffset, yOff);
end
end)
self:SetScript("OnMouseDown",function(self)
if open==false then
  open = true;
  self.anim:SetOffset(-xOffset,0);
  self.animGroup:Play();
else
  open = false;
  self.anim:SetOffset(xOffset,0);
  self.animGroup:Play();
end
end)
Currently it jitters at the end of the animation, but the frame ends up in the right spot.

I've gotta go to bed for now, I'll look further into this tomorrow!
  Reply With Quote
03-25-12, 09:13 PM   #7
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Sweet, thank you VERY much, Waky.

Wow. Just..wow. For all it's simplicity (what it does, not how it's written) that has got to be one of the coolest things I've seen. I just sat there and clicked it non-stop, for like 20 minutes. Even WITH the jitter.
__________________

Last edited by Kendian : 03-25-12 at 09:44 PM.
  Reply With Quote
03-26-12, 11:44 AM   #8
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Remade the code here:

OnLoad:
Code:
local open = false;
local active = false;
local xOffset = 100;
local yOffset = 0;
local animDuration = 2;
local point, relTo, relPt, xOff, yOff;

self.animGroup = self:CreateAnimationGroup("SlidingFrame");
self.animOpen = self.animGroup:CreateAnimation("Translation");
self.animOpen:SetDuration(animDuration);
self.animOpen:SetOrder(1);
self.animOpen:SetOffset(-xOffset,yOffset);
self.animOpen:SetScript("OnFinished",function()
  self.animGroup:Pause();
  active = false;
end)
self.animClose = self.animGroup:CreateAnimation("Translation");
self.animClose:SetDuration(animDuration);
self.animClose:SetOrder(2);
self.animClose:SetOffset(xOffset,yOffset);
self.animClose:SetScript("OnFinished",function() active = false; end)
self:SetScript("OnMouseDown",function(self)
if active==false then 
  if open==false then
    active = true;
    open = true;
    self.animGroup:Play();
  else
    active = true;
    open = false;
    self.animGroup:Play();
  end
end
end)
This manner prevents the frame from having to be positioned at all, and can tell if it's currently opening/closing to prevent errors.

Hope this works!
  Reply With Quote
03-26-12, 02:08 PM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,928
Cool, thanks Waky. Might have to see how that works. Was thinking of something similar for some of my plugin addons.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
03-27-12, 12:58 PM   #10
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Waky, this worked PERFECTLY. My thanks, very much~


__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Sliding Panel


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off