classdef LinearLayoutBase < LayoutBase
    %LINEARLAYOUTBASE Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        children = {}
        
        children_controls = {}
    end
    
    methods
        function add_child(object, child)
            object.children{end+1} = child;
            child.addlistener('BoundingBoxChanged', @(src, event)object.relayout());
        end
        
        %NOTE REMOVAL IS NOT SUPPORTED!!!!
        function draw_onto(object, phandle)
            assert(size(object.children, 2) >= size(object.children_controls, 2), 'DONT DO THAT!');
            
            for i=1:size(object.children, 2)
                if size(object.children_controls, 2) < i
                    object.children_controls{i} = uipanel(phandle, 'Units', 'pixels');
                end
                cc = object.children_controls{i};
                object.children{i}.draw(cc);
            end
            relayout(object);
        end
    end
    
end

