Merge branch 'master' of https://github.com/Immediate-Mode-UI/Nuklear into disable-widgets

This commit is contained in:
Yukyduky 2023-10-17 08:13:06 +02:00
commit 2b7f047f15
7 changed files with 93 additions and 5 deletions

View File

@ -1,6 +1,6 @@
# Allegro v5 nuklear backend
This backend provides support for [Allegro version 5](http://liballeg.org/). It works on on all supported platforms with an OpenGL backend, including iOS and Android.
This backend provides support for [Allegro version 5](https://liballeg.github.io). It works on on all supported platforms with an OpenGL backend, including iOS and Android.
Touch support is provided by handling the first touch (ignoring any extra simultaneous touches) and emitting nuklear mouse events. nuklear will handle only the first touch like a single left-mouse click. Dragging the touch screen emits mouse-move events.

View File

@ -584,6 +584,18 @@ overview(struct nk_context *ctx)
}
nk_tree_pop(ctx);
}
if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal Rule", NK_MINIMIZED))
{
nk_layout_row_dynamic(ctx, 12, 1);
nk_label(ctx, "Use this to subdivide spaces visually", NK_TEXT_LEFT);
nk_layout_row_dynamic(ctx, 4, 1);
nk_rule_horizontal(ctx, nk_white, nk_true);
nk_layout_row_dynamic(ctx, 75, 1);
nk_label_wrap(ctx, "Best used in 'Card'-like layouts, with a bigger title font on top. Takes on the size of the previous layout definition. Rounding optional.");
nk_tree_pop(ctx);
}
nk_tree_pop(ctx);
}

View File

@ -373,7 +373,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_SIZE_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_SIZE_TYPE unsigned long
#else
#define NK_SIZE_TYPE unsigned int
@ -388,7 +388,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_POINTER_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_POINTER_TYPE unsigned long
#else
#define NK_POINTER_TYPE unsigned int
@ -2004,6 +2004,19 @@ NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_st
/// __cond__ | condition that has to be met to actually commit the visbility state change
*/
NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
/*/// #### nk_window_show_if
/// Line for visual seperation. Draws a line with thickness determined by the current row height.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, NK_BOOL rounding)
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// ----------------|-------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __color__ | Color of the horizontal line
/// __rounding__ | Whether or not to make the line round
*/
NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
/* =============================================================================
*
* LAYOUT
@ -6119,8 +6132,23 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop
#ifdef NK_INCLUDE_FONT_BAKING
/**
* @def NK_NO_STB_RECT_PACK_IMPLEMENTATION
*
* When defined, will avoid enabling STB_RECT_PACK_IMPLEMENTATION for when stb_rect_pack.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */
/**
* @def NK_NO_STB_TRUETYPE_IMPLEMENTATION
*
* When defined, will avoid enabling STB_TRUETYPE_IMPLEMENTATION for when stb_truetype.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */
/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
#ifndef STBTT_malloc
@ -20818,6 +20846,15 @@ nk_window_set_focus(struct nk_context *ctx, const char *name)
}
ctx->active = win;
}
NK_API void
nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding)
{
struct nk_rect space;
enum nk_widget_layout_states state = nk_widget(&space, ctx);
struct nk_command_buffer *canvas = nk_window_get_canvas(ctx);
if (!state) return;
nk_fill_rect(canvas, space, rounding && space.h > 1.5f ? space.h / 2.0f : 0, color);
}
@ -29914,6 +29951,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
/// nk_edit_xxx limit
/// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
/// - 2022/04/19 (4.9.8) - Added nk_rule_horizontal() widget
/// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
/// only trigger when the mouse position was inside the same button on down
/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS

View File

@ -16,6 +16,7 @@
/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
/// nk_edit_xxx limit
/// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
/// - 2022/04/19 (4.9.8) - Added nk_rule_horizontal() widget
/// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
/// only trigger when the mouse position was inside the same button on down
/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS

View File

@ -151,7 +151,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_SIZE_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_SIZE_TYPE unsigned long
#else
#define NK_SIZE_TYPE unsigned int
@ -166,7 +166,7 @@ extern "C" {
#elif (defined(_WIN32) || defined(WIN32)) && defined(_MSC_VER)
#define NK_POINTER_TYPE unsigned __int32
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__aarch64__)
#if defined(__x86_64__) || defined(__ppc64__) || defined(__PPC64__) || defined(__aarch64__)
#define NK_POINTER_TYPE unsigned long
#else
#define NK_POINTER_TYPE unsigned int
@ -1782,6 +1782,19 @@ NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_st
/// __cond__ | condition that has to be met to actually commit the visbility state change
*/
NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
/*/// #### nk_window_show_if
/// Line for visual seperation. Draws a line with thickness determined by the current row height.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, NK_BOOL rounding)
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// ----------------|-------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct
/// __color__ | Color of the horizontal line
/// __rounding__ | Whether or not to make the line round
*/
NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding);
/* =============================================================================
*
* LAYOUT

View File

@ -328,8 +328,23 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop
#ifdef NK_INCLUDE_FONT_BAKING
/**
* @def NK_NO_STB_RECT_PACK_IMPLEMENTATION
*
* When defined, will avoid enabling STB_RECT_PACK_IMPLEMENTATION for when stb_rect_pack.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_RECT_PACK_IMPLEMENTATION
#define STB_RECT_PACK_IMPLEMENTATION
#endif /* NK_NO_STB_RECT_PACK_IMPLEMENTATION */
/**
* @def NK_NO_STB_TRUETYPE_IMPLEMENTATION
*
* When defined, will avoid enabling STB_TRUETYPE_IMPLEMENTATION for when stb_truetype.h is already implemented elsewhere.
*/
#ifndef NK_NO_STB_TRUETYPE_IMPLEMENTATION
#define STB_TRUETYPE_IMPLEMENTATION
#endif /* NK_NO_STB_TRUETYPE_IMPLEMENTATION */
/* Allow consumer to define own STBTT_malloc/STBTT_free, and use the font atlas' allocator otherwise */
#ifndef STBTT_malloc

View File

@ -670,3 +670,12 @@ nk_window_set_focus(struct nk_context *ctx, const char *name)
}
ctx->active = win;
}
NK_API void
nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk_bool rounding)
{
struct nk_rect space;
enum nk_widget_layout_states state = nk_widget(&space, ctx);
struct nk_command_buffer *canvas = nk_window_get_canvas(ctx);
if (!state) return;
nk_fill_rect(canvas, space, rounding && space.h > 1.5f ? space.h / 2.0f : 0, color);
}