lullaby/modules/layout/layout.cc
// Calculate the primary direction weight and sizes.
Calculate the primary direction weight and sizes.
Calculate the primary direction weight and sizes .
void ApplyLayoutInnerDesired(const float inner_spacing,
                             const float inner_canvas_size,
                             ApplyLayoutContext* context,
                             std::vector<OuterElement>* outer_elements) {
  for (size_t outer_idx = 0; outer_idx < outer_elements->size(); ++outer_idx) {
    const InnerIndexRange range = context->GetRangeForOuter(outer_idx);
    if (range.size == 0) {
      return;
    }
    float total_inner_weight = 0.0f;
    float used_inner_size = 0.0f;
    for (size_t i = 0; i < range.size; ++i) {
      const InnerElement inner_element =
          context->GetInnerElementInRange(range, i);
      outer_elements->at(outer_idx).UpdateFromInnerElement(inner_element);
      UpdateWeightAndSize(inner_element.GetWeight(), inner_element.GetSize(),
                          &total_inner_weight, &used_inner_size);
    }
    if (total_inner_weight > 0) {
      const float free_size_per_weight = CalculateFreeSizePerWeight(
          used_inner_size, total_inner_weight, inner_spacing, inner_canvas_size,
          range.size);
      for (size_t i = 0; i < range.size; ++i) {
        InnerElement inner_element = context->GetInnerElementInRange(range, i);
        if (inner_element.GetWeight() > 0) {
          const float child_inner_size = CalculateChildSizeFromWeight(
              inner_element.GetWeight(), free_size_per_weight);
          inner_element.SetInnerDesiredSize(child_inner_size);
        }
      }
    }
  }
}
void ApplyLayoutInnerDesired ( const float inner_spacing , const float inner_canvas_size , ApplyLayoutContext * context , std :: vector < OuterElement > * outer_elements ) { for ( size_t outer_idx = 0 ; outer_idx < outer_elements -> size ( ) ; ++ outer_idx ) { const InnerIndexRange range = context -> GetRangeForOuter ( outer_idx ) ; if ( range . size == 0 ) { return ; } float total_inner_weight = 0.0f ; float used_inner_size = 0.0f ; for ( size_t i = 0 ; i < range . size ; ++ i ) { const InnerElement inner_element = context -> GetInnerElementInRange ( range , i ) ; outer_elements -> at ( outer_idx ) . UpdateFromInnerElement ( inner_element ) ; UpdateWeightAndSize ( inner_element . GetWeight ( ) , inner_element . GetSize ( ) , & total_inner_weight , & used_inner_size ) ; } if ( total_inner_weight > 0 ) { const float free_size_per_weight = CalculateFreeSizePerWeight ( used_inner_size , total_inner_weight , inner_spacing , inner_canvas_size , range . size ) ; for ( size_t i = 0 ; i < range . size ; ++ i ) { InnerElement inner_element = context -> GetInnerElementInRange ( range , i ) ; if ( inner_element . GetWeight ( ) > 0 ) { const float child_inner_size = CalculateChildSizeFromWeight ( inner_element . GetWeight ( ) , free_size_per_weight ) ; inner_element . SetInnerDesiredSize ( child_inner_size ) ; } } } } }
Calculate the primary direction weight and sizes.
Calculate the primary direction weight and sizes .
// Inner_element will have the values for the outer direction, and we will // only use the max for outer direction calculations. // Apply desired_size to all children