Skip to content

Commit

Permalink
Fix most warnings. Weird bug in allegro backend dissapeared
Browse files Browse the repository at this point in the history
  • Loading branch information
Hejsil committed Apr 13, 2020
1 parent 181ce7d commit 12d3a57
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 67 deletions.
2 changes: 1 addition & 1 deletion demo/allegro5/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
BIN = demo

# Flags
CFLAGS += -std=c99 -pedantic -ggdb -Wall -Wextra -Werror
CFLAGS += -std=c99 -pedantic -O2

SRC = main.c
OBJ = $(SRC:.c=.o)
Expand Down
45 changes: 12 additions & 33 deletions nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -3053,7 +3053,7 @@ enum nk_widget_states {
NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED /* widget is currently activated */
};
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*, struct nk_vec2);
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*);
NK_API struct nk_rect nk_widget_bounds(struct nk_context*);
NK_API struct nk_vec2 nk_widget_position(struct nk_context*);
NK_API struct nk_vec2 nk_widget_size(struct nk_context*);
Expand Down Expand Up @@ -5640,7 +5640,7 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
#endif

#ifndef STBTT_malloc
static nk_handle fictional_handle = {0};
static const nk_handle fictional_handle = {0};

#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
#define STBTT_free(x,u) nk_mfree( fictional_handle , x)
Expand Down Expand Up @@ -5871,7 +5871,7 @@ NK_LIB int nk_panel_begin(struct nk_context *ctx, struct nk_slice title, enum nk
NK_LIB void nk_panel_end(struct nk_context *ctx);

/* layout */
NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type, float total_space, int columns);
NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, float total_space, int columns);
NK_LIB void nk_panel_layout(const struct nk_context *ctx, struct nk_window *win, float height, int cols);
NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, float height, int cols, int width);
NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
Expand Down Expand Up @@ -8318,7 +8318,7 @@ nk_str_append_str_char(struct nk_str *s, struct nk_slice str)
NK_API int
nk_str_append_str_runes(struct nk_str *str, const nk_rune *text, nk_size len)
{
int i = 0;
nk_size i = 0;
int byte_len = 0;
nk_glyph glyph;

Expand Down Expand Up @@ -20112,7 +20112,6 @@ nk_item_is_any_active(struct nk_context *ctx)
NK_API int
nk_window_is_collapsed(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20126,7 +20125,6 @@ nk_window_is_collapsed(struct nk_context *ctx, struct nk_slice name)
NK_API int
nk_window_is_closed(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20140,7 +20138,6 @@ nk_window_is_closed(struct nk_context *ctx, struct nk_slice name)
NK_API int
nk_window_is_hidden(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20154,7 +20151,6 @@ nk_window_is_hidden(struct nk_context *ctx, struct nk_slice name)
NK_API int
nk_window_is_active(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20168,7 +20164,6 @@ nk_window_is_active(struct nk_context *ctx, struct nk_slice name)
NK_API struct nk_window*
nk_window_find(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
title_hash = nk_murmur_hash(name, NK_WINDOW_TITLE);
return nk_find_window(ctx, title_hash, name);
Expand Down Expand Up @@ -20232,7 +20227,6 @@ NK_API void
nk_window_collapse(struct nk_context *ctx, struct nk_slice name,
enum nk_collapse_states c)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20256,7 +20250,6 @@ nk_window_collapse_if(struct nk_context *ctx, struct nk_slice name,
NK_API void
nk_window_show(struct nk_context *ctx, struct nk_slice name, enum nk_show_states s)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand All @@ -20281,7 +20274,6 @@ nk_window_show_if(struct nk_context *ctx, struct nk_slice name,
NK_API void
nk_window_set_focus(struct nk_context *ctx, struct nk_slice name)
{
int title_len;
nk_hash title_hash;
struct nk_window *win;
NK_ASSERT(ctx);
Expand Down Expand Up @@ -20312,7 +20304,6 @@ nk_popup_begin(struct nk_context *ctx, enum nk_popup_type type,
struct nk_window *win;
struct nk_panel *panel;

int title_len;
nk_hash title_hash;
nk_size allocated;

Expand Down Expand Up @@ -20645,7 +20636,7 @@ nk_contextual_item_label(struct nk_context *ctx, struct nk_slice text,

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down Expand Up @@ -20675,7 +20666,7 @@ nk_contextual_item_image_label(struct nk_context *ctx, struct nk_image img,

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down Expand Up @@ -20705,7 +20696,7 @@ nk_contextual_item_symbol_label(struct nk_context *ctx, enum nk_symbol_type symb

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down Expand Up @@ -21070,12 +21061,11 @@ nk_layout_reset_min_row_height(struct nk_context *ctx)
layout->row.min_height += ctx->style.window.min_row_height_padding*2;
}
NK_LIB float
nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type,
nk_layout_row_calculate_usable_space(const struct nk_style *style,
float total_space, int columns)
{
float panel_spacing;
float panel_space;

struct nk_vec2 spacing;

spacing = style->window.spacing;
Expand Down Expand Up @@ -21417,7 +21407,7 @@ nk_layout_row_template_end(struct nk_context *ctx)
}
}
if (variable_count) {
float space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
float space = nk_layout_row_calculate_usable_space(&ctx->style,
layout->bounds.w, layout->row.columns);
float var_width = (NK_MAX(space-min_fixed_width,0.0f)) / (float)variable_count;
int enough_space = var_width >= max_variable_width;
Expand Down Expand Up @@ -21625,7 +21615,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
NK_ASSERT(bounds);

spacing = style->window.spacing;
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
panel_space = nk_layout_row_calculate_usable_space(&ctx->style,
layout->bounds.w, layout->row.columns);

#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
Expand Down Expand Up @@ -21909,7 +21899,6 @@ nk_tree_base(struct nk_context *ctx, enum nk_tree_type type,
struct nk_slice hash, int line)
{
struct nk_window *win = ctx->current;
int title_len = 0;
nk_hash tree_hash = 0;
nk_uint *state = 0;

Expand Down Expand Up @@ -21989,13 +21978,11 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
float row_height;
struct nk_vec2 padding;

int text_len;
float text_width;

struct nk_vec2 item_spacing;
struct nk_rect header = {0,0,0,0};
struct nk_rect sym = {0,0,0,0};
struct nk_text text;

nk_flags ws = 0;
enum nk_widget_layout_states widget_state;
Expand Down Expand Up @@ -22025,14 +22012,12 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
const struct nk_style_item *background = &style->tab.background;
if (background->type == NK_STYLE_ITEM_IMAGE) {
nk_draw_image(out, header, &background->data.image, nk_white);
text.background = nk_rgba(0,0,0,0);
} else {
text.background = background->data.color;
nk_fill_rect(out, header, 0, style->tab.border_color);
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
style->tab.rounding, background->data.color);
}
} else text.background = style->window.background;
}

in = (!(layout->flags & NK_WINDOW_ROM)) ? &ctx->input: 0;
in = (in && widget_state == NK_WIDGET_VALID) ? &ctx->input : 0;
Expand Down Expand Up @@ -22090,7 +22075,6 @@ nk_tree_element_base(struct nk_context *ctx, enum nk_tree_type type,
int *selected, struct nk_slice hash, int line)
{
struct nk_window *win = ctx->current;
int title_len = 0;
nk_hash tree_hash = 0;
nk_uint *state = 0;

Expand Down Expand Up @@ -22255,7 +22239,6 @@ NK_API int
nk_group_begin_titled(struct nk_context *ctx, struct nk_slice id,
struct nk_slice title, nk_flags flags)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset;
Expand Down Expand Up @@ -22296,7 +22279,6 @@ nk_group_end(struct nk_context *ctx)
NK_API void
nk_group_get_scroll(struct nk_context *ctx, struct nk_slice id, nk_uint *x_offset, nk_uint *y_offset)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset_ptr;
Expand Down Expand Up @@ -22371,7 +22353,6 @@ NK_API int
nk_list_view_begin(struct nk_context *ctx, struct nk_list_view *view,
struct nk_slice title, nk_flags flags, int row_height, int row_count)
{
int title_len;
nk_hash title_hash;
nk_uint *x_offset;
nk_uint *y_offset;
Expand Down Expand Up @@ -22623,12 +22604,10 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
return NK_WIDGET_VALID;
}
NK_API enum nk_widget_layout_states
nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx,
struct nk_vec2 item_padding)
nk_widget_fitting(struct nk_rect *bounds, struct nk_context *ctx)
{
/* update the bounds to stand without padding */
enum nk_widget_layout_states state;
NK_UNUSED(item_padding);

NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
Expand Down
4 changes: 2 additions & 2 deletions src/nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -2834,7 +2834,7 @@ enum nk_widget_states {
NK_WIDGET_STATE_ACTIVE = NK_WIDGET_STATE_ACTIVED|NK_WIDGET_STATE_MODIFIED /* widget is currently activated */
};
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect*, const struct nk_context*);
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*, struct nk_vec2);
NK_API enum nk_widget_layout_states nk_widget_fitting(struct nk_rect*, struct nk_context*);
NK_API struct nk_rect nk_widget_bounds(struct nk_context*);
NK_API struct nk_vec2 nk_widget_position(struct nk_context*);
NK_API struct nk_vec2 nk_widget_size(struct nk_context*);
Expand Down Expand Up @@ -5421,7 +5421,7 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
#endif

#ifndef STBTT_malloc
static nk_handle fictional_handle = {0};
static const nk_handle fictional_handle = {0};

#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
#define STBTT_free(x,u) nk_mfree( fictional_handle , x)
Expand Down
6 changes: 3 additions & 3 deletions src/nuklear_contextual.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ nk_contextual_item_label(struct nk_context *ctx, struct nk_slice text,

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down Expand Up @@ -114,7 +114,7 @@ nk_contextual_item_image_label(struct nk_context *ctx, struct nk_image img,

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down Expand Up @@ -144,7 +144,7 @@ nk_contextual_item_symbol_label(struct nk_context *ctx, enum nk_symbol_type symb

win = ctx->current;
style = &ctx->style;
state = nk_widget_fitting(&bounds, ctx, style->contextual_button.padding);
state = nk_widget_fitting(&bounds, ctx);
if (!state) return nk_false;

in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
Expand Down
2 changes: 0 additions & 2 deletions src/nuklear_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ NK_API int
nk_group_begin_titled(struct nk_context *ctx, struct nk_slice id,
struct nk_slice title, nk_flags flags)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset;
Expand Down Expand Up @@ -168,7 +167,6 @@ nk_group_end(struct nk_context *ctx)
NK_API void
nk_group_get_scroll(struct nk_context *ctx, struct nk_slice id, nk_uint *x_offset, nk_uint *y_offset)
{
int id_len;
nk_hash id_hash;
struct nk_window *win;
nk_uint *x_offset_ptr;
Expand Down
2 changes: 1 addition & 1 deletion src/nuklear_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ NK_LIB int nk_panel_begin(struct nk_context *ctx, struct nk_slice title, enum nk
NK_LIB void nk_panel_end(struct nk_context *ctx);

/* layout */
NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type, float total_space, int columns);
NK_LIB float nk_layout_row_calculate_usable_space(const struct nk_style *style, float total_space, int columns);
NK_LIB void nk_panel_layout(const struct nk_context *ctx, struct nk_window *win, float height, int cols);
NK_LIB void nk_row_layout(struct nk_context *ctx, enum nk_layout_format fmt, float height, int cols, int width);
NK_LIB void nk_panel_alloc_row(const struct nk_context *ctx, struct nk_window *win);
Expand Down
7 changes: 3 additions & 4 deletions src/nuklear_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ nk_layout_reset_min_row_height(struct nk_context *ctx)
layout->row.min_height += ctx->style.window.min_row_height_padding*2;
}
NK_LIB float
nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel_type type,
nk_layout_row_calculate_usable_space(const struct nk_style *style,
float total_space, int columns)
{
float panel_spacing;
float panel_space;

struct nk_vec2 spacing;

spacing = style->window.spacing;
Expand Down Expand Up @@ -388,7 +387,7 @@ nk_layout_row_template_end(struct nk_context *ctx)
}
}
if (variable_count) {
float space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
float space = nk_layout_row_calculate_usable_space(&ctx->style,
layout->bounds.w, layout->row.columns);
float var_width = (NK_MAX(space-min_fixed_width,0.0f)) / (float)variable_count;
int enough_space = var_width >= max_variable_width;
Expand Down Expand Up @@ -596,7 +595,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
NK_ASSERT(bounds);

spacing = style->window.spacing;
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
panel_space = nk_layout_row_calculate_usable_space(&ctx->style,
layout->bounds.w, layout->row.columns);

#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
Expand Down
1 change: 0 additions & 1 deletion src/nuklear_list_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ NK_API int
nk_list_view_begin(struct nk_context *ctx, struct nk_list_view *view,
struct nk_slice title, nk_flags flags, int row_height, int row_count)
{
int title_len;
nk_hash title_hash;
nk_uint *x_offset;
nk_uint *y_offset;
Expand Down
1 change: 0 additions & 1 deletion src/nuklear_popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ nk_popup_begin(struct nk_context *ctx, enum nk_popup_type type,
struct nk_window *win;
struct nk_panel *panel;

int title_len;
nk_hash title_hash;
nk_size allocated;

Expand Down
2 changes: 1 addition & 1 deletion src/nuklear_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ nk_str_append_str_char(struct nk_str *s, struct nk_slice str)
NK_API int
nk_str_append_str_runes(struct nk_str *str, const nk_rune *text, nk_size len)
{
int i = 0;
nk_size i = 0;
int byte_len = 0;
nk_glyph glyph;

Expand Down
Loading

0 comments on commit 12d3a57

Please sign in to comment.