aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/LayoutHelper.cpp
blob: a9121321e20559f0d3d4630a15775131a79a0edc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "cru/ui/render/LayoutHelper.h"

#include "cru/common/log/Logger.h"

namespace cru::ui::render {
float CalculateAnchorByAlignment(Alignment alignment, float start_point,
                                 float content_length, float child_length) {
  switch (alignment) {
    case Alignment::Start:
      return start_point;
    case Alignment::Center:
      return start_point + (content_length - child_length) / 2.0f;
    case Alignment::End:
      return start_point + content_length - child_length;
    default:
      return start_point;
  }
}
}  // namespace cru::ui::render