Refactor: Remove BLF _ex functions using default arguments
Remove all BLF "_ex" versions of functions by using default arguments. These functions only differ by having an optional argument that can return extra details about the result of the operation. This PR just make these part of the main function as optional arguments with default values - all nullptr. Pull Request: https://projects.blender.org/blender/blender/pulls/119994
This commit is contained in:
parent
b28861682e
commit
27c95da888
|
@ -144,8 +144,8 @@ void BLF_batch_draw_end();
|
|||
/**
|
||||
* Draw the string using the current font.
|
||||
*/
|
||||
void BLF_draw_ex(int fontid, const char *str, size_t str_len, ResultBLF *r_info) ATTR_NONNULL(2);
|
||||
void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2);
|
||||
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info = nullptr)
|
||||
ATTR_NONNULL(2);
|
||||
int BLF_draw_mono(int fontid, const char *str, size_t str_len, int cwidth, int tab_columns)
|
||||
ATTR_NONNULL(2);
|
||||
|
||||
|
@ -205,23 +205,21 @@ size_t BLF_width_to_rstrlen(int fontid,
|
|||
* This function return the bounding box of the string
|
||||
* and are not multiplied by the aspect.
|
||||
*/
|
||||
void BLF_boundbox_ex(int fontid, const char *str, size_t str_len, rcti *box, ResultBLF *r_info)
|
||||
ATTR_NONNULL(2);
|
||||
void BLF_boundbox(int fontid, const char *str, size_t str_len, rcti *box) ATTR_NONNULL();
|
||||
void BLF_boundbox(int fontid,
|
||||
const char *str,
|
||||
size_t str_len,
|
||||
rcti *box,
|
||||
ResultBLF *r_info = nullptr) ATTR_NONNULL(2);
|
||||
|
||||
/**
|
||||
* The next both function return the width and height
|
||||
* of the string, using the current font and both value
|
||||
* are multiplied by the aspect of the font.
|
||||
*/
|
||||
float BLF_width_ex(int fontid, const char *str, size_t str_len, ResultBLF *r_info)
|
||||
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info = nullptr)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
|
||||
float BLF_width(int fontid, const char *str, size_t str_len) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL();
|
||||
float BLF_height_ex(int fontid, const char *str, size_t str_len, ResultBLF *r_info)
|
||||
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info = nullptr)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2);
|
||||
float BLF_height(int fontid, const char *str, size_t str_len) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL();
|
||||
|
||||
/**
|
||||
* Return dimensions of the font without any sample text.
|
||||
|
@ -306,9 +304,8 @@ void BLF_buffer_col(int fontid, const float rgba[4]) ATTR_NONNULL(2);
|
|||
* Draw the string into the buffer, this function draw in both buffer,
|
||||
* float and unsigned char _BUT_ it's not necessary set both buffer, NULL is valid here.
|
||||
*/
|
||||
void BLF_draw_buffer_ex(int fontid, const char *str, size_t str_len, ResultBLF *r_info)
|
||||
void BLF_draw_buffer(int fontid, const char *str, size_t str_len, ResultBLF *r_info = nullptr)
|
||||
ATTR_NONNULL(2);
|
||||
void BLF_draw_buffer(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2);
|
||||
|
||||
/* `blf_thumbs.cc` */
|
||||
|
||||
|
|
|
@ -567,13 +567,21 @@ static void blf_draw_gpu__end(const FontBLF *font)
|
|||
}
|
||||
}
|
||||
|
||||
void BLF_draw_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
void BLF_draw(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
BLF_RESULT_CHECK_INIT(r_info);
|
||||
|
||||
if (str_len == 0 || str[0] == '\0') {
|
||||
return;
|
||||
}
|
||||
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
if (font) {
|
||||
|
||||
/* Avoid bgl usage to corrupt BLF drawing. */
|
||||
GPU_bgl_end();
|
||||
|
||||
blf_draw_gpu__start(font);
|
||||
if (font->flags & BLF_WORD_WRAP) {
|
||||
blf_font_draw__wrap(font, str, str_len, r_info);
|
||||
|
@ -584,17 +592,6 @@ void BLF_draw_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r
|
|||
blf_draw_gpu__end(font);
|
||||
}
|
||||
}
|
||||
void BLF_draw(int fontid, const char *str, const size_t str_len)
|
||||
{
|
||||
if (str_len == 0 || str[0] == '\0') {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Avoid bgl usage to corrupt BLF drawing. */
|
||||
GPU_bgl_end();
|
||||
|
||||
BLF_draw_ex(fontid, str, str_len, nullptr);
|
||||
}
|
||||
|
||||
int BLF_draw_mono(int fontid, const char *str, const size_t str_len, int cwidth, int tab_columns)
|
||||
{
|
||||
|
@ -699,7 +696,7 @@ size_t BLF_width_to_rstrlen(
|
|||
return 0;
|
||||
}
|
||||
|
||||
void BLF_boundbox_ex(
|
||||
void BLF_boundbox(
|
||||
int fontid, const char *str, const size_t str_len, rcti *r_box, ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
@ -716,11 +713,6 @@ void BLF_boundbox_ex(
|
|||
}
|
||||
}
|
||||
|
||||
void BLF_boundbox(int fontid, const char *str, const size_t str_len, rcti *r_box)
|
||||
{
|
||||
BLF_boundbox_ex(fontid, str, str_len, r_box, nullptr);
|
||||
}
|
||||
|
||||
void BLF_width_and_height(
|
||||
int fontid, const char *str, const size_t str_len, float *r_width, float *r_height)
|
||||
{
|
||||
|
@ -734,7 +726,7 @@ void BLF_width_and_height(
|
|||
}
|
||||
}
|
||||
|
||||
float BLF_width_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
float BLF_width(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
|
@ -747,11 +739,6 @@ float BLF_width_ex(int fontid, const char *str, const size_t str_len, ResultBLF
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
float BLF_width(int fontid, const char *str, const size_t str_len)
|
||||
{
|
||||
return BLF_width_ex(fontid, str, str_len, nullptr);
|
||||
}
|
||||
|
||||
float BLF_fixed_width(int fontid)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
@ -763,7 +750,7 @@ float BLF_fixed_width(int fontid)
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
float BLF_height_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
float BLF_height(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
|
@ -776,11 +763,6 @@ float BLF_height_ex(int fontid, const char *str, const size_t str_len, ResultBLF
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
float BLF_height(int fontid, const char *str, const size_t str_len)
|
||||
{
|
||||
return BLF_height_ex(fontid, str, str_len, nullptr);
|
||||
}
|
||||
|
||||
int BLF_height_max(int fontid)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
@ -915,7 +897,7 @@ void blf_draw_buffer__start(FontBLF *font)
|
|||
}
|
||||
void blf_draw_buffer__end() {}
|
||||
|
||||
void BLF_draw_buffer_ex(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
void BLF_draw_buffer(int fontid, const char *str, const size_t str_len, ResultBLF *r_info)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
||||
|
@ -930,10 +912,6 @@ void BLF_draw_buffer_ex(int fontid, const char *str, const size_t str_len, Resul
|
|||
blf_draw_buffer__end();
|
||||
}
|
||||
}
|
||||
void BLF_draw_buffer(int fontid, const char *str, const size_t str_len)
|
||||
{
|
||||
BLF_draw_buffer_ex(fontid, str, str_len, nullptr);
|
||||
}
|
||||
|
||||
blender::Vector<blender::StringRef> BLF_string_wrap(int fontid,
|
||||
blender::StringRef str,
|
||||
|
|
|
@ -2003,7 +2003,7 @@ void BKE_image_stamp_buf(Scene *scene,
|
|||
|
||||
/* must enable BLF_WORD_WRAP before using */
|
||||
#define TEXT_SIZE_CHECK_WORD_WRAP(str, w, h) \
|
||||
((str[0]) && (BLF_boundbox_ex(mono, str, sizeof(str), &wrap.rect, &wrap.info), \
|
||||
((str[0]) && (BLF_boundbox(mono, str, sizeof(str), &wrap.rect, &wrap.info), \
|
||||
(void)(h = h_fixed * wrap.info.lines), \
|
||||
(w = BLI_rcti_size_x(&wrap.rect))))
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void UI_fontstyle_draw_ex(const uiFontStyle *fs,
|
|||
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
|
||||
BLF_color4ubv(fs->uifont_id, col);
|
||||
|
||||
BLF_draw_ex(fs->uifont_id, str, str_len, r_info);
|
||||
BLF_draw(fs->uifont_id, str, str_len, r_info);
|
||||
|
||||
BLF_disable(fs->uifont_id, font_flag);
|
||||
|
||||
|
|
|
@ -1208,7 +1208,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
|
|||
}
|
||||
|
||||
if (!field->text.empty()) {
|
||||
w = BLF_width_ex(font_id, field->text.c_str(), field->text.size(), &info);
|
||||
w = BLF_width(font_id, field->text.c_str(), field->text.size(), &info);
|
||||
}
|
||||
|
||||
/* check for suffix (enum label) */
|
||||
|
|
|
@ -3773,7 +3773,7 @@ static void frame_node_draw_label(TreeDrawContext &tree_draw_ctx,
|
|||
if (line->line[0]) {
|
||||
BLF_position(fontid, x, y, 0);
|
||||
ResultBLF info;
|
||||
BLF_draw_ex(fontid, line->line, line->len, &info);
|
||||
BLF_draw(fontid, line->line, line->len, &info);
|
||||
y -= line_spacing * info.lines;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -731,7 +731,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
|
|||
BLF_enable(fontid, BLF_WORD_WRAP);
|
||||
BLF_wordwrap(fontid, ibuf->x - (margin * 2));
|
||||
BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
|
||||
BLF_draw_ex(fontid, temp_str, sizeof(temp_str), &info);
|
||||
BLF_draw(fontid, temp_str, sizeof(temp_str), &info);
|
||||
BLF_wordwrap(fontid, 0);
|
||||
BLF_disable(fontid, BLF_WORD_WRAP);
|
||||
ofs_y += vertical_offset * info.lines;
|
||||
|
@ -804,7 +804,7 @@ static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
|
|||
|
||||
BLF_enable(fontid, BLF_WORD_WRAP);
|
||||
BLF_wordwrap(fontid, ibuf->x - (margin * 2));
|
||||
BLF_boundbox_ex(fontid, str, sizeof(str), &wrap.rect, &wrap.info);
|
||||
BLF_boundbox(fontid, str, sizeof(str), &wrap.rect, &wrap.info);
|
||||
BLF_wordwrap(fontid, 0);
|
||||
BLF_disable(fontid, BLF_WORD_WRAP);
|
||||
|
||||
|
|
|
@ -2770,7 +2770,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
|
|||
rcti rect;
|
||||
} wrap;
|
||||
|
||||
BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
|
||||
BLF_boundbox(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info);
|
||||
|
||||
if ((data->align == SEQ_TEXT_ALIGN_X_LEFT) && (data->align_y == SEQ_TEXT_ALIGN_Y_TOP)) {
|
||||
y -= line_height;
|
||||
|
|
Loading…
Reference in New Issue