added documentation to editbox
This commit is contained in:
parent
6e86465606
commit
4694584a91
10
gui.c
10
gui.c
|
@ -1067,7 +1067,7 @@ gui_edit_box_get_const(struct gui_edit_box *eb)
|
|||
}
|
||||
|
||||
gui_char
|
||||
gui_edit_box_at_byte(struct gui_edit_box *eb, gui_size pos)
|
||||
gui_edit_box_at_char(struct gui_edit_box *eb, gui_size pos)
|
||||
{
|
||||
gui_char *c;
|
||||
GUI_ASSERT(eb);
|
||||
|
@ -1131,7 +1131,7 @@ gui_edit_box_get_cursor(struct gui_edit_box *eb)
|
|||
}
|
||||
|
||||
gui_size
|
||||
gui_edit_box_len_byte(struct gui_edit_box *eb)
|
||||
gui_edit_box_len_char(struct gui_edit_box *eb)
|
||||
{
|
||||
GUI_ASSERT(eb);
|
||||
return eb->buffer.allocated;
|
||||
|
@ -2686,7 +2686,6 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel,
|
|||
in->mouse_down)
|
||||
{
|
||||
gui_float py;
|
||||
|
||||
bounds.y += in->mouse_delta.y;
|
||||
bounds.h += -in->mouse_delta.y;
|
||||
scaler.y = bounds.y;
|
||||
|
@ -2744,7 +2743,6 @@ gui_panel_begin_tiled(struct gui_panel_layout *tile, struct gui_panel *panel,
|
|||
!(layout->flags & GUI_LAYOUT_INACTIVE))
|
||||
{
|
||||
gui_float cx, lx;
|
||||
|
||||
bounds.w -= in->mouse_delta.x;
|
||||
bounds.x += in->mouse_delta.x;
|
||||
bounds.w = MAX(config->properties[GUI_PROPERTY_SIZE].x, bounds.w);
|
||||
|
@ -2913,9 +2911,9 @@ gui_panel_row_templated(struct gui_panel_layout *layout, gui_float height,
|
|||
static void
|
||||
gui_panel_alloc_row(struct gui_panel_layout *layout)
|
||||
{
|
||||
const gui_float *ratio;
|
||||
const struct gui_config *c = layout->config;
|
||||
enum gui_panel_row_layout_type type = layout->row.type;
|
||||
const gui_float *ratio;
|
||||
struct gui_vec2 spacing = gui_config_property(c, GUI_PROPERTY_ITEM_SPACING);
|
||||
const gui_float row_height = layout->row.height - spacing.y;
|
||||
|
||||
|
@ -2952,7 +2950,7 @@ gui_panel_alloc_space(struct gui_rect *bounds, struct gui_panel_layout *layout)
|
|||
if (layout->index >= layout->row.columns)
|
||||
gui_panel_alloc_row(layout);
|
||||
|
||||
/* calculate the total width of the useable panel space */
|
||||
/* calculate the useable panel space */
|
||||
panel_padding = 2 * padding.x;
|
||||
panel_spacing = (gui_float)(layout->row.columns - 1) * spacing.x;
|
||||
panel_space = layout->width - panel_padding - panel_spacing;
|
||||
|
|
64
gui.h
64
gui.h
|
@ -719,24 +719,84 @@ gui_bool gui_filter_input_binary(gui_long unicode);
|
|||
/* editbox */
|
||||
void gui_edit_box_init(struct gui_edit_box*, struct gui_allocator*, gui_size initial,
|
||||
gui_float grow_fac, const struct gui_clipboard*, gui_filter);
|
||||
/* this function initializes the editbox a growing buffer
|
||||
Input:
|
||||
- allocator implementation
|
||||
- initital buffer size
|
||||
- buffer growing factor
|
||||
- clipboard implementation for copy&paste or NULL of not needed
|
||||
- character filtering callback to limit input or NULL of not needed
|
||||
*/
|
||||
void gui_edit_box_init_fixed(struct gui_edit_box*, void *memory, gui_size size,
|
||||
const struct gui_clipboard*, gui_filter);
|
||||
/* this function initializes the editbox a static buffer
|
||||
Input:
|
||||
- memory block to fill
|
||||
- sizeo of the memory block
|
||||
- clipboard implementation for copy&paste or NULL of not needed
|
||||
- character filtering callback to limit input or NULL of not needed
|
||||
*/
|
||||
#define gui_edit_box_reset(b)\
|
||||
do {gui_buffer_reset(&(b)->buffer); (b)->cursor = (b)->glyphes = 0;} while(0);
|
||||
/* this function resets the buffer and sets everything back into a clean state */
|
||||
#define gui_edit_box_clear(b) gui_buffer_clear(&(b)->buffer)
|
||||
/* this function frees all internal memory in a dynamically growing buffer */
|
||||
#define gui_edit_box_info(status, b)\
|
||||
gui_buffer_info((status), &(b)->buffer)
|
||||
/* this function return information about the memory in use */
|
||||
void gui_edit_box_add(struct gui_edit_box*, const char*, gui_size);
|
||||
/* this function adds text at the current cursor position
|
||||
Input:
|
||||
- string buffer or glyph to copy/add to the buffer
|
||||
- length of the string buffer or glyph
|
||||
*/
|
||||
void gui_edit_box_remove(struct gui_edit_box*);
|
||||
/* removes the glyph at the current cursor position */
|
||||
gui_char *gui_edit_box_get(struct gui_edit_box*);
|
||||
/* returns the string buffer inside the edit box */
|
||||
const gui_char *gui_edit_box_get_const(struct gui_edit_box*);
|
||||
/* returns the constant string buffer inside the edit box */
|
||||
void gui_edit_box_at(struct gui_edit_box*, gui_size pos, gui_glyph, gui_size*);
|
||||
/* this function returns the glyph at a given offset
|
||||
Input:
|
||||
- glyph offset inside the buffer
|
||||
Output:
|
||||
- utf8 glyph at the given position
|
||||
- byte length of the glyph
|
||||
*/
|
||||
void gui_edit_box_at_cursor(struct gui_edit_box*, gui_glyph, gui_size*);
|
||||
gui_char gui_edit_box_at_byte(struct gui_edit_box*, gui_size pos);
|
||||
/* this function returns the glyph at the cursor
|
||||
Output:
|
||||
- utf8 glyph at the cursor position
|
||||
- byte length of the glyph
|
||||
*/
|
||||
gui_char gui_edit_box_at_char(struct gui_edit_box*, gui_size pos);
|
||||
/* this function returns the character at a given byte position
|
||||
Input:
|
||||
- character offset inside the buffer
|
||||
Output:
|
||||
- character at the given position
|
||||
*/
|
||||
void gui_edit_box_set_cursor(struct gui_edit_box*, gui_size pos);
|
||||
/* this function sets the cursor at a given glyph position
|
||||
Input:
|
||||
- glyph offset inside the buffer
|
||||
*/
|
||||
gui_size gui_edit_box_get_cursor(struct gui_edit_box *eb);
|
||||
gui_size gui_edit_box_len_byte(struct gui_edit_box*);
|
||||
/* this function returns the cursor glyph position
|
||||
Output:
|
||||
- cursor glyph offset inside the buffer
|
||||
*/
|
||||
gui_size gui_edit_box_len_char(struct gui_edit_box*);
|
||||
/* this function returns length of the buffer in bytes
|
||||
Output:
|
||||
- string buffer byte length
|
||||
*/
|
||||
gui_size gui_edit_box_len(struct gui_edit_box*);
|
||||
/* this function returns length of the buffer in glyphes
|
||||
Output:
|
||||
- string buffer glyph length
|
||||
*/
|
||||
/*
|
||||
* ==============================================================
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue