MCPcopy Create free account
hub / github.com/Aloshi/EmulationStation / getCellOffset

Method getCellOffset

src/components/ComponentListComponent.cpp:94–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92unsigned int ComponentListComponent::getColumnWidth(int col) { return mColumnWidths[col]; }
93
94Eigen::Vector3f ComponentListComponent::getCellOffset(Eigen::Vector2i pos)
95{
96 Eigen::Vector3f offset(0, 0, 0);
97
98 for(int y = 0; y < pos.y(); y++)
99 offset[1] += getRowHeight(y);
100
101 for(int x = 0; x < pos.x(); x++)
102 offset[0] += getColumnWidth(x);
103
104 ComponentEntry* entry = getCell(pos.x(), pos.y());
105
106 Eigen::Vector2i gridSize(0, 0);
107 for(int x = pos.x(); x < pos.x() + entry->dim[0]; x++)
108 gridSize[0] += getColumnWidth(x);
109 for(int y = pos.y(); y < pos.y() + entry->dim[1]; y++)
110 gridSize[1] += getRowHeight(y);
111
112 //if AlignCenter, add half of cell width - half of control width
113 if(entry->alignment == AlignCenter)
114 offset[0] += gridSize.x() / 2 - entry->component->getSize().x() / 2;
115
116 //if AlignRight, add cell width - control width
117 if(entry->alignment == AlignRight)
118 offset[0] += gridSize.x() - entry->component->getSize().x();
119
120 //always center on the Y axis
121 offset[1] += gridSize.y() / 2 - entry->component->getSize().y() / 2;
122
123 return offset;
124}
125
126void ComponentListComponent::setCell(unsigned int x, unsigned int y, ComponentEntry* entry)
127{

Callers

nothing calls this directly

Calls 1

getSizeMethod · 0.45

Tested by

no test coverage detected