40 textbox.placeholder_wrap_cache.reset();
45 label.markdown_cache.reset();
61 int but_pos = textbox->
pos;
64 const wmIMEData *ime_data = button_ime_data_get(textbox);
65 if (ime_data && !ime_data->composite.empty() && ime_data->cursor_pos != -1) {
66 but_pos += ime_data->cursor_pos;
69 const char *cursor = lines[0].begin() + but_pos;
71 if (line.begin() > cursor) {
72 line_cursor = std::max(0, line_cursor - 1);
77 const int visible_bounds[] = {textbox->
line_scroll(),
79 if (visible_bounds[0] <= line_cursor && line_cursor < visible_bounds[1]) {
82 if (visible_bounds[0] > line_cursor) {
111 (end.y - xy.y) / (end.y - start.y) * (textbox->
visible_lines());
112 line_under_mouse = std::clamp<int>(line_under_mouse,
115 line_under_mouse = std::clamp<int>(line_under_mouse, 0, lines.size() - 1);
117 const StringRef line = lines[line_under_mouse];
119 start.x -=
U.pixelsize / aspect;
129 const wmIMEData *ime_data = button_ime_data_get(textbox);
141 const char *dest = lines.first().begin() + offset;
144 if (line.begin() > dest) {
150 i = std::clamp<int>(i, 0, lines.size() - 1);
163 const char *
str = lines.first().begin();
164 const bool append_selection = textbox->
selend == textbox->
pos;
171 lines[line_cursor].
begin(),
172 lines[line_cursor].size(),
173 textbox->
pos - (lines[line_cursor].begin() -
str),
177 if (line_cursor == lines.size() - 1) {
178 textbox->
pos = lines.last().end() -
str;
181 dest_line = lines[line_cursor + 1];
185 if (line_cursor == 0) {
189 dest_line = lines[line_cursor - 1];
192 if (dest_line.
data()) {
195 fontid, dest_line.
data(), dest_line.
size(), offset);
202 if (append_selection) {
223 std::string ime_text;
224 const wmIMEData *ime_data = button_ime_data_get(textbox);
225 if (ime_data && !ime_data->composite.empty()) {
229 ime_text = fmt::format(
"{}{}{}",
l, ime_data->composite, r);
239 textbox->
wrap_cache = std::make_unique<TextWrapCache>();
255 if (lines.is_empty()) {
266 for (
int i : lines.index_range()) {
267 if (lines[i].endswith(
"\n")) {
268 lines[i] = lines[i].drop_suffix(1);
328 const int initial_visible_lines)
331 if (link.
idname == idname) {
345 return std::clamp(this->
state->
scroll, 0, max_scroll);
357 return std::max<int>(
#define RNA_warning(format,...)
constexpr const char * c_str() const
constexpr const char * end() const
constexpr const char * begin() const
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 bool endswith(StringRef suffix) const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void textbox_add_scroll(ButtonTextBox *textbox, int step)
int textbox_but_height(const TextboxState &state)
Vector< StringRef > textbox_wrap_lines(ButtonTextBox *textbox)
const uiStyle * style_get()
Vector< StringRef > textbox_wrap_placeholder(ButtonTextBox *textbox)
void block_to_window_fl(const ARegion *region, const Block *block, float *x, float *y)
void fontstyle_set(const uiFontStyle *fs)
void invalidate_text_wrap_cache(const ARegion ®ion)
void fontscale(float *points, float aspect)
void textbox_textedit_set_cursor_pos(ButtonTextBox *textbox, const ARegion *region, const float2 xy)
void button_flag_enable(Button *but, int64_t flag)
Button * uiDefButR_prop(Block *block, ButtonType type, std::optional< StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< StringRef > tip)
constexpr int textbox_minimum_visible_lines
int textbox_wrapped_line_index_from_char_offset(Span< StringRef > lines, int offset)
Button * uiDefButTextBoxR(Block *block, PointerRNA *ptr, StringRefNull propname, TextboxState *state, int x, int y, short width)
int fontstyle_height_max(const uiFontStyle *fs)
int button_text_padding(const Button *button)
float textbox_grip_height()
TextboxState * textbox_ensure_state(ARegion *region, StringRefNull idname, const int initial_visible_lines)
float textbox_vertical_padding()
void button_update(Button *but)
void textbox_scroll_to_cursor(ButtonTextBox *textbox)
void textbox_jump_line(ButtonTextBox *textbox, eStrCursorJumpDirection direction, const bool select)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
PropertyRNA * RNA_struct_find_property_check(PointerRNA &props, const char *name, const PropertyType property_type_check)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
VecBase< float, 2 > float2
int RNA_property_flag(PropertyRNA *prop)
Vector< StringRef > BLF_string_wrap(int fontid, StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
const char * RNA_struct_identifier(const StructRNA *type)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
bool int BLF_str_offset_to_cursor(int fontid, const char *str, size_t str_len, size_t str_offset, int cursor_width)
size_t BLF_str_offset_from_cursor_position(int fontid, const char *str, size_t str_len, int location_x) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
const char * RNA_property_ui_name(const PropertyRNA *prop, const PointerRNA *ptr)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
ListBaseT< uiTextboxStateLink > textbox_states
ListBaseT< ui::Block > uiblocks
Vector< std::shared_ptr< MarkdownLayoutCache > > markdown_layout_cache
Vector< std::shared_ptr< TextWrapCache > > text_wrap_cache
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
int visible_lines() const
void line_scroll_set(int line_scroll)
std::unique_ptr< TextWrapCache > placeholder_wrap_cache
std::unique_ptr< TextWrapCache > wrap_cache
Vector< StringRef > wrapped_lines