MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / PosToItem

Method PosToItem

LibLemon/include/lemon/gui/widgets.h:314–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312
313 void ResetScrollBar();
314 int PosToItem(vector2i_t relPos){
315 if(!items.size()) return -1;
316
317 int column = 0;
318 int row = 0;
319
320 if(relPos.x){
321 column = relPos.x / itemSize.x;
322 if(column >= itemsPerRow){
323 return -1;
324 }
325 }
326
327 if(relPos.y){
328 row = relPos.y / itemSize.y;
329 if(row > static_cast<int>(items.size()) / itemsPerRow){
330 return -1;
331 }
332 }
333
334 return row * itemsPerRow + column;
335 }
336 public:
337 GridView(rect_t bounds) : Widget(bounds){}
338 ~GridView() = default;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected