Thread Tools Display Modes
04/04/14, 08:42 AM   #1
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Any Tutorial on Using WINDOW_MANAGER?

Hey all,

I am looking for some more insight on creating controls outside of the XML. I am having a hard time understanding how each attribute is set and how to set position of each control. Any help or general walkthrough would be helpful.

Thanks,
Sharp
  Reply With Quote
04/04/14, 10:05 AM   #2
ingeniousclown
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 122
Spend some time to study the "Controls" part of the wiki: http://wiki.esoui.com/Controls

It's not laid out in the absolute best way and is sometimes confusing, but it has (almost) all of the information you will need.

A few general tips:
In most cases you'll only ever need to call WINDOW_MANAGER:CreateControl(name, parent, type) or :CreateTopLevelWindow(name)
Created controls/windows can be accessed directly by name after they're created, regardless of their place in the hierarchy.
:SetDimensions(), :SetHidden(), :SetColor(), :SetTexture(), :SetAnchor(), :ClearAnchors(), and :SetTexture() are a few (but not all!) of the important calls for controls. (I didn't include arguments in that list in the interest of time, you can look them up on the wiki )
  Reply With Quote
04/04/14, 10:25 AM   #3
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Originally Posted by ingeniousclown View Post
Spend some time to study the "Controls" part of the wiki: http://wiki.esoui.com/Controls

It's not laid out in the absolute best way and is sometimes confusing, but it has (almost) all of the information you will need.

A few general tips:
In most cases you'll only ever need to call WINDOW_MANAGER:CreateControl(name, parent, type) or :CreateTopLevelWindow(name)
Created controls/windows can be accessed directly by name after they're created, regardless of their place in the hierarchy.
:SetDimensions(), :SetHidden(), :SetColor(), :SetTexture(), :SetAnchor(), :ClearAnchors(), and :SetTexture() are a few (but not all!) of the important calls for controls. (I didn't include arguments in that list in the interest of time, you can look them up on the wiki )
Thanks for the input I really appreciate it! I am really looking for some insight on the SetAnchor function, as I am not sure how to position it. Also, I see a lot of people using a CHAIN function to create controls, is that needed? What is the best way to position control relevant to the previous control?
  Reply With Quote
04/04/14, 11:34 AM   #4
ingeniousclown
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 122
Originally Posted by Sharp View Post
Thanks for the input I really appreciate it! I am really looking for some insight on the SetAnchor function, as I am not sure how to position it. Also, I see a lot of people using a CHAIN function to create controls, is that needed? What is the best way to position control relevant to the previous control?
The CHAIN is not necessary, it just makes a person's life easier when defining controls. Instead of using CHAIN, you can just do control:SetBlah(lol) on every line.

As for how to position using SetAnchor, that really depends on what you need. Sometimes you need to position from the CENTER, sometimes you really need BOTTOM or BOTTOMRIGHT. Do whatever fits your need at the time. It's hard to visualize at first but you'll understand it better with practice When in doubt, TOPRIGHT and TOPRIGHT (for self and relative) are good defaults since they are the most natural to the way the screen units are indexed.
  Reply With Quote
04/04/14, 11:38 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
frame:SetAnchor(pointOnFrame, relativeToThisFrame, pointOnThatOtherFrame, offsetX, offsetY)

Offsets increase in a positive direction to the right (for X) and down (for Y). They increase in a negative direction to the left (for X) and up (for Y).

So... If you want to anchor your MyAddonFrame to the main screen (GuiRoot), in the top-left corner, but out from each side about 10 pixels, you'd do this:
Lua Code:
  1. MyAddonFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, 10, 10)

If you want to anchor the left side of your MyAddonFrame2 to the right side of your MyAddonFrame1, you'd do this:
Lua Code:
  1. MyAddonFrame2:SetAnchor(LEFT, MyAddonFrame1, RIGHT, 0, 0)

If you want to make your MyAddonBG texture fill your whole MyAddonFrame (anchoring to all corners), then you can do this:
Lua Code:
  1. MyAddonBG:SetAnchorFill(MyAdonFrame)

One last example: if you want your MyAddonFrame to spread across the bottom of the screen, without having to worry about figuring out how big the users screen is (resolution/width), then you can do this:
Lua Code:
  1. MyAddonFrame:SetAnchor(BOTTOMLEFT, GuiRoot, BOTTOMLEFT, 0, 0)
  2. MyAddonFrame:SetAnchor(BOTTOMRIGHT, GuiRoot, BOTTOMRIGHT, 0, 0)
  3. MyAddonFrame:SetHeight(100)
  Reply With Quote
04/04/14, 04:21 PM   #6
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Thanks both of you for your input, it has really helped me a lot! I may ask more if I get stuck again.
  Reply With Quote
04/05/14, 11:24 AM   #7
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Code:
WINDOW_MANAGER:CreateControl(name, parent, type)
How is type (integer) used? Where is it useful/necessary?
  Reply With Quote
04/05/14, 11:31 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
It's used all the time. It's to say what type of control you are creating.
http://wiki.esoui.com/Globals#ControlType
  Reply With Quote
04/05/14, 12:22 PM   #9
chase
Join Date: Apr 2014
Posts: 3
Originally Posted by Seerah View Post
One last example: if you want your MyAddonFrame to spread across the bottom of the screen, without having to worry about figuring out how big the users screen is (resolution/width), then you can do this:
Lua Code:
  1. MyAddonFrame:SetAnchor(BOTTOMLEFT, GuiRoot, BOTTOMLEFT, 0, 0)
  2. MyAddonFrame:SetAnchor(BOTTOMRIGHT, GuiRoot, BOTTOMRIGHT, 0, 0)
  3. MyAddonFrame:SetHeight(100)
Thanks for this, until now I haven't realized there can be multiple anchors on a single control.
  Reply With Quote
04/06/14, 11:33 AM   #10
Sharp
 
Sharp's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 32
Any tips on getting it Centered in the parent control? will I need to use the offset x/y or is there an easier way?
  Reply With Quote
04/06/14, 11:48 AM   #11
Wukar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 27
Try that
lua Code:
  1. myAddonFrame:SetAnchor(CENTER, {Parent}, CENTER, 0, 0)
  Reply With Quote
04/06/14, 03:48 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
In the above case, where there is no x or y offset, and your anchoring in relation to the parent, you may do simply this:
Lua Code:
  1. myAddonFrame:SetAnchor(CENTER)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Any Tutorial on Using WINDOW_MANAGER?


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