36#include <fmt/format.h>
65static std::array<MdHeaderStyle, 6>
headers = {
70 .margin_bottom = 0.50f},
75 .margin_bottom = 0.50f},
80 .margin_bottom = 0.25f},
85 .margin_bottom = 0.25f},
90 .margin_bottom = 0.25f},
95 .margin_bottom = 0.25f},
109 .margin_bottom = 1.00f,
110 .item_spacing_loose = 0.50f,
111 .item_spacing_tight = 0.25f,
112 .nested_margin_top = 0.25f};
165 float default_line_height_px;
168 FontConfig main_font_;
169 FontConfig mono_font_;
177 float pending_spacing_ = 0.0f;
179 std::optional<float> flow_bottom_;
188 std::optional<LineBox> current_line_box_;
197 struct UnorderedListBlock {
198 bool is_tight =
false;
200 bool has_item =
false;
203 struct OrderedListBlock {
204 bool is_tight =
false;
206 bool has_item =
false;
208 char mark_delimiter =
'.';
211 struct ListItemBlock {
213 std::optional<int> number;
218 bool marker_pending =
true;
221 struct ParagraphBlock {};
228 float start_y = 0.0f;
230 float content_bottom =
FLT_MAX;
233 struct HorizontalRuleBlock {};
235 struct UnknownBlock {};
238 struct StrongSpan {};
245 bool padding_left_applied =
false;
247 struct UnknownSpan {};
249 using MdBlock = std::variant<DocBlock,
259 using MdSpan = std::variant<EmSpan, StrongSpan, LinkSpan, CodeSpan, UnknownSpan>;
277 const float default_size,
278 const int default_weight,
279 const int bold_weight)
282 config.fontid = fontid;
283 config.default_size = default_size;
284 config.default_weight = default_weight;
285 config.bold_weight = bold_weight;
286 markdown_apply_font(fontid, default_size * cache_.key.pixels_per_point, default_weight,
false);
293 MD_PARSER md_parser{};
294 md_parser.enter_block = [](MD_BLOCKTYPE block_type,
void *
detail,
void *userdata) {
298 md_parser.leave_block = [](MD_BLOCKTYPE block_type,
void *
detail,
void *userdata) {
302 md_parser.enter_span = [](MD_SPANTYPE span_type,
void *
detail,
void *userdata) {
306 md_parser.leave_span = [](MD_SPANTYPE span_type,
void *
detail,
void *userdata) {
310 md_parser.text = [](MD_TEXTTYPE text_type,
const char *text,
uint32_t length,
void *userdata) {
316 md_parse(text.data(), text.size(), &md_parser,
this);
322 pending_spacing_ = std::max(pending_spacing_, this->
spacing_px(spacing));
327 if (!current_line_box_) {
330 flow_bottom_ = current_line_box_->top - current_line_box_->height;
331 current_line_box_.reset();
336 if (current_line_box_) {
340 const float top = flow_bottom_.value_or(0.0f) - pending_spacing_;
341 flow_bottom_ = top - main_font_.default_line_height_px;
342 pending_spacing_ = 0.0f;
347 switch (block_type) {
348 case MD_BLOCK_QUOTE: {
349 block_stack_.append(QuoteBlock{});
353 const auto *ul_detail =
static_cast<const MD_BLOCK_UL_DETAIL *
>(
detail);
354 block_stack_.append(UnorderedListBlock{bool(ul_detail->is_tight)});
358 const auto *ol_detail =
static_cast<const MD_BLOCK_OL_DETAIL *
>(
detail);
359 block_stack_.append(OrderedListBlock{bool(ol_detail->is_tight),
361 int(ol_detail->start),
362 char(ol_detail->mark_delimiter)});
366 ListItemBlock list_item;
367 if (!block_stack_.is_empty()) {
368 if (
auto *ol = std::get_if<OrderedListBlock>(&block_stack_.last())) {
369 list_item.number = ol->next_number++;
376 else if (
auto *ul = std::get_if<UnorderedListBlock>(&block_stack_.last())) {
384 block_stack_.append(list_item);
388 const auto *h_detail =
static_cast<const MD_BLOCK_H_DETAIL *
>(
detail);
389 block_stack_.append(HeaderBlock{std::clamp<int>(h_detail->level, 1, 6)});
392 case MD_BLOCK_CODE: {
393 CodeBlock code_block;
395 block_stack_.append(code_block);
399 block_stack_.append(ParagraphBlock{});
403 block_stack_.append(DocBlock{});
407 block_stack_.append(HorizontalRuleBlock{});
418 block_stack_.append(UnknownBlock{});
423 if (!std::holds_alternative<DocBlock>(block_stack_.last())) {
430 if (std::holds_alternative<CodeBlock>(block_stack_.last())) {
438 switch (block_type) {
443 case MD_BLOCK_QUOTE: {
444 std::get<QuoteBlock>(block_stack_.last()).start_y = flow_bottom_.value_or(0.0f) -
481 for (
const int i : span_stack_.index_range()) {
482 MdSpan &md_span = span_stack_[span_stack_.size() - 1 - i];
483 if (
auto *code_span = std::get_if<CodeSpan>(&md_span)) {
492 float indentation = 0.0f;
494 for (
const auto &md_block : block_stack_) {
495 if (std::holds_alternative<QuoteBlock>(md_block)) {
496 indentation += indent;
498 if (std::holds_alternative<ListItemBlock>(md_block)) {
499 indentation += indent;
516 float x =
float(cache_.key.wrap_width_px);
537 for (
const int64_t list_item_index : block_stack_.index_range()) {
538 auto *list_item = std::get_if<ListItemBlock>(&block_stack_[list_item_index]);
539 if (!list_item || !list_item->marker_pending) {
542 list_item->marker_pending =
false;
545 item.
size_px = main_font_.default_size * cache_.key.pixels_per_point;
546 item.
fontid = main_font_.fontid;
547 item.
weight = main_font_.default_weight;
552 int unordered_list_level = -1;
553 char ordered_delimiter =
'.';
554 float content_x = 0.0f;
556 const MdBlock &ancestor = block_stack_[ancestor_index];
557 if (std::holds_alternative<QuoteBlock>(ancestor) ||
558 std::holds_alternative<ListItemBlock>(ancestor))
562 if (std::holds_alternative<UnorderedListBlock>(ancestor)) {
563 unordered_list_level++;
565 if (
const auto *ordered_list = std::get_if<OrderedListBlock>(&ancestor)) {
566 ordered_delimiter = ordered_list->mark_delimiter;
570 if (list_item->number) {
571 item.
text = cache_.scope.allocator().copy_string(
572 fmt::format(
"{}{}", *list_item->number, ordered_delimiter));
582 if (list_item->number) {
584 item.
x = content_x - marker_width -
589 item.
x = content_x - this->
list_indent_px() * 0.5f - marker_width * 0.5f;
591 cache_.md_layout.items.append(item);
599 const float rule_top = flow_bottom_.value_or(0.0f) - pending_spacing_ -
padding;
600 constexpr float rule_height = 1.0f;
602 flow_bottom_ = rule_top - rule_height -
padding;
603 pending_spacing_ = 0.0f;
617 for (MdBlock &md_block : block_stack_) {
618 if (
auto *quote = std::get_if<QuoteBlock>(&md_block)) {
619 quote->content_top = std::max(quote->content_top, top);
620 quote->content_bottom = std::min(quote->content_bottom, bottom);
633 const rctf part{.xmin = item.
x, .xmax = right, .ymin = bottom, .ymax = top};
636 for (MdBlock &md_block : block_stack_) {
637 if (
auto *code_block = std::get_if<CodeBlock>(&md_block)) {
653 if (!code_span || code_span->padding_left_applied) {
657 code_span->padding_left_applied =
true;
666 code_span->line_bounds.append(code_span->current_bounds);
675 for (
const rctf &
bounds : code_span.line_bounds) {
686 cache_.md_layout.items.append(box);
698 flow_bottom_ = box_bottom;
701 flow_bottom_ = std::min(*flow_bottom_, box_bottom);
706 const auto *code_block = std::get_if<CodeBlock>(&block_stack_.last());
717 box.
rect.
ymax = code_block->bounds.ymax + padding_y;
718 box.
rect.
ymin = code_block->bounds.ymin - padding_y;
719 cache_.md_layout.items.append(box);
724 const auto *quote = std::get_if<QuoteBlock>(&block_stack_.last());
732 if (quote->content_top != -
FLT_MAX) {
734 top = quote->content_top +
padding;
735 bottom = quote->content_bottom -
padding;
738 top = quote->start_y;
742 const float height = top - bottom;
743 if (height <= 0.0f) {
750 cache_.md_layout.items.append(line);
755 for (
const auto &md_block : block_stack_) {
756 if (std::holds_alternative<QuoteBlock>(md_block)) {
765 for (
const MdBlock &md_block : block_stack_) {
766 if (std::holds_alternative<CodeBlock>(md_block)) {
775 for (
const MdSpan &md_span : span_stack_) {
776 if (std::holds_alternative<CodeSpan>(md_span)) {
790 return std::holds_alternative<UnorderedListBlock>(block) ||
791 std::holds_alternative<OrderedListBlock>(block);
796 if (block_stack_.size() < 2) {
799 return std::holds_alternative<ListItemBlock>(block_stack_[block_stack_.size() - 2]);
804 return main_font_.default_line_height_px * multiplier;
809 if (
const auto *header = std::get_if<HeaderBlock>(&block)) {
812 if (std::holds_alternative<ParagraphBlock>(block)) {
815 if (std::holds_alternative<QuoteBlock>(block)) {
818 if (std::holds_alternative<CodeBlock>(block)) {
821 if (std::holds_alternative<HorizontalRuleBlock>(block)) {
824 if (std::holds_alternative<UnorderedListBlock>(block) ||
825 std::holds_alternative<OrderedListBlock>(block))
834 if (
const auto *header = std::get_if<HeaderBlock>(&block)) {
837 if (std::holds_alternative<ParagraphBlock>(block)) {
840 if (std::holds_alternative<QuoteBlock>(block)) {
843 if (std::holds_alternative<CodeBlock>(block)) {
846 if (std::holds_alternative<HorizontalRuleBlock>(block)) {
849 if (std::holds_alternative<UnorderedListBlock>(block) ||
850 std::holds_alternative<OrderedListBlock>(block))
859 const MdBlock &md_block = block_stack_.last();
860 if (
const auto *list_item = std::get_if<ListItemBlock>(&md_block);
861 list_item && list_item->marker_pending)
864 main_font_.default_size * cache_.key.pixels_per_point,
865 main_font_.default_weight,
869 if (std::holds_alternative<HeaderBlock>(md_block) ||
870 std::holds_alternative<ListItemBlock>(md_block) ||
871 std::holds_alternative<ParagraphBlock>(md_block) ||
872 std::holds_alternative<CodeBlock>(md_block))
876 switch (block_type) {
877 case MD_BLOCK_QUOTE: {
878 BLI_assert(std::holds_alternative<QuoteBlock>(md_block));
883 BLI_assert(std::holds_alternative<UnorderedListBlock>(md_block));
887 BLI_assert(std::holds_alternative<OrderedListBlock>(md_block));
891 BLI_assert(std::holds_alternative<ListItemBlock>(md_block));
895 BLI_assert(std::holds_alternative<HeaderBlock>(md_block));
898 case MD_BLOCK_CODE: {
899 BLI_assert(std::holds_alternative<CodeBlock>(md_block));
905 BLI_assert(std::holds_alternative<ParagraphBlock>(md_block));
909 BLI_assert(std::holds_alternative<DocBlock>(md_block));
913 BLI_assert(std::holds_alternative<HorizontalRuleBlock>(md_block));
923 BLI_assert(std::holds_alternative<UnknownBlock>(md_block));
928 block_stack_.pop_last();
935 span_stack_.append(EmSpan{});
938 case MD_SPAN_STRONG: {
939 span_stack_.append(StrongSpan{});
943 const auto *a_detail =
static_cast<const MD_SPAN_A_DETAIL *
>(
detail);
944 span_stack_.append(LinkSpan{cache_.scope.allocator().copy_string(
945 StringRef(a_detail->href.text, a_detail->href.size))});
951 span_stack_.append(code_span);
956 case MD_SPAN_LATEXMATH:
957 case MD_SPAN_LATEXMATH_DISPLAY:
958 case MD_SPAN_WIKILINK:
961 span_stack_.append(UnknownSpan{});
969 const MdSpan &md_span = span_stack_.last();
972 BLI_assert(std::holds_alternative<EmSpan>(md_span));
975 case MD_SPAN_STRONG: {
976 BLI_assert(std::holds_alternative<StrongSpan>(md_span));
980 BLI_assert(std::holds_alternative<LinkSpan>(md_span));
984 BLI_assert(std::holds_alternative<CodeSpan>(md_span));
992 case MD_SPAN_LATEXMATH:
993 case MD_SPAN_LATEXMATH_DISPLAY:
994 case MD_SPAN_WIKILINK:
996 BLI_assert(std::holds_alternative<UnknownSpan>(md_span));
1000 span_stack_.pop_last();
1005 switch (text_type) {
1006 case MD_TEXT_NORMAL: {
1010 case MD_TEXT_CODE: {
1015 case MD_TEXT_SOFTBR: {
1020 case MD_TEXT_NULLCHAR:
1021 case MD_TEXT_ENTITY:
1023 case MD_TEXT_LATEXMATH: {
1048 settings.
size * cache_.key.pixels_per_point,
1053 if (text[0] ==
'\n') {
1092 const float line_height =
BLF_height_max(fontid) + 2.0f * padding_y;
1093 if (current_line_box_) {
1094 current_line_box_->height = std::max(current_line_box_->height, line_height);
1098 current_line_box_ = LineBox{flow_bottom_.value_or(0.0f) - pending_spacing_, line_height};
1099 y_ = current_line_box_->top -
BLF_ascender(fontid) - padding_y;
1100 pending_spacing_ = 0.0f;
1108 settings.
fontid = main_font_.fontid;
1109 settings.
weight = main_font_.default_weight;
1110 settings.
size = main_font_.default_size;
1114 settings.
fontid = mono_font_.fontid;
1115 settings.
size = mono_font_.default_size;
1116 settings.
weight = mono_font_.default_weight;
1121 for (
const auto &md_block : block_stack_) {
1122 if (
const auto *header_block = std::get_if<HeaderBlock>(&md_block)) {
1124 settings.
fontid = main_font_.fontid;
1130 for (
const auto &md_span : span_stack_) {
1131 if (std::holds_alternative<CodeSpan>(md_span)) {
1132 settings.
fontid = mono_font_.fontid;
1133 settings.
weight = mono_font_.default_weight;
1136 if (std::holds_alternative<StrongSpan>(md_span)) {
1137 settings.
weight = main_font_.bold_weight;
1139 if (std::holds_alternative<EmSpan>(md_span)) {
1142 if (
const auto *link_span = std::get_if<LinkSpan>(&md_span)) {
1143 settings.
url = link_span->url;
1154 const std::optional<StringRef> &url,
1155 const float start_x)
1158 item_template.
size_px = size * cache_.key.pixels_per_point;
1159 item_template.
fontid = fontid;
1160 item_template.
weight = weight;
1161 item_template.
italic = italic;
1168 item_template.
url = url;
1181 float needed_width = 0.0f;
1183 fontid, text.
data(),
size_t(text.
size()), remaining_width, &needed_width));
1186 int64_t draw_bytes = last_fit_char_i;
1188 int64_t drop_bytes = last_fit_char_i;
1189 const bool wrap_to_next_line = last_fit_char_i < text.
size();
1191 if (wrap_to_next_line) {
1192 const int64_t last_space = (last_fit_char_i > 0) ?
1196 draw_bytes = last_space;
1198 drop_bytes = last_space + 1;
1201 else if (x_ > start_x) {
1208 else if (last_fit_char_i == 0) {
1211 drop_bytes = draw_bytes;
1219 if (draw_bytes > 0) {
1220 item_template.
text = fitting_text;
1221 item_template.
x = x_;
1222 item_template.
y = y_;
1223 cache_.md_layout.items.append(item_template);
1227 if (wrap_to_next_line) {
1243 if (!flow_bottom_) {
1244 cache_.md_layout.content_height = main_font_.default_line_height_px;
1248 float bottom_y = *flow_bottom_;
1249 for (
const MarkdownItem &item : cache_.md_layout.items) {
1250 if (
const auto *quote_line = std::get_if<MarkdownItemQuoteLine>(&item)) {
1251 bottom_y = std::min(bottom_y, quote_line->y - quote_line->height);
1253 if (
const auto *code_box = std::get_if<MarkdownItemCodeBox>(&item)) {
1254 bottom_y = std::min(bottom_y, code_box->rect.ymin);
1257 cache_.md_layout.content_height = -bottom_y;
1272 const float aspect = block->
aspect;
1279 const auto *text_item_ptr = std::get_if<MarkdownItemText>(&item);
1280 if (!text_item_ptr || !text_item_ptr->url) {
1290 const float font_height = (ascender_px - descender_px) * aspect;
1293 const float x = button->
rect.
xmin + text_item.
x * aspect;
1294 const float y = button->
rect.
ymax + (text_item.
y + descender_px) * aspect;
1311 static_cast<ButtonPush *
>(but)->draw_as_link =
true;
1372 if (cache.
key != cache_lookup_key) {
1379 for (std::shared_ptr<MarkdownLayoutCache> &cache_ptr :
1383 if (cache.
key == cache_lookup_key) {
1400 button->
markdown_cache = std::make_shared<MarkdownLayoutCache>();
1402 cache.
key = cache_lookup_key;
1437 constexpr float quote_dimmed_blend = 0.3f;
1438 constexpr float code_span_fill_blend = 0.20f;
1461 back_color, code_box_fill_color, code_span_fill_blend, 0, code_span_fill_color);
1462 code_span_fill_color.
a = 255;
1488 const auto *code_box = std::get_if<MarkdownItemCodeBox>(&item);
1493 rctf box_rect = code_box->rect;
1511 &box_rect, colors.
code_span_fill,
nullptr, 1.0f,
nullptr, 0.0f, corner_radius);
1516 if (
const auto *text_item = std::get_if<MarkdownItemText>(&item)) {
1518 if (text_item->url) {
1519 if (text_item->is_in_quote) {
1530 if (text_item->is_in_quote) {
1543 const float x = rect->
xmin + text_item->x;
1544 const float y = rect->
ymax + text_item->y;
1546 BLF_draw(text_item->fontid, text_item->text.data(), text_item->text.size());
1549 else if (
const auto *rule_item = std::get_if<MarkdownItemHorizontalRule>(&item)) {
1550 const float y = rect->
ymax + rule_item->y;
1565 else if (
const auto *quote_line = std::get_if<MarkdownItemQuoteLine>(&item)) {
1566 const float x = rect->
xmin + quote_line->x;
1567 const float y_top = rect->
ymax + quote_line->y;
1568 const float y_bottom = y_top - quote_line->height;
1594 fmt::memory_buffer buf;
1595 fmt::appender dst{buf};
1597 fmt::format_to(dst,
"namespace md_style {{\n\n");
1598 fmt::format_to(dst,
"static std::array<MdHeaderStyle, 6> headers = {{\n");
1602 " MdHeaderStyle{{.size_factor = {:.2f}f, .weight = {}, .italic = {}, "
1603 ".margin_top = {:.2f}f, .margin_bottom = {:.2f}f}},\n",
1606 style.
italic ?
"true" :
"false",
1610 fmt::format_to(dst,
"}};\n\n");
1612 auto append_block_spacing = [&](
const char *name,
const MdBlockSpacing &spacing) {
1615 "static MdBlockSpacing {} = {{.margin_top = {:.2f}f, .margin_bottom = {:.2f}f}};\n",
1618 spacing.margin_bottom);
1633 fmt::format_to(dst,
"\n");
1635 auto append_list_spacing = [&](
const char *name,
const MdListSpacing &spacing) {
1637 "static MdListSpacing {} = {{.margin_top = {:.2f}f, .margin_bottom = {:.2f}f, "
1638 ".item_spacing_loose = {:.2f}f, .item_spacing_tight = {:.2f}f, "
1639 ".nested_margin_top = {:.2f}f}};\n",
1642 spacing.margin_bottom,
1643 spacing.item_spacing_loose,
1644 spacing.item_spacing_tight,
1645 spacing.nested_margin_top);
1648 fmt::format_to(dst,
"\n");
1655 fmt::format_to(dst,
"\n}};\n");
1656 return fmt::to_string(buf);
1692 block,
ButtonType::Label, label, 0, 0, width,
UI_UNIT_Y,
nullptr, 0.0f, 0.0f, std::nullopt);
1701 const int precision,
1727 const int precision,
1754 block,
ButtonType::Checkbox,
"", 0, 0,
UI_UNIT_X,
UI_UNIT_Y, value, 0, 0, tip);
1780 const std::string h_label = fmt::format(
"H{}", level + 1);
1789 IFACE_(
"Size factor relative to body text"));
1791 block, col_weight, &style.
weight, 100, 900, 100, -1,
IFACE_(
"Font weight"));
1800 IFACE_(
"Top margin as a multiple of the default line height"));
1809 IFACE_(
"Bottom margin as a multiple of the default line height"));
1828 struct BlockMarginRow {
1831 float &margin_bottom;
1834 const BlockMarginRow rows[] = {
1838 {
IFACE_(
"Horizontal Rule"),
1844 for (
const BlockMarginRow &row : rows) {
1853 IFACE_(
"Top margin as a multiple of the default line height"));
1862 IFACE_(
"Bottom margin as a multiple of the default line height"));
1891 IFACE_(
"Spacing between items in loose lists"));
1899 IFACE_(
"Spacing between items in tight lists"));
1907 IFACE_(
"Margin above the first item in a nested list"));
1950 IFACE_(
"Vertical padding around quote text for the quote bar")},
1957 IFACE_(
"Additional vertical padding around the horizontal rule line")},
1964 IFACE_(
"Horizontal indent per list level in pixels at 1x scale")},
1971 IFACE_(
"Padding between ordered list markers and item text in pixels at 1x scale")},
1981 IFACE_(
"Horizontal padding around fenced code blocks in pixels at 1x scale")},
1988 IFACE_(
"Vertical padding around fenced code blocks in pixels at 1x scale")},
1998 IFACE_(
"Horizontal padding around inline code spans in pixels at 1x scale")},
2005 IFACE_(
"Vertical padding around inline code spans in pixels at 1x scale")},
2009 block, panel_col,
Span(general_columns, std::size(general_columns)));
2011 block, panel_col,
Span(code_block_columns, std::size(code_block_columns)));
2013 block, panel_col,
Span(code_span_columns, std::size(code_span_columns)));
2031 if (
Layout *panel = layout.
panel(
C,
"md_style_block_margins",
false,
IFACE_(
"Block Margins"))) {
2035 if (
Layout *panel = layout.
panel(
C,
"md_style_list_spacing",
false,
IFACE_(
"List Spacing"))) {
2048 IFACE_(
"Copy Style to Clipboard"),
2056 IFACE_(
"Copy md_style namespace source to the clipboard"));
#define BLI_SCOPED_DEFER(function_to_defer)
constexpr IndexRange()=default
StringRefNull copy_string(StringRef str)
LinearAllocator & allocator()
constexpr StringRef drop_prefix(int64_t n) const
constexpr int64_t find_first_of(StringRef chars, int64_t pos=0) const
static constexpr int64_t not_found
constexpr bool is_empty() const
constexpr int64_t size() const
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr const char * data() const
constexpr int64_t find_last_of(StringRef chars, int64_t pos=INT64_MAX) const
void append(const T &value)
void md_text_normal(const StringRef text)
void append_horizontal_rule()
float context_content_end_x() const
void apply_code_span_left_padding()
CodeSpan * mutable_current_code_span()
float context_content_start_x() const
float spacing_px(const float multiplier) const
bool has_code_span() const
void append_code_block_box()
void md_leave_span(const MD_SPANTYPE span_type, void *)
bool is_in_fenced_code_block() const
void track_code_text_bounds(const MarkdownItemText &item)
void finalize_vertical_positions()
ContextFontSettings get_context_font_settings() const
void append_pending_list_marker()
void append_code_span_boxes(const CodeSpan &code_span)
float list_indent_px() const
float code_block_padding_x_px() const
float context_block_start_x() const
void md_enter_block(const MD_BLOCKTYPE block_type, void *detail)
bool is_direct_child_of_list_item() const
void add_pending_spacing(const float spacing)
float code_span_padding_x_px() const
void md_leave_block(const MD_BLOCKTYPE block_type, void *)
void md_text(const MD_TEXTTYPE text_type, const StringRef text)
MarkdownLayouter(MarkdownLayoutCache &cache_)
static bool is_list_container_block(const MdBlock &block)
static StringRef unordered_bullet_for_level(const int level)
float code_span_padding_y_px() const
void finalize_code_span_line_bounds()
void md_text_code(StringRef text)
FontConfig make_font_config(const int fontid, const float default_size, const int default_weight, const int bold_weight)
float block_margin_top(const MdBlock &block) const
void ensure_line_box(const int fontid)
void track_quote_text_bounds(const MarkdownItemText &item)
void md_enter_span(const MD_SPANTYPE span_type, void *detail)
void output_wrapped_text(StringRef text, const float size, const int fontid, const int weight, const bool italic, const std::optional< StringRef > &url, const float start_x)
void extend_flow_bottom_for_code_block(const CodeBlock &code_block)
float code_block_padding_y_px() const
float block_margin_bottom(const MdBlock &block) const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float length(VecOp< float, D >) RET
BLI_INLINE ColorTheme4f to_float(const ColorTheme4b &theme4b)
static std::array< MdHeaderStyle, 6 > headers
static MdBlockSpacing paragraph
static float code_block_padding_y
static MdListSpacing list
static MdBlockSpacing code_block
static float horizontal_rule_padding
static MdBlockSpacing quote
static float list_marker_padding_px
static float code_block_padding_x
static float code_span_padding_x
static float quote_bar_padding
static float list_indent_px
static float code_span_padding_y
static MdBlockSpacing horizontal_rule
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_blend_shade_3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
const bTheme * theme_get()
void get_color_3ubv(int colorid, unsigned char col[3])
static void markdown_disable_item_font(const MarkdownItemText &item)
static void label_markdown_dev_config_col_label(Block *block, Layout &col, const StringRef label, const short width)
void label_markdown_create_link_buttons(Block *block)
static void label_markdown_dev_config_int(Block *block, Layout &col, int *value, const float min, const float max, const float step, const int precision, const StringRef tip)
static short md_dev_config_num_width()
void button_func_set(Button *but, std::function< void(bContext &)> func)
static void label_markdown_dev_config_block_margins_table(Block *block, Layout &panel_col)
bool button_label_is_markdown(const Button *button)
const uiStyle * style_get()
void label_markdown_dev_config(Layout &layout)
static void label_markdown_dev_config_checkbox(Block *block, Layout &col, bool *value, const StringRef tip)
void label_markdown_resolve(ButtonLabel *button)
static MarkdownDrawColors markdown_draw_colors_init(const uchar color[4])
static short md_dev_config_name_col_width()
static short md_dev_config_detail_label_width()
void button_number_step_size_set(Button *but, float step_size)
static void label_markdown_dev_config_details_table(Block *block, Layout &panel_col)
void button_func_tooltip_custom_set(Button *but, ButtonToolTipCustomFunc func, void *arg, FreeArgFunc free_arg)
EmbossType block_emboss_get(Block *block)
static MarkdownLayoutCacheKey markdown_layout_key_for_button(const ButtonLabel &button)
void button_number_precision_set(Button *but, float precision)
static void markdown_apply_font(const int fontid, const float size_px, const int weight, const bool italic)
static int markdown_layout_generation
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
void draw_roundbox_corner_set(int type)
static short md_dev_config_h_col_width()
std::variant< MarkdownItemText, MarkdownItemHorizontalRule, MarkdownItemQuoteLine, MarkdownItemCodeBox > MarkdownItem
void tooltip_text_field_add(TooltipData &data, std::string text, std::string suffix, const TooltipStyle style, const TooltipColorID color_id, const bool is_pad=false)
void block_emboss_set(Block *block, EmbossType emboss)
void label_markdown_draw(const ButtonLabel *button, const uchar color[4], const rcti *rect)
void draw_roundbox_4fv_ex(const rctf *rect, const float inner1[4], const float inner2[4], float shade_dir, const float outline[4], float outline_width, float rad)
static void label_markdown_copy_style_to_clipboard(bContext &)
static std::string markdown_md_style_to_source()
void button_operator_set(Button *but, wmOperatorType *optype, wm::OpCallContext opcontext, const PointerRNA *opptr=nullptr)
Button * uiDefIconBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, int icon, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
static void markdown_apply_item_font(const MarkdownItemText &item)
static void markdown_apply_button_height(ButtonLabel &button)
static void create_link_buttons_for_label(ButtonLabel *button)
static void label_markdown_dev_config_update(bContext &)
Button * uiDefButV(Block *block, ButtonType type, StringRef str, int x, int y, short width, short height, T *poin, float min, float max, std::optional< StringRef > tip)
static void label_markdown_dev_config_list_spacing_table(Block *block, Layout &panel_col)
void block_layout_set_current(Block *block, Layout *layout)
static void label_markdown_dev_config_headers_table(Block *block, Layout &panel_col)
static void label_markdown_dev_config_details_row(Block *block, Layout &panel_col, const Span< MarkdownDevConfigDetailColumn > columns)
static void label_markdown_dev_config_num(Block *block, Layout &col, float *value, const float min, const float max, const float step, const int precision, const StringRef tip)
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ColorTheme4< uint8_t > ColorTheme4b
uint padding(uint offset, uint alignment)
void BLF_position(int fontid, float x, float y, float z)
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
size_t BLF_width_to_strlen(int fontid, const char *str, size_t str_len, float width, float *r_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
GPUVertFormat * immVertexFormat()
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void immBegin(GPUPrimType, uint vertex_len)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
void BLF_character_weight(int fontid, int weight)
void BLF_disable(int fontid, FontFlags flag)
void GPU_line_width(float width)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void BLF_size(int fontid, float size)
bool BLI_rctf_is_empty(const struct rctf *rect)
void immVertex2f(uint attr_id, float x, float y)
BMesh const char void * data
@ GPU_SHADER_3D_UNIFORM_COLOR
void BLI_rctf_init_minmax(struct rctf *rect)
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
int BLF_ascender(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void WM_clipboard_text_set(const char *buf, bool selection)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
ColorTheme4< float > ColorTheme4f
void GPU_blend(GPUBlend blend)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void immUniformColor4ubv(const unsigned char rgba[4])
void BLF_enable(int fontid, FontFlags flag)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
Vector< std::shared_ptr< MarkdownLayoutCache > > markdown_layout_cache
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
void alignment_set(LayoutAlign alignment)
void use_property_split_set(bool is_sep)
void label(StringRef name, int icon)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
ColorTheme4b horizontal_rule
ColorTheme4b quote_dimmed_link
ColorTheme4b code_box_text
ColorTheme4f code_box_fill
ColorTheme4b code_span_text
ColorTheme4f code_span_fill
ColorTheme4f code_box_border
ColorTheme4b quote_dimmed
ColorTheme4b code_span_link
std::optional< StringRef > url
int markdown_layout_generation
MarkdownLayoutCacheKey key
Vector< MarkdownItem > items
std::optional< StringRef > url