• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 30712175708

01 Aug 2026 06:17PM UTC coverage: 15.231% (-0.03%) from 15.263%
30712175708

Pull #2169

github

web-flow
Merge c60ea2870 into 3ceec338e
Pull Request #2169: 3rdparty: stop vendored xtensor/xtl/xsimd from polluting score's install

30395 of 199565 relevant lines covered (15.23%)

1075.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.93
/src/plugins/score-plugin-scenario/Scenario/Document/TimeSync/TriggerView.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "TriggerView.hpp"
4

5
#include <score/model/Skin.hpp>
6
#include <score/widgets/Pixmap.hpp>
7

8
#include <QBitmap>
9
#include <QCursor>
10
#include <QGraphicsSceneMouseEvent>
11
#include <QGuiApplication>
12
#include <QPainter>
13

14
#include <wobjectimpl.h>
15

16
W_OBJECT_IMPL(Scenario::TriggerView)
156✔
17
namespace Scenario
18
{
19
static const constexpr int iconSize = 20;
20

21
static const QPixmap& triggerPixmap()
×
22
{
23
  static auto p = score::get_pixmap(":/icons/scenario_trigger.png");
×
24
  //p.setDevicePixelRatio(qApp->devicePixelRatio());
25
  return p;
×
26
}
×
27
static const QImage& triggerImage()
×
28
{
29
  static auto p = triggerPixmap().toImage();
×
30
  return p;
×
31
}
×
32
static const QPixmap& selectedTriggerPixmap()
×
33
{
34
  static auto p = score::get_pixmap(":/icons/scenario_trigger_selected.png");
×
35
  //p.setDevicePixelRatio(qApp->devicePixelRatio());
36
  return p;
×
37
}
×
38
static const QPixmap& hoveredTriggerPixmap()
×
39
{
40
  static auto p = score::get_pixmap(":/icons/scenario_trigger_hovered.png");
×
41
  //p.setDevicePixelRatio(qApp->devicePixelRatio());
42
  return p;
×
43
}
×
44
static const QPixmap& triggerSpriteSheet()
×
45
{
46
  static auto p = score::get_pixmap(":/icons/trigger_sprite.png");
×
47
  //p.setDevicePixelRatio(qApp->devicePixelRatio());
48
  return p;
×
49
}
×
50

51
TriggerView::TriggerView(QGraphicsItem* parent)
30✔
52
    : QGraphicsItem{parent}
30✔
53
    , m_currentFrame{0}
30✔
54
    , m_frameDirection{1}
30✔
55
    , m_selected{false}
30✔
56
    , m_hovered{false}
30✔
57
    , m_waiting{false}
30✔
58
{
30✔
59
  auto& skin = score::Skin::instance();
30✔
60
  this->setToolTip(QObject::tr("Trigger\nUsed to introduce temporal interactions."));
30✔
61
  this->setCursor(skin.CursorPointingHand);
30✔
62
  this->setCacheMode(QGraphicsItem::NoCache);
30✔
63
  this->setAcceptHoverEvents(true);
30✔
64
  this->setAcceptDrops(true);
30✔
65
}
30✔
66

67
void TriggerView::setSelected(bool b) noexcept
×
68
{
69
  m_selected = b;
×
70
  update();
×
71
}
×
72

73
QRectF TriggerView::boundingRect() const
36✔
74
{
75
  return {0, 0, iconSize, iconSize};
36✔
76
}
77

78
void TriggerView::paint(
×
79
    QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
80
{
81
  const qreal sz = painter->device()->devicePixelRatioF() * iconSize;
×
82
  auto& pixmap = currentPixmap();
×
83
  if(&pixmap == &triggerSpriteSheet())
×
84
  {
85
    painter->drawPixmap(QPointF{}, pixmap, QRectF{qreal(m_currentFrame), 0, sz, sz});
×
86
    nextFrame();
×
87
  }
×
88
  else
89
  {
90
    painter->drawPixmap(QPointF{}, pixmap);
×
91
  }
92
}
×
93

94
bool TriggerView::contains(const QPointF& point) const
×
95
{
96
  return boundingRect().contains(point);
×
97
  // const double p = triggerImage().devicePixelRatio();
98
  // return triggerImage().pixelColor(point.x() * p, point.y() * p).alpha() > 0
99
  // ;
100
}
101

102
void TriggerView::mousePressEvent(QGraphicsSceneMouseEvent* event)
×
103
{
104
  if(event->button() == Qt::MouseButton::LeftButton)
×
105
    pressed(event->scenePos());
×
106
  event->accept();
×
107
}
×
108

109
void TriggerView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
×
110
{
111
  moved(event->scenePos());
×
112
  event->accept();
×
113
}
×
114

115
void TriggerView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
×
116
{
117
  released(event->scenePos());
×
118
  event->accept();
×
119
}
×
120

121
void TriggerView::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
×
122
{
123
  m_hovered = true;
×
124
  update();
×
125
  event->accept();
×
126
}
×
127

128
void TriggerView::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
×
129
{
130
  m_hovered = false;
×
131
  update();
×
132
  event->accept();
×
133
}
×
134

135
void TriggerView::dropEvent(QGraphicsSceneDragDropEvent* event)
×
136
{
137
  dropReceived(event->scenePos(), *event->mimeData());
×
138
}
×
139

140
void TriggerView::nextFrame()
×
141
{
142
  if(!m_waiting)
×
143
    return;
×
144

145
  const double p = triggerImage().devicePixelRatio();
×
146
  const auto sz = p * iconSize;
×
147
  m_currentFrame += m_frameDirection * sz;
×
148
  if(m_currentFrame >= triggerSpriteSheet().width())
×
149
  {
150
    m_currentFrame = triggerSpriteSheet().width() - sz;
×
151
    m_frameDirection = -1;
×
152
  }
×
153
  else if(m_currentFrame < 0)
×
154
  {
155
    m_currentFrame = 0;
×
156
    m_frameDirection = 1;
×
157
  }
×
158
  update();
×
159
}
×
160

161
const QPixmap& TriggerView::currentPixmap() const noexcept
×
162
{
163
  if(m_selected)
×
164
  {
165
    return selectedTriggerPixmap();
×
166
  }
167
  else if(m_hovered)
×
168
  {
169
    return hoveredTriggerPixmap();
×
170
  }
171
  else if(m_waiting)
×
172
  {
173
    return triggerSpriteSheet();
×
174
  }
175
  else
176
  {
177
    return triggerPixmap();
×
178
  }
179
}
×
180

181
void TriggerView::onWaitStart()
×
182
{
183
  m_waiting = true;
×
184
  update();
×
185
}
×
186

187
void TriggerView::onWaitEnd()
×
188
{
189
  m_waiting = false;
×
190
  m_currentFrame = 0;
×
191
  update();
×
192
}
×
193
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc