1#ifndef FASTUIDRAW_DEMO_PAINTERWIDGET_HPP
2#define FASTUIDRAW_DEMO_PAINTERWIDGET_HPP
3
4#include <list>
5#include <fastuidraw/util/reference_counted.hpp>
6#include <fastuidraw/util/vecN.hpp>
7#include <fastuidraw/util/matrix.hpp>
8#include <fastuidraw/util/util.hpp>
9#include <fastuidraw/painter/painter.hpp>
10
11class PainterWidget:fastuidraw::noncopyable
12{
13public:
14
15 explicit
16 PainterWidget(PainterWidget *parent = nullptr);
17
18 virtual
19 ~PainterWidget(void);
20
21 void
22 paint(const fastuidraw::reference_counted_ptr<fastuidraw::Painter> &painter);
23
24 PainterWidget*
25 parent(void)
26 {
27 return m_parent;
28 }
29
30 void
31 parent(PainterWidget *p);
32
33 /* returns true if an ancestor of q
34 is this
35 */
36 bool
37 is_ancestor_of(PainterWidget *q);
38
39 /* clip_in_rect for widget
40 */
41 fastuidraw::vec2 m_dimensions;
42
43 /* transformation from local coordinate to parent coordinates
44 */
45 fastuidraw::float3x3 m_parent_matrix_this;
46
47 /* if true, content is clipped to m_dimensions
48 */
49 bool m_clipped;
50
51 /* if true, draw the PainterWidget as transparent
52 */
53 bool m_draw_transparent;
54
55 /* if true, skip drawing both the widgets
56 and alls its descendants
57 */
58 bool m_skip_drawing;
59protected:
60
61 virtual
62 void
63 pre_paint(void) {}
64
65 virtual
66 void
67 paint_pre_children(const fastuidraw::reference_counted_ptr<fastuidraw::Painter> &painter);
68
69 virtual
70 void
71 paint_post_children(const fastuidraw::reference_counted_ptr<fastuidraw::Painter> &painter);
72
73private:
74 PainterWidget *m_parent;
75 std::list<PainterWidget*>::iterator m_iterator_loc;
76 std::list<PainterWidget*> m_children;
77};
78
79#endif
80