ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Any Tutorial on Using WINDOW_MANAGER? (https://www.esoui.com/forums/showthread.php?t=555)

Sharp 04/04/14 08:42 AM

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

ingeniousclown 04/04/14 10:05 AM

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 :) )

Sharp 04/04/14 10:25 AM

Quote:

Originally Posted by ingeniousclown (Post 2674)
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?

ingeniousclown 04/04/14 11:34 AM

Quote:

Originally Posted by Sharp (Post 2680)
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.

Seerah 04/04/14 11:38 AM

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)

Sharp 04/04/14 04:21 PM

Thanks both of you for your input, it has really helped me a lot! I may ask more if I get stuck again.

Wukar 04/05/14 11:24 AM

Code:

WINDOW_MANAGER:CreateControl(name, parent, type)
How is type (integer) used? Where is it useful/necessary?

Seerah 04/05/14 11:31 AM

It's used all the time. It's to say what type of control you are creating.
http://wiki.esoui.com/Globals#ControlType

chase 04/05/14 12:22 PM

Quote:

Originally Posted by Seerah (Post 2693)
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.

Sharp 04/06/14 11:33 AM

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?

Wukar 04/06/14 11:48 AM

Try that
lua Code:
  1. myAddonFrame:SetAnchor(CENTER, {Parent}, CENTER, 0, 0)

Seerah 04/06/14 03:48 PM

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)


All times are GMT -6. The time now is 08:06 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI