1#include "Library/Clipping/ViewIdHolder.h"
2
3#include "Library/Placement/PlacementFunction.h"
4#include "Library/Placement/PlacementId.h"
5#include "Library/Placement/PlacementInfo.h"
6
7namespace al {
8ViewIdHolder::ViewIdHolder() {}
9
10ViewIdHolder* ViewIdHolder::tryCreate(const PlacementInfo& placementInfo) {
11 if (calcLinkChildNum(placementInfo, linkName: "ViewGroup") < 1) {
12 return nullptr;
13 } else {
14 ViewIdHolder* holder = new ViewIdHolder();
15 holder->init(placementInfo);
16 return holder;
17 }
18}
19
20void ViewIdHolder::init(const PlacementInfo& placementInfo) {
21 mNumPlacements = calcLinkChildNum(placementInfo, linkName: "ViewGroup");
22 mPlacementIds = new PlacementId[mNumPlacements];
23 for (s32 i = 0; i < mNumPlacements; ++i) {
24 PlacementInfo info;
25 getLinksInfoByIndex(linkPlacementInfo: &info, placementInfo, linkName: "ViewGroup", index: i);
26 mPlacementIds[i].init(info);
27 }
28}
29
30const PlacementId& ViewIdHolder::getViewId(s32 idx) const {
31 return mPlacementIds[idx];
32}
33} // namespace al
34