Ace3

22 - Adding a child after

What is the enhancement in mind? How should it look and feel?
Say I have an existing container to which I want to add a widget. Right now the only method to do that is "AddChild". But this way I cannot control where my widget will appear, it will always appear at the end of my container, a AddChildAfter(widget, sibling) method would be handy.

Please provide any additional information below.
This problem is aggravated by the fact that if the last sibling is set to fill the remaining container space (quite common for TreeGroups for example) my widget seems to not even be displayed.

User When Change
Nevcairiel Feb 15, 2009 at 12:14 UTC Changed status from New to Fixed
Mokhtar Feb 06, 2009 at 22:21 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of Nevcairiel Nevcairiel Feb 15, 2009 at 13:57 UTC - 0 likes

    I've changed the behaviour to add the widget before the specified widget, since it eliminates the need for the special "1" case.

  • Avatar of Nevcairiel Nevcairiel Feb 15, 2009 at 12:14 UTC - 0 likes

    I extended the API of AddChild to take an optional third argument "previousWidget", doing exactly the same as you described, just in the same (old) API call.

    Additionally you can also pass the number 1 as the third argument to insert the widget at the first position in the list.

  • Avatar of Mokhtar Mokhtar Feb 06, 2009 at 22:41 UTC - 0 likes

    This seems to do the job :

    AceGUI.WidgetContainerBase.AddChildAfter = function(self, widget, sibling)
    	local siblingIndex = 1
    	for _, child in pairs(self.children) do
    		if sibling == child then
    			break
    		end
    		siblingIndex = siblingIndex + 1 
    	end
    	tinsert(self.children, siblingIndex + 1, widget)
    	widget:SetParent(self)
    	widget.frame:Show()
    	self:DoLayout()
    end
    
  • 3 comments

Facts

Last updated
Feb 15, 2009
Reported
Feb 06, 2009
Status
Fixed - Developer made requested changes. QA should verify.
Type
Enhancement - A change which is intended to better the project in some way
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees