((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/nuklear" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "nuklear" (toc) (section 3 "Introduction" (p "This egg provides an incomplete set of bindings to the " (link "https://github.com/vurtun/nuklear" "nuklear") " immediate mode GUI library.")) (section 3 "Author" (p "Vasilij Schneidermann")) (section 3 "Repository" (p (link "https://depp.brause.cc/nuklear"))) (section 3 "Current state of the bindings" (section 4 "Backends" (ul (li (tt "glfw-opengl2")))) (section 4 "API Support" (p "Everything required for " (link "https://github.com/vurtun/nuklear/tree/master/demo/glfw_opengl2" "the GLFW3 OpenGL2 demos") " is supported.")) (section 4 "Vendored headers" (p "Last synced: 07-06-2016"))) (section 3 "Requirements" (p "To compile the egg successfully, all foreign dependencies for the " (tt "glfw-opengl2") " backend must be met:") (ul (li "GLFW3") (li "GL") (li "GLU")) (p "Additionally to this, you will need a GPU supporting OpenGL2.  The setup script has only been tested on Linux and will most certainly need adjustments to work on OS X and Windows.")) (section 3 "API" (section 4 "Backends" (section 5 ((tt "glfw-opengl2") " Backend") (section 6 "anti-alias?" (def (sig (parameter "(anti-alias?)" (id anti-alias?)) (parameter "(anti-alias? FLAG)" (id anti-alias?))) (p "Controls whether anti-aliasing is enabled, defaulting to " (tt "#t") "."))) (section 6 "max-vertex-buffer" (def (sig (parameter "(max-vertex-buffer)" (id max-vertex-buffer)) (parameter "(max-vertex-buffer N)" (id max-vertex-buffer))) (p "Controls the maximum amount of vertices, defaulting to 512*1024."))) (section 6 "max-element-buffer" (def (sig (parameter "(max-element-buffer)" (id max-element-buffer)) (parameter "(max-element-buffer N)" (id max-element-buffer))) (p "Controls the maximum amount of elements, defaulting to 128*1024."))) (section 6 "init!" (def (sig (procedure "(init! window install-callbacks?)" (id init!))) (p "Initializes the backend and returns a context to be used in all GUI procedures.  " (tt "WINDOW") " must be a GLFW3 window and can be obtained with its " (tt "(window)") " parameter after successful setup.  If " (tt "INSTALL-CALLBACKS?") " is " (tt "#t") ", input and scrolling callbacks are set up, otherwise the created context can only be used for visualizing data."))) (section 6 "init-font!" (def (sig (procedure "(init-font! [context path size])" (id init-font!))) (p "Initializes either the default font or a custom one if " (tt "CONTEXT") ", " (tt "PATH") " and " (tt "SIZE") " are provided.  The optional arguments need to be a previously obtained context, a string specifying the path to the font and a number for the font size."))) (section 6 "new-frame" (def (sig (procedure "(new-frame)" (id new-frame))) (p "Starts a new frame to operate on."))) (section 6 "render!" (def (sig (procedure "(render!)" (id render!))) (p "Commits all changes done to the current frame."))) (section 6 "shutdown!" (def (sig (procedure "(shutdown!)" (id shutdown!))) (p "Shuts down the backend.  This must be called after exiting the main loop and before terminating GLFW3."))))) (section 4 "Basic types" (section 5 "Panels" (section 6 "make-panel" (def (sig (procedure "(make-panel)" (id make-panel))) (p "Creates and returns a panel."))) (section 6 "panel-bounds" (def (sig (procedure "(panel-bounds PANEL)" (id panel-bounds))) (p "Returns a rectangle describing the panel's bounds.")))) (section 5 "Rects" (section 6 "make-rect" (def (sig (procedure "(make-rect X Y W H)" (id make-rect))) (p "Creates and returns a rectangle at the coordinates " (tt "X") " and " (tt "Y") " with the dimensions " (tt "W") " and " (tt "H") ".  Note that all arguments can be floats."))) (section 6 "rect-x / rect-x-set!" (def (sig (procedure "(rect-x RECT)" (id rect-x)) (procedure "(rect-x-set! RECT X)" (id rect-x-set!)) (setter "(set! (rect-x RECT) X)" (id set!))) (p "Retrieves or sets the x coordinate of " (tt "RECT") "."))) (section 6 "rect-y / rect-y-set!" (def (sig (procedure "(rect-y RECT)" (id rect-y)) (procedure "(rect-y-set! RECT Y)" (id rect-y-set!)) (setter "(set! (rect-y RECT) Y)" (id set!))) (p "Retrieves or sets the y coordinate of " (tt "RECT") "."))) (section 6 "rect-w / rect-w-set!" (def (sig (procedure "(rect-w RECT)" (id rect-w)) (procedure "(rect-w-set! RECT W)" (id rect-w-set!)) (setter "(set! (rect-w RECT) W)" (id set!))) (p "Retrieves or sets the w coordinate of " (tt "RECT") "."))) (section 6 "rect-h / rect-h-set!" (def (sig (procedure "(rect-h RECT)" (id rect-h)) (procedure "(rect-h-set! RECT H)" (id rect-h-set!)) (setter "(set! (rect-h RECT) H)" (id set!))) (p "Retrieves or sets the h coordinate of " (tt "RECT") ".")))) (section 5 "Vectors" (section 6 "make-vec2" (def (sig (procedure "(make-vec2 X Y)" (id make-vec2))) (p "Creates and returns a vector with the components " (tt "X") " and " (tt "Y") ". Note that all arguments can be floats."))) (section 6 "vec2-x / vec2-x-set!" (def (sig (procedure "(vec2-x VECTOR)" (id vec2-x)) (procedure "(vec2-x-set! VECTOR X)" (id vec2-x-set!)) (setter "(set! (vec2-x VECTOR) X)" (id set!))) (p "Retrieves or sets the x component of " (tt "VECTOR") "."))) (section 6 "vec2-y / vec2-y-set!" (def (sig (procedure "(vec2-y VECTOR)" (id vec2-y)) (procedure "(vec2-y-set! VECTOR Y)" (id vec2-y-set!)) (setter "(set! (vec2-y VECTOR) Y)" (id set!))) (p "Retrieves or sets the y component of " (tt "VECTOR") ".")))) (section 5 "Colors" (section 6 "make-color" (def (sig (procedure "(make-color R G B A)" (id make-color))) (p "Creates and returns a color with the components " (tt "R") ", " (tt "G") ", " (tt "B") " and " (tt "A") ".  All arguments must be integers between 0 and 255."))) (section 6 "color-r / color-r-set!" (def (sig (procedure "(color-r COLOR)" (id color-r)) (procedure "(color-r-set! COLOR R)" (id color-r-set!)) (setter "(set! (color-r COLOR) R)" (id set!))) (p "Retrieves or sets the red component of " (tt "COLOR") "."))) (section 6 "color-g / color-g-set!" (def (sig (procedure "(color-g COLOR)" (id color-g)) (procedure "(color-g-set! COLOR G)" (id color-g-set!)) (setter "(set! (color-g COLOR) G)" (id set!))) (p "Retrieves or sets the green component of " (tt "COLOR") "."))) (section 6 "color-b / color-b-set!" (def (sig (procedure "(color-b COLOR)" (id color-b)) (procedure "(color-b-set! COLOR B)" (id color-b-set!)) (setter "(set! (color-b COLOR) B)" (id set!))) (p "Retrieves or sets the blue component of " (tt "COLOR") "."))) (section 6 "color-a / color-a-set!" (def (sig (procedure "(color-a COLOR)" (id color-a)) (procedure "(color-a-set! COLOR A)" (id color-a-set!)) (setter "(set! (color-a COLOR) A)" (id set!))) (p "Retrieves or sets the alpha component of " (tt "COLOR") ".")))) (section 5 "Color helpers" (section 6 "rgb->color" (def (sig (procedure "(rgb->color R G B)" (id rgb->color))) (p "Returns a color with the components " (tt "R") ", " (tt "G") " and " (tt "B") ".  All arguments must be integers between 0 and 255."))) (section 6 "color->rgba-floats" (def (sig (procedure "(color->rgba-floats COLOR)" (id color->rgba-floats))) (p "Returns a list of red, green, blue and alpha components as floats between 0 and 1."))) (section 6 "hsva->color" (def (sig (procedure "(hsva->color H S V A)" (id hsva->color))) (p "Returns a color with the components " (tt "H") ", " (tt "S") ", " (tt "V") " and " (tt "A") ". All arguments must be integers between 0 and 255."))) (section 6 "color->hsva-ints" (def (sig (procedure "(color->hsva-ints COLOR)" (id color->hsva-ints))) (p "Returns a list of hue, saturation, value and alpha components as integers between 0 and 255."))))) (section 4 "Window helpers" (section 5 "window-bounds" (def (sig (procedure "(window-bounds CONTEXT)" (id window-bounds))) (p "Returns a rectangle describing the boundaries of the currently active window."))) (section 5 "window-content-region" (def (sig (procedure "(window-content-region CONTEXT)" (id window-content-region))) (p "Returns a rectangle describing the content region of the currently active window."))) (section 5 "window-canvas" (def (sig (procedure "(window-canvas CONTEXT)" (id window-canvas))) (p "Returns a canvas suitable for drawing on the currently active window."))) (section 5 "window-closed?" (def (sig (procedure "(window-closed? CONTEXT TITLE)" (id window-closed?))) (p "Returns " (tt "#t") " if a window as identified by " (tt "TITLE") " is no longer open, otherwise " (tt "#f") ".")))) (section 4 "Layouts" (section 5 "Constrained positioning" (section 6 "layout-row-dynamic" (def (sig (procedure "(layout-row-dynamic CONTEXT HEIGHT COLUMNS)" (id layout-row-dynamic))) (p "Sets up the following widgets to be positioned dynamically into rows. " (tt "HEIGHT") " is the height of the row, " (tt "COLUMNS") " the amount of widgets per row."))) (section 6 "layout-row-static" (def (sig (procedure "(layout-row-static CONTEXT HEIGHT ITEM-WIDTH COLUMNS)" (id layout-row-static))) (p "Sets up the following widgets to be positioned statically into rows. " (tt "HEIGHT") " is the height of the row, " (tt "ITEM-WIDTH") " the width of each widget and " (tt "COLUMNS") " the amount of widgets per row."))) (section 6 "layout-row-begin" (def (sig (procedure "(layout-row-begin CONTEXT DYNAMIC? HEIGHT COLUMNS)" (id layout-row-begin))) (p "Sets up the following widgets to be positioned dynamically or statically into a row, depending on " (tt "DYNAMIC?") ".  " (tt "COLUMNS") " is the amount of widgets to be positioned."))) (section 6 "layout-row-push" (def (sig (procedure "(layout-row-push CONTEXT RATIO-OR-WIDTH)" (id layout-row-push))) (p "Adds a widget to a row.  If the positioning is dynamic, " (tt "RATIO-OR-WIDTH") " is interpreted as ratio, otherwise as width in pixels."))) (section 6 "layout-row-end" (def (sig (procedure "(layout-row-end CONTEXT)" (id layout-row-end))) (p "Terminates a layouted row."))) (section 6 "layout-row" (def (sig (procedure "(layout-row CONTEXT DYNAMIC? HEIGHT RATIOS-OR-WIDTHS)" (id layout-row))) (p "Sets up the following widgets to be positioned dynamically or statically into a row, depending on " (tt "DYNAMIC?") ".  " (tt "HEIGHT") " is the height of the row.  " (tt "RATIONS-OR-WIDTHS") " is a list of ratios or widths, depending on " (tt "DYNAMIC?") ".  This is equivalent to using " (tt "layout-row-begin") ", " (tt "layout-row-push") " and " (tt "layout-row-end") ".")))) (section 5 "Free positioning" (section 6 "layout-space-begin" (def (sig (procedure "(layout-space-begin CONTEXT DYNAMIC? HEIGHT WIDGET-COUNT)" (id layout-space-begin))) (p "Sets up the following widgets to be positioned freely.  If " (tt "DYNAMIC?") " is " (tt "#t") ", widgets are scaled.  " (tt "HEIGHT") " is the total height of all widgets,  " (tt "WIDGET-COUNT") " the number of widgets."))) (section 6 "layout-space-push" (def (sig (procedure "(layout-space-push CONTEXT RECT)" (id layout-space-push))) (p "Adds a freely positioned widget at " (tt "RECT") "."))) (section 6 "layout-space-end" (def (sig (procedure "(layout-space-end CONTEXT)" (id layout-space-end))) (p "Terminates free positioning.")))) (section 5 "Layout space helpers" (section 6 "layout-space-bounds" (def (sig (procedure "(layout-space-bounds CONTEXT)" (id layout-space-bounds))) (p "Returns a rectangle describing the inner bounds of the current widget."))) (section 6 "layout-space-to-screen" (def (sig (procedure "(layout-space-to-screen CONTEXT VECTOR)" (id layout-space-to-screen))) (p "Returns a copy of " (tt "VECTOR") " with absolute coordinates."))) (section 6 "layout-space-rect-to-screen" (def (sig (procedure "(layout-space-rect-to-screen CONTEXT RECT)" (id layout-space-rect-to-screen))) (p "Returns a copy of " (tt "RECT") " with absolute coordinates."))) (section 6 "layout-space-rect-to-local" (def (sig (procedure "(layout-space-rect-to-local CONTEXT RECT)" (id layout-space-rect-to-local))) (p "Returns a copy of " (tt "RECT") " with relative coordinates.")))) (section 5 "Misc" (section 6 "spacing" (def (sig (procedure "(spacing CONTEXT COLUMNS)" (id spacing))) (p "Adds " (tt "COLUMNS") " of spacing."))))) (section 4 "Blocks" (section 5 "Window block" (section 6 "window-begin" (def (sig (procedure "(window-begin CONTEXT PANEL TITLE RECT FLAG-OR-FLAGS)" (id window-begin))) (p "Starts a window block with " (tt "TITLE") " as window title.  " (tt "RECT") " specifies the window boundaries.  " (tt "FLAG-OR-FLAGS") " is a symbol or a list of symbols, each of which must be one of " (tt "(border border-header movable scalable closable minimizable dynamic no-scrollbar title)") ". Returns " (tt "#t") " if the window is visible."))) (section 6 "window-end" (def (sig (procedure "(window-end CONTEXT)" (id window-end))) (p "Terminates the window block.  Must be used after starting a window block, regardless of whether the window is visible or not.")))) (section 5 "Group block" (section 6 "group-begin" (def (sig (procedure "(group-begin CONTEXT PANEL TITLE FLAG-OR-FLAGS)" (id group-begin))) (p "Starts a group block with " (tt "TEXT") " as title.  " (tt "FLAG-OR-FLAGS") " is a symbol or list of symbols, each of which must be one of " (tt "(border border-header movable scalable closable minimizable dynamic no-scrollbar title)") ".  Returns " (tt "#t") " if the group is visible."))) (section 6 "group-end" (def (sig (procedure "(group-end CONTEXT)" (id group-end))) (p "Terminates the group block.  May only be used when the group is visible.")))) (section 5 "Tree block" (section 6 "tree-push" (def (sig (procedure "(tree-push CONTEXT TAB? TEXT MAXIMIZED?)" (id tree-push))) (p "Starts a tree block with " (tt "TEXT") " as label.  If " (tt "TAB?") " is " (tt "#t") ", the tree header is highlighted specially.  If " (tt "MAXIMIZED?") " is " (tt "#t") ", the tree starts expanded, otherwise minimized.  Returns " (tt "#t") " if the tree is expanded."))) (section 6 "tree-pop" (def (sig (procedure "(tree-pop CONTEXT)" (id tree-pop))) (p "Terminates the tree block.  May only be used when the tree is expanded.")))) (section 5 "Chart block" (section 6 "chart-begin" (def (sig (procedure "(chart-begin CONTEXT LINES? COUNT MIN-VALUE MAX-VALUE)" (id chart-begin))) (p "Starts a chart block.  If " (tt "LINES?") " is " (tt "#t") ", draw lines, otherwise columns.  " (tt "COUNT") " is the number of data points, " (tt "MIN-VALUE") " and " (tt "MAX-VALUE") " the extremes.  Returns " (tt "#t") " if the chart is visible."))) (section 6 "chart-begin-colored" (def (sig (procedure "(chart-begin-colored CONTEXT LINES? COLOR HIGHLIGHT COUNT MIN-VALUE MAX-VALUE)" (id chart-begin-colored))) (p "Starts a colored chart block.  If " (tt "LINES?") " if " (tt "#t") ", draw lines, otherwise columns.  " (tt "COLOR") " is used for the chart itself and " (tt "HIGHLIGHT") " for values hovered over.  " (tt "COUNT") " is the number of data points, " (tt "MIN-VALUE") " and " (tt "MAX-VALUE") " the extremes.  Returns " (tt "#t") " if the chart is visible."))) (section 6 "chart-push" (def (sig (procedure "(chart-push CONTEXT VALUE)" (id chart-push))) (p "Adds " (tt "VALUE") " to the data points in the chart.  Returns either " (tt "#f") " or a list of events for the data point, each of which is one of " (tt "(hovering clicked)") "."))) (section 6 "chart-push-slot" (def (sig (procedure "(chart-push-slot CONTEXT VALUE SLOT)" (id chart-push-slot))) (p "Adds " (tt "VALUE") " to the data points in the chart " (tt "SLOT") ".  Returns either " (tt "#f") " or a list of events for the data point, each of which is one of " (tt "(hovering clicked)") "."))) (section 6 "chart-add-slot" (def (sig (procedure "(chart-add-slot CONTEXT LINES? COUNT MIN-VALUE MAX-VALUE)" (id chart-add-slot))) (p "Adds an extra slot to the chart.  Slots are integer values starting from 0.  If " (tt "LINES?") " is " (tt "#t") ", draw lines, otherwise columns. " (tt "COUNT") " is the number of data points, " (tt "MIN-VALUE") " and " (tt "MAX-VALUE") " the extremes."))) (section 6 "chart-add-slot-colored" (def (sig (procedure "(chart-add-slot-colored CONTEXT LINES? COLOR HIGHLIGHT COUNT MIN-VALUE MAX-VALUE)" (id chart-add-slot-colored))) (p "Adds an extra colored slot to the chart.  If " (tt "LINES?") " is " (tt "#t") ", draw lines, otherwise columns.  " (tt "COLOR") " is used for the chart itself and " (tt "HIGHLIGHT") " for values hovered over.  " (tt "COUNT") " is the number of data points, " (tt "MIN-VALUE") " and " (tt "MAX-VALUE") " the extremes."))) (section 6 "chart-end" (def (sig (procedure "(chart-end CONTEXT)" (id chart-end))) (p "Terminates a chart block.")))) (section 5 "Popup block" (section 6 "popup-begin" (def (sig (procedure "(popup-begin CONTEXT PANEL DYNAMIC? FLAG-OR-FLAGS RECT)" (id popup-begin))) (p "Starts a popup block.  If " (tt "DYNAMIC?") " is " (tt "#t") ", the popup uses the " (tt "dynamic") " flag.  " (tt "FLAG-OR-FLAGS") " is a symbol or list of symbols, each of which must be one of " (tt "(border border-header movable scalable closable minimizable dynamic no-scrollbar title)") ".  " (tt "RECT") " specifies the boundaries of the popup.  Returns " (tt "#t") " if the popup is visible."))) (section 6 "popup-close" (def (sig (procedure "(popup-close CONTEXT)" (id popup-close))) (p "Closes the popup.  Must be used inside a popup block."))) (section 6 "popup-end" (def (sig (procedure "(popup-end CONTEXT)" (id popup-end))) (p "Terminates a popup block.  May only be used if the popup is visible.")))) (section 5 "Combo block" (section 6 "combo-begin-label" (def (sig (procedure "(combo-begin-label CONTEXT PANEL TEXT MAX-HEIGHT)" (id combo-begin-label))) (p "Starts a combo block with " (tt "TEXT") " as displayed item.  " (tt "MAX-HEIGHT") " specifies the maximum height the opened combo block may occupy. Returns " (tt "#t") " if the combo block is opened."))) (section 6 "combo-begin-color" (def (sig (procedure "(combo-begin-color CONTEXT PANEL COLOR MAX-HEIGHT)" (id combo-begin-color))) (p "Starts a combo block with " (tt "COLOR") " as displayed item.  " (tt "MAX-HEIGHT") " specifies the maximum height the opened combo block may occupy. Returns " (tt "#t") " if the combo block is opened."))) (section 6 "combo-items-height" (def (sig (procedure "(combo-items-height CONTEXT COUNT ITEM-HEIGHT)" (id combo-items-height))) (p "Returns the height " (tt "COUNT") " labels each of which is " (tt "ITEM-HEIGHT") " tall would occupy.  This includes padding and borders."))) (section 6 "combo-item-label" (def (sig (procedure "(combo-item-label CONTEXT TEXT ALIGNMENT)" (id combo-item-label))) (p "Adds a combo item with " (tt "TEXT") " as label.  " (tt "ALIGNMENT") " is a symbol and must be one of " (tt "(left centered right)") "."))) (section 6 "combo-close" (def (sig (procedure "(combo-close CONTEXT)" (id combo-close))) (p "Closes the combo block.  Must be used inside a combo block."))) (section 6 "combo-end" (def (sig (procedure "(combo-end CONTEXT)" (id combo-end))) (p "Terminates a combo block.  May only be used if the combo block is visible.")))) (section 5 "Contextual block" (section 6 "contextual-begin" (def (sig (procedure "(contextual-begin CONTEXT PANEL FLAG-OR-FLAGS SIZE TRIGGER-BOUNDS)" (id contextual-begin))) (p "Starts a context block.  " (tt "SIZE") " is a vector describing its size. " (tt "TRIGGER-BOUNDS") " is a rectangle specifying where it can be triggered with a right mouse click.  " (tt "FLAG-OR-FLAGS") " is a symbol or list of symbols, each of which must be one of " (tt "(border border-header movable scalable closable minimizable dynamic no-scrollbar title)") ".  Returns " (tt "#t") " if the context block is visible."))) (section 6 "contextual-item-label" (def (sig (procedure "(contextual-item-label CONTEXT TEXT ALIGNMENT)" (id contextual-item-label))) (p "Adds a context item to the current context block with " (tt "TEXT") " as label.  " (tt "ALIGNMENT") " is a symbol and must be one of " (tt "(left centered right)") ".  Returns " (tt "#t") " when clicked, otherwise " (tt "#f") "."))) (section 6 "contextual-end" (def (sig (procedure "(contextual-end CONTEXT)" (id contextual-end))) (p "Terminates the context block.  May only be used if the context block is visible.")))) (section 5 "Menubar block" (section 6 "menubar-begin" (def (sig (procedure "(menubar-begin CONTEXT)" (id menubar-begin))) (p "Starts a menubar block."))) (section 6 "menubar-end" (def (sig (procedure "(menubar-end CONTEXT)" (id menubar-end))) (p "Terminates a menubar block.")))) (section 5 "Menu block" (section 6 "menu-begin-label" (def (sig (procedure "(menu-begin-label CONTEXT PANEL TEXT ALIGNMENT WIDTH)" (id menu-begin-label))) (p "Starts a menu block with " (tt "TEXT") " as label.  " (tt "ALIGNMENT") " is a symbol and must be one of " (tt "(left centered right)") ".  " (tt "WIDTH") " specifies the menu width.  Returns " (tt "#t") " if the menu block is visible."))) (section 6 "menu-item-label" (def (sig (procedure "(menu-item-label CONTEXT TEXT ALIGNMENT)" (id menu-item-label))) (p "Adds a menu item to the current menu block with " (tt "TEXT") " as label. " (tt "ALIGNMENT") " is a symbol and must be one of " (tt "(left centered right)") ".  Returns " (tt "#t") " when clicked."))) (section 6 "menu-end" (def (sig (procedure "(menu-end CONTEXT)" (id menu-end))) (p "Terminates a menu block.  May only be used if the menu block is visible."))))) (section 4 "Widgets" (section 5 "Label widget" (section 6 "label" (def (sig (procedure "(label CONTEXT TEXT ALIGNMENT)" (id label))) (p "Creates a label widget with " (tt "TEXT") " as label.  " (tt "ALIGNMENT") " controls how the text is aligned and must be one of " (tt "(left centered right)") "."))) (section 6 "label-colored" (def (sig (procedure "(label-colored CONTEXT TEXT ALIGNMENT COLOR)" (id label-colored))) (p "Creates a colored label widget with " (tt "TEXT") " as label painted with " (tt "COLOR") ".  " (tt "ALIGNMENT") " controls how the text is aligned and must be one of " (tt "(left centered right)") "."))) (section 6 "label-wrap" (def (sig (procedure "(label-wrap CONTEXT TEXT)" (id label-wrap))) (p "Creates a label widget with wrapped " (tt "TEXT") " as label.")))) (section 5 "Button widget" (section 6 "button-label" (def (sig (procedure "(button-label CONTEXT TEXT [REPEATER?])" (id button-label))) (p "Creates a button widget with " (tt "TEXT") " as label.  If " (tt "REPEATER?") " is " (tt "#t") ", the button fires as long as it's clicked, otherwise only once. Returns " (tt "#t") " if the button has been clicked."))) (section 6 "button-color" (def (sig (procedure "(button-color CONTEXT COLOR [REPEATER?])" (id button-color))) (p "Creates a color button widget with " (tt "COLOR") " as value.  If " (tt "REPEATER?") " is " (tt "#t") ", the button fires as long as it's clicked, otherwise only once.  Returns " (tt "#t") " if the button has been clicked."))) (section 6 "button-symbol" (def (sig (procedure "(button-symbol CONTEXT SYMBOL [REPEATER?])" (id button-symbol))) (p "Creates a button with " (tt "SYMBOL") " on it.  " (tt "SYMBOL") " must be one of " (tt "(none x underscore circle circle-filled rect rect-filled triangle-up triangle-down triangle-left triangle-right plus minus)") ".  If " (tt "REPEATER?") " is " (tt "#t") ", the button fires as long as it's clicked, otherwise only once.  Returns " (tt "#t") " if the button has been clicked."))) (section 6 "button-symbol-label" (def (sig (procedure "(button-symbol-label CONTEXT SYMBOL TEXT ALIGNMENT [REPEATER?])" (id button-symbol-label))) (p "Creates a button with " (tt "SYMBOL") " and " (tt "TEXT") " as label on it. " (tt "SYMBOL") " must be one of " (tt "(none x underscore circle circle-filled rect rect-filled triangle-up triangle-down triangle-left triangle-right plus minus)") ".  " (tt "ALIGNMENT") " controls how the text is aligned and must be one of " (tt "(left centered right)") ".  If " (tt "REPEATER?") " is " (tt "#t") ", the button fires as long as it's clicked, otherwise only once.  Returns " (tt "#t") " if the button has been clicked.")))) (section 5 "Checkbox widget" (section 6 "checkbox-label" (def (sig (procedure "(checkbox-label CONTEXT TEXT ACTIVE?)" (id checkbox-label))) (p "Creates a checkbox widget with " (tt "TEXT") " as label and " (tt "ACTIVE?") " as value.  Returns the new value.")))) (section 5 "Option widget" (section 6 "option-label" (def (sig (procedure "(option-label CONTEXT TEXT ACTIVE?)" (id option-label))) (p "Creates an option widget with " (tt "TEXT") " as label and " (tt "ACTIVE?") " as value. Returns the new value.")))) (section 5 "Selectable widget" (section 6 "selectable-label" (def (sig (procedure "(selectable-label CONTEXT TEXT ALIGNMENT ACTIVE?)" (id selectable-label))) (p "Creates a selectable widget with " (tt "TEXT") " as label and " (tt "ACTIVE?") " as value.  " (tt "ALIGNMENT") " must be one of " (tt "(left centered right)") ". Returns two values, the new value and whether it is different from the old one.")))) (section 5 "Slider widget" (section 6 "slider-float" (def (sig (procedure "(slider-float CONTEXT MIN VALUE MAX STEP)" (id slider-float))) (p "Creates a slider widget with " (tt "VALUE") " as initial float value and " (tt "MIN") " and " (tt "MAX") " as boundaries.  " (tt "STEP") " determines how much the value changes per step.  Returns two values, the new float value and whether it is different from the old one."))) (section 6 "slider-int" (def (sig (procedure "(slider-int CONTEXT MIN VALUE MAX STEP)" (id slider-int))) (p "Creates a slider widget with " (tt "VALUE") " as initial integer value and " (tt "MIN") " and " (tt "MAX") " as boundaries.  " (tt "STEP") " determines how much the value changes per step.  Returns two values, the new integer value and whether it is different from the old one.")))) (section 5 "Progressbar widget" (section 6 "progressbar" (def (sig (procedure "(progressbar CONTEXT VALUE MAX MODIFIABLE?)" (id progressbar))) (p "Creates a progressbar widget with " (tt "VALUE") " as initial value.  " (tt "MAX") " specifies the maximum value that can be displayed.  If " (tt "MODIFIABLE?") " is " (tt "#t") ", the value of the widget can be changed interactively. Returns two values, the new value and whether it is different from the old one.")))) (section 5 "Color picker widget" (section 6 "color-picker" (def (sig (procedure "(color-picker CONTEXT COLOR [RGB?])" (id color-picker))) (p "Creates a color picker widget with " (tt "COLOR") " as initially picked color.  If the optional " (tt "RGB?") " argument is " (tt "#t") ", use a RGB instead of a RGBA picker.  Returns the new color.")))) (section 5 "Property widget" (section 6 "property-float" (def (sig (procedure "(property-float CONTEXT TEXT MIN VALUE MAX STEP PIXEL-STEP)" (id property-float))) (p "Creates a property widget with " (tt "VALUE") " as initial float value and " (tt "MIN") " and " (tt "MAX") " as boundaries.  " (tt "TEXT") " specifies the widget label, " (tt "STEP") " controls the change in value for each step, " (tt "PIXEL-STEP") " the travel in pixels necessary to change the widget value when dragging.  Returns the new float value."))) (section 6 "property-int" (def (sig (procedure "(property-int CONTEXT TEXT MIN VALUE MAX STEP PIXEL-STEP)" (id property-int))) (p "Creates a property widget with " (tt "VALUE") " as initial integer value and " (tt "MIN") " and " (tt "MAX") " as boundaries.  " (tt "TEXT") " specifies the widget label, " (tt "STEP") " controls the change in value for each step, " (tt "PIXEL-STEP") " the travel in pixels necessary to change the widget value when dragging.  Returns the new integer value.")))) (section 5 "Editor widget" (section 6 "edit-string" (def (sig (procedure "(edit-string CONTEXT EDIT-FLAG-OR-FLAGS TEXT MAX [FILTER-FLAG])" (id edit-string))) (p "Creates an text editing widget with " (tt "TEXT") " for its initial contents and a maximum length of " (tt "MAX") ".  " (tt "EDIT-FLAG-OR-FLAGS") " must be a symbol or list of symbols specifying the general widget behaviour, with the permitted symbols being " (tt "(simple field box editor)") " for predefined behavior and " (tt "(default read-only auto-select sig-enter allow-tab no-cursor selectable clipboard ctrl-enter-newline no-horizontal-scroll always-insert-mode multiline)") " for finer-grained control over it.  " (tt "FILTER-FLAG") " restricts chars that can be entered and must be one of " (tt "(default ascii float decimal hex oct binary)") ". Returns two values, the new text and a list of edit events, each of which are one of " (tt "(active inactive activated deactivated committed)") "."))))) (section 4 "Tooltip" (section 5 "tooltip" (def (sig (procedure "(tooltip CONTEXT TEXT)" (id tooltip))) (p "Creates a tooltip with " (tt "TEXT") " as content.")))) (section 4 "Context" (section 5 "context-input" (def (sig (procedure "(context-input CONTEXT)" (id context-input))) (p "Returns the current input state associated with " (tt "CONTEXT") "."))) (section 5 "context-style" (def (sig (procedure "(context-style CONTEXT)" (id context-style))) (p "Returns the current style associated with " (tt "CONTEXT") ".")))) (section 4 "Canvas" (section 5 "stroke-line" (def (sig (procedure "(stroke-line CANVAS X0 Y0 X1 Y1 LINE-THICKNESS COLOR)" (id stroke-line))) (p "Draw a line between the coordinates " (tt "X0") ", " (tt "Y0") ", " (tt "X1") ", " (tt "Y1") " with the width " (tt "LINE-THICKNESS") " and " (tt "COLOR") " on " (tt "CANVAS") "."))) (section 5 "stroke-curve" (def (sig (procedure "(stroke-curve CANVAS AX AY CTRL0X CTRL0Y CTRL1X CTRL1Y BX BY LINE-THICKNESS COLOR)" (id stroke-curve))) (p "Draw a curve between the coordinates " (tt "AX") ", " (tt "AY") ", " (tt "BX") ", " (tt "BY") " with control points " (tt "CTRL0X") ", " (tt "CTRL0Y") ", " (tt "CTRL1X") ", " (tt "CTRL1Y") ", the width " (tt "LINE-THICKNESS") " and " (tt "COLOR") " on " (tt "CANVAS") "."))) (section 5 "fill-circle" (def (sig (procedure "(fill-circle CANVAS RECT COLOR)" (id fill-circle))) (p "Draw a filled circle in " (tt "RECT") " with " (tt "COLOR") " on " (tt "CANVAS") ".")))) (section 4 "Styling" (section 5 "style-window-border" (def (sig (procedure "(style-window-border STYLE)" (id style-window-border))) (p "Returns the window border width associated with " (tt "STYLE") "."))) (section 5 "style-window-header-align-set!" (def (sig (procedure "(style-window-header-align-set! STYLE RIGHT?)" (id style-window-header-align-set!))) (p "Sets the window header alignment for " (tt "STYLE") ".  If " (tt "RIGHT?") " is " (tt "#t") ", it is set to right-aligned, otherwise left-aligned.")))) (section 4 "Input" (section 5 "input-mouse" (def (sig (procedure "(input-mouse INPUT)" (id input-mouse))) (p "Returns the mouse state for " (tt "INPUT") "."))) (section 5 "mouse-delta" (def (sig (procedure "(mouse-delta MOUSE)" (id mouse-delta))) (p "Returns a vector describing the relative change in pixels between the current and last mouse position for " (tt "MOUSE") "."))) (section 5 "mouse-position" (def (sig (procedure "(mouse-position MOUSE)" (id mouse-position))) (p "Returns a vector describing the current mouse position in pixels for " (tt "MOUSE") "."))) (section 5 "input-mouse-click-down-in-rect?" (def (sig (procedure "(input-mouse-click-down-in-rect? INPUT BUTTON RECT DOWN?)" (id input-mouse-click-down-in-rect?))) (p "Returns " (tt "#t") " if the " (tt "BUTTON") " has been clicked in " (tt "RECT") " for " (tt "INPUT") " and its clicked state is equal to the " (tt "DOWN?") " argument. " (tt "BUTTON") " must be one of " (tt "(left middle right)") "."))) (section 5 "input-mouse-hovering-in-rect?" (def (sig (procedure "(input-mouse-hovering-in-rect? INPUT RECT)" (id input-mouse-hovering-in-rect?))) (p "Returns " (tt "#t") " if the mouse has been hovering in " (tt "RECT") " for " (tt "INPUT") ", otherwise " (tt "#f") "."))) (section 5 "input-mouse-previously-hovering-in-rect?" (def (sig (procedure "(input-mouse-previously-hovering-in-rect? INPUT RECT)" (id input-mouse-previously-hovering-in-rect?))) (p "Returns " (tt "#t") " if the mouse has been hovering in the previous frame in " (tt "RECT") " for " (tt "INPUT") ", otherwise " (tt "#f") "."))) (section 5 "input-mouse-clicked?" (def (sig (procedure "(input-mouse-clicked? INPUT BUTTON RECT)" (id input-mouse-clicked?))) (p "Returns " (tt "#t") " if the " (tt "BUTTON") " has been clicked in " (tt "RECT") " for " (tt "INPUT") ", otherwise " (tt "#f") ".  " (tt "BUTTON") " must be one of " (tt "(left middle right)") "."))) (section 5 "input-mouse-down?" (def (sig (procedure "(input-mouse-down? INPUT BUTTON)" (id input-mouse-down?))) (p "Returns " (tt "#t") " if the " (tt "BUTTON") " is pressed down for " (tt "INPUT") ", otherwise " (tt "#f") ".  " (tt "BUTTON") " must be one of " (tt "(left middle right)") "."))) (section 5 "input-mouse-released?" (def (sig (procedure "(input-mouse-released? INPUT BUTTON)" (id input-mouse-released?))) (p "Returns " (tt "#t") " if the " (tt "BUTTON") " is released for " (tt "INPUT") ", otherwise " (tt "#f") ".  " (tt "BUTTON") " must be one of " (tt "(left middle right)") "."))))) (section 3 "Examples" (p "The following example requires the " (int-link "glfw3") " and " (int-link "opengl-glew") " eggs.") (highlight scheme "(use (prefix glfw3 glfw:)\n     (prefix opengl-glew gl:)\n     (prefix nuklear nk:))\n\n(require-library nuklear-glfw-opengl2)\n(import (prefix nuklear-glfw-opengl2 backend:))\n\n(define width 250)\n(define height 150)\n\n(glfw:init)\n(glfw:make-window width height \"Hello World\")\n(glfw:make-context-current (glfw:window))\n(set!-values (width height) (glfw:get-window-size (glfw:window)))\n\n(define context (backend:init! (glfw:window) #t))\n(backend:init-font!)\n\n(define quit? #f)\n(define show-greeting? #f)\n\n(define layout (nk:make-panel))\n(define popup-layout (nk:make-panel))\n\n(let loop ()\n  (when (and (not (glfw:window-should-close (glfw:window))) (not quit?))\n    (glfw:poll-events)\n    (backend:new-frame)\n\n    (when (nk:window-begin context layout \"Hello World!\"\n                           (nk:make-rect 10 10 192 100)\n                           '(border no-scrollbar movable))\n      (nk:layout-row-dynamic context 30 2)\n      (when (nk:button-label context \"Click Me!\")\n        (printf \"Yay\\n\")\n        (set! show-greeting? #t))\n      (when (nk:button-label context \"Quit\")\n        (set! quit? #t))\n\n      (when show-greeting?\n        (if (nk:popup-begin context popup-layout #f \"Greeting\" '(dynamic)\n                            (nk:make-rect 15 50 200 150))\n            (begin\n              (nk:layout-row-dynamic context 25 1)\n              (nk:label context \"Hello World!\" 'centered)\n              (nk:layout-row-dynamic context 25 1)\n              (when (nk:button-label context \"OK\")\n                (set! show-greeting? #f)\n                (nk:popup-close context))\n              (nk:popup-end context))\n            (set! show-greeting? #f))))\n    (nk:window-end context)\n\n    (let-values (((width height) (glfw:get-window-size (glfw:window))))\n      (gl:viewport 0 0 width height))\n    (gl:clear gl:+color-buffer-bit+)\n    (gl:clear-color (/ 28 255) (/ 48 255) (/ 62 255) 0)\n    (backend:render!)\n    (glfw:swap-buffers (glfw:window))\n    (loop)))\n\n(backend:shutdown!)\n(glfw:terminate)") (p "Further examples can be found " (link "https://depp.brause.cc/nuklear/examples" "in the repository") ". Additionally to the previously mentioned eggs, " (int-link "format") " is required to run the calculator, overview and node editor demos.")) (section 3 "Notes" (ul (li "If you wish to use a different font than the default, set it at init time.  Loading multiple fonts and switching the active one is currently unsupported.") (li "You will need to write your own main loop using eggs that match the chosen backend and the backend API.  As only the " (tt "glfw-opengl2") " backend is supported for now, that would be the " (int-link "glfw3") " and " (int-link "opengl-glew") " eggs.  Each example contains a full implementation you can reuse.") (li "As backends can be platform-specific and are built at installation time, their modules aren't automatically loaded by the egg.  Therefore you'll need to use " (tt "require-library") " and " (tt "import") " to load one.") (li "Widgets typically take an input value and return an output value. Therefore you will need to use global variables, parameters or named-let initializers in the main loop for managing them.  Some widgets return multiple values with the output value first, use " (tt "receive") " to access the other values.") (li "Block starters (for windows, groups, combo boxes, etc.) typically return a boolean to indicate whether they're active.  If this is the case, then one can draw widgets inside them and finally terminate the block with the matching procedure.") (li "Layouts must be used inside blocks, otherwise no widgets will be drawn.") (li "Bind the context and panels to top-level identifiers, otherwise they'll be gone by the next GC and make your application segfault."))) (section 3 "License" (pre "This software is dual-licensed to the public domain and under the following license: you are granted a perpetual, irrevocable license to copy, modify, publish and distribute its files as you see fit.")) (section 3 "Version history" (section 4 "0.1" (ul (li "Initial release"))))))