Rob Loach 4 years ago
parent
commit
bcc02d85c9

+ 1 - 1
CMakeLists.txt

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.11)
 project(raylib-nuklear
     DESCRIPTION "raylib-nuklear: Nuklear immediate mode GUI for raylib."
     HOMEPAGE_URL "https://github.com/robloach/raylib-nuklear"
-    VERSION 1.2.0
+    VERSION 1.2.1
     LANGUAGES C
 )
 

+ 10 - 5
README.md

@@ -2,7 +2,7 @@
 
 Use the [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) immediate mode cross-platform GUI library in [raylib](https://www.raylib.com/).
 
-![raylib-nuklear-example screenshot](examples/raylib-nuklear-example.png)
+[![raylib-nuklear-example Screenshot](examples/raylib-nuklear-example.png)](examples)
 
 ## Example
 
@@ -20,10 +20,15 @@ int main() {
         // Update the Nuklear context, along with input
         UpdateNuklear(ctx);
 
-        // Add your own Nuklear GUI
-        // See the Nuklear Wiki for examples:
+        // Nuklear GUI Code
         // https://github.com/Immediate-Mode-UI/Nuklear/wiki/Window
-        // ...
+        if (nk_begin(ctx, "Nuklear", nk_rect(100, 100, 220, 220),
+                     NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
+            if (nk_button_label(ctx, "Button")) {
+                /* event handling */
+            }
+        }
+        nk_end(ctx);
 
         // Render
         BeginDrawing();
@@ -72,4 +77,4 @@ make
 
 ## License
 
-raylib-nuklear is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.
+*raylib-nuklear* is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check [LICENSE](LICENSE) for further details.

+ 3 - 3
examples/raylib-nuklear-example.c

@@ -35,8 +35,8 @@ int main(void)
 {
     // Initialization
     //--------------------------------------------------------------------------------------
-    const int screenWidth = 800;
-    const int screenHeight = 450;
+    const int screenWidth = 700;
+    const int screenHeight = 394;
     InitWindow(screenWidth, screenHeight, "[raylib-nuklear] example");
 
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
@@ -53,7 +53,7 @@ int main(void)
         // Update
         UpdateNuklear(ctx);
 
-        /* GUI */
+        // GUI
         if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
             NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
             NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))

BIN
examples/raylib-nuklear-example.png


+ 0 - 1
include/nuklear.h

@@ -29501,4 +29501,3 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
 /// in libraries and brought me to create some of my own. Finally Apoorva Joshi
 /// for his single header file packer.
 */
-

+ 58 - 1
include/raylib-nuklear.h

@@ -7,7 +7,7 @@
 *
 *   DEPENDENCIES:
 *       - raylib https://www.raylib.com/
-*       - nuklear modified version at vendor/nuklear/nuklear.h
+*       - nuklear https://github.com/Immediate-Mode-UI/Nuklear
 *
 *   LICENSE: zlib/libpng
 *
@@ -83,6 +83,11 @@ NK_API struct nk_rect RectangleToNuklear(Rectangle rect);
 #define RAYLIB_NUKLEAR_FONTSIZE 10
 #endif  // RAYLIB_NUKLEAR_FONTSIZE
 
+/**
+ * Nuklear callback; Get the width of the given text.
+ *
+ * @internal
+ */
 NK_API float
 nk_raylib_font_get_text_width(nk_handle handle, float height, const char *text, int len)
 {
@@ -102,6 +107,11 @@ nk_raylib_font_get_text_width(nk_handle handle, float height, const char *text,
     // return MeasureTextEx(font, text, 10, 1.0f);
 }
 
+/**
+ * Nuklear callback; Paste the current clipboard.
+ *
+ * @internal
+ */
 NK_API void
 nk_raylib_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
 {
@@ -112,11 +122,19 @@ nk_raylib_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
     }
 }
 
+/**
+ * Nuklear callback; Copy the given text.
+ *
+ * @internal
+ */
 NK_API void
 nk_raylib_clipboard_copy(nk_handle usr, const char *text, int len) {
     SetClipboardText(text);
 }
 
+/**
+ * Initialize the Nuklear context for use with Raylib.
+ */
 NK_API struct nk_context*
 InitNuklear()
 {
@@ -143,6 +161,9 @@ InitNuklear()
     return ctx;
 }
 
+/**
+ * Convert the given Nuklear color to a raylib color.
+ */
 NK_API Color
 ColorFromNuklear(struct nk_color color)
 {
@@ -154,6 +175,9 @@ ColorFromNuklear(struct nk_color color)
     return rc;
 }
 
+/**
+ * Convert the given raylib color to a Nuklear color.
+ */
 NK_API struct nk_color
 ColorToNuklear(Color color)
 {
@@ -165,18 +189,27 @@ ColorToNuklear(Color color)
     return rc;
 }
 
+/**
+ * Convert the given Nuklear float color to a raylib color.
+ */
 NK_API Color
 ColorFromNuklearF(struct nk_colorf color)
 {
     return ColorFromNuklear(nk_rgba_cf(color));
 }
 
+/**
+ * Convert the given raylib color to a raylib float color.
+ */
 NK_API struct nk_colorf
 ColorToNuklearF(Color color)
 {
     return nk_color_cf(ColorToNuklear(color));
 }
 
+/**
+ * Draw the given Nuklear context in raylib.
+ */
 NK_API void
 DrawNuklear(struct nk_context * ctx)
 {
@@ -394,6 +427,11 @@ DrawNuklear(struct nk_context * ctx)
     nk_clear(ctx);
 }
 
+/**
+ * Convert the given raylib mouse button to a Nuklear mouse button.
+ *
+ * @internal
+ */
 NK_API int
 nk_raylib_translate_mouse_button(int button)
 {
@@ -410,6 +448,8 @@ nk_raylib_translate_mouse_button(int button)
 
 /**
  * Returns 1 when pressed, 0 when released, or -1 when no change.
+ *
+ * @internal
  */
 NK_API int nk_raylib_input_changed(int key) {
     if (IsKeyPressed(key)) {
@@ -421,6 +461,11 @@ NK_API int nk_raylib_input_changed(int key) {
     return -1;
 }
 
+/**
+ * Update the Nuklear context for the keyboard input from raylib.
+ *
+ * @internal
+ */
 NK_API void nk_raylib_input_keyboard(struct nk_context * ctx)
 {
     int down;
@@ -506,6 +551,9 @@ NK_API void nk_raylib_input_keyboard(struct nk_context * ctx)
     }
 }
 
+/**
+ * Update the Nuklear context for raylib's state.
+ */
 NK_API void
 UpdateNuklear(struct nk_context * ctx)
 {
@@ -530,6 +578,9 @@ UpdateNuklear(struct nk_context * ctx)
     nk_input_end(ctx);
 }
 
+/**
+ * Unload the given Nuklear context, along with all internal raylib textures.
+ */
 NK_API void
 UnloadNuklear(struct nk_context * ctx)
 {
@@ -544,6 +595,9 @@ UnloadNuklear(struct nk_context * ctx)
     nk_free(ctx);
 }
 
+/**
+ * Convert the given Nuklear rectangle to a raylib Rectangle.
+ */
 NK_API struct
 Rectangle RectangleFromNuklear(struct nk_rect rect)
 {
@@ -555,6 +609,9 @@ Rectangle RectangleFromNuklear(struct nk_rect rect)
     return output;
 }
 
+/**
+ * Convert the given raylib Rectangle to a Nuklear rectangle.
+ */
 NK_API struct
 nk_rect RectangleToNuklear(Rectangle rect)
 {