add support for Ayatana indicator to Notification plugin
[claws.git] / src / plugins / litehtml_viewer / litehtml / flex_item.h
bloba2b3426f15206d3b0e8be47fbd0880b9b2f7e646
1 #ifndef LITEHTML_FLEX_ITEM_H
2 #define LITEHTML_FLEX_ITEM_H
4 #include <functional>
5 #include "formatting_context.h"
7 namespace litehtml
9 class flex_line;
11 /**
12 * Base class for flex item
14 class flex_item
16 public:
17 std::shared_ptr<render_item> el;
18 int base_size;
19 int min_size;
20 def_value<int> max_size;
21 int main_size;
22 int grow;
23 int shrink;
24 int scaled_flex_shrink_factor;
25 bool frozen;
26 int order;
27 int src_order;
28 def_value<int> auto_margin_main_start;
29 def_value<int> auto_margin_main_end;
30 bool auto_margin_cross_start;
31 bool auto_margin_cross_end;
32 flex_align_items align;
34 explicit flex_item(std::shared_ptr<render_item> &_el) :
35 el(_el),
36 align(flex_align_items_auto),
37 grow(0),
38 base_size(0),
39 shrink(0),
40 min_size(0),
41 frozen(false),
42 main_size(0),
43 max_size(0),
44 order(0),
45 src_order(0),
46 scaled_flex_shrink_factor(0),
47 auto_margin_main_start(0),
48 auto_margin_main_end(0),
49 auto_margin_cross_start(false),
50 auto_margin_cross_end(false)
53 virtual ~flex_item() = default;
55 bool operator<(const flex_item& b) const
57 if(order < b.order) return true;
58 if(order == b.order) return src_order < b.src_order;
59 return false;
61 void init(const litehtml::containing_block_context &self_size,
62 litehtml::formatting_context *fmt_ctx, flex_align_items align_items);
63 virtual void apply_main_auto_margins() = 0;
64 virtual bool apply_cross_auto_margins(int cross_size) = 0;
65 virtual void set_main_position(int pos) = 0;
66 virtual void set_cross_position(int pos) = 0;
67 virtual int get_el_main_size() = 0;
68 virtual int get_el_cross_size() = 0;
70 void place(flex_line &ln, int main_pos,
71 const containing_block_context &self_size,
72 formatting_context *fmt_ctx);
73 int get_last_baseline(baseline::_baseline_type type) const;
74 int get_first_baseline(baseline::_baseline_type type) const;
76 protected:
77 virtual void direction_specific_init(const litehtml::containing_block_context &self_size,
78 litehtml::formatting_context *fmt_ctx) = 0;
79 virtual void align_stretch(flex_line &ln, const containing_block_context &self_size,
80 formatting_context *fmt_ctx) = 0;
81 virtual void align_baseline(flex_line &ln,
82 const containing_block_context &self_size,
83 formatting_context *fmt_ctx) = 0;
86 /**
87 * Flex item with "flex-direction: row" or " flex-direction: row-reverse"
89 class flex_item_row_direction : public flex_item
91 public:
92 explicit flex_item_row_direction(std::shared_ptr<render_item> &_el) : flex_item(_el) {}
94 void apply_main_auto_margins() override;
95 bool apply_cross_auto_margins(int cross_size) override;
96 void set_main_position(int pos) override;
97 void set_cross_position(int pos) override;
98 int get_el_main_size() override;
99 int get_el_cross_size() override;
101 protected:
102 void direction_specific_init(const litehtml::containing_block_context &self_size,
103 litehtml::formatting_context *fmt_ctx) override;
104 void align_stretch(flex_line &ln, const containing_block_context &self_size,
105 formatting_context *fmt_ctx) override;
106 void align_baseline(flex_line &ln,
107 const containing_block_context &self_size,
108 formatting_context *fmt_ctx) override;
112 * Flex item with "flex-direction: column" or " flex-direction: column-reverse"
114 class flex_item_column_direction : public flex_item
116 public:
117 explicit flex_item_column_direction(std::shared_ptr<render_item> &_el) : flex_item(_el) {}
119 void apply_main_auto_margins() override;
120 bool apply_cross_auto_margins(int cross_size) override;
121 void set_main_position(int pos) override;
122 void set_cross_position(int pos) override;
123 int get_el_main_size() override;
124 int get_el_cross_size() override;
126 protected:
127 void direction_specific_init(const litehtml::containing_block_context &self_size,
128 litehtml::formatting_context *fmt_ctx) override;
129 void align_stretch(flex_line &ln, const containing_block_context &self_size,
130 formatting_context *fmt_ctx) override;
131 void align_baseline(flex_line &ln,
132 const containing_block_context &self_size,
133 formatting_context *fmt_ctx) override;
137 #endif //LITEHTML_FLEX_ITEM_H