• 0

    posted a message on AceGUI-3.0 child anchoring confusion
    You're welcome. Every time I dive into an addon, I learn something :).
    Posted in: Ace3
  • 0

    posted a message on AceGUI-3.0 child anchoring confusion
    I made some additions to the script:
    local A = LibStub("AceGUI-3.0")
    
    ACE_TFrame = A:Create("Frame")
    local container = ACE_TFrame
    local oldPL = container.PerformLayout
    container.PerformLayout = function(self) print(debugstack()) oldPL(self) end
    container:SetLayout("Flow")
    container:SetWidth(400)
    container:SetHeight(200)
    
    local icon = A:Create("Icon")
    local oldSP = icon.SetPoint
    icon.SetPoint = function(self, ...) print(debugstack()) oldSP(self, ...) end
    icon:SetImage("Interface\\HELPFRAME\\HelpIcon-Suggestion")
    icon:SetImageSize(24,24)
    icon:SetWidth(24)
    icon:SetHeight(24)
    
    local button1 = A:Create("Button")
    button1:SetWidth(200)
    button1:SetText("button1 - anchor me")
    button1.OnClick = function(_,event,mbutton)
      icon:ClearAllPoints()
      icon:SetPoint("LEFT",button1.frame,"RIGHT",2,5) -- manually triggering works
    end
    button1:SetCallback("OnClick",button1.OnClick)
    
    local button2 = A:Create("Button")
    button2:SetWidth(200)
    button2:SetText("button2")
    button2:SetCallback("OnClick", function() container:DoLayout() end)
    
    icon.OnClick = function()
      for i = 1, icon:GetNumPoints() do
        local p, rf, rp, x, y = icon:GetPoint(i)
        print(p, "Frame", rp, x, y)
        local f = "??"
        if rf == container.frame then f = "container"
        elseif rf == icon.frame then f = "icon"
        elseif rf == button1.frame then f = "button1"
        elseif rf == button2.frame then f = "button2"
        end
        print("Frame is '"..f.."'")
      end 
    end
    icon:SetCallback("OnClick", icon.OnClick)
    
    container:AddChildren(button1,button2,icon)
    
    icon:ClearAllPoints()
    icon:SetPoint("LEFT",button1.frame,"RIGHT",2,5) -- this doesn't work


    It's because of the "Flow" layout. Here's the output:
    [string "Testing"]:6: in function `PerformLayout'
    ...\AceGUI-3.0\AceGUI-3.0.lua:441: in function `DoLayout'
    ...\AceGUI-3.0\AceGUI-3.0.lua:472: in function `AddChildren'
    [string "Testing"]:48: in main chunk
    (tail call): ?
    (tail call): ?
    [C]: in function `pcall'
    Interface\AddOns\_DevPad\_DevPad.lua:40: in function <Interface\AddOns\_DevPad\_DevPad.lua:39>
    (tail call): ?
    
    [string "Testing"]:13: in function `SetPoint'
    [string "Testing"]:51: in main chunk
    (tail call): ?
    (tail call): ?
    [C]: in function `pcall'
    Interface\AddOns\_DevPad\_DevPad.lua:40: in function <Interface\AddOns\_DevPad\_DevPad.lua:39>
    (tail call): ?
    
    [string "Testing"]:6: in function `PerformLayout'
    ...\AceGUI-3.0\AceGUI-3.0.lua:441: in function `DoLayout'
    ...\AceGUI-3.0\AceGUI-3.0.lua:511: in function <...\AceGUI-3.0.lua:507> (local function ContentResize(this))


    It looks like it's because the ContentResize function runs as the handler for "OnSizeChanged". The current script has to finish before the game can call the event handler.

    ---------------

    The constructor for Icon sets a top padding of 5 pixels for the image within the Icon frame.
    image:SetPoint("TOP", 0, -5)

    The Flow layout parents each frame to the previous frame.

    So, you can accomplish the same as what you were trying to do (resulting in a properly vertically centered icon and its point set relative to the button before it) by changing one line and adding one:
    (add) icon.image:SetPoint("TOP",0,0)
    (change) container:AddChildren(button1,icon,button2)


    Alternatively, the layout code looks for a widget key "alignoffset". It uses that to determine what the y-axis value for SetPoint should be.
    frameoffset = child.alignoffset or (frameheight / 2)
    --...
    frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT", 0, frameoffset - lastframeoffset)

    So, if you set it to (0.5 * button1.height) + 5, that would do it. Except that "OnAcquire" hasn't run for the same reason that caused the problems to begin with, which means the default value for height hasn't been set yet. It's 24. So: 17 :).
    icon.alignoffset = 17
    Posted in: Ace3
  • 0

    posted a message on LibMounts-1.0
    The code sample for GetMountCurrentType does not include the tertiary return value.
    The name is a little confusing; is it talking about the mount I'm currently mounted on or is it talking about what mounts are possible to use in the current zone/area?

    #6 return from GetMountInfo is listed as "passagners" rather than "passengers".
    The code sample for GetMountInfo does not include the passengers return value.

    GetMountList includes a parameter uT that has no documentation.
    Neither uT nor table are included in the code sample.
    Wouldn't having a parameter named "table" prevent you from accessing the global "table" in that function?

    #6 return from GetProfessionRestriction is listed as "summanable" rather than "summonable".
    Wouldn't it be sufficient to just return profession, level and check profession for nil to determine if there is no profession restriction?
    Posted in: Libraries
  • 0

    posted a message on Functions in a local table
    Quote from Farmbuyer
    There's no special correspondence between "declaration" and "call" syntax in Lua. (Functions aren't really "declared" as in imperative languages, there's no function signature here.)


    More or less everything I said here was in response to this. There is a "declared" "signature" of a function in terms of its parameters. There is a correspondence between "declaration" and "call" in that if you don't declare the parameters, you can't receive them.

    I thought Farmbuyer was telling me something I didn't know, and it turned out s/he wasn't :).
    Posted in: Lua Code Discussion
  • 0

    posted a message on Functions in a local table
    The confusion was only related to you telling me that there wasn't anything going on when a function was written down for the first time.

    I think it's clear now that if a function is not either defined on a table with colon syntax or manually defined with its first parameter reserved for a frame, it cannot later be called that way.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Range sliders ignoring stepping
    Well, from the OP, it does round, but only after the drag stops; the value reported during the drag is not rounded.

    I don't think the OP had anything about jumping between stops, but that should definitely be in any slider control with stepping control. I think it was in Windows 3.0.
    Posted in: Ace3
  • 0

    posted a message on Functions in a local table
    I'm trying to reconcile these two:
    There's no special correspondence between "declaration" and "call" syntax in Lua. (Functions aren't really "declared" as in imperative languages, there's no function signature here.)

    Using colon notation when defining a function just means "there will be a hidden first parameter, and it will be called 'self'".


    Two things:
    1. function(param1, param2)
          --body
      end
    2. That's a function declaration, isn't it? It's defining the parameter list. I can call it with no parameters [as ___()] and it just passes nil for each one, but I can't call it with more parameters than what it was originally "declared" as having and expect those extra values to be accessible. I'd have to put the vararg in there explicitly to be able to use it within the function scope (to make it a "vararg function", I think the error message says).
    3. Your use of the phrasing "there will be" also seems to imply that something is "set" when code like the above is written.

    So, given this...
    local f = {}
    
    function f.Dot(name)
    	print(type(name))
    end
    
    function f:Colon()
    	print(self == nil)
    end
    
    f:Dot("Johnny") -- this prints "table"
    f.Colon() -- this prints "true"

    ...there is something "saved" at the point of declaration. The self keyword isn't something that magically becomes available within the function's scope. It's really there in the parameter list at the first position. The value "Johnny" disappears into the ether in the first call as there are no more parameters left.
    Posted in: Lua Code Discussion
  • 0

    posted a message on LibMapPins-1.0
    I thought of a few questions:
    1. How about DeletePinsByMapID and DeleteAllPins functions to get the rest of the things in the TomTom pin/arrow right-click menu?
    2. What is the difference between a minimap pin and a world map pin? Wouldn't the minimap just be a window through which you'd see world map pins as you arrived near their location? I just see the CreateMinimapPin function in the mixins table, so I'm not sure what the signature was going to be like.
    3. As I just learned, just today, that libraries can't have saved variables, are you going to require consumers of the library to dedicate a section of their variables to dehydrated pin information (persisted, maybe, with some kind of Save/Load functions that they would need to call on ADDON_LOADED and PLAYER_LOGOUT or...)(...maybe the library would take a handle on the config section and update it constantly rather than loading once and saving once...)?
    Posted in: Libraries
  • 0

    posted a message on Functions in a local table
    I'm not sure if I was misreading that other thread or what, but what I took away from the post that said your functions were polluting the global namespace was that you just needed to put the word "local" in their declarations. I'm not sure it was entirely necessary to attach them all to a table unless you wanted to pass that table around to other parts of your addon. I might be missing something, though...

    Though, as a result of looking at the code, I have a question: if a method is declared as...
    function Table:Method()

    ...but is called like...
    Table.Method()

    ...what does that mean for the self parameter? Is that actually just hidden from the parameter list or is that variable and its value injected into the function's scope from the C side? If it's the former, not passing it just means it's empty, right? So, what if there are other parameters.

    For example, this...
    function RIA:OnEvent(event, ...)

    ...being used like this...
    RIA.eventFrame:SetScript("OnEvent", RIA.OnEvent)


    Wouldn't OnEvent be expecting, when called using dot notation, the first parameter to be self? So, wouldn't the event name actually get thrown into self?
    Posted in: Lua Code Discussion
  • 0

    posted a message on .docmeta questions
    Considering:
    1. How sparse (as in, the amount of negative space) the output of that is, and...
    2. How ugly and bulky the LuaDoc header comments look in the code.

    I might just consider what Phanx suggested and come up with my own more-condensed and less-airy documentation format, should I ever make anything with a public API.

    WRT (2), though: it is possible that, after staring at .NET XML documentation for almost 8 years now, anything else would just be automatically "ugly and bulky", regardless of its syntactic quality or its verbosity.
    Posted in: General Chat
  • 0

    posted a message on Remapping the map!
    Awesome. I'll have to check out the TomTom code sometime.

    Issues with stuff not being documented at all has frustrated me so much in my life that I consider documentation of outward-facing functionality as essential to the product as the code that drives it. I know how you feel :(.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Remapping the map!
    Since you made the addon thread, I guess you figured it out. Did you do what TomTom does or did you go a different route?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Remapping the map!
    Have you looked at how TomTom does its waypoint blips? It also has a remove this, remove all in this zone, remove all option.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Remapping the map!
    Well, how does the default UI world map load one of those ambiguous maps?
    Posted in: Lua Code Discussion
  • 0

    posted a message on zone number help
    That's why I tend to format calls like that as:

    function HelloWorld()
    	local hw = CreateFrame("FRAME")
    	hw:RegisterEvent("ZONE_CHANGED_NEW_AREA")
    	hw:SetScript(
    		"OnEvent",
    		function()
    			local mapName = GetCurrentMapAreaID()
    			print(mapName) 
    		end
    	)
    end


    If you treat the method as a block, then each parameter gets indented. If it were that way, you'd've indented the contents of the function and then the indentation level would've been easier to read.
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.