Lines Matching defs:state
29 /// This is a minimal state immediate mode graphical user interface toolkit
33 /// library approach by using simple input state for input and draw
48 /// - No global or hidden state
109 /// NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events
177 /// // init gui state
516 /// Contexts are the main entry point and the majestro of nuklear and contain all required state.
612 /// used for allocating windows, panels and state tables.
629 /// Resets the context state at the end of the frame. This includes mostly
676 /// The input API is responsible for holding the current input state composed of
679 /// Instead all input state has to be provided by platform specific code. This on one hand
696 /// Input state needs to be provided to nuklear by first calling `nk_input_begin`
697 /// which resets internal state like delta mouse position and button transistions.
698 /// After `nk_input_begin` all current input state needs to be provided. This includes
700 /// Both event- or state-based input handling are supported by this API
701 /// and should work without problems. Finally after all input state has been
728 /// __nk_input_key__ | Mirrors key state with either pressed or released
729 /// __nk_input_button__ | Mirrors mouse button state with either pressed or released
734 /// __nk_input_end__ | Ends the input mirroring process by calculating state changes. Don't call any `nk_input_xxx` function referenced above after this call
780 /// mouse, previous mouse position and movement as well as key state transitions,
806 /// Mirrors the state of a specific key to nuklear
820 /// Mirrors the state of a specific mouse button to nuklear
903 /// state to ensure the mouse cursor is not grabbed indefinitely.
1310 /// Windows are the main persistent state used inside nuklear and are life time
1314 /// assert in debug or no state change in release mode.<br /><br />
1316 /// Each window holds frame persistent state like position, size, flags, state tables,
1317 /// and some garbage collected internal persistent widget state. Each window
1400 /// nk_window_get_panel | Returns the underlying panel which contains all processing state of the current window
1505 /// All widget calls after this functions will result in asserts or no state changes
1613 /// Returns the underlying panel which contains all processing state of the current window.
1627 /// Returns a pointer to window internal `nk_panel` state.
1935 /// Updates collapse state of a window with given name
1937 /// void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
1946 NK_API void nk_window_collapse(struct nk_context*, const char *name, enum nk_collapse_states state);
1948 /// Updates collapse state of a window with given name if given condition is met
1958 /// __cond__ | condition that has to be met to actually commit the collapse state change
1962 /// updates visibility state of a window with given name
1971 /// __state__ | state with either visible or hidden to modify the window with
1975 /// Updates visibility state of a window with given name if a given condition is met
1984 /// __state__ | state with either visible or hidden to modify the window with
1985 /// __cond__ | condition that has to be met to actually commit the visbility state change
2773 /// UI section that can be either in a hidden or visibile state. They allow the UI
2781 /// and optionally an image to be displayed and the initial collapse state from
2784 /// The runtime state of the tree is either stored outside the library by the caller
2818 /// nk_tree_push | Start a collapsable UI section with internal state management
2819 /// nk_tree_push_id | Start a collapsable UI section with internal state management callable in a look
2820 /// nk_tree_push_hashed | Start a collapsable UI section with internal state management with full control over internal unique ID use to store state
2822 /// nk_tree_image_push_id | Start a collapsable UI section with image and label header and internal state management callable in a look
2823 /// nk_tree_image_push_hashed | Start a collapsable UI section with image and label header and internal state management with full control over internal unique ID use to store state
2826 /// nk_tree_state_push | Start a collapsable UI section with external state management
2827 /// nk_tree_state_image_push | Start a collapsable UI section with image and label header and external state management
2837 /// Starts a collapsable UI section with internal state management
2839 /// To keep track of the runtime tree collapsable state this function uses
2845 /// #define nk_tree_push(ctx, type, title, state)
2853 /// __state__ | Initial tree state value out of nk_collapse_states
2857 #define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2859 /// Starts a collapsable UI section with internal state management callable in a look
2861 /// #define nk_tree_push_id(ctx, type, title, state, id)
2869 /// __state__ | Initial tree state value out of nk_collapse_states
2874 #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2876 /// Start a collapsable UI section with internal state management with full
2877 /// control over internal unique ID used to store state
2887 /// __state__ | Initial tree state value out of nk_collapse_states
2898 /// To keep track of the runtime tree collapsable state this function uses
2904 /// #define nk_tree_image_push(ctx, type, img, title, state)
2913 /// __state__ | Initial tree state value out of nk_collapse_states
2917 #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
2919 /// Start a collapsable UI section with image and label header and internal state
2923 /// #define nk_tree_image_push_id(ctx, type, img, title, state, id)
2932 /// __state__ | Initial tree state value out of nk_collapse_states
2937 #define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
2939 /// Start a collapsable UI section with internal state management with full
2940 /// control over internal unique ID used to store state
2951 /// __state__ | Initial tree state value out of nk_collapse_states
2971 /// Start a collapsable UI section with external state management
2973 /// int nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
2981 /// __state__ | Persistent state to update
2985 NK_API int nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
2987 /// Start a collapsable UI section with image and label header and external state management
2989 /// int nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
2998 /// __state__ | Persistent state to update
3002 NK_API int nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
3015 #define nk_tree_element_push(ctx, type, title, state, sel) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
3016 #define nk_tree_element_push_id(ctx, type, title, state, sel, id) nk_tree_element_push_hashed(ctx, type, title, state, sel, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
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 */
3836 an extension to nuklear and does not really depend on any `nk_context` state.
4352 enum nk_widget_layout_states state;
4353 state = nk_widget(&space, ctx);
4354 if (!state) return;
4356 if (state != NK_WIDGET_ROM)
4369 but also returns the state of the widget space. If your widget is not seen and does
4371 to be drawn the state will be `NK_WIDGET_ROM` otherwise you can do both
5406 int state;
5421 /* persistent widget state */
5857 NK_LIB void nk_textedit_clear_state(struct nk_text_edit *state, enum nk_text_edit_type type, nk_plugin_filter filter);
5858 NK_LIB void nk_textedit_click(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
5859 NK_LIB void nk_textedit_drag(struct nk_text_edit *state, float x, float y, const struct nk_user_font *font, float row_height);
5860 NK_LIB void nk_textedit_key(struct nk_text_edit *state, enum nk_keys key, int shift_mod, const struct nk_user_font *font, float row_height);
5926 NK_LIB int nk_button_behavior(nk_flags *state, struct nk_rect r, const struct nk_input *i, enum nk_button_behavior behavior);
5927 NK_LIB const struct nk_style_item* nk_draw_button(struct nk_command_buffer *out, const struct nk_rect *bounds, nk_flags state, const struct nk_style_button *style);
5928 NK_LIB int nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, const struct nk_style_button *style, const struct nk_input *in, enum nk_button_behavior behavior, struct nk_rect *content);
5929 NK_LIB void nk_draw_button_text(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const char *txt, int len, nk_flags text_alignment, const struct nk_user_font *font);
5930 NK_LIB int nk_do_button_text(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *string, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
5931 NK_LIB void nk_draw_button_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, enum nk_symbol_type type, const struct nk_user_font *font);
5932 NK_LIB int nk_do_button_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_input *in, const struct nk_user_font *font);
5933 NK_LIB void nk_draw_button_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state, const struct nk_style_button *style, const struct nk_image *img);
5934 NK_LIB int nk_do_button_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, enum nk_button_behavior b, const struct nk_style_button *style, const struct nk_input *in);
5935 NK_LIB void nk_draw_button_text_symbol(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style, const char *str, int len, enum nk_symbol_type type, const struct nk_user_font *font);
5936 NK_LIB int nk_do_button_text_symbol(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, enum nk_symbol_type symbol, const char *str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
5937 NK_LIB void nk_draw_button_text_image(struct nk_command_buffer *out, const struct nk_rect *bounds, const struct nk_rect *label, const struct nk_rect *image, nk_flags state, const struct nk_style_button *style, const char *str, int len, const struct nk_user_font *font, const struct nk_image *img);
5938 NK_LIB int nk_do_button_text_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, struct nk_image img, const char* str, int len, nk_flags align, enum nk_button_behavior behavior, const struct nk_style_button *style, const struct nk_user_font *font, const struct nk_input *in);
5945 NK_LIB int nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, int active);
5946 NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, int active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
5947 NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, int active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
5948 NK_LIB int nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, int *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font);
5951 NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, int modifiable);
5952 NK_LIB void nk_draw_progress(struct nk_command_buffer *out, nk_flags state, const struct nk_style_progress *style, const struct nk_rect *bounds, const struct nk_rect *scursor, nk_size value, nk_size max);
5953 NK_LIB nk_size nk_do_progress(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, nk_size value, nk_size max, int modifiable, const struct nk_style_progress *style, struct nk_input *in);
5956 NK_LIB float nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor, struct nk_rect *visual_cursor, struct nk_input *in, struct nk_rect bounds, float slider_min, float slider_max, float slider_value, float slider_step, float slider_steps);
5957 NK_LIB void nk_draw_slider(struct nk_command_buffer *out, nk_flags state, const struct nk_style_slider *style, const struct nk_rect *bounds, const struct nk_rect *visual_cursor, float min, float value, float max);
5958 NK_LIB float nk_do_slider(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, float min, float val, float max, float step, const struct nk_style_slider *style, struct nk_input *in, const struct nk_user_font *font);
5961 NK_LIB float nk_scrollbar_behavior(nk_flags *state, struct nk_input *in, int has_scrolling, const struct nk_rect *scroll, const struct nk_rect *cursor, const struct nk_rect *empty0, const struct nk_rect *empty1, float scroll_offset, float target, float scroll_step, enum nk_orientation o);
5962 NK_LIB void nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state, const struct nk_style_scrollbar *style, const struct nk_rect *bounds, const struct nk_rect *scroll);
5963 NK_LIB float nk_do_scrollbarv(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
5964 NK_LIB float nk_do_scrollbarh(nk_flags *state, struct nk_command_buffer *out, struct nk_rect scroll, int has_scrolling, float offset, float target, float step, float button_pixel_inc, const struct nk_style_scrollbar *style, struct nk_input *in, const struct nk_user_font *font);
5967 NK_LIB void nk_draw_selectable(struct nk_command_buffer *out, nk_flags state, const struct nk_style_selectable *style, int active, const struct nk_rect *bounds, const struct nk_rect *icon, const struct nk_image *img, enum nk_symbol_type sym, const char *string, int len, nk_flags align, const struct nk_user_font *font);
5968 NK_LIB int nk_do_selectable(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, int *value, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
5969 NK_LIB int nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out, struct nk_rect bounds, const char *str, int len, nk_flags align, int *value, const struct nk_image *img, const struct nk_style_selectable *style, const struct nk_input *in, const struct nk_user_font *font);
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);
5976 NK_LIB int nk_color_picker_behavior(nk_flags *state, const struct nk_rect *bounds, const struct nk_rect *matrix, const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar, struct nk_colorf *color, const struct nk_input *in);
5978 NK_LIB int nk_do_color_picker(nk_flags *state, struct nk_command_buffer *out, struct nk_colorf *col, enum nk_color_format fmt, struct nk_rect bounds, struct nk_vec2 padding, const struct nk_input *in, const struct nk_user_font *font);
6011 NK_LIB void nk_drag_behavior(nk_flags *state, const struct nk_input *in, struct nk_rect drag, struct nk_property_variant *variant, float inc_per_pixel);
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);
6013 NK_LIB void nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *style, const struct nk_rect *bounds, const struct nk_rect *label, nk_flags state, const char *name, int len, const struct nk_user_font *font);
6014 NK_LIB void nk_do_property(nk_flags *ws, struct nk_command_buffer *out, struct nk_rect property, const char *name, struct nk_property_variant *variant, float inc_per_pixel, char *buffer, int *len, int *state, int *cursor, int *select_begin, int *select_end, const struct nk_style_property *style, enum nk_property_filter filter, struct nk_input *in, const struct nk_user_font *font, struct nk_text_edit *text_edit, enum nk_button_behavior behavior);
11412 /* where we can start, and we need to save some state for when we wraparound. */
15110 /* remove unused window state tables */
15158 /* save buffer fill state for popup */
15629 /* pull state into local stack */
15954 nk_flags state = 0;
15964 scroll_offset = nk_do_scrollbarv(&state, out, scroll, scroll_has_scrolling,
15973 nk_flags state = 0;
15983 scroll_offset = nk_do_scrollbarh(&state, out, scroll, scroll_has_scrolling,
16156 /*free window state tables */
17133 enum nk_widget_layout_states state;
17143 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
17144 if (!state) return nk_false;
17146 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17168 enum nk_widget_layout_states state;
17178 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
17179 if (!state) return nk_false;
17181 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17204 enum nk_widget_layout_states state;
17214 state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
17215 if (!state) return nk_false;
17217 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17396 nk_flags state;
17405 state = nk_widget(&header, ctx);
17406 if (!state) return 0;
17407 in = (state == NK_WIDGET_ROM || win->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17426 nk_flags state;
17435 state = nk_widget(&header, ctx);
17436 if (!state) return 0;
17437 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17451 nk_flags state;
17460 state = nk_widget(&header, ctx);
17461 if (!state) return 0;
17462 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17476 nk_flags state;
17485 state = nk_widget(&header, ctx);
17486 if (!state) return 0;
17487 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
17508 nk_flags state;
17517 state = nk_widget(&header, ctx);
17518 if (!state) return 0;
17520 in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
18351 struct nk_image *img, const char *title, enum nk_collapse_states *state)
18403 /* update node state */
18407 *state = (*state == NK_MAXIMIZED) ? NK_MINIMIZED : NK_MAXIMIZED;
18410 if (*state == NK_MAXIMIZED) {
18449 if (*state == NK_MAXIMIZED) {
18465 nk_uint *state = 0;
18467 /* retrieve tree state from internal widget state tables */
18472 state = nk_find_value(win, tree_hash);
18473 if (!state) {
18474 state = nk_add_value(ctx, win, tree_hash, 0);
18475 *state = initial_state;
18477 return nk_tree_state_base(ctx, type, img, title, (enum nk_collapse_states*)state);
18481 const char *title, enum nk_collapse_states *state)
18483 return nk_tree_state_base(ctx, type, 0, title, state);
18487 struct nk_image img, const char *title, enum nk_collapse_states *state)
18489 return nk_tree_state_base(ctx, type, &img, title, state);
18532 enum nk_collapse_states *state, int *selected)
18593 if (*state == NK_MAXIMIZED) {
18609 *state = (*state == NK_MAXIMIZED) ? NK_MINIMIZED : NK_MAXIMIZED;}
18632 if (*state == NK_MAXIMIZED) {
18648 nk_uint *state = 0;
18650 /* retrieve tree state from internal widget state tables */
18655 state = nk_find_value(win, tree_hash);
18656 if (!state) {
18657 state = nk_add_value(ctx, win, tree_hash, 0);
18658 *state = initial_state;
18660 nk_strlen(title), (enum nk_collapse_states*)state, selected);
19192 enum nk_widget_layout_states state;
19204 state = nk_widget(bounds, ctx);
19215 return state;
19746 nk_button_behavior(nk_flags *state, struct nk_rect r,
19750 nk_widget_state_reset(state);
19753 *state = NK_WIDGET_STATE_HOVERED;
19755 *state = NK_WIDGET_STATE_ACTIVE;
19766 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(i, r))
19767 *state |= NK_WIDGET_STATE_ENTERED;
19769 *state |= NK_WIDGET_STATE_LEFT;
19774 const struct nk_rect *bounds, nk_flags state,
19778 if (state & NK_WIDGET_STATE_HOVER)
19780 else if (state & NK_WIDGET_STATE_ACTIVED)
19793 nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r,
19799 NK_ASSERT(state);
19815 return nk_button_behavior(state, bounds, in, behavior);
19819 const struct nk_rect *bounds, const struct nk_rect *content, nk_flags state,
19825 background = nk_draw_button(out, bounds, state, style);
19831 if (state & NK_WIDGET_STATE_HOVER)
19833 else if (state & NK_WIDGET_STATE_ACTIVED)
19841 nk_do_button_text(nk_flags *state,
19850 NK_ASSERT(state);
19858 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19860 nk_draw_button_text(out, &bounds, &content, *state, style, string, len, align, font);
19867 nk_flags state, const struct nk_style_button *style,
19874 background = nk_draw_button(out, bounds, state, style);
19879 if (state & NK_WIDGET_STATE_HOVER)
19881 else if (state & NK_WIDGET_STATE_ACTIVED)
19887 nk_do_button_symbol(nk_flags *state,
19896 NK_ASSERT(state);
19900 if (!out || !style || !font || !state)
19903 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
19905 nk_draw_button_symbol(out, &bounds, &content, *state, style, symbol, font);
19912 nk_flags state, const struct nk_style_button *style, const struct nk_image *img)
19914 nk_draw_button(out, bounds, state, style);
19918 nk_do_button_image(nk_flags *state,
19926 NK_ASSERT(state);
19929 if (!out || !style || !state)
19932 ret = nk_do_button(state, out, bounds, style, in, b, &content);
19939 nk_draw_button_image(out, &bounds, &content, *state, style, &img);
19946 const struct nk_rect *symbol, nk_flags state, const struct nk_style_button *style,
19955 background = nk_draw_button(out, bounds, state, style);
19961 if (state & NK_WIDGET_STATE_HOVER) {
19964 } else if (state & NK_WIDGET_STATE_ACTIVED) {
19977 nk_do_button_text_symbol(nk_flags *state,
19993 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
20004 *state, style, str, len, symbol, font);
20011 const struct nk_rect *image, nk_flags state, const struct nk_style_button *style,
20017 background = nk_draw_button(out, bounds, state, style);
20023 if (state & NK_WIDGET_STATE_HOVER)
20025 else if (state & NK_WIDGET_STATE_ACTIVED)
20034 nk_do_button_text_image(nk_flags *state,
20045 NK_ASSERT(state);
20051 ret = nk_do_button(state, out, bounds, style, in, behavior, &content);
20065 nk_draw_button_text_image(out, &bounds, &content, &icon, *state, style, str, len, font, &img);
20123 enum nk_widget_layout_states state;
20133 state = nk_widget(&bounds, ctx);
20135 if (!state) return 0;
20136 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20168 enum nk_widget_layout_states state;
20179 state = nk_widget(&bounds, ctx);
20180 if (!state) return 0;
20181 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20201 enum nk_widget_layout_states state;
20211 state = nk_widget(&bounds, ctx);
20212 if (!state) return 0;
20213 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20233 enum nk_widget_layout_states state;
20244 state = nk_widget(&bounds, ctx);
20245 if (!state) return 0;
20246 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20267 enum nk_widget_layout_states state;
20278 state = nk_widget(&bounds, ctx);
20279 if (!state) return 0;
20280 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20314 enum nk_widget_layout_states state;
20325 state = nk_widget(&bounds, ctx);
20326 if (!state) return 0;
20327 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20361 nk_flags *state, int active)
20363 nk_widget_state_reset(state);
20364 if (nk_button_behavior(state, select, in, NK_BUTTON_DEFAULT)) {
20365 *state = NK_WIDGET_STATE_ACTIVE;
20368 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, select))
20369 *state |= NK_WIDGET_STATE_ENTERED;
20371 *state |= NK_WIDGET_STATE_LEFT;
20376 nk_flags state, const struct nk_style_toggle *style, int active,
20386 if (state & NK_WIDGET_STATE_HOVER) {
20390 } else if (state & NK_WIDGET_STATE_ACTIVED) {
20418 nk_flags state, const struct nk_style_toggle *style, int active,
20428 if (state & NK_WIDGET_STATE_HOVER) {
20432 } else if (state & NK_WIDGET_STATE_ACTIVED) {
20459 nk_do_toggle(nk_flags *state,
20506 *active = nk_toggle_behavior(in, bounds, state, *active);
20512 nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20514 nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
20534 enum nk_widget_layout_states state;
20546 state = nk_widget(&bounds, ctx);
20547 if (!state) return active;
20548 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20629 enum nk_widget_layout_states state;
20641 state = nk_widget(&bounds, ctx);
20642 if (!state) return (int)state;
20643 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20682 nk_flags state, const struct nk_style_selectable *style, int active,
20693 if (state & NK_WIDGET_STATE_ACTIVED) {
20696 } else if (state & NK_WIDGET_STATE_HOVER) {
20704 if (state & NK_WIDGET_STATE_ACTIVED) {
20707 } else if (state & NK_WIDGET_STATE_HOVER) {
20730 nk_do_selectable(nk_flags *state, struct nk_command_buffer *out,
20738 NK_ASSERT(state);
20746 if (!state || !out || !str || !len || !value || !style || !font) return 0;
20756 if (nk_button_behavior(state, touch, in, NK_BUTTON_DEFAULT))
20761 nk_draw_selectable(out, *state, style, *value, &bounds, 0,0,NK_SYMBOL_NONE, str, len, align, font);
20766 nk_do_selectable_image(nk_flags *state, struct nk_command_buffer *out,
20775 NK_ASSERT(state);
20783 if (!state || !out || !str || !len || !value || !style || !font) return 0;
20791 if (nk_button_behavior(state, touch, in, NK_BUTTON_DEFAULT))
20808 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, img, NK_SYMBOL_NONE, str, len, align, font);
20813 nk_do_selectable_symbol(nk_flags *state, struct nk_command_buffer *out,
20822 NK_ASSERT(state);
20830 if (!state || !out || !str || !len || !value || !style || !font) return 0;
20838 if (nk_button_behavior(state, touch, in, NK_BUTTON_DEFAULT))
20855 nk_draw_selectable(out, *state, style, *value, &bounds, &icon, 0, sym, str, len, align, font);
20869 enum nk_widget_layout_states state;
20883 state = nk_widget(&bounds, ctx);
20884 if (!state) return 0;
20885 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20898 enum nk_widget_layout_states state;
20912 state = nk_widget(&bounds, ctx);
20913 if (!state) return 0;
20914 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
20927 enum nk_widget_layout_states state;
20941 state = nk_widget(&bounds, ctx);
20942 if (!state) return 0;
20943 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
21004 nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor,
21013 nk_widget_state_reset(state);
21024 *state = NK_WIDGET_STATE_ACTIVE;
21035 /* slider widget state */
21037 *state = NK_WIDGET_STATE_HOVERED;
21038 if (*state & NK_WIDGET_STATE_HOVER &&
21040 *state |= NK_WIDGET_STATE_ENTERED;
21042 *state |= NK_WIDGET_STATE_LEFT;
21046 nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
21062 if (state & NK_WIDGET_STATE_ACTIVED) {
21066 } else if (state & NK_WIDGET_STATE_HOVER) {
21105 nk_do_slider(nk_flags *state,
21183 slider_value = nk_slider_behavior(state, &logical_cursor, &visual_cursor,
21189 nk_draw_slider(out, *state, style, &bounds, &visual_cursor, slider_min, slider_value, slider_max);
21205 enum nk_widget_layout_states state;
21218 state = nk_widget(&bounds, ctx);
21219 if (!state) return ret;
21220 in = (/*state == NK_WIDGET_ROM || */ layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
21259 nk_progress_behavior(nk_flags *state, struct nk_input *in,
21265 nk_widget_state_reset(state);
21271 *state = NK_WIDGET_STATE_HOVERED;
21278 *state |= NK_WIDGET_STATE_ACTIVE;
21281 /* set progressbar widget state */
21282 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, r))
21283 *state |= NK_WIDGET_STATE_ENTERED;
21285 *state |= NK_WIDGET_STATE_LEFT;
21289 nk_draw_progress(struct nk_command_buffer *out, nk_flags state,
21300 if (state & NK_WIDGET_STATE_ACTIVED) {
21303 } else if (state & NK_WIDGET_STATE_HOVER){
21324 nk_do_progress(nk_flags *state,
21345 prog_value = nk_progress_behavior(state, in, bounds, cursor,max, prog_value, modifiable);
21350 nk_draw_progress(out, *state, style, &bounds, &cursor, value, max);
21363 enum nk_widget_layout_states state;
21376 state = nk_widget(&bounds, ctx);
21377 if (!state) return 0;
21379 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
21402 nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
21414 nk_widget_state_reset(state);
21422 *state = NK_WIDGET_STATE_HOVERED;
21428 *state = NK_WIDGET_STATE_ACTIVE;
21471 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, *scroll))
21472 *state |= NK_WIDGET_STATE_ENTERED;
21474 *state |= NK_WIDGET_STATE_LEFT;
21478 nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state,
21486 if (state & NK_WIDGET_STATE_ACTIVED) {
21489 } else if (state & NK_WIDGET_STATE_HOVER) {
21512 nk_do_scrollbarv(nk_flags *state,
21529 NK_ASSERT(state);
21589 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21596 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21601 nk_do_scrollbarh(nk_flags *state,
21677 scroll_offset = nk_scrollbar_behavior(state, in, has_scrolling, &scroll, &cursor,
21684 nk_draw_scrollbar(out, *state, style, &scroll, &cursor);
21813 nk_textedit_click(struct nk_text_edit *state, float x, float y,
21818 state->cursor = nk_textedit_locate_coord(state, x, y, font, row_height);
21819 state->select_start = state->cursor;
21820 state->select_end = state->cursor;
21821 state->has_preferred_x = 0;
21824 nk_textedit_drag(struct nk_text_edit *state, float x, float y,
21829 int p = nk_textedit_locate_coord(state, x, y, font, row_height);
21830 if (state->select_start == state->select_end)
21831 state->select_start = state->cursor;
21832 state->cursor = state->select_end = p;
21835 nk_textedit_find_charpos(struct nk_text_find *find, struct nk_text_edit *state,
21842 int z = state->string.len;
21849 nk_textedit_layout_row(&r, state, 0, row_height, font);
21857 nk_textedit_layout_row(&r, state, i, row_height, font);
21874 nk_textedit_layout_row(&r, state, i, row_height, font);
21889 find->x += nk_textedit_get_width(state, first, i, font);
21892 nk_textedit_clamp(struct nk_text_edit *state)
21894 /* make the selection/cursor state valid if client altered the string */
21895 int n = state->string.len;
21896 if (NK_TEXT_HAS_SELECTION(state)) {
21897 if (state->select_start > n) state->select_start = n;
21898 if (state->select_end > n) state->select_end = n;
21900 if (state->select_start == state->select_end)
21901 state->cursor = state->select_start;
21903 if (state->cursor > n) state->cursor = n;
21906 nk_textedit_delete(struct nk_text_edit *state, int where, int len)
21909 nk_textedit_makeundo_delete(state, where, len);
21910 nk_str_delete_runes(&state->string, where, len);
21911 state->has_preferred_x = 0;
21914 nk_textedit_delete_selection(struct nk_text_edit *state)
21917 nk_textedit_clamp(state);
21918 if (NK_TEXT_HAS_SELECTION(state)) {
21919 if (state->select_start < state->select_end) {
21920 nk_textedit_delete(state, state->select_start,
21921 state->select_end - state->select_start);
21922 state->select_end = state->cursor = state->select_start;
21924 nk_textedit_delete(state, state->select_end,
21925 state->select_start - state->select_end);
21926 state->select_start = state->cursor = state->select_end;
21928 state->has_preferred_x = 0;
21932 nk_textedit_sortselection(struct nk_text_edit *state)
21935 if (state->select_end < state->select_start) {
21936 int temp = state->select_end;
21937 state->select_end = state->select_start;
21938 state->select_start = temp;
21942 nk_textedit_move_to_first(struct nk_text_edit *state)
21945 if (NK_TEXT_HAS_SELECTION(state)) {
21946 nk_textedit_sortselection(state);
21947 state->cursor = state->select_start;
21948 state->select_end = state->select_start;
21949 state->has_preferred_x = 0;
21953 nk_textedit_move_to_last(struct nk_text_edit *state)
21956 if (NK_TEXT_HAS_SELECTION(state)) {
21957 nk_textedit_sortselection(state);
21958 nk_textedit_clamp(state);
21959 state->cursor = state->select_end;
21960 state->select_start = state->select_end;
21961 state->has_preferred_x = 0;
21965 nk_is_word_boundary( struct nk_text_edit *state, int idx)
21970 if (!nk_str_at_rune(&state->string, idx, &c, &len)) return 1;
21976 nk_textedit_move_to_word_previous(struct nk_text_edit *state)
21978 int c = state->cursor - 1;
21979 while( c >= 0 && !nk_is_word_boundary(state, c))
21988 nk_textedit_move_to_word_next(struct nk_text_edit *state)
21990 const int len = state->string.len;
21991 int c = state->cursor+1;
21992 while( c < len && !nk_is_word_boundary(state, c))
22001 nk_textedit_prep_selection_at_cursor(struct nk_text_edit *state)
22004 if (!NK_TEXT_HAS_SELECTION(state))
22005 state->select_start = state->select_end = state->cursor;
22006 else state->cursor = state->select_end;
22009 nk_textedit_cut(struct nk_text_edit *state)
22012 if (state->mode == NK_TEXT_EDIT_MODE_VIEW)
22014 if (NK_TEXT_HAS_SELECTION(state)) {
22015 nk_textedit_delete_selection(state); /* implicitly clamps */
22016 state->has_preferred_x = 0;
22022 nk_textedit_paste(struct nk_text_edit *state, char const *ctext, int len)
22027 if (state->mode == NK_TEXT_EDIT_MODE_VIEW) return 0;
22030 nk_textedit_clamp(state);
22031 nk_textedit_delete_selection(state);
22035 if (nk_str_insert_text_char(&state->string, state->cursor, text, len)) {
22036 nk_textedit_makeundo_insert(state, state->cursor, glyphs);
22037 state->cursor += len;
22038 state->has_preferred_x = 0;
22042 if (state->undo.undo_point)
22043 --state->undo.undo_point;
22047 nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len)
22053 NK_ASSERT(state);
22055 if (!text || !total_len || state->mode == NK_TEXT_EDIT_MODE_VIEW) return;
22063 if (unicode == '\n' && state->single_line) goto next;
22065 if (state->filter && !state->filter(state, unicode)) goto next;
22067 if (!NK_TEXT_HAS_SELECTION(state) &&
22068 state->cursor < state->string.len)
22070 if (state->mode == NK_TEXT_EDIT_MODE_REPLACE) {
22071 nk_textedit_makeundo_replace(state, state->cursor, 1, 1);
22072 nk_str_delete_runes(&state->string, state->cursor, 1);
22074 if (nk_str_insert_text_utf8(&state->string, state->cursor,
22077 ++state->cursor;
22078 state->has_preferred_x = 0;
22081 nk_textedit_delete_selection(state); /* implicitly clamps */
22082 if (nk_str_insert_text_utf8(&state->string, state->cursor,
22085 nk_textedit_makeundo_insert(state, state->cursor, 1);
22086 ++state->cursor;
22087 state->has_preferred_x = 0;
22096 nk_textedit_key(struct nk_text_edit *state, enum nk_keys key, int shift_mod,
22113 nk_textedit_undo(state);
22114 state->has_preferred_x = 0;
22118 nk_textedit_redo(state);
22119 state->has_preferred_x = 0;
22123 nk_textedit_select_all(state);
22124 state->has_preferred_x = 0;
22128 if (state->mode == NK_TEXT_EDIT_MODE_VIEW)
22129 state->mode = NK_TEXT_EDIT_MODE_INSERT;
22132 if (state->mode == NK_TEXT_EDIT_MODE_VIEW)
22133 state->mode = NK_TEXT_EDIT_MODE_REPLACE;
22136 if (state->mode == NK_TEXT_EDIT_MODE_INSERT ||
22137 state->mode == NK_TEXT_EDIT_MODE_REPLACE)
22138 state->mode = NK_TEXT_EDIT_MODE_VIEW;
22143 nk_textedit_clamp(state);
22144 nk_textedit_prep_selection_at_cursor(state);
22146 if (state->select_end > 0)
22147 --state->select_end;
22148 state->cursor = state->select_end;
22149 state->has_preferred_x = 0;
22153 if (NK_TEXT_HAS_SELECTION(state))
22154 nk_textedit_move_to_first(state);
22155 else if (state->cursor > 0)
22156 --state->cursor;
22157 state->has_preferred_x = 0;
22162 nk_textedit_prep_selection_at_cursor(state);
22164 ++state->select_end;
22165 nk_textedit_clamp(state);
22166 state->cursor = state->select_end;
22167 state->has_preferred_x = 0;
22171 if (NK_TEXT_HAS_SELECTION(state))
22172 nk_textedit_move_to_last(state);
22173 else ++state->cursor;
22174 nk_textedit_clamp(state);
22175 state->has_preferred_x = 0;
22180 if( !NK_TEXT_HAS_SELECTION( state ) )
22181 nk_textedit_prep_selection_at_cursor(state);
22182 state->cursor = nk_textedit_move_to_word_previous(state);
22183 state->select_end = state->cursor;
22184 nk_textedit_clamp(state );
22186 if (NK_TEXT_HAS_SELECTION(state))
22187 nk_textedit_move_to_first(state);
22189 state->cursor = nk_textedit_move_to_word_previous(state);
22190 nk_textedit_clamp(state );
22196 if( !NK_TEXT_HAS_SELECTION( state ) )
22197 nk_textedit_prep_selection_at_cursor(state);
22198 state->cursor = nk_textedit_move_to_word_next(state);
22199 state->select_end = state->cursor;
22200 nk_textedit_clamp(state);
22202 if (NK_TEXT_HAS_SELECTION(state))
22203 nk_textedit_move_to_last(state);
22205 state->cursor = nk_textedit_move_to_word_next(state);
22206 nk_textedit_clamp(state );
22215 if (state->single_line) {
22222 nk_textedit_prep_selection_at_cursor(state);
22223 else if (NK_TEXT_HAS_SELECTION(state))
22224 nk_textedit_move_to_last(state);
22227 nk_textedit_clamp(state);
22228 nk_textedit_find_charpos(&find, state, state->cursor, state->single_line,
22235 float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
22238 state->cursor = start;
22239 nk_textedit_layout_row(&row, state, state->cursor, row_height, font);
22243 float dx = nk_textedit_get_width(state, start, i, font);
22247 ++state->cursor;
22249 nk_textedit_clamp(state);
22251 state->has_preferred_x = 1;
22252 state->preferred_x = goal_x;
22254 state->select_end = state->cursor;
22263 if (state->single_line) {
22270 nk_textedit_prep_selection_at_cursor(state);
22271 else if (NK_TEXT_HAS_SELECTION(state))
22272 nk_textedit_move_to_first(state);
22275 nk_textedit_clamp(state);
22276 nk_textedit_find_charpos(&find, state, state->cursor, state->single_line,
22283 float goal_x = state->has_preferred_x ? state->preferred_x : find.x;
22285 state->cursor = find.prev_first;
22286 nk_textedit_layout_row(&row, state, state->cursor, row_height, font);
22290 float dx = nk_textedit_get_width(state, find.prev_first, i, font);
22294 ++state->cursor;
22296 nk_textedit_clamp(state);
22298 state->has_preferred_x = 1;
22299 state->preferred_x = goal_x;
22300 if (sel) state->select_end = state->cursor;
22305 if (state->mode == NK_TEXT_EDIT_MODE_VIEW)
22307 if (NK_TEXT_HAS_SELECTION(state))
22308 nk_textedit_delete_selection(state);
22310 int n = state->string.len;
22311 if (state->cursor < n)
22312 nk_textedit_delete(state, state->cursor, 1);
22314 state->has_preferred_x = 0;
22318 if (state->mode == NK_TEXT_EDIT_MODE_VIEW)
22320 if (NK_TEXT_HAS_SELECTION(state))
22321 nk_textedit_delete_selection(state);
22323 nk_textedit_clamp(state);
22324 if (state->cursor > 0) {
22325 nk_textedit_delete(state, state->cursor-1, 1);
22326 --state->cursor;
22329 state->has_preferred_x = 0;
22334 nk_textedit_prep_selection_at_cursor(state);
22335 state->cursor = state->select_end = 0;
22336 state->has_preferred_x = 0;
22338 state->cursor = state->select_start = state->select_end = 0;
22339 state->has_preferred_x = 0;
22345 nk_textedit_prep_selection_at_cursor(state);
22346 state->cursor = state->select_end = state->string.len;
22347 state->has_preferred_x = 0;
22349 state->cursor = state->string.len;
22350 state->select_start = state->select_end = 0;
22351 state->has_preferred_x = 0;
22358 nk_textedit_clamp(state);
22359 nk_textedit_prep_selection_at_cursor(state);
22360 if (state->string.len && state->cursor == state->string.len)
22361 --state->cursor;
22362 nk_textedit_find_charpos(&find, state,state->cursor, state->single_line,
22364 state->cursor = state->select_end = find.first_char;
22365 state->has_preferred_x = 0;
22368 if (state->string.len && state->cursor == state->string.len)
22369 --state->cursor;
22370 nk_textedit_clamp(state);
22371 nk_textedit_move_to_first(state);
22372 nk_textedit_find_charpos(&find, state, state->cursor, state->single_line,
22374 state->cursor = find.first_char;
22375 state->has_preferred_x = 0;
22382 nk_textedit_clamp(state);
22383 nk_textedit_prep_selection_at_cursor(state);
22384 nk_textedit_find_charpos(&find, state, state->cursor, state->single_line,
22386 state->has_preferred_x = 0;
22387 state->cursor = find.first_char + find.length;
22388 if (find.length > 0 && nk_str_rune_at(&state->string, state->cursor-1) == '\n')
22389 --state->cursor;
22390 state->select_end = state->cursor;
22393 nk_textedit_clamp(state);
22394 nk_textedit_move_to_first(state);
22395 nk_textedit_find_charpos(&find, state, state->cursor, state->single_line,
22398 state->has_preferred_x = 0;
22399 state->cursor = find.first_char + find.length;
22400 if (find.length > 0 && nk_str_rune_at(&state->string, state->cursor-1) == '\n')
22401 --state->cursor;
22406 nk_textedit_flush_redo(struct nk_text_undo_state *state)
22408 state->redo_point = NK_TEXTEDIT_UNDOSTATECOUNT;
22409 state->redo_char_point = NK_TEXTEDIT_UNDOCHARCOUNT;
22412 nk_textedit_discard_undo(struct nk_text_undo_state *state)
22415 if (state->undo_point > 0) {
22416 /* if the 0th undo state has characters, clean those up */
22417 if (state->undo_rec[0].char_storage >= 0) {
22418 int n = state->undo_rec[0].insert_length, i;
22420 state->undo_char_point = (short)(state->undo_char_point - n);
22421 NK_MEMCPY(state->undo_char, state->undo_char + n,
22422 (nk_size)state->undo_char_point*sizeof(nk_rune));
22423 for (i=0; i < state->undo_point; ++i) {
22424 if (state->undo_rec[i].char_storage >= 0)
22425 state->undo_rec[i].char_storage = (short)
22426 (state->undo_rec[i].char_storage - n);
22429 --state->undo_point;
22430 NK_MEMCPY(state->undo_rec, state->undo_rec+1,
22431 (nk_size)((nk_size)state->undo_point * sizeof(state->undo_rec[0])));
22435 nk_textedit_discard_redo(struct nk_text_undo_state *state)
22443 if (state->redo_point <= k) {
22444 /* if the k'th undo state has characters, clean those up */
22445 if (state->undo_rec[k].char_storage >= 0) {
22446 int n = state->undo_rec[k].insert_length, i;
22448 state->redo_char_point = (short)(state->redo_char_point + n);
22449 num = (nk_size)(NK_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point);
22450 NK_MEMCPY(state->undo_char + state->redo_char_point,
22451 state->undo_char + state->redo_char_point-n, num * sizeof(char));
22452 for (i = state->redo_point; i < k; ++i) {
22453 if (state->undo_rec[i].char_storage >= 0) {
22454 state->undo_rec[i].char_storage = (short)
22455 (state->undo_rec[i].char_storage + n);
22459 ++state->redo_point;
22460 num = (nk_size)(NK_TEXTEDIT_UNDOSTATECOUNT - state->redo_point);
22461 if (num) NK_MEMCPY(state->undo_rec + state->redo_point-1,
22462 state->undo_rec + state->redo_point, num * sizeof(state->undo_rec[0]));
22466 nk_textedit_create_undo_record(struct nk_text_undo_state *state, int numchars)
22469 nk_textedit_flush_redo(state);
22473 if (state->undo_point == NK_TEXTEDIT_UNDOSTATECOUNT)
22474 nk_textedit_discard_undo(state);
22479 state->undo_point = 0;
22480 state->undo_char_point = 0;
22486 while (state->undo_char_point + numchars > NK_TEXTEDIT_UNDOCHARCOUNT)
22487 nk_textedit_discard_undo(state);
22488 return &state->undo_rec[state->undo_point++];
22491 nk_textedit_createundo(struct nk_text_undo_state *state, int pos,
22494 struct nk_text_undo_record *r = nk_textedit_create_undo_record(state, insert_len);
22506 r->char_storage = state->undo_char_point;
22507 state->undo_char_point = (short)(state->undo_char_point + insert_len);
22508 return &state->undo_char[r->char_storage];
22512 nk_textedit_undo(struct nk_text_edit *state)
22514 struct nk_text_undo_state *s = &state->undo;
22560 nk_str_rune_at(&state->string, u.where + i);
22563 nk_str_delete_runes(&state->string, u.where, u.delete_length);
22569 nk_str_insert_text_runes(&state->string, u.where,
22573 state->cursor = (short)(u.where + u.insert_length);
22579 nk_textedit_redo(struct nk_text_edit *state)
22581 struct nk_text_undo_state *s = &state->undo;
22611 nk_str_rune_at(&state->string, u->where + i);
22614 nk_str_delete_runes(&state->string, r.where, r.delete_length);
22619 nk_str_insert_text_runes(&state->string, r.where,
22622 state->cursor = r.where + r.insert_length;
22628 nk_textedit_makeundo_insert(struct nk_text_edit *state, int where, int length)
22630 nk_textedit_createundo(&state->undo, where, 0, length);
22633 nk_textedit_makeundo_delete(struct nk_text_edit *state, int where, int length)
22636 nk_rune *p = nk_textedit_createundo(&state->undo, where, length, 0);
22639 p[i] = nk_str_rune_at(&state->string, where+i);
22643 nk_textedit_makeundo_replace(struct nk_text_edit *state, int where,
22647 nk_rune *p = nk_textedit_createundo(&state->undo, where, old_length, new_length);
22650 p[i] = nk_str_rune_at(&state->string, where+i);
22654 nk_textedit_clear_state(struct nk_text_edit *state, enum nk_text_edit_type type,
22657 /* reset the state to default */
22658 state->undo.undo_point = 0;
22659 state->undo.undo_char_point = 0;
22660 state->undo.redo_point = NK_TEXTEDIT_UNDOSTATECOUNT;
22661 state->undo.redo_char_point = NK_TEXTEDIT_UNDOCHARCOUNT;
22662 state->select_end = state->select_start = 0;
22663 state->cursor = 0;
22664 state->has_preferred_x = 0;
22665 state->preferred_x = 0;
22666 state->cursor_at_end_of_line = 0;
22667 state->initialized = 1;
22668 state->single_line = (unsigned char)(type == NK_TEXT_EDIT_SINGLE_LINE);
22669 state->mode = NK_TEXT_EDIT_MODE_VIEW;
22670 state->filter = filter;
22671 state->scrollbar = nk_vec2(0,0);
22674 nk_textedit_init_fixed(struct nk_text_edit *state, void *memory, nk_size size)
22676 NK_ASSERT(state);
22678 if (!state || !memory || !size) return;
22679 NK_MEMSET(state, 0, sizeof(struct nk_text_edit));
22680 nk_textedit_clear_state(state, NK_TEXT_EDIT_SINGLE_LINE, 0);
22681 nk_str_init_fixed(&state->string, memory, size);
22684 nk_textedit_init(struct nk_text_edit *state, struct nk_allocator *alloc, nk_size size)
22686 NK_ASSERT(state);
22688 if (!state || !alloc) return;
22689 NK_MEMSET(state, 0, sizeof(struct nk_text_edit));
22690 nk_textedit_clear_state(state, NK_TEXT_EDIT_SINGLE_LINE, 0);
22691 nk_str_init(&state->string, alloc, size);
22695 nk_textedit_init_default(struct nk_text_edit *state)
22697 NK_ASSERT(state);
22698 if (!state) return;
22699 NK_MEMSET(state, 0, sizeof(struct nk_text_edit));
22700 nk_textedit_clear_state(state, NK_TEXT_EDIT_SINGLE_LINE, 0);
22701 nk_str_init_default(&state->string);
22705 nk_textedit_select_all(struct nk_text_edit *state)
22707 NK_ASSERT(state);
22708 state->select_start = 0;
22709 state->select_end = state->string.len;
22712 nk_textedit_free(struct nk_text_edit *state)
22714 NK_ASSERT(state);
22715 if (!state) return;
22716 nk_str_free(&state->string);
22871 nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
22886 NK_ASSERT(state);
22889 if (!state || !out || !style)
22905 /* update edit state */
23027 /* set widget state */
23029 *state = NK_WIDGET_STATE_ACTIVE;
23030 else nk_widget_state_reset(state);
23033 *state |= NK_WIDGET_STATE_HOVERED;
23041 if (*state & NK_WIDGET_STATE_ACTIVED)
23043 else if (*state & NK_WIDGET_STATE_HOVER)
23230 if (*state & NK_WIDGET_STATE_ACTIVED) {
23237 } else if (*state & NK_WIDGET_STATE_HOVER) {
23349 if (*state & NK_WIDGET_STATE_ACTIVED) {
23352 } else if (*state & NK_WIDGET_STATE_HOVER) {
23403 nk_flags state;
23442 state = nk_edit_buffer(ctx, flags, edit, filter);
23452 } return state;
23462 enum nk_widget_layout_states state;
23479 state = nk_widget(&bounds, ctx);
23480 if (!state) return state;
23536 nk_drag_behavior(nk_flags *state, const struct nk_input *in,
23544 nk_widget_state_reset(state);
23546 *state = NK_WIDGET_STATE_HOVERED;
23567 *state = NK_WIDGET_STATE_ACTIVE;
23569 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, drag))
23570 *state |= NK_WIDGET_STATE_ENTERED;
23572 *state |= NK_WIDGET_STATE_LEFT;
23577 struct nk_rect empty, int *state, struct nk_property_variant *variant,
23580 if (in && *state == NK_PROPERTY_DEFAULT) {
23582 *state = NK_PROPERTY_EDIT;
23584 *state = NK_PROPERTY_DRAG;
23586 *state = NK_PROPERTY_DRAG;
23588 if (*state == NK_PROPERTY_DRAG) {
23590 if (!(*ws & NK_WIDGET_STATE_ACTIVED)) *state = NK_PROPERTY_DEFAULT;
23595 const struct nk_rect *bounds, const struct nk_rect *label, nk_flags state,
23602 if (state & NK_WIDGET_STATE_ACTIVED) {
23605 } else if (state & NK_WIDGET_STATE_HOVER) {
23632 int *state, int *cursor, int *select_begin, int *select_end,
23677 if (*state == NK_PROPERTY_EDIT) {
23716 old = (*state == NK_PROPERTY_EDIT);
23717 nk_property_behavior(ws, in, property, label, edit, empty, state, variant, inc_per_pixel);
23748 if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) {
23756 } else active = (*state == NK_PROPERTY_EDIT);
23771 filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
23782 *state = NK_PROPERTY_DEFAULT;
23849 int *state = 0;
23888 state = &win->property.state;
23895 state = &dummy_state;
23901 old_state = *state;
23906 variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
23910 if (in && *state != NK_PROPERTY_DEFAULT && !win->property.active) {
23916 win->property.state = *state;
23920 if (*state == NK_PROPERTY_DRAG) {
23926 if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {
24351 nk_color_picker_behavior(nk_flags *state,
24360 NK_ASSERT(state);
24367 if (nk_button_behavior(state, *matrix, in, NK_BUTTON_REPEATER)) {
24373 if (nk_button_behavior(state, *hue_bar, in, NK_BUTTON_REPEATER)) {
24379 if (nk_button_behavior(state, *alpha_bar, in, NK_BUTTON_REPEATER)) {
24384 nk_widget_state_reset(state);
24387 *state = NK_WIDGET_STATE_ACTIVE;
24391 *state = NK_WIDGET_STATE_ACTIVE;
24393 /* set color picker widget state */
24395 *state = NK_WIDGET_STATE_HOVERED;
24396 if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, *bounds))
24397 *state |= NK_WIDGET_STATE_ENTERED;
24399 *state |= NK_WIDGET_STATE_LEFT;
24462 nk_do_color_picker(nk_flags *state,
24476 NK_ASSERT(state);
24478 if (!out || !col || !state || !font)
24502 ret = nk_color_picker_behavior(state, &bounds, &matrix, &hue_bar,
24516 enum nk_widget_layout_states state;
24529 state = nk_widget(&bounds, ctx);
24530 if (!state) return 0;
24531 in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
25484 /// - 2018/10/31 (4.00.2) - Added NK_KEYSTATE_BASED_INPUT to "fix" state based backends
25574 /// - 2016/11/10 (1.27.0) - Added additional `nk_tree` versions to support external state