aboutsummaryrefslogtreecommitdiffstats
path: root/include/litehtml/flex_line.h
diff options
context:
space:
mode:
authorYuri Kobets <[email protected]>2024-01-31 03:48:44 +0300
committerGitHub <[email protected]>2024-01-31 03:48:44 +0300
commit6ca1ab0419e770e6d35a1ef690238773a1dafcee (patch)
tree16df635edd594dc1d1b9d0044993e2ae4d0e0200 /include/litehtml/flex_line.h
parent8c320007878795fe629de7fe1eaef9328ac9c719 (diff)
parentd85ebec101e77825e5708e58df0e2508ec4fd389 (diff)
Merge pull request #285 from litehtml/flex_layoutHEADv0.9dev
Flex layout
Diffstat (limited to 'include/litehtml/flex_line.h')
-rw-r--r--include/litehtml/flex_line.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/litehtml/flex_line.h b/include/litehtml/flex_line.h
new file mode 100644
index 00000000..4803d238
--- /dev/null
+++ b/include/litehtml/flex_line.h
@@ -0,0 +1,56 @@
+#ifndef LITEHTML_FLEX_LINE_H
+#define LITEHTML_FLEX_LINE_H
+
+#include "formatting_context.h"
+
+namespace litehtml
+{
+ class flex_item;
+
+ class flex_line
+ {
+ public:
+ std::list<std::shared_ptr<flex_item>> items;
+ int cross_start; // for row direction: top. for column direction: left
+ int main_size; // sum of all items main size
+ int cross_size; // sum of all items cross size
+ int base_size;
+ int total_grow;
+ int total_shrink;
+ int num_auto_margin_main_start; // number of items with auto margin left/top
+ int num_auto_margin_main_end; // number of items with auto margin right/bottom
+ baseline first_baseline;
+ baseline last_baseline;
+ bool reverse_main;
+ bool reverse_cross;
+
+ flex_line(bool _reverse_main, bool _reverse_cross) :
+ cross_size(0),
+ cross_start(0),
+ total_grow(0),
+ base_size(0),
+ total_shrink(0),
+ main_size(0),
+ num_auto_margin_main_start(0),
+ num_auto_margin_main_end(0),
+ first_baseline(),
+ last_baseline(),
+ reverse_main(_reverse_main),
+ reverse_cross(_reverse_cross)
+ {}
+
+ void init(int container_main_size, bool fit_container, bool is_row_direction,
+ const litehtml::containing_block_context &self_size,
+ litehtml::formatting_context *fmt_ctx);
+ bool distribute_main_auto_margins(int free_main_size);
+ int calculate_items_position(int container_main_size,
+ flex_justify_content justify_content,
+ bool is_row_direction,
+ const containing_block_context &self_size,
+ formatting_context *fmt_ctx);
+ protected:
+ void distribute_free_space(int container_main_size);
+ };
+}
+
+#endif //LITEHTML_FLEX_LINE_H