View Single Post
09-25-16, 09:55 PM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kagura View Post
To visualize how the UI element is setup you are going through 32 lines of code just to realise it won't work (You can figure out why).
Reading through code is never a good way to "visualize how the UI element is setup", in any programming language. Even an XML-style markup language like HTML or JSX quickly becomes too long for that in for a UI of any complexity.

(Also, the code I posted was a drycoded example. It wasn't meant to be used as-is, and it certainly wasn't tested. Any typographical errors in it are totally irrelevant to the actual discussion.)

Originally Posted by Kagura View Post
Let's now say I want to split my window into two panels and all I had in the first one goes into second one and on the left one I want buttons. In Phanx's example, I'd have to go through the created ui elements that are a 'child' of my original one and change either the creation of all these elements or the parenting (SetParent) for each of the created UI element. In my original example, I would change nothing except the indenting after (I am referring to the JSX here, not LUA)
You're making this sound like way more work than it actually is:

Code:
local frame1 = New("Frame")
frame1:SetParent(window)
frame1:SetPoint("TOPLEFT")
frame1:SetPoint("BOTTOMLEFT", "$parent", "BOTTOM")

local button1 = New("SmallButton")
button1:SetParent(frame1)
Nothing needs to be moved around, re-indented, or wrapped in a new scope, and it's still straighforward, readable, and efficient code that isn't generating a bunch of extra tables or functions.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote