Swiftray  1.0
text-shape.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QFont>
4 #include <shape/path-shape.h>
5 
6 class TextShape : public PathShape {
7 public:
8  TextShape() noexcept;
9 
10  TextShape(QString text, QFont font);
11 
12  void paint(QPainter *painter) const override;
13 
14  Shape::Type type() const override;
15 
16  shared_ptr<Shape> clone() const override;
17 
18  // Getters
19 
20  QString text();
21 
22  const QFont &font() const;
23 
24  float lineHeight() const;
25 
26  void makeCursorRect(int cursor);
27 
28  bool isEditing() const;
29 
30  // Setters
31 
32  void setEditing(bool editing);
33 
34  void setText(QString text);
35 
36  void setFont(const QFont &font);
37 
38  void setLineHeight(float line_height);
39 
40  friend class DocumentSerializer;
41 
42 private:
43  bool editing_;
44  float line_height_;
45  QStringList lines_;
46  QFont font_;
47  QRectF cursor_rect_;
48 
49  void makePath();
50 };
51 
52 typedef shared_ptr<TextShape *> TextShapePtr;
Save and load documents as binary format.
Definition: document-serializer.h:18
Definition: path-shape.h:7
Type
Definition: shape.h:19
Definition: text-shape.h:6
shared_ptr< Shape > clone() const override
Definition: text-shape.cpp:94
void paint(QPainter *painter) const override
Definition: text-shape.cpp:82
float lineHeight() const
Definition: text-shape.cpp:22
const QFont & font() const
Definition: text-shape.cpp:18
QString text()
Definition: text-shape.cpp:16
void setLineHeight(float line_height)
Definition: text-shape.cpp:24
Shape::Type type() const override
Definition: text-shape.cpp:14
void setFont(const QFont &font)
Definition: text-shape.cpp:36
void setText(QString text)
Definition: text-shape.cpp:29
bool isEditing() const
Definition: text-shape.cpp:20
void makeCursorRect(int cursor)
Definition: text-shape.cpp:53
void setEditing(bool editing)
Definition: text-shape.cpp:41
TextShape() noexcept
Definition: text-shape.cpp:5
shared_ptr< TextShape * > TextShapePtr
Definition: text-shape.h:52