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
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 {
37 painter->setRenderHint(QPainter::Antialiasing, true);
38 painter->setPen(score::Skin::instance().DarkGray.main.pen_cosmetic);
39 painter->drawLines(positions.data(), positions.size());
40 }
41
42 QLineF& operator[](int i)
43 {
44 if(i >= std::ssize(positions))
45 {
46 positions.resize((i + 1) * 1.2);
47 }
48 return positions[i];
49 }
50
51 void updateShapes()
52 {
53 prepareGeometryChange();
54 update();
55 }
56};
57
58class LighterBars : public QGraphicsItem
59{
60public:
61 std::vector<QLineF> positions;
63 {
64 setFlag(ItemStacksBehindParent);
65 setZValue(-10);
66 positions.resize(1);
67 }
68
69 ~LighterBars() { }
70
71 QRectF boundingRect() const
72 {
73 if(positions.empty())
74 return {};
75 return {
76 positions.front().x1(), 0, positions.back().x1() - positions.front().x1(),
77 10000};
78 }
79
80 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
81 {
82 painter->setRenderHint(QPainter::Antialiasing, true);
83 painter->setPen(score::Skin::instance().DarkGray.darker300.pen_cosmetic);
84 painter->drawLines(positions.data(), positions.size());
85 }
86
87 QLineF& operator[](int i)
88 {
89 if(i >= std::ssize(positions))
90 {
91 positions.resize((i + 1) * 1.2);
92 }
93 return positions[i];
94 }
95
96 void updateShapes()
97 {
98 prepareGeometryChange();
99 update();
100 }
101};
102
103}
Definition Timebar.hpp:14
Definition Timebar.hpp:59
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13