2#include <score/model/Skin.hpp>
16 static constexpr double width = 12.;
20 static bool sideBySide(
const QRectF& box)
noexcept
28 return sideBySide(box) ? 2. * width : width;
32 static bool visible(
const QRectF& box)
noexcept
34 return box.width() >
stripWidth(box) + 2. * width;
37 static QRectF rect(
const QRectF& box)
noexcept
39 const double left = std::max(box.left(), box.right() -
stripWidth(box));
40 return QRectF{QPointF{left, box.top()}, QPointF{box.right(), box.bottom()}};
44 static QRectF
half(
const QRectF& box,
int step)
noexcept
46 const QRectF strip = rect(box);
48 return step > 0 ? QRectF{QPointF{strip.center().x(), strip.top()}, strip.bottomRight()}
49 : QRectF{strip.topLeft(), QPointF{strip.center().x(), strip.bottom()}};
50 return step > 0 ? QRectF{strip.topLeft(), QPointF{strip.right(), strip.center().y()}}
51 : QRectF{QPointF{strip.left(), strip.center().y()}, strip.bottomRight()};
55 static int stepAt(
const QRectF& box, QPointF pos)
noexcept
59 if(
half(box, +1).contains(pos))
61 if(
half(box, -1).contains(pos))
68 QPainter& painter,
const score::Skin& skin,
const QRectF& box,
int pressedStep)
70 const QRectF halves[2] = {
half(box, +1),
half(box, -1)};
73 const double arm = 2.;
74 for(
int i = 0; i < 2; i++)
76 const int step = i == 0 ? +1 : -1;
77 const QRectF&
half = halves[i];
81 const bool pressed = pressedStep == step;
84 painter.setPen(skin.NoPen);
85 painter.setBrush(skin.Base4.main.brush);
86 painter.drawRect(
half);
91 const QPointF c{std::round(
half.center().x()), std::round(
half.center().y())};
92 painter.setPen(pressed ? skin.Emphasis2.main.pen1 : skin.Base4.main.pen1);
93 painter.drawLine(QPointF{c.x() - arm, c.y()}, QPointF{c.x() + arm, c.y()});
95 painter.drawLine(QPointF{c.x(), c.y() - arm}, QPointF{c.x(), c.y() + arm});
Base toolkit upon which the software is built.
Definition Application.cpp:85
Definition Stepper.hpp:15
static bool visible(const QRectF &box) noexcept
Shown only when the box leaves room for its content next to it.
Definition Stepper.hpp:32
static double stripWidth(const QRectF &box) noexcept
Width of the strip in that box.
Definition Stepper.hpp:26
static int stepAt(const QRectF &box, QPointF pos) noexcept
+1 or -1 for the half under pos, 0 outside the strip.
Definition Stepper.hpp:55
static void paint(QPainter &painter, const score::Skin &skin, const QRectF &box, int pressedStep)
pressedStep: the half held down (0 for none) while the pointer is on it.
Definition Stepper.hpp:67
static QRectF half(const QRectF &box, int step) noexcept
The half that steps by step: +1 or -1.
Definition Stepper.hpp:44
static constexpr double min_stacked_height
Below this height the halves sit side by side.
Definition Stepper.hpp:18