diff --git a/.Doxyfile b/.Doxyfile index 003d71a87..ae997b547 100644 --- a/.Doxyfile +++ b/.Doxyfile @@ -53,7 +53,7 @@ PROJECT_NUMBER = # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI." +PROJECT_BRIEF = "Minimal-state, immediate-mode graphical user interface toolkit written in ANSI C." # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 @@ -171,7 +171,7 @@ INLINE_INHERITED_MEMB = NO # shortest path that makes the file name unique will be used # The default value is: YES. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = NO # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand @@ -633,7 +633,7 @@ SHOW_HEADERFILE = YES # the files that are included by a file in the documentation of that file. # The default value is: YES. -SHOW_INCLUDE_FILES = YES +SHOW_INCLUDE_FILES = NO # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each # grouped member an include statement to the documentation, telling the reader @@ -755,14 +755,14 @@ MAX_INITIALIZER_LINES = 30 # list will mention the files that were used to generate the documentation. # The default value is: YES. -SHOW_USED_FILES = YES +SHOW_USED_FILES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This # will remove the Files entry from the Quick Index and from the Folder Tree View # (if specified). # The default value is: YES. -SHOW_FILES = YES +SHOW_FILES = NO # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces # page. This will remove the Namespaces entry from the Quick Index and from the @@ -906,8 +906,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "./src" \ - "./src/HEADER.md" +INPUT = ./src README.md @@ -998,9 +997,11 @@ RECURSIVE = NO # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = "./src/Readme.md" \ +EXCLUDE = "./src/README.md" \ "./src/paq.sh" \ - "./src/paq.bat" + "./src/paq.bat" \ + "./src/stb_rect_pack.h" \ + "./src/stb_truetype.h" # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1109,7 +1110,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. -USE_MDFILE_AS_MAINPAGE = src/HEADER.md +USE_MDFILE_AS_MAINPAGE = README.md #--------------------------------------------------------------------------- # Configuration options related to source browsing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..e2579224e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,35 @@ +# Contributing + +## Reviewers guide + +When reviewing pull request there are common things a reviewer should keep +in mind. + +Reviewing changes to `src/*` and `nuklear.h`: + +* Ensure C89 compatibility. +* The code should work for several backends to an acceptable degree. +* Check no other parts of `nuklear.h` are related to the PR and thus nothing is missing. +* Recommend simple optimizations. + * Pass small structs by value instead of by pointer. + * Use local buffers over heap allocation when possible. +* Check that the coding style is consistent with code around it. + * Variable/function name casing. + * Indentation. + * Curly bracket (`{}`) placement. +* Ensure that the contributor has bumped the appropriate version in + [clib.json](https://github.com/Immediate-Mode-UI/Nuklear/blob/master/clib.json). +* Have at least one other person review the changes before merging. + +Reviewing changes to `demo/*`, `example/*` and other files in the repo: + +* Focus on getting working code merged. + * We want to make it easy for people to get started with Nuklear, and any + `demo` and `example` improvements helps in this regard. +* Use of newer C features, or even other languages is not discouraged. + * If another language is used, ensure that the build process is easy to figure out. +* Messy or less efficient code can be merged so long as these outliers are pointed out + and easy to find. +* Version shouldn't be bumped for these changes. +* Changes that improves code to be more inline with `nuklear.h` are ofc always welcome. + diff --git a/LICENSE b/LICENSE index 0ffdc1855..6d1be1064 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ ------------------------------------------------------------------------------- +License + This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- + ALTERNATIVE A - MIT License Copyright (c) 2017 Micha Mettke Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -18,7 +19,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- + ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this @@ -36,4 +37,3 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ diff --git a/Makefile b/Makefile index f0fe41f74..821525bda 100644 --- a/Makefile +++ b/Makefile @@ -17,17 +17,17 @@ DOXYFILE:=.Doxyfile ## note: source file paths are prefixed later, no need to add prefix here; just ## give it the name. MACRO = NK -INTRO = HEADER.md +INTRO = HEADER.h PUB = nuklear.h OUTPUT = nuklear.h -PRIV1 = nuklear_internal.h nuklear_math.c nuklear_util.c nuklear_color.c nuklear_utf8.c nuklear_buffer.c nuklear_string.c nuklear_draw.c nuklear_vertex.c +PRIV1 = nuklear_internal.h nuklear_math.c nuklear_util.c nuklear_color.c nuklear_utf8.c nuklear_buffer.c nuklear_string.c nuklear_draw.c nuklear_vertex.c -EXTERN = stb_rect_pack.h stb_truetype.h +EXTERN = stb_rect_pack.h stb_truetype.h PRIV2 = nuklear_font.c nuklear_input.c nuklear_style.c nuklear_context.c nuklear_pool.c nuklear_page_element.c nuklear_table.c nuklear_panel.c nuklear_window.c nuklear_popup.c nuklear_contextual.c nuklear_menu.c nuklear_layout.c nuklear_tree.c nuklear_group.c nuklear_list_view.c nuklear_widget.c nuklear_text.c nuklear_image.c nuklear_9slice.c nuklear_button.c nuklear_toggle.c nuklear_selectable.c nuklear_slider.c nuklear_knob.c nuklear_progress.c nuklear_scrollbar.c nuklear_text_editor.c nuklear_edit.c nuklear_property.c nuklear_chart.c nuklear_color_picker.c nuklear_combo.c nuklear_tooltip.c -OUTRO = LICENSE CHANGELOG CREDITS +OUTRO = ../LICENSE CHANGELOG CREDITS ## Demo settings DEMO_LIST = $(shell find $(DEMO_PATH) -type f -name Makefile -printf "%h ") @@ -45,7 +45,7 @@ usage: echo "make demos to build all of the demos" echo "make all to re-pack the header and create documentation" -all: docs nuke demos +all: docs nuke demos demos: $(DEMO_LIST) @@ -62,7 +62,7 @@ nuke: $(addprefix $(SRC_PATH)/, $(SRC)) ######################################################################################## ## Docs -docs: $(DOCS_PATH)/html/index.html +docs: $(DOCS_PATH)/html/index.html $(DOCS_PATH)/html/index.html: $(DOCS_PATH)/doxygen-awesome-css/doxygen-awesome.css $(DOXYFILE) doxygen $(DOXYFILE) diff --git a/Readme.md b/README.md similarity index 79% rename from Readme.md rename to README.md index eff05cd08..202e411ff 100644 --- a/Readme.md +++ b/README.md @@ -27,7 +27,7 @@ render backends, it focuses only on the actual UI. - Optional font baker and vertex buffer output - [Documentation](https://Immediate-Mode-UI.github.io/Nuklear/) -## Building +## Usage This library is self-contained in one single header file and can be used either in header-only mode or in implementation mode. The header-only mode is used @@ -128,37 +128,3 @@ in libraries and brought me to create some of my own. Finally Apoorva Joshi for ## License Nuklear is avaliable under either the MIT License or public domain. See [LICENSE](LICENSE) for more info. - -## Reviewers guide - -When reviewing pull request there are common things a reviewer should keep -in mind. - -Reviewing changes to `src/*` and `nuklear.h`: - -* Ensure C89 compatibility. -* The code should work for several backends to an acceptable degree. -* Check no other parts of `nuklear.h` are related to the PR and thus nothing is missing. -* Recommend simple optimizations. - * Pass small structs by value instead of by pointer. - * Use local buffers over heap allocation when possible. -* Check that the coding style is consistent with code around it. - * Variable/function name casing. - * Indentation. - * Curly bracket (`{}`) placement. -* Ensure that the contributor has bumped the appropriate version in - [clib.json](https://github.com/Immediate-Mode-UI/Nuklear/blob/master/clib.json). -* Have at least one other person review the changes before merging. - -Reviewing changes to `demo/*`, `example/*` and other files in the repo: - -* Focus on getting working code merged. - * We want to make it easy for people to get started with Nuklear, and any - `demo` and `example` improvements helps in this regard. -* Use of newer C features, or even other languages is not discouraged. - * If another language is used, ensure that the build process is easy to figure out. -* Messy or less efficient code can be merged so long as these outliers are pointed out - and easy to find. -* Version shouldn't be bumped for these changes. -* Changes that improves code to be more inline with `nuklear.h` are ofc always welcome. - diff --git a/nuklear.h b/nuklear.h index e6df337b1..ee1341f0e 100644 --- a/nuklear.h +++ b/nuklear.h @@ -1,222 +1,189 @@ -/* -# Nuklear -![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif) - -## Contents -1. About section -2. Highlights section -3. Features section -4. Usage section - 1. Flags section - 2. Constants section - 3. Dependencies section -5. Example section -6. API section - 1. Context section - 2. Input section - 3. Drawing section - 4. Window section - 5. Layouting section - 6. Groups section - 7. Tree section - 8. Properties section -7. License section -8. Changelog section -9. Gallery section -10. Credits section - -## About -This is a minimal state immediate mode graphical user interface toolkit -written in ANSI C and licensed under public domain. It was designed as a simple -embeddable user interface for application and does not have any dependencies, -a default renderbackend or OS window and input handling but instead provides a very modular -library approach by using simple input state for input and draw -commands describing primitive shapes as output. So instead of providing a -layered library that tries to abstract over a number of platform and -render backends it only focuses on the actual UI. - -## Highlights -- Graphical user interface toolkit -- Single header library -- Written in C89 (a.k.a. ANSI C or ISO C90) -- Small codebase (~18kLOC) -- Focus on portability, efficiency and simplicity -- No dependencies (not even the standard library if not wanted) -- Fully skinnable and customizable -- Low memory footprint with total memory control if needed or wanted -- UTF-8 support -- No global or hidden state -- Customizable library modules (you can compile and use only what you need) -- Optional font baker and vertex buffer output -- [Code available on github](https://github.com/Immediate-Mode-UI/Nuklear/) - -## Features -- Absolutely no platform dependent code -- Memory management control ranging from/to - - Ease of use by allocating everything from standard library - - Control every byte of memory inside the library -- Font handling control ranging from/to - - Use your own font implementation for everything - - Use this libraries internal font baking and handling API -- Drawing output control ranging from/to - - Simple shapes for more high level APIs which already have drawing capabilities - - Hardware accessible anti-aliased vertex buffer output -- Customizable colors and properties ranging from/to - - Simple changes to color by filling a simple color table - - Complete control with ability to use skinning to decorate widgets -- Bendable UI library with widget ranging from/to - - Basic widgets like buttons, checkboxes, slider, ... - - Advanced widget like abstract comboboxes, contextual menus,... -- Compile time configuration to only compile what you need - - Subset which can be used if you do not want to link or use the standard library -- Can be easily modified to only update on user input instead of frame updates - -## Usage -This library is self contained in one single header file and can be used either -in header only mode or in implementation mode. The header only mode is used -by default when included and allows including this header in other headers -and does not contain the actual implementation.

- -The implementation mode requires to define the preprocessor macro -NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C - #define NK_IMPLEMENTATION - #include "nuklear.h" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Also optionally define the symbols listed in the section "OPTIONAL DEFINES" -below in header and implementation mode if you want to use additional functionality -or need more control over the library. - -!!! WARNING - Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions. - -### Flags -Flag | Description ---------------------------------|------------------------------------------ -NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation -NK_INCLUDE_FIXED_TYPES | If defined it will include header `` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself. -NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management. -NK_INCLUDE_STANDARD_IO | If defined it will include header `` and provide additional functions depending on file loading. -NK_INCLUDE_STANDARD_VARARGS | If defined it will include header and provide additional functions depending on file loading. -NK_INCLUDE_STANDARD_BOOL | If defined it will include header `` for nk_bool otherwise nuklear defines nk_bool as int. -NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,... -NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it. -NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font -NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures. -NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released. -NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame. -NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit -NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events -NK_IS_WORD_BOUNDARY(c) | Define this to a function macro that takes a single nk_rune (nk_uint) and returns true if it's a word separator. If not defined, uses the default definition (see nk_is_word_boundary()) - -!!! WARNING - The following flags will pull in the standard C library: - - NK_INCLUDE_DEFAULT_ALLOCATOR - - NK_INCLUDE_STANDARD_IO - - NK_INCLUDE_STANDARD_VARARGS - -!!! WARNING - The following flags if defined need to be defined for both header and implementation: - - NK_INCLUDE_FIXED_TYPES - - NK_INCLUDE_DEFAULT_ALLOCATOR - - NK_INCLUDE_STANDARD_VARARGS - - NK_INCLUDE_STANDARD_BOOL - - NK_INCLUDE_VERTEX_BUFFER_OUTPUT - - NK_INCLUDE_FONT_BAKING - - NK_INCLUDE_DEFAULT_FONT - - NK_INCLUDE_STANDARD_VARARGS - - NK_INCLUDE_COMMAND_USERDATA - - NK_UINT_DRAW_INDEX - -### Constants -Define | Description ---------------------------------|--------------------------------------- -NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it. -NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient. -NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient. - -!!! WARNING - The following constants if defined need to be defined for both header and implementation: - - NK_MAX_NUMBER_BUFFER - - NK_BUFFER_DEFAULT_INITIAL_SIZE - - NK_INPUT_MAX - -### Dependencies -Function | Description -------------|--------------------------------------------------------------- -NK_ASSERT | If you don't define this, nuklear will use with assert(). -NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. -NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. -NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. -NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. -NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. -NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). -NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). -NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe. - -!!! WARNING - The following dependencies will pull in the standard C library if not redefined: - - NK_ASSERT - -!!! WARNING - The following dependencies if defined need to be defined for both header and implementation: - - NK_ASSERT - -!!! WARNING - The following dependencies if defined need to be defined only for the implementation part: - - NK_MEMSET - - NK_MEMCPY - - NK_SQRT - - NK_SIN - - NK_COS - - NK_STRTOD - - NK_DTOA - - NK_VSNPRINTF - -## Example - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c -// init gui state -enum {EASY, HARD}; -static int op = EASY; -static float value = 0.6f; -static int i = 20; -struct nk_context ctx; - -nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); -if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), - NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) { - // fixed widget pixel width - nk_layout_row_static(&ctx, 30, 80, 1); - if (nk_button_label(&ctx, "button")) { - // event handling - } - - // fixed widget window ratio width - nk_layout_row_dynamic(&ctx, 30, 2); - if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY; - if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD; - - // custom widget pixel width - nk_layout_row_begin(&ctx, NK_STATIC, 30, 2); - { - nk_layout_row_push(&ctx, 50); - nk_label(&ctx, "Volume:", NK_TEXT_LEFT); - nk_layout_row_push(&ctx, 110); - nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f); - } - nk_layout_row_end(&ctx); -} -nk_end(&ctx); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png) - -## API - -*/ +/** + * Nuklear + * Single-header ANSI C immediate mode cross-platform GUI library. + * + * VERSION: + * v4.13.3 + * + * HOMEPAGE: + * https://github.com/Immediate-Mode-UI/Nuklear/ + * + * ABOUT: + * This is a minimal state immediate mode graphical user interface toolkit + * written in ANSI C and licensed under public domain. It was designed as a simple + * embeddable user interface for application and does not have any dependencies, + * a default renderbackend or OS window and input handling but instead provides a very modular + * library approach by using simple input state for input and draw + * commands describing primitive shapes as output. So instead of providing a + * layered library that tries to abstract over a number of platform and + * render backends it only focuses on the actual UI. + * + * HIGHLIGHTS: + * - Graphical user interface toolkit + * - Single header library + * - Written in C89 (a.k.a. ANSI C or ISO C90) + * - Small codebase (~18kLOC) + * - Focus on portability, efficiency and simplicity + * - No dependencies (not even the standard library if not wanted) + * - Fully skinnable and customizable + * - Low memory footprint with total memory control if needed or wanted + * - UTF-8 support + * - No global or hidden state + * - Customizable library modules (you can compile and use only what you need) + * - Optional font baker and vertex buffer output + * + * FEATURES: + * - Absolutely no platform dependent code + * - Memory management control ranging from/to + * - Ease of use by allocating everything from standard library + * - Control every byte of memory inside the library + * - Font handling control ranging from/to + * - Use your own font implementation for everything + * - Use this libraries internal font baking and handling API + * - Drawing output control ranging from/to + * - Simple shapes for more high level APIs which already have drawing capabilities + * - Hardware accessible anti-aliased vertex buffer output + * - Customizable colors and properties ranging from/to + * - Simple changes to color by filling a simple color table + * - Complete control with ability to use skinning to decorate widgets + * - Bendable UI library with widget ranging from/to + * - Basic widgets like buttons, checkboxes, slider, ... + * - Advanced widget like abstract comboboxes, contextual menus,... + * - Compile time configuration to only compile what you need + * - Subset which can be used if you do not want to link or use the standard library + * - Can be easily modified to only update on user input instead of frame updates + * + * USAGE: + * This library is self contained in one single header file and can be used either + * in header only mode or in implementation mode. The header only mode is used + * by default when included and allows including this header in other headers + * and does not contain the actual implementation. + * The implementation mode requires to define the preprocessor macro + * NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.: + * + * #define NK_IMPLEMENTATION + * #include "nuklear.h" + * + * Also optionally define the symbols listed in the section "OPTIONAL DEFINES" + * below in header and implementation mode if you want to use additional functionality + * or need more control over the library. + * + * @warning Every time nuklear is included define the same compiler flags. This is very + * important — not doing so could lead to compiler errors or even worse stack corruptions. + * + * @subsection flags Flags + * Flag | Description + * --------------------------------|------------------------------------------ + * NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation + * NK_INCLUDE_FIXED_TYPES | If defined it will include header `` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself. + * NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management. + * NK_INCLUDE_STANDARD_IO | If defined it will include header `` and provide additional functions depending on file loading. + * NK_INCLUDE_STANDARD_VARARGS | If defined it will include header `` and provide additional functions depending on file loading. + * NK_INCLUDE_STANDARD_BOOL | If defined it will include header `` for nk_bool otherwise nuklear defines nk_bool as int. + * NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,... + * NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it. + * NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font + * NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures. + * NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released. + * NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame. + * NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit + * NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events + * NK_IS_WORD_BOUNDARY(c) | Define this to a function macro that takes a single nk_rune (nk_uint) and returns true if it's a word separator. If not defined, uses the default definition (see nk_is_word_boundary()) + * + * @warning The following flags will pull in the standard C library: + * - NK_INCLUDE_DEFAULT_ALLOCATOR + * - NK_INCLUDE_STANDARD_IO + * - NK_INCLUDE_STANDARD_VARARGS + * + * @warning The following flags if defined need to be defined for both header and implementation: + * - NK_INCLUDE_FIXED_TYPES + * - NK_INCLUDE_DEFAULT_ALLOCATOR + * - NK_INCLUDE_STANDARD_VARARGS + * - NK_INCLUDE_STANDARD_BOOL + * - NK_INCLUDE_VERTEX_BUFFER_OUTPUT + * - NK_INCLUDE_FONT_BAKING + * - NK_INCLUDE_DEFAULT_FONT + * - NK_INCLUDE_COMMAND_USERDATA + * - NK_UINT_DRAW_INDEX + * + * @subsection constants Constants + * Define | Description + * --------------------------------|--------------------------------------- + * NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it. + * NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string. Under normal circumstances this should be more than sufficient. + * NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient. + * + * @warning The following constants if defined need to be defined for both header and implementation: + * - NK_MAX_NUMBER_BUFFER + * - NK_BUFFER_DEFAULT_INITIAL_SIZE + * - NK_INPUT_MAX + * + * @subsection dependencies Dependencies + * Function | Description + * -------------|--------------------------------------------------------------- + * NK_ASSERT | If you don't define this, nuklear will use `` with assert(). + * NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. + * NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. + * NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. + * NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. + * NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. + * NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). + * NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). + * NK_VSNPRINTF | If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe. + * + * @warning The following dependencies will pull in the standard C library if not redefined: + * - NK_ASSERT + * + * @warning The following dependencies if defined need to be defined for both header and implementation: + * - NK_ASSERT + * + * @warning The following dependencies if defined need to be defined only for the implementation part: + * - NK_MEMSET + * - NK_MEMCPY + * - NK_SQRT + * - NK_SIN + * - NK_COS + * - NK_STRTOD + * - NK_DTOA + * - NK_VSNPRINTF + * + * @section example Example + * + * ```c + * // init gui state + * enum {EASY, HARD}; + * static int op = EASY; + * static float value = 0.6f; + * static int i = 20; + * struct nk_context ctx; + * + * nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); + * if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), + * NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) { + * // fixed widget pixel width + * nk_layout_row_static(&ctx, 30, 80, 1); + * if (nk_button_label(&ctx, "button")) { + * // event handling + * } + * + * // fixed widget window ratio width + * nk_layout_row_dynamic(&ctx, 30, 2); + * if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY; + * if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD; + * + * // custom widget pixel width + * nk_layout_row_begin(&ctx, NK_STATIC, 30, 2); + * { + * nk_layout_row_push(&ctx, 50); + * nk_label(&ctx, "Volume:", NK_TEXT_LEFT); + * nk_layout_row_push(&ctx, 110); + * nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f); + * } + * nk_layout_row_end(&ctx); + * } + * nk_end(&ctx); + * ``` + */ #ifndef NK_SINGLE_FILE #define NK_SINGLE_FILE #endif @@ -30876,82 +30843,71 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args) #endif /* NK_IMPLEMENTATION */ - /* -/// ## License -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~none -/// ------------------------------------------------------------------------------ -/// This software is available under 2 licenses -- choose whichever you prefer. -/// ------------------------------------------------------------------------------ -/// ALTERNATIVE A - MIT License -/// Copyright (c) 2016-2018 Micha Mettke -/// Permission is hereby granted, free of charge, to any person obtaining a copy of -/// this software and associated documentation files (the "Software"), to deal in -/// the Software without restriction, including without limitation the rights to -/// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -/// of the Software, and to permit persons to whom the Software is furnished to do -/// so, subject to the following conditions: -/// The above copyright notice and this permission notice shall be included in all -/// copies or substantial portions of the Software. -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -/// SOFTWARE. -/// ------------------------------------------------------------------------------ -/// ALTERNATIVE B - Public Domain (www.unlicense.org) -/// This is free and unencumbered software released into the public domain. -/// Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -/// software, either in source code form or as a compiled binary, for any purpose, -/// commercial or non-commercial, and by any means. -/// In jurisdictions that recognize copyright laws, the author or authors of this -/// software dedicate any and all copyright interest in the software to the public -/// domain. We make this dedication for the benefit of the public at large and to -/// the detriment of our heirs and successors. We intend this dedication to be an -/// overt act of relinquishment in perpetuity of all present and future rights to -/// this software under copyright law. -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -/// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -/// ------------------------------------------------------------------------------ -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -/// ## Changelog -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/// The CHANGELOG can be found for each release in: -/// https://github.com/Immediate-Mode-UI/Nuklear/releases -/// -/// An archive of the old changelog can be found in the wiki: -/// https://github.com/Immediate-Mode-UI/Nuklear/wiki/CHANGELOG -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/// ## Gallery -/// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png) -/// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png) -/// ![Figure [widgets]: Widget overview](https://cloud.githubusercontent.com/assets/8057201/11282359/3325e3c6-8eff-11e5-86cb-cf02b0596087.png) -/// ![Figure [blackwhite]: Black and white](https://cloud.githubusercontent.com/assets/8057201/11033668/59ab5d04-86e5-11e5-8091-c56f16411565.png) -/// ![Figure [filexp]: File explorer](https://cloud.githubusercontent.com/assets/8057201/10718115/02a9ba08-7b6b-11e5-950f-adacdd637739.png) -/// ![Figure [opengl]: OpenGL Editor](https://cloud.githubusercontent.com/assets/8057201/12779619/2a20d72c-ca69-11e5-95fe-4edecf820d5c.png) -/// ![Figure [nodedit]: Node Editor](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif) -/// ![Figure [skinning]: Using skinning in Nuklear](https://cloud.githubusercontent.com/assets/8057201/15991632/76494854-30b8-11e6-9555-a69840d0d50b.png) -/// ![Figure [bf]: Heavy modified version](https://cloud.githubusercontent.com/assets/8057201/14902576/339926a8-0d9c-11e6-9fee-a8b73af04473.png) -/// -/// ## Credits -/// Developed by Micha Mettke and every direct or indirect github contributor.

-/// -/// Embeds [stb_texedit](https://github.com/nothings/stb/blob/master/stb_textedit.h), [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) and [stb_rectpack](https://github.com/nothings/stb/blob/master/stb_rect_pack.h) by Sean Barret (public domain)
-/// Uses [stddoc.c](https://github.com/r-lyeh/stddoc.c) from r-lyeh@github.com for documentation generation

-/// Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).
-/// -/// Big thank you to Omar Cornut (ocornut@github) for his [imgui library](https://github.com/ocornut/imgui) and -/// giving me the inspiration for this library, Casey Muratori for handmade hero -/// and his original immediate mode graphical user interface idea and Sean -/// Barret for his amazing single header libraries which restored my faith -/// in libraries and brought me to create some of my own. Finally Apoorva Joshi -/// for his single header file packer. -*/ +License + +This software is available under 2 licenses -- choose whichever you prefer. +ALTERNATIVE A - MIT License +Copyright (c) 2017 Micha Mettke +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Changelog + +The CHANGELOG can be found for each release in: +https://github.com/Immediate-Mode-UI/Nuklear/releases + +An archive of the old changelog can be found in the wiki: +https://github.com/Immediate-Mode-UI/Nuklear/wiki/CHANGELOG + +Credits + +Developed by Micha Mettke and every direct or indirect github contributor. + +Embeds stb public domain libraries by Sean Barret... +- stb_texedit: https://github.com/nothings/stb/blob/master/stb_textedit.h +- stb_truetype: https://github.com/nothings/stb/blob/master/stb_truetype.h +- stb_rectpack: https://github.com/nothings/stb/blob/master/stb_rect_pack.h + +Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license) + +Big thank you to Omar Cornut (ocornut@github) for his imgui library (https://github.com/ocornut/imgui) +and giving me the inspiration for this library, Casey Muratori for handmade +hero and his original immediate mode graphical user interface idea and Sean +Barret for his amazing single header libraries which restored my faith +in libraries and brought me to create some of my own. Finally Apoorva Joshi +for his single header file packer. + +*/ diff --git a/src/CHANGELOG b/src/CHANGELOG index a2d01eb66..6c720fd8c 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -1,8 +1,7 @@ -/// ## Changelog -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/// The CHANGELOG can be found for each release in: -/// https://github.com/Immediate-Mode-UI/Nuklear/releases -/// -/// An archive of the old changelog can be found in the wiki: -/// https://github.com/Immediate-Mode-UI/Nuklear/wiki/CHANGELOG -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Changelog + +The CHANGELOG can be found for each release in: +https://github.com/Immediate-Mode-UI/Nuklear/releases + +An archive of the old changelog can be found in the wiki: +https://github.com/Immediate-Mode-UI/Nuklear/wiki/CHANGELOG diff --git a/src/CREDITS b/src/CREDITS index b2458cc4c..8508cbc46 100644 --- a/src/CREDITS +++ b/src/CREDITS @@ -1,24 +1,17 @@ -/// ## Gallery -/// ![Figure [blue]: Feature overview with blue color styling](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png) -/// ![Figure [red]: Feature overview with red color styling](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png) -/// ![Figure [widgets]: Widget overview](https://cloud.githubusercontent.com/assets/8057201/11282359/3325e3c6-8eff-11e5-86cb-cf02b0596087.png) -/// ![Figure [blackwhite]: Black and white](https://cloud.githubusercontent.com/assets/8057201/11033668/59ab5d04-86e5-11e5-8091-c56f16411565.png) -/// ![Figure [filexp]: File explorer](https://cloud.githubusercontent.com/assets/8057201/10718115/02a9ba08-7b6b-11e5-950f-adacdd637739.png) -/// ![Figure [opengl]: OpenGL Editor](https://cloud.githubusercontent.com/assets/8057201/12779619/2a20d72c-ca69-11e5-95fe-4edecf820d5c.png) -/// ![Figure [nodedit]: Node Editor](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif) -/// ![Figure [skinning]: Using skinning in Nuklear](https://cloud.githubusercontent.com/assets/8057201/15991632/76494854-30b8-11e6-9555-a69840d0d50b.png) -/// ![Figure [bf]: Heavy modified version](https://cloud.githubusercontent.com/assets/8057201/14902576/339926a8-0d9c-11e6-9fee-a8b73af04473.png) -/// -/// ## Credits -/// Developed by Micha Mettke and every direct or indirect github contributor.

-/// -/// Embeds [stb_texedit](https://github.com/nothings/stb/blob/master/stb_textedit.h), [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) and [stb_rectpack](https://github.com/nothings/stb/blob/master/stb_rect_pack.h) by Sean Barret (public domain)
-/// Uses [stddoc.c](https://github.com/r-lyeh/stddoc.c) from r-lyeh@github.com for documentation generation

-/// Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license).
-/// -/// Big thank you to Omar Cornut (ocornut@github) for his [imgui library](https://github.com/ocornut/imgui) and -/// giving me the inspiration for this library, Casey Muratori for handmade hero -/// and his original immediate mode graphical user interface idea and Sean -/// Barret for his amazing single header libraries which restored my faith -/// in libraries and brought me to create some of my own. Finally Apoorva Joshi -/// for his single header file packer. +Credits + +Developed by Micha Mettke and every direct or indirect github contributor. + +Embeds stb public domain libraries by Sean Barret... +- stb_texedit: https://github.com/nothings/stb/blob/master/stb_textedit.h +- stb_truetype: https://github.com/nothings/stb/blob/master/stb_truetype.h +- stb_rectpack: https://github.com/nothings/stb/blob/master/stb_rect_pack.h + +Embeds ProggyClean.ttf font by Tristan Grimmer (MIT license) + +Big thank you to Omar Cornut (ocornut@github) for his imgui library (https://github.com/ocornut/imgui) +and giving me the inspiration for this library, Casey Muratori for handmade +hero and his original immediate mode graphical user interface idea and Sean +Barret for his amazing single header libraries which restored my faith +in libraries and brought me to create some of my own. Finally Apoorva Joshi +for his single header file packer. diff --git a/src/HEADER.h b/src/HEADER.h new file mode 100644 index 000000000..ef59d6a62 --- /dev/null +++ b/src/HEADER.h @@ -0,0 +1,186 @@ +/** + * Nuklear + * Single-header ANSI C immediate mode cross-platform GUI library. + * + * VERSION: + * v4.13.3 + * + * HOMEPAGE: + * https://github.com/Immediate-Mode-UI/Nuklear/ + * + * ABOUT: + * This is a minimal state immediate mode graphical user interface toolkit + * written in ANSI C and licensed under public domain. It was designed as a simple + * embeddable user interface for application and does not have any dependencies, + * a default renderbackend or OS window and input handling but instead provides a very modular + * library approach by using simple input state for input and draw + * commands describing primitive shapes as output. So instead of providing a + * layered library that tries to abstract over a number of platform and + * render backends it only focuses on the actual UI. + * + * HIGHLIGHTS: + * - Graphical user interface toolkit + * - Single header library + * - Written in C89 (a.k.a. ANSI C or ISO C90) + * - Small codebase (~18kLOC) + * - Focus on portability, efficiency and simplicity + * - No dependencies (not even the standard library if not wanted) + * - Fully skinnable and customizable + * - Low memory footprint with total memory control if needed or wanted + * - UTF-8 support + * - No global or hidden state + * - Customizable library modules (you can compile and use only what you need) + * - Optional font baker and vertex buffer output + * + * FEATURES: + * - Absolutely no platform dependent code + * - Memory management control ranging from/to + * - Ease of use by allocating everything from standard library + * - Control every byte of memory inside the library + * - Font handling control ranging from/to + * - Use your own font implementation for everything + * - Use this libraries internal font baking and handling API + * - Drawing output control ranging from/to + * - Simple shapes for more high level APIs which already have drawing capabilities + * - Hardware accessible anti-aliased vertex buffer output + * - Customizable colors and properties ranging from/to + * - Simple changes to color by filling a simple color table + * - Complete control with ability to use skinning to decorate widgets + * - Bendable UI library with widget ranging from/to + * - Basic widgets like buttons, checkboxes, slider, ... + * - Advanced widget like abstract comboboxes, contextual menus,... + * - Compile time configuration to only compile what you need + * - Subset which can be used if you do not want to link or use the standard library + * - Can be easily modified to only update on user input instead of frame updates + * + * USAGE: + * This library is self contained in one single header file and can be used either + * in header only mode or in implementation mode. The header only mode is used + * by default when included and allows including this header in other headers + * and does not contain the actual implementation. + * The implementation mode requires to define the preprocessor macro + * NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.: + * + * #define NK_IMPLEMENTATION + * #include "nuklear.h" + * + * Also optionally define the symbols listed in the section "OPTIONAL DEFINES" + * below in header and implementation mode if you want to use additional functionality + * or need more control over the library. + * + * @warning Every time nuklear is included define the same compiler flags. This is very + * important — not doing so could lead to compiler errors or even worse stack corruptions. + * + * @subsection flags Flags + * Flag | Description + * --------------------------------|------------------------------------------ + * NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation + * NK_INCLUDE_FIXED_TYPES | If defined it will include header `` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself. + * NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management. + * NK_INCLUDE_STANDARD_IO | If defined it will include header `` and provide additional functions depending on file loading. + * NK_INCLUDE_STANDARD_VARARGS | If defined it will include header `` and provide additional functions depending on file loading. + * NK_INCLUDE_STANDARD_BOOL | If defined it will include header `` for nk_bool otherwise nuklear defines nk_bool as int. + * NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,... + * NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it. + * NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font + * NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures. + * NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released. + * NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame. + * NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit + * NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events + * NK_IS_WORD_BOUNDARY(c) | Define this to a function macro that takes a single nk_rune (nk_uint) and returns true if it's a word separator. If not defined, uses the default definition (see nk_is_word_boundary()) + * + * @warning The following flags will pull in the standard C library: + * - NK_INCLUDE_DEFAULT_ALLOCATOR + * - NK_INCLUDE_STANDARD_IO + * - NK_INCLUDE_STANDARD_VARARGS + * + * @warning The following flags if defined need to be defined for both header and implementation: + * - NK_INCLUDE_FIXED_TYPES + * - NK_INCLUDE_DEFAULT_ALLOCATOR + * - NK_INCLUDE_STANDARD_VARARGS + * - NK_INCLUDE_STANDARD_BOOL + * - NK_INCLUDE_VERTEX_BUFFER_OUTPUT + * - NK_INCLUDE_FONT_BAKING + * - NK_INCLUDE_DEFAULT_FONT + * - NK_INCLUDE_COMMAND_USERDATA + * - NK_UINT_DRAW_INDEX + * + * @subsection constants Constants + * Define | Description + * --------------------------------|--------------------------------------- + * NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it. + * NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string. Under normal circumstances this should be more than sufficient. + * NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient. + * + * @warning The following constants if defined need to be defined for both header and implementation: + * - NK_MAX_NUMBER_BUFFER + * - NK_BUFFER_DEFAULT_INITIAL_SIZE + * - NK_INPUT_MAX + * + * @subsection dependencies Dependencies + * Function | Description + * -------------|--------------------------------------------------------------- + * NK_ASSERT | If you don't define this, nuklear will use `` with assert(). + * NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. + * NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. + * NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. + * NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. + * NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. + * NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). + * NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). + * NK_VSNPRINTF | If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe. + * + * @warning The following dependencies will pull in the standard C library if not redefined: + * - NK_ASSERT + * + * @warning The following dependencies if defined need to be defined for both header and implementation: + * - NK_ASSERT + * + * @warning The following dependencies if defined need to be defined only for the implementation part: + * - NK_MEMSET + * - NK_MEMCPY + * - NK_SQRT + * - NK_SIN + * - NK_COS + * - NK_STRTOD + * - NK_DTOA + * - NK_VSNPRINTF + * + * @section example Example + * + * ```c + * // init gui state + * enum {EASY, HARD}; + * static int op = EASY; + * static float value = 0.6f; + * static int i = 20; + * struct nk_context ctx; + * + * nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); + * if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), + * NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) { + * // fixed widget pixel width + * nk_layout_row_static(&ctx, 30, 80, 1); + * if (nk_button_label(&ctx, "button")) { + * // event handling + * } + * + * // fixed widget window ratio width + * nk_layout_row_dynamic(&ctx, 30, 2); + * if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY; + * if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD; + * + * // custom widget pixel width + * nk_layout_row_begin(&ctx, NK_STATIC, 30, 2); + * { + * nk_layout_row_push(&ctx, 50); + * nk_label(&ctx, "Volume:", NK_TEXT_LEFT); + * nk_layout_row_push(&ctx, 110); + * nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f); + * } + * nk_layout_row_end(&ctx); + * } + * nk_end(&ctx); + * ``` + */ diff --git a/src/HEADER.md b/src/HEADER.md deleted file mode 100644 index 60b24788c..000000000 --- a/src/HEADER.md +++ /dev/null @@ -1,217 +0,0 @@ -# Nuklear -![](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif) - -## Contents -1. About section -2. Highlights section -3. Features section -4. Usage section - 1. Flags section - 2. Constants section - 3. Dependencies section -5. Example section -6. API section - 1. Context section - 2. Input section - 3. Drawing section - 4. Window section - 5. Layouting section - 6. Groups section - 7. Tree section - 8. Properties section -7. License section -8. Changelog section -9. Gallery section -10. Credits section - -## About -This is a minimal state immediate mode graphical user interface toolkit -written in ANSI C and licensed under public domain. It was designed as a simple -embeddable user interface for application and does not have any dependencies, -a default renderbackend or OS window and input handling but instead provides a very modular -library approach by using simple input state for input and draw -commands describing primitive shapes as output. So instead of providing a -layered library that tries to abstract over a number of platform and -render backends it only focuses on the actual UI. - -## Highlights -- Graphical user interface toolkit -- Single header library -- Written in C89 (a.k.a. ANSI C or ISO C90) -- Small codebase (~18kLOC) -- Focus on portability, efficiency and simplicity -- No dependencies (not even the standard library if not wanted) -- Fully skinnable and customizable -- Low memory footprint with total memory control if needed or wanted -- UTF-8 support -- No global or hidden state -- Customizable library modules (you can compile and use only what you need) -- Optional font baker and vertex buffer output -- [Code available on github](https://github.com/Immediate-Mode-UI/Nuklear/) - -## Features -- Absolutely no platform dependent code -- Memory management control ranging from/to - - Ease of use by allocating everything from standard library - - Control every byte of memory inside the library -- Font handling control ranging from/to - - Use your own font implementation for everything - - Use this libraries internal font baking and handling API -- Drawing output control ranging from/to - - Simple shapes for more high level APIs which already have drawing capabilities - - Hardware accessible anti-aliased vertex buffer output -- Customizable colors and properties ranging from/to - - Simple changes to color by filling a simple color table - - Complete control with ability to use skinning to decorate widgets -- Bendable UI library with widget ranging from/to - - Basic widgets like buttons, checkboxes, slider, ... - - Advanced widget like abstract comboboxes, contextual menus,... -- Compile time configuration to only compile what you need - - Subset which can be used if you do not want to link or use the standard library -- Can be easily modified to only update on user input instead of frame updates - -## Usage -This library is self contained in one single header file and can be used either -in header only mode or in implementation mode. The header only mode is used -by default when included and allows including this header in other headers -and does not contain the actual implementation.

- -The implementation mode requires to define the preprocessor macro -NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.: - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C - #define NK_IMPLEMENTATION - #include "nuklear.h" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Also optionally define the symbols listed in the section "OPTIONAL DEFINES" -below in header and implementation mode if you want to use additional functionality -or need more control over the library. - -!!! WARNING - Every time nuklear is included define the same compiler flags. This very important not doing so could lead to compiler errors or even worse stack corruptions. - -### Flags -Flag | Description ---------------------------------|------------------------------------------ -NK_PRIVATE | If defined declares all functions as static, so they can only be accessed inside the file that contains the implementation -NK_INCLUDE_FIXED_TYPES | If defined it will include header `` for fixed sized types otherwise nuklear tries to select the correct type. If that fails it will throw a compiler error and you have to select the correct types yourself. -NK_INCLUDE_DEFAULT_ALLOCATOR | If defined it will include header `` and provide additional functions to use this library without caring for memory allocation control and therefore ease memory management. -NK_INCLUDE_STANDARD_IO | If defined it will include header `` and provide additional functions depending on file loading. -NK_INCLUDE_STANDARD_VARARGS | If defined it will include header and provide additional functions depending on file loading. -NK_INCLUDE_STANDARD_BOOL | If defined it will include header `` for nk_bool otherwise nuklear defines nk_bool as int. -NK_INCLUDE_VERTEX_BUFFER_OUTPUT | Defining this adds a vertex draw command list backend to this library, which allows you to convert queue commands into vertex draw commands. This is mainly if you need a hardware accessible format for OpenGL, DirectX, Vulkan, Metal,... -NK_INCLUDE_FONT_BAKING | Defining this adds `stb_truetype` and `stb_rect_pack` implementation to this library and provides font baking and rendering. If you already have font handling or do not want to use this font handler you don't have to define it. -NK_INCLUDE_DEFAULT_FONT | Defining this adds the default font: ProggyClean.ttf into this library which can be loaded into a font atlas and allows using this library without having a truetype font -NK_INCLUDE_COMMAND_USERDATA | Defining this adds a userdata pointer into each command. Can be useful for example if you want to provide custom shaders depending on the used widget. Can be combined with the style structures. -NK_BUTTON_TRIGGER_ON_RELEASE | Different platforms require button clicks occurring either on buttons being pressed (up to down) or released (down to up). By default this library will react on buttons being pressed, but if you define this it will only trigger if a button is released. -NK_ZERO_COMMAND_MEMORY | Defining this will zero out memory for each drawing command added to a drawing queue (inside nk_command_buffer_push). Zeroing command memory is very useful for fast checking (using memcmp) if command buffers are equal and avoid drawing frames when nothing on screen has changed since previous frame. -NK_UINT_DRAW_INDEX | Defining this will set the size of vertex index elements when using NK_VERTEX_BUFFER_OUTPUT to 32bit instead of the default of 16bit -NK_KEYSTATE_BASED_INPUT | Define this if your backend uses key state for each frame rather than key press/release events -NK_IS_WORD_BOUNDARY(c) | Define this to a function macro that takes a single nk_rune (nk_uint) and returns true if it's a word separator. If not defined, uses the default definition (see nk_is_word_boundary()) - -!!! WARNING - The following flags will pull in the standard C library: - - NK_INCLUDE_DEFAULT_ALLOCATOR - - NK_INCLUDE_STANDARD_IO - - NK_INCLUDE_STANDARD_VARARGS - -!!! WARNING - The following flags if defined need to be defined for both header and implementation: - - NK_INCLUDE_FIXED_TYPES - - NK_INCLUDE_DEFAULT_ALLOCATOR - - NK_INCLUDE_STANDARD_VARARGS - - NK_INCLUDE_STANDARD_BOOL - - NK_INCLUDE_VERTEX_BUFFER_OUTPUT - - NK_INCLUDE_FONT_BAKING - - NK_INCLUDE_DEFAULT_FONT - - NK_INCLUDE_STANDARD_VARARGS - - NK_INCLUDE_COMMAND_USERDATA - - NK_UINT_DRAW_INDEX - -### Constants -Define | Description ---------------------------------|--------------------------------------- -NK_BUFFER_DEFAULT_INITIAL_SIZE | Initial buffer size allocated by all buffers while using the default allocator functions included by defining NK_INCLUDE_DEFAULT_ALLOCATOR. If you don't want to allocate the default 4k memory then redefine it. -NK_MAX_NUMBER_BUFFER | Maximum buffer size for the conversion buffer between float and string Under normal circumstances this should be more than sufficient. -NK_INPUT_MAX | Defines the max number of bytes which can be added as text input in one frame. Under normal circumstances this should be more than sufficient. - -!!! WARNING - The following constants if defined need to be defined for both header and implementation: - - NK_MAX_NUMBER_BUFFER - - NK_BUFFER_DEFAULT_INITIAL_SIZE - - NK_INPUT_MAX - -### Dependencies -Function | Description -------------|--------------------------------------------------------------- -NK_ASSERT | If you don't define this, nuklear will use with assert(). -NK_MEMSET | You can define this to 'memset' or your own memset implementation replacement. If not nuklear will use its own version. -NK_MEMCPY | You can define this to 'memcpy' or your own memcpy implementation replacement. If not nuklear will use its own version. -NK_INV_SQRT | You can define this to your own inverse sqrt implementation replacement. If not nuklear will use its own slow and not highly accurate version. -NK_SIN | You can define this to 'sinf' or your own sine implementation replacement. If not nuklear will use its own approximation implementation. -NK_COS | You can define this to 'cosf' or your own cosine implementation replacement. If not nuklear will use its own approximation implementation. -NK_STRTOD | You can define this to `strtod` or your own string to double conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). -NK_DTOA | You can define this to `dtoa` or your own double to string conversion implementation replacement. If not defined nuklear will use its own imprecise and possibly unsafe version (does not handle nan or infinity!). -NK_VSNPRINTF| If you define `NK_INCLUDE_STANDARD_VARARGS` as well as `NK_INCLUDE_STANDARD_IO` and want to be safe define this to `vsnprintf` on compilers supporting later versions of C or C++. By default nuklear will check for your stdlib version in C as well as compiler version in C++. if `vsnprintf` is available it will define it to `vsnprintf` directly. If not defined and if you have older versions of C or C++ it will be defined to `vsprintf` which is unsafe. - -!!! WARNING - The following dependencies will pull in the standard C library if not redefined: - - NK_ASSERT - -!!! WARNING - The following dependencies if defined need to be defined for both header and implementation: - - NK_ASSERT - -!!! WARNING - The following dependencies if defined need to be defined only for the implementation part: - - NK_MEMSET - - NK_MEMCPY - - NK_SQRT - - NK_SIN - - NK_COS - - NK_STRTOD - - NK_DTOA - - NK_VSNPRINTF - -## Example - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c -// init gui state -enum {EASY, HARD}; -static int op = EASY; -static float value = 0.6f; -static int i = 20; -struct nk_context ctx; - -nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); -if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), - NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) { - // fixed widget pixel width - nk_layout_row_static(&ctx, 30, 80, 1); - if (nk_button_label(&ctx, "button")) { - // event handling - } - - // fixed widget window ratio width - nk_layout_row_dynamic(&ctx, 30, 2); - if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY; - if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD; - - // custom widget pixel width - nk_layout_row_begin(&ctx, NK_STATIC, 30, 2); - { - nk_layout_row_push(&ctx, 50); - nk_label(&ctx, "Volume:", NK_TEXT_LEFT); - nk_layout_row_push(&ctx, 110); - nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f); - } - nk_layout_row_end(&ctx); -} -nk_end(&ctx); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -![](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png) - -## API - diff --git a/src/LICENSE b/src/LICENSE deleted file mode 100644 index c0fb9af45..000000000 --- a/src/LICENSE +++ /dev/null @@ -1,43 +0,0 @@ -/// ## License -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~none -/// ------------------------------------------------------------------------------ -/// This software is available under 2 licenses -- choose whichever you prefer. -/// ------------------------------------------------------------------------------ -/// ALTERNATIVE A - MIT License -/// Copyright (c) 2016-2018 Micha Mettke -/// Permission is hereby granted, free of charge, to any person obtaining a copy of -/// this software and associated documentation files (the "Software"), to deal in -/// the Software without restriction, including without limitation the rights to -/// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -/// of the Software, and to permit persons to whom the Software is furnished to do -/// so, subject to the following conditions: -/// The above copyright notice and this permission notice shall be included in all -/// copies or substantial portions of the Software. -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -/// SOFTWARE. -/// ------------------------------------------------------------------------------ -/// ALTERNATIVE B - Public Domain (www.unlicense.org) -/// This is free and unencumbered software released into the public domain. -/// Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -/// software, either in source code form or as a compiled binary, for any purpose, -/// commercial or non-commercial, and by any means. -/// In jurisdictions that recognize copyright laws, the author or authors of this -/// software dedicate any and all copyright interest in the software to the public -/// domain. We make this dedication for the benefit of the public at large and to -/// the detriment of our heirs and successors. We intend this dedication to be an -/// overt act of relinquishment in perpetuity of all present and future rights to -/// this software under copyright law. -/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -/// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -/// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -/// ------------------------------------------------------------------------------ -/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - diff --git a/src/README.md b/src/README.md new file mode 100644 index 000000000..4269697af --- /dev/null +++ b/src/README.md @@ -0,0 +1,8 @@ +# File Packer + +This will build out [nuklear.h](../nuklear.h). + +## Usage + +- On Linux/Mac, run `./paq.sh` +- On Windows just run `paq.bat` diff --git a/src/Readme.md b/src/Readme.md deleted file mode 100644 index e4d9ad3e2..000000000 --- a/src/Readme.md +++ /dev/null @@ -1,4 +0,0 @@ -File Packer: ------------- -- On Linux/Mac just run ./paq.sh > ../nuklear.h -- On Windows just run paq.bat diff --git a/src/build.py b/src/build.py index ff5c455d8..26e2e609e 100644 --- a/src/build.py +++ b/src/build.py @@ -15,9 +15,7 @@ def print_help(): The resulting code is packed as follows: - /* [intro file contents] - */ #ifndef _SINGLE_HEADER #define _SINGLE_HEADER @@ -131,10 +129,8 @@ def fix_comments(str): # Print concatenated output # ------------------------- -print("/*") for f in intro_files: sys.stdout.write(open(f, 'r').read()) -print("*/") # print("\n#ifndef " + macro + "_SINGLE_HEADER"); # print("#define " + macro + "_SINGLE_HEADER"); @@ -162,8 +158,8 @@ def fix_comments(str): print("#endif /* " + macro + "_IMPLEMENTATION */"); -print("\n/*") +print("/*") for f in outro_files: sys.stdout.write(open(f, 'r').read()) -print("*/\n") - + print("") +print("*/") diff --git a/src/paq.bat b/src/paq.bat index 654734819..57b468b90 100644 --- a/src/paq.bat +++ b/src/paq.bat @@ -1 +1 @@ -build.py --macro NK --intro HEADER.md --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ..\nuklear.h +build.py --macro NK --intro HEADER.h --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro ../LICENSE,CHANGELOG,CREDITS > ..\nuklear.h diff --git a/src/paq.sh b/src/paq.sh index 5e8a1da48..d1bdb27fe 100755 --- a/src/paq.sh +++ b/src/paq.sh @@ -1,2 +1,2 @@ #!/bin/sh -python3 build.py --macro NK --intro HEADER.md --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h +python3 build.py --macro NK --intro HEADER.h --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_knob.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro ../LICENSE,CHANGELOG,CREDITS > ../nuklear.h