Loading...
Searching...
No Matches
Timebar.hpp
1#pragma once
2#include <score/model/Skin.hpp>
3
4#include <ossia/detail/ssize.hpp>
5
6#include <QGraphicsItem>
7#include <QPainter>
8
9#include <array>
10
11namespace Scenario
12{
13class LightBars : public QGraphicsItem
14{
15public:
16 std::vector<QLineF> positions;
17 LightBars()
18 {
19 setFlag(ItemStacksBehindParent);
20 setZValue(-9);
21 positions.resize(1);
22 }
23
24 ~LightBars() { }
25
26 QRectF boundingRect() const override
27 {
28 if(positions.empty())
29 return {};
30 return {
31 positions.front().x1(), 0, positions.back().x1() - positions.front().x1(),
32 10000};
33 }
34
35 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
36 override
37 {
38 painter->setRenderHint(QPainter::Antialiasing, true);
39 painter->setPen(score::Skin::instance().DarkGray.main.pen_cosmetic);
40 painter->drawLines(positions.data(), positions.size());
41 }
42
43 QLineF& operator[](int i)
44 {
45 if(i >= std::ssize(positions))
46 {
47 positions.resize((i + 1) * 1.2);
48 }
49 return positions[i];
50 }
51
52 void updateShapes()
53 {
54 prepareGeometryChange();
55 update();
56 }
57 int type() const override { return 90077; }
58};
59
60class LighterBars : public QGraphicsItem
61{
62public:
63 std::vector<QLineF> positions;
65 {
66 setFlag(ItemStacksBehindParent);
67 setZValue(-10);
68 positions.resize(1);
69 }
70
71 ~LighterBars() { }
72
73 QRectF boundingRect() const override
74 {
75 if(positions.empty())
76 return {};
77 return {
78 positions.front().x1(), 0, positions.back().x1() - positions.front().x1(),
79 10000};
80 }
81
82 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
83 override
84 {
85 painter->setRenderHint(QPainter::Antialiasing, true);
86 painter->setPen(score::Skin::instance().DarkGray.darker300.pen_cosmetic);
87 painter->drawLines(positions.data(), positions.size());
88 }
89
90 QLineF& operator[](int i)
91 {
92 if(i >= std::ssize(positions))
93 {
94 positions.resize((i + 1) * 1.2);
95 }
96 return positions[i];
97 }
98
99 void updateShapes()
100 {
101 prepareGeometryChange();
102 update();
103 }
104 int type() const override { return 90078; }
105};
106
107}
Definition Timebar.hpp:14
Definition Timebar.hpp:61
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13