Loading...
Searching...
No Matches
GraphicsStripDetailLayout.hpp
1#pragma once
2
3#include <score/graphics/layouts/GraphicsBoxLayout.hpp>
4
5#include <functional>
6#include <vector>
7
8class QMimeData;
9
10namespace score
11{
13class SCORE_LIB_BASE_EXPORT GraphicsStripCell : public GraphicsVBoxLayout
14{
15public:
16 explicit GraphicsStripCell(QGraphicsItem* parent);
18
19 void setTitle(const QString& title);
21 void setShownTitle(const QString& title);
22 void setSelected(bool selected);
23 std::function<void()> onClicked;
24
25 void setDropHandler(
26 std::function<bool(const QMimeData&)> accepts,
27 std::function<void(const QMimeData&)> drop);
28 bool acceptsDrop(const QMimeData& data) const;
29 void drop(const QMimeData& data);
30 void setDropHighlight(bool on);
31
32 void layout() override;
33 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
34 override;
35
36private:
37 qreal titleHeight() const;
38
39 QString m_title;
40 QString m_shownTitle;
41 QString m_elided;
42 QFont m_elidedFont;
43 qreal m_elidedWidth{-1.};
44 qreal m_elidedAscent{};
45 QGraphicsItem* m_hitArea{};
46 std::function<bool(const QMimeData&)> m_acceptsDrop;
47 std::function<void(const QMimeData&)> m_drop;
48 bool m_selected{};
49 bool m_dropHighlight{};
50};
51
54class SCORE_LIB_BASE_EXPORT GraphicsStripDetailLayout : public GraphicsLayout
55{
56public:
57 explicit GraphicsStripDetailLayout(QGraphicsItem* parent);
59
60 GraphicsLayout& strip();
61 void addCell(GraphicsStripCell* cell);
62
63 int currentIndex() const noexcept { return m_currentIndex; }
64 void setCurrentIndex(int index);
66 std::function<void(int)> onCurrentIndexChanged;
68 void setStripVisible(bool visible);
69
70 void layout() override;
71
72private:
73 QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
74 std::vector<QGraphicsItem*> pages() const;
75
76 GraphicsHBoxLayout* m_strip{};
77 std::vector<GraphicsStripCell*> m_cells;
78 int m_currentIndex{};
79 bool m_stripVisible{true};
80};
81}
Definition GraphicsBoxLayout.hpp:13
Definition GraphicsLayout.hpp:8
Summary of a page, selects it on click.
Definition GraphicsStripDetailLayout.hpp:14
Definition GraphicsStripDetailLayout.hpp:55
std::function< void(int)> onCurrentIndexChanged
On cell click.
Definition GraphicsStripDetailLayout.hpp:66
Definition GraphicsBoxLayout.hpp:22
Base toolkit upon which the software is built.
Definition Application.cpp:108