def rearrange
      # Calculate the number of the dynamic dimension.
      case @type
      when :fixed_rows
        @num_columns = (size / @num_rows.to_f).ceil
      when :fixed_columns
        @num_rows = (size / @num_columns.to_f).ceil
      end

      # Create an array containing all the rows.
      @rows = case @type
      when :fixed_rows
        # Rearrange the list, arranged by columns, into rows.
        rows = Array.new(@num_rows) { [] }
        @children.each_with_index do |child, i|
          rows[i % @num_rows].push child
        end
        rows
      when :fixed_columns
        @children.each_slice(@num_columns).to_a
      end

      nil
    end
def rearrange
      # Calculate the number of the dynamic dimension.
      case @type
      when :fixed_rows
        @num_columns = (size / @num_rows.to_f).ceil
      when :fixed_columns
        @num_rows = (size / @num_columns.to_f).ceil
      end

      # Create an array containing all the rows.
      @rows = case @type
      when :fixed_rows
        # Rearrange the list, arranged by columns, into rows.
        rows = Array.new(@num_rows) { [] }
        @children.each_with_index do |child, i|
          rows[i % @num_rows].push child
        end
        rows
      when :fixed_columns
        @children.each_slice(@num_columns).to_a
      end

      nil
    end
Rearrange the cells based on changes to the number of rows/columns or adding/removing elements.