MCPcopy Create free account
hub / github.com/Nelarius/imnodes / DrawPinShape

Function DrawPinShape

imnodes.cpp:1341–1417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1339}
1340
1341void DrawPinShape(const ImVec2& pin_pos, const ImPinData& pin, const ImU32 pin_color)
1342{
1343 static const int CIRCLE_NUM_SEGMENTS = 8;
1344
1345 switch (pin.Shape)
1346 {
1347 case ImNodesPinShape_Circle:
1348 {
1349 GImNodes->CanvasDrawList->AddCircle(
1350 pin_pos,
1351 GImNodes->Style.PinCircleRadius,
1352 pin_color,
1353 CIRCLE_NUM_SEGMENTS,
1354 GImNodes->Style.PinLineThickness);
1355 }
1356 break;
1357 case ImNodesPinShape_CircleFilled:
1358 {
1359 GImNodes->CanvasDrawList->AddCircleFilled(
1360 pin_pos, GImNodes->Style.PinCircleRadius, pin_color, CIRCLE_NUM_SEGMENTS);
1361 }
1362 break;
1363 case ImNodesPinShape_Quad:
1364 {
1365 const QuadOffsets offset = CalculateQuadOffsets(GImNodes->Style.PinQuadSideLength);
1366 GImNodes->CanvasDrawList->AddQuad(
1367 pin_pos + offset.TopLeft,
1368 pin_pos + offset.BottomLeft,
1369 pin_pos + offset.BottomRight,
1370 pin_pos + offset.TopRight,
1371 pin_color,
1372 GImNodes->Style.PinLineThickness);
1373 }
1374 break;
1375 case ImNodesPinShape_QuadFilled:
1376 {
1377 const QuadOffsets offset = CalculateQuadOffsets(GImNodes->Style.PinQuadSideLength);
1378 GImNodes->CanvasDrawList->AddQuadFilled(
1379 pin_pos + offset.TopLeft,
1380 pin_pos + offset.BottomLeft,
1381 pin_pos + offset.BottomRight,
1382 pin_pos + offset.TopRight,
1383 pin_color);
1384 }
1385 break;
1386 case ImNodesPinShape_Triangle:
1387 {
1388 const TriangleOffsets offset =
1389 CalculateTriangleOffsets(GImNodes->Style.PinTriangleSideLength);
1390 GImNodes->CanvasDrawList->AddTriangle(
1391 pin_pos + offset.TopLeft,
1392 pin_pos + offset.BottomLeft,
1393 pin_pos + offset.Right,
1394 pin_color,
1395 // NOTE: for some weird reason, the line drawn by AddTriangle is
1396 // much thinner than the lines drawn by AddCircle or AddQuad.
1397 // Multiplying the line thickness by two seemed to solve the
1398 // problem at a few different thickness values.

Callers 1

DrawPinFunction · 0.85

Calls 8

CalculateQuadOffsetsFunction · 0.85
CalculateTriangleOffsetsFunction · 0.85
AddCircleMethod · 0.80
AddCircleFilledMethod · 0.80
AddQuadMethod · 0.80
AddQuadFilledMethod · 0.80
AddTriangleMethod · 0.80
AddTriangleFilledMethod · 0.80

Tested by

no test coverage detected