Lines Matching defs:edit

3438     NK_EDIT_ACTIVE      = NK_FLAG(0), /* edit widget is currently being modified */
3439 NK_EDIT_INACTIVE = NK_FLAG(1), /* edit widget is not active and is not being modified */
3440 NK_EDIT_ACTIVATED = NK_FLAG(2), /* edit widget went from state inactive to state active */
3441 NK_EDIT_DEACTIVATED = NK_FLAG(3), /* edit widget went from state active to state inactive */
3442 NK_EDIT_COMMITED = NK_FLAG(4) /* edit widget has received an enter and lost focus */
5071 struct nk_style_edit edit;
5230 struct nk_style_edit edit;
5424 struct nk_edit_state edit;
5971 /* edit */
5973 NK_LIB nk_flags nk_do_edit(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_flags flags, nk_plugin_filter filter, struct nk_text_edit *edit, const struct nk_style_edit *style, struct nk_input *in, const struct nk_user_font *font);
6012 NK_LIB void nk_property_behavior(nk_flags *ws, const struct nk_input *in, struct nk_rect property, struct nk_rect label, struct nk_rect edit, struct nk_rect empty, int *state, struct nk_property_variant *variant, float inc_per_pixel);
14283 struct nk_style_edit *edit;
14533 /* edit */
14534 edit = &style->edit;
14535 nk_zero_struct(*edit);
14536 edit->normal = nk_style_item_color(table[NK_COLOR_EDIT]);
14537 edit->hover = nk_style_item_color(table[NK_COLOR_EDIT]);
14538 edit->active = nk_style_item_color(table[NK_COLOR_EDIT]);
14539 edit->cursor_normal = table[NK_COLOR_TEXT];
14540 edit->cursor_hover = table[NK_COLOR_TEXT];
14541 edit->cursor_text_normal= table[NK_COLOR_EDIT];
14542 edit->cursor_text_hover = table[NK_COLOR_EDIT];
14543 edit->border_color = table[NK_COLOR_BORDER];
14544 edit->text_normal = table[NK_COLOR_TEXT];
14545 edit->text_hover = table[NK_COLOR_TEXT];
14546 edit->text_active = table[NK_COLOR_TEXT];
14547 edit->selected_normal = table[NK_COLOR_TEXT];
14548 edit->selected_hover = table[NK_COLOR_TEXT];
14549 edit->selected_text_normal = table[NK_COLOR_EDIT];
14550 edit->selected_text_hover = table[NK_COLOR_EDIT];
14551 edit->scrollbar_size = nk_vec2(10,10);
14552 edit->scrollbar = style->scrollv;
14553 edit->padding = nk_vec2(4,4);
14554 edit->row_padding = 2;
14555 edit->cursor_size = 4;
14556 edit->border = 1;
14557 edit->rounding = 0;
14599 /* property edit */
14600 edit = &style->property.edit;
14601 nk_zero_struct(*edit);
14602 edit->normal = nk_style_item_color(table[NK_COLOR_PROPERTY]);
14603 edit->hover = nk_style_item_color(table[NK_COLOR_PROPERTY]);
14604 edit->active = nk_style_item_color(table[NK_COLOR_PROPERTY]);
14605 edit->border_color = nk_rgba(0,0,0,0);
14606 edit->cursor_normal = table[NK_COLOR_TEXT];
14607 edit->cursor_hover = table[NK_COLOR_TEXT];
14608 edit->cursor_text_normal= table[NK_COLOR_EDIT];
14609 edit->cursor_text_hover = table[NK_COLOR_EDIT];
14610 edit->text_normal = table[NK_COLOR_TEXT];
14611 edit->text_hover = table[NK_COLOR_TEXT];
14612 edit->text_active = table[NK_COLOR_TEXT];
14613 edit->selected_normal = table[NK_COLOR_TEXT];
14614 edit->selected_hover = table[NK_COLOR_TEXT];
14615 edit->selected_text_normal = table[NK_COLOR_EDIT];
14616 edit->selected_text_hover = table[NK_COLOR_EDIT];
14617 edit->padding = nk_vec2(0,0);
14618 edit->cursor_size = 8;
14619 edit->border = 0;
14620 edit->rounding = 0;
16102 /* edit garbage collector */
16103 if (window->edit.active && window->edit.old != window->edit.seq &&
16104 window->edit.active == window->edit.prev) {
16105 nk_zero(&window->edit, sizeof(window->edit));
16107 window->edit.old = window->edit.seq;
16108 window->edit.prev = window->edit.active;
16109 window->edit.seq = 0;
21723 nk_textedit_get_width(const struct nk_text_edit *edit, int line_start, int char_id,
21728 const char *str = nk_str_at_const(&edit->string, line_start + char_id, &unicode, &len);
21732 nk_textedit_layout_row(struct nk_text_edit_row *r, struct nk_text_edit *edit,
21739 int len = nk_str_len_char(&edit->string);
21740 const char *end = nk_str_get_const(&edit->string) + len;
21741 const char *text = nk_str_at_const(&edit->string, line_start_id, &unicode, &l);
21753 nk_textedit_locate_coord(struct nk_text_edit *edit, float x, float y,
21757 int n = edit->string.len;
21767 nk_textedit_layout_row(&r, edit, i, row_height, font);
21795 float w = nk_textedit_get_width(edit, k, i, font);
21808 if (nk_str_rune_at(&edit->string, i+r.num_chars-1) == '\n')
22873 struct nk_text_edit *edit, const struct nk_style_edit *style,
22905 /* update edit state */
22906 prev_state = (char)edit->active;
22909 edit->active = NK_INBOX(in->mouse.pos.x, in->mouse.pos.y,
22914 if (!prev_state && edit->active) {
22917 nk_textedit_clear_state(edit, type, filter);
22921 edit->cursor = edit->string.len;
22924 } else if (!edit->active) edit->mode = NK_TEXT_EDIT_MODE_VIEW;
22926 edit->mode = NK_TEXT_EDIT_MODE_VIEW;
22928 edit->mode = NK_TEXT_EDIT_MODE_INSERT;
22930 ret = (edit->active) ? NK_EDIT_ACTIVE: NK_EDIT_INACTIVE;
22931 if (prev_state != edit->active)
22932 ret |= (edit->active) ? NK_EDIT_ACTIVATED: NK_EDIT_DEACTIVATED;
22935 if (edit->active && in)
22938 const float mouse_x = (in->mouse.pos.x - area.x) + edit->scrollbar.x;
22939 const float mouse_y = (in->mouse.pos.y - area.y) + edit->scrollbar.y;
22944 nk_textedit_select_all(edit);
22947 nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
22950 nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
22954 nk_textedit_key(edit, NK_KEY_TEXT_WORD_LEFT, nk_false, font, row_height);
22955 nk_textedit_key(edit, NK_KEY_TEXT_WORD_RIGHT, nk_true, font, row_height);
22960 int old_mode = edit->mode;
22964 nk_textedit_key(edit, (enum nk_keys)i, shift_mod, font, row_height);
22968 if (old_mode != edit->mode) {
22973 edit->filter = filter;
22975 nk_textedit_text(edit, in->keyboard.text, in->keyboard.text_len);
22984 nk_textedit_text(edit, "\n", 1);
22987 else nk_textedit_text(edit, "\n", 1);
22998 int b = edit->select_start;
22999 int e = edit->select_end;
23003 text = nk_str_at_const(&edit->string, begin, &unicode, &glyph_len);
23004 if (edit->clip.copy)
23005 edit->clip.copy(edit->clip.userdata, text, end - begin);
23007 nk_textedit_cut(edit);
23014 if (paste && (flags & NK_EDIT_CLIPBOARD) && edit->clip.paste) {
23015 edit->clip.paste(edit->clip.userdata, edit);
23022 nk_textedit_text(edit, " ", 4);
23028 if (edit->active)
23036 {const char *text = nk_str_get_const(&edit->string);
23037 int len = nk_str_len_char(&edit->string);
23054 if (edit->active)
23069 int selection_begin = NK_MIN(edit->select_start, edit->select_end);
23070 int selection_end = NK_MAX(edit->select_start, edit->select_end);
23092 if (!cursor_ptr && glyphs == edit->cursor)
23109 if (!select_begin_ptr && edit->select_start != edit->select_end &&
23127 if (!select_end_ptr && edit->select_start != edit->select_end &&
23167 if (!cursor_ptr && edit->cursor == edit->string.len) {
23180 if (cursor_pos.x < edit->scrollbar.x)
23181 edit->scrollbar.x = (float)(int)NK_MAX(0.0f, cursor_pos.x - scroll_increment);
23182 if (cursor_pos.x >= edit->scrollbar.x + area.w)
23183 edit->scrollbar.x = (float)(int)NK_MAX(0.0f, edit->scrollbar.x + scroll_increment);
23184 } else edit->scrollbar.x = 0;
23188 if (cursor_pos.y < edit->scrollbar.y)
23189 edit->scrollbar.y = NK_MAX(0.0f, cursor_pos.y - row_height);
23190 if (cursor_pos.y >= edit->scrollbar.y + area.h)
23191 edit->scrollbar.y = edit->scrollbar.y + row_height;
23192 } else edit->scrollbar.y = 0;
23209 scroll_offset = edit->scrollbar.y;
23213 edit->scrollbar.y = nk_do_scrollbarv(&ws, out, scroll, 0,
23257 if (edit->select_start == edit->select_end) {
23259 const char *begin = nk_str_get_const(&edit->string);
23260 int l = nk_str_len_char(&edit->string);
23261 nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
23262 area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
23265 /* edit has selection so draw 1-3 text chunks */
23266 if (edit->select_start != edit->select_end && selection_begin > 0){
23268 const char *begin = nk_str_get_const(&edit->string);
23270 nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
23271 area.y - edit->scrollbar.y, 0, begin, (int)(select_begin_ptr - begin),
23274 if (edit->select_start != edit->select_end) {
23278 const char *begin = nk_str_get_const(&edit->string);
23279 select_end_ptr = begin + nk_str_len_char(&edit->string);
23282 area.x - edit->scrollbar.x,
23283 area.y + selection_offset_start.y - edit->scrollbar.y,
23288 if ((edit->select_start != edit->select_end &&
23289 selection_end < edit->string.len))
23293 const char *end = nk_str_get_const(&edit->string) +
23294 nk_str_len_char(&edit->string);
23297 area.x - edit->scrollbar.x,
23298 area.y + selection_offset_end.y - edit->scrollbar.y,
23306 if (edit->select_start == edit->select_end)
23308 if (edit->cursor >= nk_str_len(&edit->string) ||
23314 cursor.x = area.x + cursor_pos.x - edit->scrollbar.x;
23316 cursor.y -= edit->scrollbar.y;
23328 label.x = area.x + cursor_pos.x - edit->scrollbar.x;
23329 label.y = area.y + cursor_pos.y - edit->scrollbar.y;
23342 int l = nk_str_len_char(&edit->string);
23343 const char *begin = nk_str_get_const(&edit->string);
23362 nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
23363 area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
23380 hash = win->edit.seq;
23381 win->edit.active = nk_true;
23382 win->edit.name = hash;
23384 win->edit.mode = NK_TEXT_EDIT_MODE_INSERT;
23395 win->edit.active = nk_false;
23396 win->edit.name = 0;
23404 struct nk_text_edit *edit;
23415 hash = win->edit.seq;
23416 edit = &ctx->text_edit;
23420 if (win->edit.active && hash == win->edit.name) {
23422 edit->cursor = nk_utf_len(memory, *len);
23423 else edit->cursor = win->edit.cursor;
23425 edit->select_start = win->edit.cursor;
23426 edit->select_end = win->edit.cursor;
23428 edit->select_start = win->edit.sel_start;
23429 edit->select_end = win->edit.sel_end;
23431 edit->mode = win->edit.mode;
23432 edit->scrollbar.x = (float)win->edit.scrollbar.x;
23433 edit->scrollbar.y = (float)win->edit.scrollbar.y;
23434 edit->active = nk_true;
23435 } else edit->active = nk_false;
23439 nk_str_init_fixed(&edit->string, memory, (nk_size)max);
23440 edit->string.buffer.allocated = (nk_size)*len;
23441 edit->string.len = nk_utf_len(memory, *len);
23442 state = nk_edit_buffer(ctx, flags, edit, filter);
23443 *len = (int)edit->string.buffer.allocated;
23445 if (edit->active) {
23446 win->edit.cursor = edit->cursor;
23447 win->edit.sel_start = edit->select_start;
23448 win->edit.sel_end = edit->select_end;
23449 win->edit.mode = edit->mode;
23450 win->edit.scrollbar.x = (nk_uint)edit->scrollbar.x;
23451 win->edit.scrollbar.y = (nk_uint)edit->scrollbar.y;
23456 struct nk_text_edit *edit, nk_plugin_filter filter)
23471 NK_ASSERT(edit);
23483 /* check if edit is currently hot item */
23484 hash = win->edit.seq++;
23485 if (win->edit.active && hash == win->edit.name) {
23487 edit->cursor = edit->string.len;
23489 edit->select_start = edit->cursor;
23490 edit->select_end = edit->cursor;
23493 edit->clip = ctx->clip;
23494 edit->active = (unsigned char)win->edit.active;
23495 } else edit->active = nk_false;
23496 edit->mode = win->edit.mode;
23499 prev_state = (unsigned char)edit->active;
23502 filter, edit, &style->edit, in, style->font);
23506 if (edit->active && prev_state != edit->active) {
23507 /* current edit is now hot */
23508 win->edit.active = nk_true;
23509 win->edit.name = hash;
23510 } else if (prev_state && !edit->active) {
23511 /* current edit is now cold */
23512 win->edit.active = nk_false;
23576 struct nk_rect property, struct nk_rect label, struct nk_rect edit,
23581 if (nk_button_behavior(ws, edit, in, NK_BUTTON_DEFAULT))
23653 struct nk_rect edit;
23676 /* edit */
23679 size += style->edit.cursor_size;
23703 edit.w = (float)size + 2 * style->padding.x;
23704 edit.w = NK_MIN(edit.w, right.x - (label.x + label.w));
23705 edit.x = right.x - (edit.w + style->padding.x);
23706 edit.y = property.y + style->border;
23707 edit.h = property.h - (2 * style->border);
23710 empty.w = edit.x - (label.x + label.w);
23717 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
23758 /* execute and run text edit field */
23770 nk_do_edit(ws, out, edit, NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
23771 filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
23781 /* property is now not active so convert edit text to value*/
25534 /// - 2017/06/08 (1.39.1) - Fixed property text edit handling bug caused by past `nk_widget` fix.
25552 /// - 2017/03/04 (1.34.2) - Fixed text edit filtering.
25555 /// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus.
25592 /// - 2016/10/18 (1.23.0) - Added `nk_edit_focus` for manually edit widget focus control.
25594 /// - 2016/09/29 (1.22.6) - Fixed edit widget UTF-8 text cursor drawing bug.
25595 /// - 2016/09/28 (1.22.5) - Fixed edit widget UTF-8 text appending/inserting/removing.
25596 /// - 2016/09/28 (1.22.4) - Fixed drawing bug inside edit widgets which offset all text
25597 /// text in every edit widget if one of them is scrolled.
25598 /// - 2016/09/28 (1.22.3) - Fixed small bug in edit widgets if not active. The wrong