MCPcopy Create free account
hub / github.com/clementgallet/libTAS / SubplotSetCell

Function SubplotSetCell

src/external/imgui/implot.cpp:3273–3312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3271static const float SUBPLOT_SPLITTER_FEEDBACK_TIMER = 0.06f;
3272
3273void SubplotSetCell(int row, int col) {
3274 ImPlotContext& gp = *GImPlot;
3275 ImPlotSubplot& subplot = *gp.CurrentSubplot;
3276 if (row >= subplot.Rows || col >= subplot.Cols)
3277 return;
3278 float xoff = 0;
3279 float yoff = 0;
3280 for (int c = 0; c < col; ++c)
3281 xoff += subplot.ColRatios[c];
3282 for (int r = 0; r < row; ++r)
3283 yoff += subplot.RowRatios[r];
3284 const ImVec2 grid_size = subplot.GridRect.GetSize();
3285 ImVec2 cpos = subplot.GridRect.Min + ImVec2(xoff*grid_size.x,yoff*grid_size.y);
3286 cpos.x = IM_ROUND(cpos.x);
3287 cpos.y = IM_ROUND(cpos.y);
3288 ImGui::GetCurrentWindow()->DC.CursorPos = cpos;
3289 // set cell size
3290 subplot.CellSize.x = IM_ROUND(subplot.GridRect.GetWidth() * subplot.ColRatios[col]);
3291 subplot.CellSize.y = IM_ROUND(subplot.GridRect.GetHeight() * subplot.RowRatios[row]);
3292 // setup links
3293 const bool lx = ImHasFlag(subplot.Flags, ImPlotSubplotFlags_LinkAllX);
3294 const bool ly = ImHasFlag(subplot.Flags, ImPlotSubplotFlags_LinkAllY);
3295 const bool lr = ImHasFlag(subplot.Flags, ImPlotSubplotFlags_LinkRows);
3296 const bool lc = ImHasFlag(subplot.Flags, ImPlotSubplotFlags_LinkCols);
3297
3298 SetNextAxisLinks(ImAxis_X1, lx ? &subplot.ColLinkData[0].Min : lc ? &subplot.ColLinkData[col].Min : nullptr,
3299 lx ? &subplot.ColLinkData[0].Max : lc ? &subplot.ColLinkData[col].Max : nullptr);
3300 SetNextAxisLinks(ImAxis_Y1, ly ? &subplot.RowLinkData[0].Min : lr ? &subplot.RowLinkData[row].Min : nullptr,
3301 ly ? &subplot.RowLinkData[0].Max : lr ? &subplot.RowLinkData[row].Max : nullptr);
3302 // setup alignment
3303 if (!ImHasFlag(subplot.Flags, ImPlotSubplotFlags_NoAlign)) {
3304 gp.CurrentAlignmentH = &subplot.RowAlignmentData[row];
3305 gp.CurrentAlignmentV = &subplot.ColAlignmentData[col];
3306 }
3307 // set idx
3308 if (ImHasFlag(subplot.Flags, ImPlotSubplotFlags_ColMajor))
3309 subplot.CurrentIdx = col * subplot.Rows + row;
3310 else
3311 subplot.CurrentIdx = row * subplot.Cols + col;
3312}
3313
3314void SubplotSetCell(int idx) {
3315 ImPlotContext& gp = *GImPlot;

Callers 2

SubplotNextCellFunction · 0.85
BeginSubplotsFunction · 0.85

Calls 5

ImVec2Function · 0.85
GetCurrentWindowFunction · 0.85
ImHasFlagFunction · 0.85
SetNextAxisLinksFunction · 0.85
GetSizeMethod · 0.80

Tested by

no test coverage detected