1#ifndef FASTUIDRAW_DEMO_TABLE_HPP
2#define FASTUIDRAW_DEMO_TABLE_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
9#include "ostream_utility.hpp"
10#include "PainterWidget.hpp"
11#include "cell_group.hpp"
12#include "simple_time.hpp"
13#include "PanZoomTracker.hpp"
14
15using namespace fastuidraw;
16
17typedef std::pair<reference_counted_ptr<const Image>, std::string> named_image;
18class CellSharedState;
19
20class TableParams
21{
22public:
23 vec2 m_wh;
24 ivec2 m_cell_count;
25 reference_counted_ptr<FontDatabase> m_font_database;
26 reference_counted_ptr<GlyphCache> m_glyph_cache;
27 reference_counted_ptr<const FontBase> m_font;
28 float m_pixel_size;
29 bool m_draw_image_name;
30 int m_max_cell_group_size;
31 int m_table_rotate_degrees_per_s;
32 bool m_timer_based_animation;
33
34 vec4 m_line_color;
35 std::vector<vec4> m_text_colors;
36 std::vector<vec4> m_background_colors;
37 std::vector<vec4> m_rect_colors;
38 std::vector<std::string> m_texts;
39 std::vector<named_image> m_images;
40 enum PainterImageBrushShader::filter_t m_image_filter;
41 enum PainterImageBrushShader::mipmap_t m_image_mipmapping;
42 vec2 m_min_speed, m_max_speed;
43 float m_min_degrees_per_s, m_max_degrees_per_s;
44 CellSharedState *m_cell_state;
45 const PanZoomTracker *m_zoomer;
46};
47
48class Table:public CellGroup
49{
50public:
51 explicit
52 Table(const TableParams &params);
53
54 ~Table() {}
55
56 bool m_rotating;
57
58protected:
59
60 virtual
61 void
62 paint_pre_children(const reference_counted_ptr<Painter> &painter);
63
64 virtual
65 void
66 paint_post_children(const reference_counted_ptr<Painter> &painter);
67
68 virtual
69 void
70 pre_paint(void);
71
72private:
73 void
74 generate_children_in_group(const reference_counted_ptr<Painter> &painter,
75 CellGroup *parent, int &J,
76 const ivec2 &xy,
77 int count_x, int count_y,
78 std::vector<PainterData::brush_value > &txt,
79 std::vector<PainterData::brush_value > &bg,
80 std::vector<PainterData::brush_value > &im);
81
82 TableParams m_params;
83 vec2 m_cell_sz;
84 bool m_first_draw;
85 PainterAttributeData m_lines;
86 PainterData::brush_value m_line_brush;
87 Path m_grid_path;
88
89 simple_time m_time;
90 int m_thousandths_degrees_rotation;
91 float m_rotation_radians;
92};
93
94#endif
95