1 | #ifndef FASTUIDRAW_DEMO_CELL_HPP |
---|---|
2 | #define FASTUIDRAW_DEMO_CELL_HPP |
3 | |
4 | #include <fastuidraw/text/font_database.hpp> |
5 | #include <fastuidraw/text/glyph_cache.hpp> |
6 | #include <fastuidraw/text/font.hpp> |
7 | #include <fastuidraw/painter/painter.hpp> |
8 | #include <fastuidraw/util/util.hpp> |
9 | |
10 | #include "ostream_utility.hpp" |
11 | #include "PainterWidget.hpp" |
12 | #include "simple_time.hpp" |
13 | |
14 | using namespace fastuidraw; |
15 | |
16 | class CellSharedState:noncopyable |
17 | { |
18 | public: |
19 | CellSharedState(void): |
20 | m_draw_text(true), |
21 | m_draw_image(true), |
22 | m_rotating(false), |
23 | m_stroke_width(10.0f), |
24 | m_pause(false), |
25 | m_anti_alias_stroking(true), |
26 | m_cells_drawn(0), |
27 | m_draw_transparent(false), |
28 | m_rect_blend_mode(Painter::blend_porter_duff_src_over) |
29 | {} |
30 | |
31 | bool m_draw_text; |
32 | bool m_draw_image; |
33 | bool m_rotating; |
34 | Path m_path; |
35 | float m_stroke_width; |
36 | bool m_pause; |
37 | bool m_draw_transparent; |
38 | bool m_anti_alias_stroking; |
39 | |
40 | int m_cells_drawn; |
41 | enum Painter::blend_mode_t m_rect_blend_mode; |
42 | enum glyph_type m_glyph_render; |
43 | }; |
44 | |
45 | class CellParams |
46 | { |
47 | public: |
48 | reference_counted_ptr<FontDatabase> m_font_database; |
49 | reference_counted_ptr<GlyphCache> m_glyph_cache; |
50 | reference_counted_ptr<const FontBase> m_font; |
51 | PainterData::brush_value m_background_brush; |
52 | PainterData::brush_value m_image_brush; |
53 | PainterData::brush_value m_text_brush; |
54 | PainterData::brush_value m_line_brush; |
55 | const Image *m_image; |
56 | ivec2 m_rect_dims; |
57 | std::string m_text; |
58 | std::string m_image_name; |
59 | vec2 m_pixels_per_ms; |
60 | int m_degrees_per_s; |
61 | float m_pixel_size; |
62 | vec2 m_size; |
63 | ivec2 m_table_pos; |
64 | bool m_timer_based_animation; |
65 | CellSharedState *m_state; |
66 | }; |
67 | |
68 | class Cell:public PainterWidget |
69 | { |
70 | public: |
71 | Cell(PainterWidget *p, const CellParams ¶ms); |
72 | ~Cell() {} |
73 | |
74 | protected: |
75 | |
76 | virtual |
77 | void |
78 | paint_pre_children(const reference_counted_ptr<Painter> &painter); |
79 | |
80 | virtual |
81 | void |
82 | pre_paint(void); |
83 | |
84 | private: |
85 | |
86 | bool m_first_frame; |
87 | simple_time m_time; |
88 | int m_thousandths_degrees_rotation; |
89 | int m_thousandths_degrees_cell_rotation; |
90 | |
91 | vec2 m_table_pos; |
92 | vec2 m_rect_dims; |
93 | |
94 | vec2 m_pixels_per_ms; |
95 | int m_degrees_per_s; |
96 | |
97 | PainterData::brush_value m_background_brush; |
98 | PainterData::brush_value m_image_brush; |
99 | PainterData::brush_value m_text_brush; |
100 | PainterData::brush_value m_line_brush; |
101 | |
102 | vec2 m_item_location; |
103 | float m_item_rotation; |
104 | GlyphSequence m_text; |
105 | CellSharedState *m_shared_state; |
106 | bool m_timer_based_animation; |
107 | }; |
108 | |
109 | #endif |
110 |