66 const int str_len_draw,
68 const uchar bg_sel[4])
70 const int sel[2] = {tds->
sel[0], tds->
sel[1]};
71 const int cwidth = tds->
cwidth;
72 const int lheight = tds->
lheight;
74 if (sel[0] <= str_len_draw && sel[1] >= 0) {
100 const char *
str,
const int str_len,
const int width,
int *r_lines,
int **r_offsets)
110 (str_len * column_width_max / std::max(1, width - (column_width_max - 1)) + 1), __func__);
114 int columns =
UNLIKELY(*(
str + j) ==
'\t') ? (tab_columns - (
i % tab_columns)) :
117 if (
i + columns > end) {
118 (*r_offsets)[*r_lines] = j;
138 const uchar icon_fg[4],
139 const uchar icon_bg[4],
140 const uchar bg_sel[4])
148 int line_bottom = tds->
xy[1];
149 int line_top = line_bottom + line_height;
151 int y_next = line_top;
156 if (y_next >= tds->
mval[1]) {
161 int iofs = int(
float(y_next - tds->
mval[1]) / tds->
lheight);
162 ofs += offsets[std::min(iofs, tot_lines - 1)];
172 CLAMP(ofs, 0, str_len);
184 if (y_next < tds->scroll_ymin) {
189 if (tds->
sel[0] != tds->
sel[1]) {
205 tds->
sel[0] = str_len - sel_orig[1];
206 tds->
sel[1] = str_len - sel_orig[0];
227 roundbox_rect.
xmin = hpadding;
228 roundbox_rect.
xmax = bg_size + hpadding;
229 roundbox_rect.
ymin = line_top - bg_size - vpadding;
230 roundbox_rect.
ymax = line_top - vpadding;
255 const int final_offset = offsets[tot_lines - 1];
256 len = str_len - final_offset;
257 s =
str + final_offset;
259 if (tds->
sel[0] != tds->
sel[1]) {
261 const int pos[2] = {tds->
xy[0], line_bottom};
273 for (
i = tot_lines - 1;
i > 0;
i--) {
274 len = offsets[
i] - offsets[
i - 1];
275 s =
str + offsets[
i - 1];
277 if (tds->
sel[0] != tds->
sel[1]) {
305 const int mval_init[2],
306 void **r_mval_pick_item,
307 int *r_mval_pick_offset)
314 int sel[2] = {-1, -1};
315 uchar fg[4], bg[4], icon_fg[4], icon_bg[4];
326 const int mval[2] = {
327 (mval_init[0] == INT_MAX) ?
330 (mval_init[1] == INT_MAX) ?
335 if (r_mval_pick_offset !=
nullptr) {
336 *r_mval_pick_offset = 0;
365 if (tvc->
begin(tvc)) {
366 uchar bg_sel[4] = {0};
374 const char *ext_line;
378 const int y_prev =
xy[1];
381 data_flag = tvc->
line_data(tvc, fg, bg, &icon, icon_fg, icon_bg);
384 tvc->
line_get(tvc, &ext_line, &ext_len);
404 if (is_out_of_view_y) {
409 if ((mval[1] != INT_MAX) && (mval[1] >= y_prev && mval[1] <=
xy[1])) {
410 *r_mval_pick_item = (
void *)tvc->
iter;
416 }
while (tvc->
step(tvc));
428 return xy[1] - y_orig;
void BLF_size(int fontid, float size)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
float BLF_fixed_width(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
void BLF_position(int fontid, float x, float y, float z)
int BLF_draw_mono(int fontid, const char *str, size_t str_len, int cwidth, int tab_columns) ATTR_NONNULL(2)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
#define BLI_UTF8_WIDTH_MAX
int BLI_str_utf8_char_width_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_str_utf8_offset_from_column_with_tabs(const char *str, size_t str_len, int column_target, int tab_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_str_utf8_offset_to_column_with_tabs(const char *str, size_t str_len, int offset_target, int tab_width) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(GPUBlend blend)
Read Guarded memory(de)allocation.
void UI_draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
void UI_draw_roundbox_corner_set(int type)
#define UI_NO_ICON_OVERLAY_TEXT
void UI_icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], bool mono_border, const IconTextOverlay *text_overlay, const bool inverted=false)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
enum eTextViewContext_LineFlag(* line_data)(TextViewContext *tvc, uchar fg[4], uchar bg[4], int *r_icon, uchar r_icon_fg[4], uchar r_icon_bg[4])
void(* end)(TextViewContext *tvc)
void(* const_colors)(TextViewContext *tvc, unsigned char bg_sel[4])
int(* begin)(TextViewContext *tvc)
void(* line_get)(TextViewContext *tvc, const char **r_line, int *r_len)
int(* step)(TextViewContext *tvc)
void(* draw_cursor)(TextViewContext *tvc, int cwidth, int columns)
const rcti * draw_rect_outer
static bool textview_draw_string(TextViewDrawState *tds, const char *str, int str_len, const uchar fg[4], const uchar bg[4], int icon, const uchar icon_fg[4], const uchar icon_bg[4], const uchar bg_sel[4])
static void textview_draw_sel(const char *str, const int xy[2], const int str_len_draw, TextViewDrawState *tds, const uchar bg_sel[4])
static void textview_font_begin(const int font_id, const int lheight)
int textview_draw(TextViewContext *tvc, const bool do_draw, const int mval_init[2], void **r_mval_pick_item, int *r_mval_pick_offset)
BLI_INLINE void textview_step_sel(TextViewDrawState *tds, const int step)
static int textview_wrap_offsets(const char *str, const int str_len, const int width, int *r_lines, int **r_offsets)