From b712a3a1633b2aacc700926343465cad500bf09a Mon Sep 17 00:00:00 2001 From: vurtun Date: Tue, 10 May 2016 14:05:55 +0200 Subject: [PATCH] Removed C89 errors and warnings and style issues --- nuklear.h | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/nuklear.h b/nuklear.h index b94945d..4c7cd22 100644 --- a/nuklear.h +++ b/nuklear.h @@ -851,6 +851,8 @@ NK_API struct nk_rect nk_recti(int x, int y, int w, int h); NK_API struct nk_rect nk_recta(struct nk_vec2 pos, struct nk_vec2 size); NK_API struct nk_rect nk_rectv(const float *xywh); NK_API struct nk_rect nk_rectiv(const int *xywh); +NK_API struct nk_vec2 nk_rect_pos(struct nk_rect); +NK_API struct nk_vec2 nk_rect_size(struct nk_rect); /* string*/ NK_API int nk_strlen(const char *str); @@ -10190,13 +10192,6 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id) return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked); } -NK_API struct nk_vec2 -nk_input_mouse_accumulated_drag_delta(const struct nk_input *i, enum nk_buttons id) -{ - if (!i || !i->mouse.buttons[id].down) return nk_vec2(0.0f, 0.0f); - return nk_vec2_sub(i->mouse.pos, i->mouse.buttons[id].clicked_pos); -} - NK_API int nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key) { @@ -15899,30 +15894,32 @@ nk_panel_end(struct nk_context *ctx) &scaler->data.image); } else { nk_fill_triangle(out, scaler_x + scaler_w, scaler_y, scaler_x + scaler_w, - scaler_y + scaler_h, scaler_x, scaler_y + scaler_h, - scaler->data.color); + scaler_y + scaler_h, scaler_x, scaler_y + scaler_h, scaler->data.color); } - /* do window scaling logic */ + /* do window scaling */ if (!(window->flags & NK_WINDOW_ROM)) { + struct nk_vec2 delta; float prev_x = in->mouse.prev.x; float prev_y = in->mouse.prev.y; struct nk_vec2 window_size = style->window.min_size; int incursor = NK_INBOX(prev_x,prev_y,scaler_x,scaler_y,scaler_w,scaler_h); if (nk_input_is_mouse_down(in, NK_BUTTON_LEFT) && - (incursor || window->scaling.active == nk_true)) { + (incursor || window->scaling.active == nk_true)) + { if(window->scaling.active == nk_false) window->scaling.start_size = nk_rect_size(window->bounds); window->scaling.active = nk_true; - struct nk_vec2 delta = nk_input_mouse_accumulated_drag_delta(in, NK_BUTTON_LEFT); - window->bounds.w = NK_MAX(window_size.x, - window->scaling.start_size.x + delta.x); + if (!in || !in->mouse.buttons[NK_BUTTON_LEFT].down) + delta = nk_vec2(0,0); + else delta = nk_vec2_sub(in->mouse.pos, in->mouse.buttons[NK_BUTTON_LEFT].clicked_pos); + window->bounds.w = NK_MAX(window_size.x, window->scaling.start_size.x + delta.x); + /* dragging in y-direction is only possible if static window */ if (!(layout->flags & NK_WINDOW_DYNAMIC)) - window->bounds.h = NK_MAX(window_size.y, - window->scaling.start_size.y + delta.y); + window->bounds.h = NK_MAX(window->scaling.start_size.y + delta.y, window_size.y); } else window->scaling.active = nk_false; } }