MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / GetGridCellAt

Method GetGridCellAt

Source/UIGrid.cpp:215–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215GridCell UIGrid::GetGridCellAt(float x, float y, float* clickHeight, float* clickWidth)
216{
217 if (mFlip)
218 y = (mHeight - 1) - y;
219
220 float xsize = float(mWidth) / mCols;
221 float ysize = float(mHeight) / mRows;
222
223 int col = ofClamp(x / xsize, 0, mCols - 1);
224 int row = ofClamp(y / ysize, 0, mRows - 1);
225
226 if (clickHeight)
227 {
228 *clickHeight = ofClamp(1 - (y / ysize - ofClamp((int)(y / ysize), 0, mRows - 1)), 0, 1);
229 if (mFlip)
230 *clickHeight = 1 - *clickHeight;
231 }
232
233 if (clickWidth)
234 {
235 *clickWidth = ofClamp(x / xsize - ofClamp((int)(x / xsize), 0, mCols - 1), 0, 1);
236 }
237
238 return GridCell(col, row);
239}
240
241ofVec2f UIGrid::GetCellPosition(int col, int row)
242{

Callers 5

KeyPressedMethod · 0.45
OnClickedMethod · 0.45
MouseMovedMethod · 0.45
KeyPressedMethod · 0.45
OnClickedMethod · 0.45

Calls 2

ofClampFunction · 0.85
GridCellClass · 0.85

Tested by 1

KeyPressedMethod · 0.36