ExtenderSlotConnectionPin.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <QPainter>
  9. #include <Components/Slots/Extender/ExtenderSlotConnectionPin.h>
  10. #include <GraphCanvas/Components/Slots/SlotBus.h>
  11. #include <GraphCanvas/Components/Slots/Extender/ExtenderSlotBus.h>
  12. #include <GraphCanvas/Components/StyleBus.h>
  13. #include <GraphCanvas/Styling/definitions.h>
  14. namespace GraphCanvas
  15. {
  16. //////////////////////////////
  17. // ExtenderSlotConnectionPin
  18. //////////////////////////////
  19. ExtenderSlotConnectionPin::ExtenderSlotConnectionPin(const AZ::EntityId& slotId)
  20. : SlotConnectionPin(slotId)
  21. {
  22. }
  23. ExtenderSlotConnectionPin::~ExtenderSlotConnectionPin()
  24. {
  25. }
  26. void ExtenderSlotConnectionPin::OnRefreshStyle()
  27. {
  28. m_style.SetStyle(m_slotId, Styling::Elements::ExecutionConnectionPin);
  29. update();
  30. }
  31. void ExtenderSlotConnectionPin::DrawConnectionPin(QPainter *painter, QRectF drawRect, bool /*isConnected*/)
  32. {
  33. qreal radius = (AZ::GetMin(drawRect.width(), drawRect.height()) * 0.5) - m_style.GetBorder().width();
  34. QPen pen = m_style.GetBorder();
  35. QColor color = pen.color();
  36. color.setAlpha(255);
  37. pen.setColor(color);
  38. painter->setPen(pen);
  39. QLineF horizontalLine(drawRect.center() - QPointF(radius, 0), drawRect.center() + QPointF(radius, 0));
  40. QLineF verticalLine(drawRect.center() - QPointF(0, radius), drawRect.center() + QPointF(0, radius));
  41. painter->drawLine(horizontalLine);
  42. painter->drawLine(verticalLine);
  43. }
  44. void ExtenderSlotConnectionPin::OnSlotClicked()
  45. {
  46. ExtenderSlotRequestBus::Event(GetEntityId(), &ExtenderSlotRequests::TriggerExtension);
  47. }
  48. }