fixed 'modifyable' API typo

This commit is contained in:
vurtun 2015-12-03 18:54:41 +01:00
parent 68f03fcffe
commit 89e7043b05
3 changed files with 36 additions and 39 deletions

View File

@ -115,7 +115,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
static int slider = 10;
static int check = zr_true;
zr_layout_row_dynamic(&menu, 25, 1);
zr_progress(&menu, &prog, 100, ZR_MODIFYABLE);
zr_progress(&menu, &prog, 100, ZR_MODIFIABLE);
zr_slider_int(&menu, 0, &slider, 16, 1);
zr_checkbox(&menu, "check", &check);
if (zr_menu_item(&menu, ZR_TEXT_CENTERED, "Hide")) {
@ -134,7 +134,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_menu_end(&layout, &menu);
zr_layout_row_push(&layout, 60);
zr_progress(&layout, &mprog, 100, ZR_MODIFYABLE);
zr_progress(&layout, &mprog, 100, ZR_MODIFIABLE);
zr_slider_int(&layout, 0, &mslider, 16, 1);
zr_checkbox(&layout, "check", &mcheck);
@ -262,7 +262,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_contextual_begin(&layout, &menu, ZR_WINDOW_NO_SCROLLBAR, &show_contextual, contextual_bounds);
zr_layout_row_dynamic(&menu, 25, 1);
zr_checkbox(&menu, "Menu", &show_menu);
zr_progress(&menu, &prog, 100, ZR_MODIFYABLE);
zr_progress(&menu, &prog, 100, ZR_MODIFIABLE);
zr_slider_int(&menu, 0, &slider, 16, 1);
if (zr_contextual_item(&menu, "About", ZR_TEXT_CENTERED))
show_app_about = zr_true;
@ -451,7 +451,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_label(&layout, "Slider float", ZR_TEXT_LEFT);
zr_slider_float(&layout, 0, &float_slider, 5.0, 0.5f);
zr_labelf(&layout, ZR_TEXT_LEFT, "Progressbar" , prog_value);
zr_progress(&layout, &prog_value, 100, ZR_MODIFYABLE);
zr_progress(&layout, &prog_value, 100, ZR_MODIFIABLE);
zr_layout_row(&layout, ZR_STATIC, 30, 2, ratio);
zr_label(&layout, "Spinner int:", ZR_TEXT_LEFT);
@ -581,10 +581,10 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_combo_begin(&layout, &combo, buffer, &prog_active);
{
zr_layout_row_dynamic(&combo, 30, 1);
zr_progress(&combo, &x, 100, ZR_MODIFYABLE);
zr_progress(&combo, &y, 100, ZR_MODIFYABLE);
zr_progress(&combo, &z, 100, ZR_MODIFYABLE);
zr_progress(&combo, &w, 100, ZR_MODIFYABLE);
zr_progress(&combo, &x, 100, ZR_MODIFIABLE);
zr_progress(&combo, &y, 100, ZR_MODIFIABLE);
zr_progress(&combo, &z, 100, ZR_MODIFIABLE);
zr_progress(&combo, &w, 100, ZR_MODIFIABLE);
}
zr_combo_end(&layout, &combo, NULL);
@ -629,7 +629,7 @@ show_test_window(struct zr_window *window, struct zr_style *config, enum theme *
zr_label(&layout, "Box:", ZR_TEXT_LEFT);
zr_layout_row_static(&layout, 75, 228, 1);
zr_edit_box(&layout, edit_box, ZR_MODIFYABLE);
zr_edit_box(&layout, edit_box, ZR_MODIFIABLE);
zr_layout_row(&layout, ZR_STATIC, 25, 2, ratio);
zr_edit(&layout, text[7], &text_len[7], 64, &text_active[7], &text_cursor[7], ZR_INPUT_ASCII);

View File

@ -3546,7 +3546,7 @@ zr_font_bake_pack(zr_size *image_memory, int *width, int *height,
ZR_ASSERT(range_n == total_range_count);
}
*height = (int32_t)zr_round_up_pow2((uint32_t)*height);
*image_memory = (zr_size)((*width) * (*height));
*image_memory = (zr_size)(*width) * (zr_size)(*height);
return zr_true;
}
@ -3573,7 +3573,7 @@ zr_font_bake(void *image_memory, int width, int height,
/* second font pass: render glyphes */
baker = (struct zr_font_baker*)ZR_ALIGN_PTR(temp, zr_baker_align);
zr_zero(image_memory, (zr_size)(width * height));
zr_zero(image_memory, (zr_size)((zr_size)width * (zr_size)height));
baker->spc.pixels = (unsigned char*)image_memory;
baker->spc.height = (int)height;
for (input_i = 0; input_i < font_count; ++input_i) {
@ -4399,8 +4399,7 @@ zr_button_behavior(enum zr_widget_states *state, struct zr_rect r,
static void
zr_button_draw(struct zr_command_buffer *o, struct zr_rect r,
const struct zr_button *b, enum zr_widget_states state,
enum zr_button_behavior behavior)
const struct zr_button *b, enum zr_widget_states state)
{
struct zr_color background;
switch (state) {
@ -4433,8 +4432,10 @@ zr_do_button(enum zr_widget_states *state,
pad.x = b->padding.x + b->border_width;
pad.y = b->padding.y + b->border_width;
*content = zr_pad_rect(r, pad);
/* execute and draw button */
ret = zr_button_behavior(state, r, i, behavior);
zr_button_draw(o, r, b, *state, behavior);
zr_button_draw(o, r, b, *state);
return ret;
}
@ -4681,7 +4682,7 @@ zr_toggle_draw(struct zr_command_buffer *out,
}
/* draw toggle text */
if (font && string) {
if (string) {
struct zr_text text;
struct zr_rect inner;
@ -4864,10 +4865,10 @@ struct zr_progress {
static zr_size
zr_progress_behavior(enum zr_widget_states *state, const struct zr_input *in,
struct zr_rect r, zr_size max, zr_size value, int modifyable)
struct zr_rect r, zr_size max, zr_size value, int modifiable)
{
*state = ZR_INACTIVE;
if (in && modifyable && zr_input_is_mouse_hovering_rect(in, r)) {
if (in && modifiable && zr_input_is_mouse_hovering_rect(in, r)) {
if (zr_input_is_mouse_down(in, ZR_BUTTON_LEFT)) {
float ratio = (float)(in->mouse.pos.x - r.x) / (float)r.w;
value = (zr_size)((float)max * ratio);
@ -4904,7 +4905,7 @@ zr_progress_draw(struct zr_command_buffer *out, const struct zr_progress *p,
static zr_size
zr_do_progress(enum zr_widget_states *state,
struct zr_command_buffer *out, struct zr_rect r,
zr_size value, zr_size max, int modifyable,
zr_size value, zr_size max, int modifiable,
const struct zr_progress *prog, const struct zr_input *in)
{
float prog_scale;
@ -4919,7 +4920,7 @@ zr_do_progress(enum zr_widget_states *state,
r = zr_pad_rect(r, zr_vec2(prog->padding.x, prog->padding.y));
prog_value = MIN(value, max);
prog_value = zr_progress_behavior(state, in, r, max, prog_value, modifyable);
prog_value = zr_progress_behavior(state, in, r, max, prog_value, modifiable);
zr_progress_draw(out, prog, *state, r, max, value);
return prog_value;
}
@ -5137,8 +5138,6 @@ zr_do_scrollbarv(enum zr_widget_states *state,
if (target <= scroll.h) return 0;
/* calculate scrollbar constants */
scroll.h = scroll.h;
scroll.y = scroll.y;
scroll_step = MIN(step, scroll.h);
scroll_offset = MIN(offset, target - scroll.h);
scroll_ratio = scroll.h / target;
@ -5205,7 +5204,7 @@ zr_do_scrollbarh(enum zr_widget_states *state,
*
* ===============================================================*/
struct zr_edit {
int modifyable;
int modifiable;
float border_size;
float rounding;
float scrollbar_width;
@ -5486,7 +5485,7 @@ zr_widget_edit_box(struct zr_command_buffer *out, struct zr_rect r,
box->active = ZR_INBOX(in->mouse.pos.x,in->mouse.pos.y,r.x,r.y,r.w,r.h);
/* input handling */
if (box->active && in && field->modifyable)
if (box->active && in && field->modifiable)
zr_edit_box_handle_input(box, in, 1);
buffer = zr_edit_box_get(box);
@ -5768,7 +5767,8 @@ zr_widget_edit_box(struct zr_command_buffer *out, struct zr_rect r,
zr_size cur_text_width;
zr_size sel_begin, sel_end, sel_len;
zr_rune unicode;
float label_x = label.x, label_w = label.w;
float label_x = label.x;
float label_w = label.w;
const char *from = zr_utf_at(&buffer[offset], row_len,
(int)(begin - glyph_off), &unicode, &l);
@ -7082,13 +7082,11 @@ zr_menubar_end(struct zr_context *layout)
layout->at_y = layout->menu.y + layout->menu.h;
zr_command_buffer_push_scissor(out, layout->clip);
}
/*
* -------------------------------------------------------------
/* -------------------------------------------------------------
*
* LAYOUT
*
* --------------------------------------------------------------
*/
* --------------------------------------------------------------*/
static void
zr_panel_layout(struct zr_context *layout, float height, zr_size cols)
{
@ -8211,7 +8209,7 @@ void zr_drag_int(struct zr_context *layout, int min, int *val,
void
zr_progress(struct zr_context *layout, zr_size *cur_value, zr_size max_value,
int is_modifyable)
int is_modifiable)
{
struct zr_rect bounds;
struct zr_progress prog;
@ -8237,7 +8235,7 @@ zr_progress(struct zr_context *layout, zr_size *cur_value, zr_size max_value,
prog.active = config->colors[ZR_COLOR_PROGRESS_CURSOR_ACTIVE];
prog.rounding = config->rounding[ZR_ROUNDING_PROGRESS];
*cur_value = zr_do_progress(&ws, layout->buffer, bounds, *cur_value, max_value,
is_modifyable, &prog, i);
is_modifiable, &prog, i);
}
static enum zr_widget_state
@ -8282,12 +8280,12 @@ zr_edit_field(struct zr_context *layout, struct zr_edit_box *box)
state = zr_edit_base(&bounds, &field, layout);
if (!state) return;
i = (state == ZR_WIDGET_ROM || layout->flags & ZR_WINDOW_ROM) ? 0 : layout->input;
field.modifyable = 1;
field.modifiable = 1;
zr_widget_edit_field(layout->buffer, bounds, box, &field, i, &config->font);
}
void
zr_edit_box(struct zr_context *layout, struct zr_edit_box *box, int modifyable)
zr_edit_box(struct zr_context *layout, struct zr_edit_box *box, int modifiable)
{
struct zr_rect bounds;
struct zr_edit field;
@ -8298,7 +8296,7 @@ zr_edit_box(struct zr_context *layout, struct zr_edit_box *box, int modifyable)
state = zr_edit_base(&bounds, &field, layout);
if (!state) return;
i = (state == ZR_WIDGET_ROM || layout->flags & ZR_WINDOW_ROM) ? 0 : layout->input;
field.modifyable = modifyable;
field.modifiable = modifiable;
zr_widget_edit_box(layout->buffer, bounds, box, &field, i, &config->font);
}

View File

@ -124,7 +124,7 @@ struct zr_user_font_glyph;
*/
enum {zr_false, zr_true};
enum zr_heading {ZR_UP, ZR_RIGHT, ZR_DOWN, ZR_LEFT};
enum zr_modify {ZR_FIXED = zr_false, ZR_MODIFYABLE = zr_true};
enum zr_modify {ZR_FIXED = zr_false, ZR_MODIFIABLE = zr_true};
struct zr_color {zr_byte r,g,b,a;};
struct zr_vec2 {float x,y;};
struct zr_vec2i {short x, y;};
@ -197,18 +197,18 @@ zr_size zr_utf_len(const char*, zr_size len);
*/
/* INPUT
----------------------------
The input API is responsible for holding input by keeping track of
mouse, key and text input state. The core of the API is the persistent
The input API is responsible for holding the input state by keeping track of
mouse, key and text. The core of the API is a persistent
zr_input struct which holds the input state while running.
It is important to note that no direct os or window handling is done by the input
API, instead all the input state has to be provided from the user. This in one hand
API, instead all the input state has to be provided by the user. This in one hand
expects more work from the user and complicates the usage but on the other hand
provides simple abstraction over a big number of platforms, libraries and other
already provided functionality.
USAGE
----------------------------
To instantiate the Input API the zr_input structure has to be zeroed at
To instantiate the Input API the zr_input structure has to be zeroed in
the beginning of the program by either using memset or setting it to {0},
since the internal state is persistent over all frames.
@ -1560,7 +1560,6 @@ void zr_font_bake_convert(void *out_memory, int img_width, int img_height,
Output:
- rgba8 output image
*/
/* ---------------------------------------------------------------
* FONT
* ---------------------------------------------------------------*/