classdef GridLayout < GUIBase
    %GRIDLAYOUT Draw a grid of other drawable elements.
    %   Draws a bunch of drawables using panels to make life simple.
    
    properties
        drawables = {}
        controls = []
        column_sizes = []
        row_sizes = []
    end
    
    methods
        function object = GridLayout()
        end
        
        function insert_drawable(object, drawable, y, x)
            object.drawables{y, x} = drawable;
            
            relayout(object);
            drawable.addlistener('BoundingBoxChanged', @(srv, event)changed_bounding_box(object));
        end
        
        function changed_bounding_box(object, src, event)
            relayout(object);
            redraw(object);
            notify(object, 'BoundingBoxChanged');
        end
    end
    
end

