MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / drawEntryLabels

Method drawEntryLabels

QtNodeEditor/src/NodePainter.cpp:233–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231
232
233void
234NodePainter::
235drawEntryLabels(QPainter * painter,
236 NodeGeometry const & geom,
237 NodeState const & state,
238 NodeDataModel const * model)
239{
240 QFontMetrics const & metrics =
241 painter->fontMetrics();
242
243 for(PortType portType: {PortType::Out, PortType::In})
244 {
245 auto const &nodeStyle = model->nodeStyle();
246
247 auto& entries = state.getEntries(portType);
248
249 size_t n = entries.size();
250
251 for (size_t i = 0; i < n; ++i)
252 {
253 QPointF p = geom.portScenePosition(i, portType);
254
255 if (entries[i].empty())
256 painter->setPen(nodeStyle.FontColorFaded);
257 else
258 painter->setPen(nodeStyle.FontColor);
259
260 QString s = model->dataType(portType, i).name;
261
262 auto rect = metrics.boundingRect(s);
263
264 p.setY(p.y() + rect.height() / 4.0);
265
266 switch (portType)
267 {
268 case PortType::In:
269 p.setX(5.0);
270 break;
271
272 case PortType::Out:
273 p.setX(geom.width() - 5.0 - rect.width());
274 break;
275
276 default:
277 break;
278 }
279
280 painter->drawText(p, s);
281 }
282 }
283}
284
285
286void

Callers

nothing calls this directly

Calls 1

dataTypeMethod · 0.80

Tested by

no test coverage detected