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

Method drawValidationRect

QtNodeEditor/src/NodePainter.cpp:301–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301void
302NodePainter::
303drawValidationRect(QPainter * painter,
304 NodeGeometry const & geom,
305 NodeDataModel const * model,
306 NodeGraphicsObject const & graphicsObject)
307{
308 auto modelValidationState = model->validationState();
309
310 if (modelValidationState != NodeValidationState::Valid)
311 {
312 NodeStyle const& nodeStyle = model->nodeStyle();
313
314 auto color = graphicsObject.isSelected()
315 ? nodeStyle.SelectedBoundaryColor
316 : nodeStyle.NormalBoundaryColor;
317
318 if (geom.hovered())
319 {
320 QPen p(color, nodeStyle.HoveredPenWidth);
321 painter->setPen(p);
322 }
323 else
324 {
325 QPen p(color, nodeStyle.PenWidth);
326 painter->setPen(p);
327 }
328
329 //Drawing the validation message background
330 if (modelValidationState == NodeValidationState::Error)
331 {
332 painter->setBrush(nodeStyle.ErrorColor);
333 }
334 else
335 {
336 painter->setBrush(nodeStyle.WarningColor);
337 }
338
339 double const radius = 3.0;
340
341 float diam = nodeStyle.ConnectionPointDiameter;
342
343 QRectF boundary(-diam,
344 -diam + geom.height() - geom.validationHeight(),
345 2.0 * diam + geom.width(),
346 2.0 * diam + geom.validationHeight());
347
348 painter->drawRoundedRect(boundary, radius, radius);
349
350 painter->setBrush(Qt::gray);
351
352 //Drawing the validation message itself
353 QString const &errorMsg = model->validationMessage();
354
355 QFont f = painter->font();
356
357 QFontMetrics metrics(f);
358

Callers

nothing calls this directly

Calls 1

hoveredMethod · 0.80

Tested by

no test coverage detected