Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compiling error when using source mode #573

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmake/nuklear-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(FindPackageHandleStandardArgs)

set(NUKLEAR_FOUND TRUE)

get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(nuklear_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)

set(nuklear_INCLUDE_DIRS ${nuklear_INSTALL_PREFIX})

add_library(nuklear INTERFACE IMPORTED)
set_target_properties(nuklear PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${nuklear_INCLUDE_DIRS}"
)

find_package_handle_standard_args(nuklear DEFAULT_MSG nuklear_INCLUDE_DIRS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we're adding a Nuklear config here. Should this be in the root?

8 changes: 8 additions & 0 deletions src/nuklear_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
default:
NK_ASSERT(0);
sym_background = nk_rgba(0, 0, 0, 0);
break;
}
{
struct nk_rect bounds = {0,0,0,0};
Expand Down Expand Up @@ -395,6 +399,10 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
default:
NK_ASSERT(0);
text.background = nk_rgba(0, 0, 0, 0);
break;
}
{
struct nk_rect content;
Expand Down
6 changes: 6 additions & 0 deletions src/nuklear_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,21 @@ NK_LIB int nk_to_upper(int c);
NK_LIB int nk_to_lower(int c);

#ifndef NK_MEMCPY
#define NK_MEMCPY_IMP
#define NK_MEMCPY nk_memcopy
NK_LIB void* nk_memcopy(void *dst, const void *src, nk_size n);
#endif
#ifndef NK_MEMSET
#define NK_MEMSET_IMP
#define NK_MEMSET nk_memset
NK_LIB void nk_memset(void *ptr, int c0, nk_size size);
#endif
NK_LIB void nk_zero(void *ptr, nk_size size);
NK_LIB char *nk_itoa(char *s, long n);
NK_LIB int nk_string_float_limit(char *string, int prec);
#ifndef NK_DTOA
#define NK_DTOA_IMP
#define NK_DTOA nk_dtoa
NK_LIB char *nk_dtoa(char *s, double n);
#endif
NK_LIB int nk_text_clamp(const struct nk_user_font *font, const char *text, int text_len, float space, int *glyphs, float *text_width, nk_rune *sep_list, int sep_count);
Expand Down
4 changes: 4 additions & 0 deletions src/nuklear_selectable.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ nk_draw_selectable(struct nk_command_buffer *out,
text.background = background->data.color;
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
break;
default:
NK_ASSERT(0);
text.background = nk_rgba(0, 0, 0, 0);
break;
}
if (icon) {
if (img) nk_draw_image(out, *icon, img, nk_white);
Expand Down
9 changes: 3 additions & 6 deletions src/nuklear_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ NK_LIB nk_bool nk_is_upper(int c){return (c >= 'A' && c <= 'Z') || (c >= 0xC0 &&
NK_LIB int nk_to_upper(int c) {return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;}
NK_LIB int nk_to_lower(int c) {return (c >= 'A' && c <= 'Z') ? (c - ('a' + 'A')) : c;}

#ifndef NK_MEMCPY
#define NK_MEMCPY nk_memcopy
#ifdef NK_MEMCPY_IMP
NK_LIB void*
nk_memcopy(void *dst0, const void *src0, nk_size length)
{
Expand Down Expand Up @@ -72,8 +71,7 @@ nk_memcopy(void *dst0, const void *src0, nk_size length)
return (dst0);
}
#endif
#ifndef NK_MEMSET
#define NK_MEMSET nk_memset
#ifdef NK_MEMSET_IMP
NK_LIB void
nk_memset(void *ptr, int c0, nk_size size)
{
Expand Down Expand Up @@ -499,8 +497,7 @@ nk_itoa(char *s, long n)
nk_strrev_ascii(s);
return s;
}
#ifndef NK_DTOA
#define NK_DTOA nk_dtoa
#ifdef NK_DTOA_IMP
NK_LIB char*
nk_dtoa(char *s, double n)
{
Expand Down