Loading...
Searching...
No Matches
QGraphicsPixmapEnum.hpp
1#pragma once
2#include <score/graphics/widgets/Constants.hpp>
3#include <score/graphics/widgets/QGraphicsEnum.hpp>
4#include <score/widgets/Pixmap.hpp>
5
6#include <QGraphicsItem>
7#include <QObject>
8
9#include <score_lib_base_export.h>
10
11#include <vector>
12#include <verdigris>
13
14namespace score
15{
16class SCORE_LIB_BASE_EXPORT QGraphicsPixmapEnum final : public QGraphicsEnum
17{
18 SCORE_GRAPHICS_ITEM_TYPE(140)
19public:
20 std::vector<QPixmap> on_images;
21 std::vector<QPixmap> off_images;
22
23 explicit QGraphicsPixmapEnum(QGraphicsItem* parent);
24
25 template <std::size_t N>
27 const std::array<const char*, N>& arr,
28 const std::array<const char*, 2 * N>& pixmaps, QGraphicsItem* parent)
29 : QGraphicsPixmapEnum{parent}
30 {
31 array.reserve(N);
32 for(auto str : arr)
33 array.push_back(str);
34
35 for(std::size_t i = 0; i < pixmaps.size(); i++)
36 {
37 if(i % 2)
38 off_images.emplace_back(score::get_pixmap(pixmaps[i]));
39 else
40 on_images.emplace_back(score::get_pixmap(pixmaps[i]));
41 }
42
43 setupDefaultColumns(N);
44 }
45
47 std::vector<QString> arr, const std::vector<QString>& pixmaps,
48 QGraphicsItem* parent)
49 : QGraphicsPixmapEnum{parent}
50 {
51 array = std::move(arr);
52
53 for(std::size_t i = 0; i < pixmaps.size(); i++)
54 {
55 if(i % 2)
56 off_images.emplace_back(score::get_pixmap(pixmaps[i]));
57 else
58 on_images.emplace_back(score::get_pixmap(pixmaps[i]));
59 }
60 setupDefaultColumns(array.size());
61 }
62
63 void updateRect();
64 void setupDefaultColumns(int N);
65
66 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
67 override;
68};
69}
Definition QGraphicsEnum.hpp:17
Definition QGraphicsPixmapEnum.hpp:17
Base toolkit upon which the software is built.
Definition Application.cpp:90