classdef VLayout < LinearLayoutBase
    %HLAYOUT Summary of this class goes here
    %   Detailed explanation goes here
    
    methods
        function [x, y] = get_bounding_box(object)
            x = 0;
            y = 0;
            
            for i=1:size(object.children, 2)
                [xi, yi] = object.children{i}.get_bounding_box();
                x = max([x, xi]);
                y = y + yi;
            end
        end
        
        function relayout(object)
            [~, y] = get_bounding_box(object);
            
            y_sofar = 0;
            
            for i=1:size(object.children, 2)
                [~, yi] = object.children{i}.get_bounding_box();
                y_sofar = y_sofar+yi;
                set(object.children_controls{i}, 'Position', [0, y-y_sofar, 1, 1]);
            end
        
            object.notify('BoundingBoxChanged');
        end
    end
    
end

