Thread Tools Display Modes
09-16-12, 03:01 AM   #1
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Linking frames?

I've got 3 CreateFrames:

MainWindow of size 300x300 and set for resize
ChildFrame of size 270x295 centered in the middle of MainWindow
ChildFrame2 of size 30x295 at the very top of MainWindow

ChildFrame2 is set to allow moving, I was trying to make it so the entire MainWindow moves with it, but they don't seem to be linked even tho they are parent/child (as in when I move it only ChildFrame2 moves)

How do I link them together so everything moves?
  Reply With Quote
09-16-12, 03:07 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Use SetPoints of center for each frame.

Frame1 = CreateFrame("Frame","Frame1",UIParent)
Frame1:SetPoint("CENTER",0,0)
Frame2 = CreateFrame("Frame","Frame2",Frame1)
Frame2:SetPoint("CENTER",0,0)
Frame3 = CreateFrame("Frame","Frame3",UIParent)
Frame3:SetPoint("TOPLEFT",0,0)
Frame3:SetPoint("TOPRIGHT",0,0)

But come to think of it, would moving a child move the parent or would you have to move the parent to move the children around.
__________________


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
09-16-12, 03:20 AM   #3
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Originally Posted by Xrystal View Post
Use SetPoints of center for each frame.

Frame1 = CreateFrame("Frame","Frame1",UIParent)
Frame1:SetPoint("CENTER",0,0)
Frame2 = CreateFrame("Frame","Frame2",Frame1)
Frame2:SetPoint("CENTER",0,0)
Frame3 = CreateFrame("Frame","Frame3",UIParent)
Frame3:SetPoint("TOPLEFT",0,0)
Frame3:SetPoint("TOPRIGHT",0,0)

But come to think of it, would moving a child move the parent or would you have to move the parent to move the children around.
I'm not sure... I know what i'm trying to do has to be possible since Carbonite did it, but i'm trying extremely hard to not look at any of there code while I work on the new one. But so far all my attempts, the child moves and the parent stays in place.
  Reply With Quote
09-16-12, 03:26 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Dont move the child ... move the parent. I use it this way (self in this snippet is the child, setuserplaced is not needed when you place it yourself):

Code:
	if(self['moveparent']) then
		self:GetParent():StartMoving()
		self:GetParent():SetUserPlaced(false)
	else
		self:StartMoving()
		self:SetUserPlaced(false)
	end
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
09-16-12, 03:32 AM   #5
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Originally Posted by Rilgamon View Post
Dont move the child ... move the parent. I use it this way (self in this snippet is the child, setuserplaced is not needed when you place it yourself):

Code:
	if(self['moveparent']) then
		self:GetParent():StartMoving()
		self:GetParent():SetUserPlaced(false)
	else
		self:StartMoving()
		self:SetUserPlaced(false)
	end
I had actually just tried using GetParent, and that works... except now it's reversed, the parent and every other child moves but the child i'm clicking on doesn't move.
  Reply With Quote
09-16-12, 03:36 AM   #6
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
SetMovable is set for the child ?
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
09-16-12, 03:36 AM   #7
nailertn
An Aku'mai Servant
Join Date: Oct 2008
Posts: 33
Originally Posted by Xrystal View Post
But come to think of it, would moving a child move the parent or would you have to move the parent to move the children around.
Parent / child relationship does not control placement, anchoring does. If you anchor frame 1 to frame 2, then moving frame 2 will move frame 1 too. Moving frame 1 does nothing to frame 2. You can't anchor two frames to each other, WoW does not allow circular anchoring.
  Reply With Quote
09-16-12, 03:40 AM   #8
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Originally Posted by Rilgamon View Post
SetMovable is set for the child ?
Yep.. both parent and child have SetMovable
  Reply With Quote
09-16-12, 03:50 AM   #9
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
ok got it... it was the fact it was SetMovable'd .. had to be only the parent with it. Thank you.
  Reply With Quote
09-16-12, 04:07 AM   #10
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Originally Posted by nailertn View Post
Parent / child relationship does not control placement, anchoring does. If you anchor frame 1 to frame 2, then moving frame 2 will move frame 1 too. Moving frame 1 does nothing to frame 2. You can't anchor two frames to each other, WoW does not allow circular anchoring.
Yeah, I realised that, but I probably have done in the past, the same thing Rythal realised just now. Set both frames movable and not just the one you should be moving rofl.
__________________


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
09-16-12, 04:16 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
No, both frames don't need to have :SetMovable(true) called on them, as nailertn was saying. All you need movable is what is going to control the placement of everything else.

Set parent as movable.
Anchor child1 to parent.
Anchor child2 to parent.
Drag parent around screen.
Children will also move because they're anchored to it.


(In other words, put a book on your table. Move the table. The book moves along with the table to the new location and even stays in the same spot on the table that it was at before.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-16-12, 04:18 PM   #12
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Originally Posted by Seerah View Post
No, both frames don't need to have :SetMovable(true) called on them, as nailertn was saying. All you need movable is what is going to control the placement of everything else.

Set parent as movable.
Anchor child1 to parent.
Anchor child2 to parent.
Drag parent around screen.
Children will also move because they're anchored to it.
I've got it working, but the problem was the parent was responable for resizable, so I needed to use a child to move the parent.
  Reply With Quote
09-16-12, 04:22 PM   #13
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I'm confused on why it can't do both?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-16-12, 04:25 PM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Originally Posted by Seerah View Post
No, both frames don't need to have :SetMovable(true) called on them, as nailertn was saying. All you need movable is what is going to control the placement of everything else.
Yeah thats what I meant, reading my post again I can see the confusion. I was just reiterating the fact that I used to make the same mistake Rythal just did and make both frames movable and wonder why they never moved together if I moved one of the frames haha. Oh well.
__________________


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
09-16-12, 04:26 PM   #15
Rythal
Featured Artist
Featured
Join Date: Aug 2012
Posts: 1,458
Originally Posted by Seerah View Post
I'm confused on why it can't do both?
it would be possible if you added checks to where in the frame you were clicking and performed the action you wanted based on that, but usually it's one onmousedown/up per parent/child with no way of telling which you wanted to do resize or move.
  Reply With Quote
09-16-12, 08:28 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Ah yes, I see. I wasn't thinking about it clearly earlier. This is why frames (such as the chat frame) usually have a corner designated for resizing.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Linking frames?


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