Raylib: Add Raylib 2.5 + Raygui

clean-macosx-x86-32
Jack Lucas 2019-04-07 19:58:55 -04:00 committed by John Benediktsson
parent 13b0da9182
commit a8200d61b2
10 changed files with 1532 additions and 0 deletions

1
extra/raylib/authors.txt Normal file
View File

@ -0,0 +1 @@
Jack Lucas

View File

@ -0,0 +1,51 @@
! Copyright (C) 2019 Jack Lucas
! See http://factorcode.org/license.txt for BSD license.
USING: raylib.ffi kernel math.ranges sequences locals random combinators.random math threads calendar namespaces accessors classes.struct combinators alien.enums ;
IN: raylib.demo
: say-hello ( -- )
"Hello, Factor!" 200 400 60 MAGENTA draw-text ;
: make-window ( -- )
640 480 "Hello, Factor!" init-window
60 set-target-fps ;
: clear-window ( -- )
RAYWHITE clear-background ;
! Save our players position in a dynamic var
SYMBOL: player
: show-player-circle ( -- )
player get
25.0 RED draw-circle-v ;
: setup-game-vars ( -- )
get-screen-width 2 /
get-screen-height 2 /
Vector2 <struct-boa> player set ;
! Make this cleaner
: change-player-position ( -- )
{
{ [ KEY_RIGHT enum>number is-key-down ] [ player get x>> 2.0 + player get x<< ] }
{ [ KEY_LEFT enum>number is-key-down ] [ player get x>> -2.0 + player get x<< ] }
{ [ KEY_DOWN enum>number is-key-down ] [ player get y>> 2.0 + player get y<< ] }
{ [ KEY_UP enum>number is-key-down ] [ player get y>> -2.0 + player get y<< ] }
[ ] } cond ;
: render-loop ( -- )
begin-drawing
clear-window show-player-circle say-hello
end-drawing ;
: main ( -- )
make-window clear-window setup-game-vars
[ change-player-position
render-loop
window-should-close not ] loop
close-window
;
MAIN: main

View File

@ -0,0 +1 @@
demos

1032
extra/raylib/ffi/ffi.factor Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
! Copyright (C) 2019 Jack Lucas
! See http://factorcode.org/license.txt for BSD license.
USING: raylib.ffi kernel math.ranges sequences locals random combinators.random math threads calendar namespaces accessors classes.struct combinators alien.enums raylib.modules.gui ;
IN: raylib.gui-demo
: make-window ( -- )
800 600 "Hello, Factor!" init-window
60 set-target-fps ;
: button-rec ( -- button )
50 50 100 100 Rectangle <struct-boa> ;
: white-background ( -- )
RAYWHITE clear-background ;
: say-hello ( -- )
"Hello Factor!" 4 4 30 RED draw-text ;
: set-button-style ( -- )
BUTTON enum>number
TEXT_ALIGNMENT enum>number
GUI_TEXT_ALIGN_LEFT enum>number
rl-gui-set-style ;
: draw-button ( -- )
set-button-style
button-rec "Button"
rl-gui-button drop ;
: render-gui ( -- )
rl-gui-lock
draw-button
rl-gui-unlock ;
: render-loop ( -- )
begin-drawing white-background
say-hello render-gui end-drawing ;
: main ( -- )
make-window
[ render-loop
window-should-close not ] loop
close-window ;

View File

@ -0,0 +1 @@
demos

View File

@ -0,0 +1,189 @@
! Copyright (C) 2019 Jack Lucas
! See http://factorcode.org/license.txt for BSD license.
! These should be complete bindings to the Raygui library 2.0
! Most of the comments are included from the original header
! for your convenience.
USING: alien alien.c-types alien.enums alien.libraries
alien.libraries.finder alien.syntax classes.struct combinators
kernel quotations system vocabs raylib.ffi ;
IN: raylib.modules.gui
! Enumerations ----------------------------------------------------------
! Gui global state enum
ENUM: GuiControlState
GUI_STATE_NORMAL
GUI_STATE_FOCUSED
GUI_STATE_PRESSED
GUI_STATE_DISABLED ;
! Gui global text alignment
ENUM: GuiTextAlignment
GUI_TEXT_ALIGN_LEFT
GUI_TEXT_ALIGN_CENTER
GUI_TEXT_ALIGN_RIGHT ;
! Gui standard controls
ENUM: GuiControlStandard
DEFAULT
LABEL ! LABELBUTTON
BUTTON ! IMAGEBUTTON
TOGGLE ! TOGGLEGROUP
SLIDER ! SLIDERBAR
PROGRESSBAR
CHECKBOX
COMBOBOX
DROPDOWNBOX
TEXTBOX ! VALUEBOX SPINNER
LISTVIEW
COLORPICKER
SCROLLBAR ;
! Gui default properties for every control
ENUM: GuiControlProperty
BORDER_COLOR_NORMAL
BASE_COLOR_NORMAL
TEXT_COLOR_NORMAL
BORDER_COLOR_FOCUSED
BASE_COLOR_FOCUSED
TEXT_COLOR_FOCUSED
BORDER_COLOR_PRESSED
BASE_COLOR_PRESSED
TEXT_COLOR_PRESSED
BORDER_COLOR_DISABLED
BASE_COLOR_DISABLED
TEXT_COLOR_DISABLED
BORDER_WIDTH
INNER_PADDING
TEXT_ALIGNMENT
RESERVED02 ;
! Gui extended properties depending on control type
! NOTE: We reserve a fixed size of additional properties per control (8)
! Default properties
ENUM: GuiDefaultProperty
{ TEXT_SIZE 16 }
{ TEXT_SPACING 17 }
{ TEXT_COLOR 18 }
{ BACKGROUND_COLOR 19 } ;
! Toggle / ToggleGroup
ENUM: GuiToggleProperty
{ GROUP_PADDING 16 } ;
! Slider / SliderBar
ENUM: GuiSliderProperty
{ SLIDER_WIDTH 16 }
{ TEXT_PADDING 17 } ;
! TextBox / ValueBox / Spinner
ENUM: GuiTextBoxProperty
{ MULTILINE_PADDING 16 }
{ SPINNER_BUTTON_WIDTH 17 }
{ SPINNER_BUTTON_PADDING 18 }
{ SPINNER_BUTTON_BORDER_WIDTH 19 } ;
! CheckBox
ENUM: GuiCheckBoxProperty
{ CHECK_TEXT_PADDING 16 } ;
! ComboBox
ENUM: GuiComboBoxProperty
{ SELECTOR_WIDTH 16 }
{ SELECTOR_PADDING 17 } ;
! DropdownBox
ENUM: GuiDropdownBoxProperty
{ ARROW_RIGHT_PADDING 16 } ;
! ColorPicker
ENUM: GuiColorPickerProperty
{ COLOR_SELECTOR_SIZE 16 }
{ BAR_WIDTH 17 } ! Lateral bar width
{ BAR_PADDING 18 } ! Later bar separation from panel
{ BAR_SELECTOR_HEIGHT 19 } ! Lateral bar selector height
{ BAR_SELECTOR_PADDING 20 } ; ! Later bar selector outer padding
! ListView
ENUM: GuiListViewProperty
{ ELEMENTS_HEIGHT 16 }
{ ELEMENTS_PADDING 17 }
{ SCROLLBAR_WIDTH 18 }
{ SCROLLBAR_SIDE 19 } ; ! This property defines vertical scrollbar side
! ScrollBar
ENUM: GuiScrollBarProperty
{ SCROLLBAR_BORDER 16 }
{ SCROLLBAR_SHOW_SPINNER_BUTTONS 17 }
{ SCROLLBAR_ARROWS_SIZE 18 }
{ SCROLLBAR_PADDING 19 }
{ SCROLLBAR_SLIDER_PADDING 20 }
{ SCROLLBAR_SLIDER_SIZE 21 }
{ SCROLLBAR_SCROLL_SPEED 22 } ;
! ScrollBar side
ENUM: GuiScrollBarSide
SCROLLBAR_LEFT_SIDE
SCROLLBAR_RIGHT_SIDE ;
! Functions ---------------------------------------------------------
! Global gui modification functions
FUNCTION-ALIAS: rl-gui-enable void GuiEnable ( ) ! Enable gui controls ( global state )
FUNCTION-ALIAS: rl-gui-disable void GuiDisable ( ) ! Disable gui controls ( global state )
FUNCTION-ALIAS: rl-gui-lock void GuiLock ( ) ! Lock gui controls ( global state )
FUNCTION-ALIAS: rl-gui-unlock void GuiUnlock ( ) ! Unlock gui controls ( global state )
FUNCTION-ALIAS: rl-gui-state void GuiState ( int state ) ! Set gui state ( global state )
FUNCTION-ALIAS: rl-gui-font void GuiFont ( Font font ) ! Set gui custom font ( global state )
FUNCTION-ALIAS: rl-gui-fade void GuiFade ( float alpha ) ! Set gui controls alpha ( global state ) , alpha goes from 0.0f to 1.0f
! Style set/get functions
FUNCTION-ALIAS: rl-gui-set-style void GuiSetStyle ( int control, int property, int value ) ! Set one style property
FUNCTION-ALIAS: rl-gui-get-style int GuiGetStyle ( int control, int property ) ! Get one style property
! Container/separator controls, useful for controls organization
FUNCTION-ALIAS: rl-gui-window-box bool GuiWindowBox ( Rectangle bounds, c-string text ) ! Window Box control, shows a window that can be closed
FUNCTION-ALIAS: rl-gui-group-box void GuiGroupBox ( Rectangle bounds, c-string text ) ! Group Box control with title name
FUNCTION-ALIAS: rl-gui-line void GuiLine ( Rectangle bounds, c-string text ) ! Line separator control, could contain text
FUNCTION-ALIAS: rl-gui-panel void GuiPanel ( Rectangle bounds ) ! Panel control, useful to group controls
FUNCTION-ALIAS: rl-gui-scrollpanel Rectangle GuiScrollPanel ( Rectangle bounds, Rectangle content, Vector2 *scroll ) ! Scroll Panel control
! Basic controls set
FUNCTION-ALIAS: rl-gui-label void GuiLabel ( Rectangle bounds, c-string text ) ! Label control, shows text
FUNCTION-ALIAS: rl-gui-button bool GuiButton ( Rectangle bounds, c-string text ) ! Button control, returns true when clicked
FUNCTION-ALIAS: rl-gui-label-button bool GuiLabelButton ( Rectangle bounds, c-string text ) ! Label button control, show true when clicked
FUNCTION-ALIAS: rl-gui-image-button bool GuiImageButton ( Rectangle bounds, Texture2D texture ) ! Image button control, returns true when clicked
FUNCTION-ALIAS: rl-gui-image-button-ex bool GuiImageButtonEx ( Rectangle bounds, Texture2D texture, Rectangle texSource, c-string text ) ! Image button extended control, returns true when clicked
FUNCTION-ALIAS: rl-gui-toggle bool GuiToggle ( Rectangle bounds, c-string text, bool active ) ! Toggle Button control, returns true when active
FUNCTION-ALIAS: rl-gui-toggle-group int GuiToggleGroup ( Rectangle bounds, c-string text, int active ) ! Toggle Group control, returns active toggle index
FUNCTION-ALIAS: rl-gui-check-box bool GuiCheckBox ( Rectangle bounds, c-string text, bool checked ) ! Check Box control, returns true when active
FUNCTION-ALIAS: rl-gui-combo-box int GuiComboBox ( Rectangle bounds, c-string text, int active ) ! Combo Box control, returns selected item index
FUNCTION-ALIAS: rl-gui-dropdown-box bool GuiDropdownBox ( Rectangle bounds, c-string text, int* active, bool editMode ) ! Dropdown Box control, returns selected item
FUNCTION-ALIAS: rl-gui-spinner bool GuiSpinner ( Rectangle bounds, int* value, int minValue, int maxValue, bool editMode ) ! Spinner control, returns selected value
FUNCTION-ALIAS: rl-gui-value-box bool GuiValueBox ( Rectangle bounds, int* value, int minValue, int maxValue, bool editMode ) ! Value Box control, updates input text with numbers
FUNCTION-ALIAS: rl-gui-text-box bool GuiTextBox ( Rectangle bounds, char *text, int textSize, bool editMode ) ! Text Box control, updates input text
FUNCTION-ALIAS: rl-gui-text-box-multi bool GuiTextBoxMulti ( Rectangle bounds, char *text, int textSize, bool editMode ) ! Text Box control with multiple lines
FUNCTION-ALIAS: rl-gui-slider float GuiSlider ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Slider control, returns selected value
FUNCTION-ALIAS: rl-gui-slider-bar float GuiSliderBar ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Slider Bar control, returns selected value
FUNCTION-ALIAS: rl-gui-progress-bar float GuiProgressBar ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Progress Bar control, shows current progress value
FUNCTION-ALIAS: rl-gui-status-bar void GuiStatusBar ( Rectangle bounds, c-string text ) ! Status Bar control, shows info text
FUNCTION-ALIAS: rl-gui-dummy-rec void GuiDummyRec ( Rectangle bounds, c-string text ) ! Dummy control for placeholders
FUNCTION-ALIAS: rl-gui-scroll-bar int GuiScrollBar ( Rectangle bounds, int value, int minValue, int maxValue ) ! Scroll Bar control
! Advance controls set
FUNCTION-ALIAS: rl-gui-list-view bool GuiListView ( Rectangle bounds, c-string text, int* active, int* scrollIndex, bool editMode ) ! List View control, returns selected list element index
FUNCTION-ALIAS: rl-gui-list-view-ex bool GuiListViewEx ( Rectangle bounds, c-string *text, int count, int* enabled, int* active, int* focus, int* scrollIndex, bool editMode ) ! List View with extended parameters
FUNCTION-ALIAS: rl-gui-message-box int GuiMessageBox ( Rectangle bounds, c-string windowTitle, c-string message, c-string buttons ) ! Message Box control, displays a message
FUNCTION-ALIAS: rl-gui-color-picker Color GuiColorPicker ( Rectangle bounds, Color color ) ! Color Picker control
FUNCTION-ALIAS: rl-gui-grid Vector2 GuiGrid ( Rectangle bounds, float spacing, int subdivs ) ! Grid
! Styles loading functions
FUNCTION-ALIAS: rl-gui-load-style void GuiLoadStyle ( c-string fileName ) ! Load style file ( .rgs )
FUNCTION-ALIAS: rl-gui-load-style-props void GuiLoadStyleProps ( int* props, int count ) ! Load style properties from array
FUNCTION-ALIAS: rl-gui-load-style-default void GuiLoadStyleDefault ( ) ! Load style default over global style
FUNCTION-ALIAS: rl-gui-update-style-complete void GuiUpdateStyleComplete ( ) ! Updates full style properties set with default values
FUNCTION-ALIAS: rl-gui-icon-text c-string GuiIconText ( int iconId, c-string text ) ! Get text with icon id prepended

View File

@ -0,0 +1,211 @@
! Copyright (C) 2019 Jack Lucas
! See http://factorcode.org/license.txt for BSD license.
! These should be complete bindings to the Raylib Icons module
USING: alien alien.c-types alien.enums alien.libraries
alien.libraries.finder alien.syntax classes.struct combinators
kernel quotations system vocabs raylib.ffi ;
IN: raylib.modules.ricons
FUNCTION-ALIAS: rl-draw-icon void DrawIcon ( int iconId, Vector2 position, int pixelSize, Color color )
ENUM: rIconDescription
RICON_NONE
RICON_FOLDER_FILE_OPEN
RICON_FILE_SAVE_CLASSIC
RICON_FOLDER_OPEN
RICON_FOLDER_SAVE
RICON_FILE_OPEN
RICON_FILE_SAVE
RICON_FILE_EXPORT
RICON_FILE_NEW
RICON_FILE_DELETE
RICON_FILETYPE_TEXT
RICON_FILETYPE_AUDIO
RICON_FILETYPE_IMAGE
RICON_FILETYPE_PLAY
RICON_FILETYPE_VIDEO
RICON_FILETYPE_INFO
RICON_FILE_COPY
RICON_FILE_CUT
RICON_FILE_PASTE
RICON_CURSOR_HAND
RICON_CURSOR_POINTER
RICON_CURSOR_CLASSIC
RICON_PENCIL
RICON_PENCIL_BIG
RICON_BRUSH_CLASSIC
RICON_BRUSH_PAINTER
RICON_WATER_DROP
RICON_COLOR_PICKER
RICON_RUBBER
RICON_COLOR_BUCKET
RICON_TEXT_T
RICON_TEXT_A
RICON_SCALE
RICON_RESIZE
RICON_FILTER_POINT
RICON_FILTER_BILINEAR
RICON_CROP
RICON_CROP_ALPHA
RICON_SQUARE_TOGGLE
RICON_SIMMETRY
RICON_SIMMETRY_HORIZONTAL
RICON_SIMMETRY_VERTICAL
RICON_LENS
RICON_LENS_BIG
RICON_EYE_ON
RICON_EYE_OFF
RICON_FILTER_TOP
RICON_FILTER
RICON_TARGET_POINT
RICON_TARGET_SMALL
RICON_TARGET_BIG
RICON_TARGET_MOVE
RICON_CURSOR_MOVE
RICON_CURSOR_SCALE
RICON_CURSOR_SCALE_RIGHT
RICON_CURSOR_SCALE_LEFT
RICON_UNDO
RICON_REDO
RICON_REREDO
RICON_MUTATE
RICON_ROTATE
RICON_REPEAT
RICON_SHUFFLE
RICON_EMPTYBOX
RICON_TARGET
RICON_TARGET_SMALL_FILL
RICON_TARGET_BIG_FILL
RICON_TARGET_MOVE_FILL
RICON_CURSOR_MOVE_FILL
RICON_CURSOR_SCALE_FILL
RICON_CURSOR_SCALE_RIGHT_FILL
RICON_CURSOR_SCALE_LEFT_FILL
RICON_UNDO_FILL
RICON_REDO_FILL
RICON_REREDO_FILL
RICON_MUTATE_FILL
RICON_ROTATE_FILL
RICON_REPEAT_FILL
RICON_SHUFFLE_FILL
RICON_EMPTYBOX_SMALL
RICON_BOX
RICON_BOX_TOP
RICON_BOX_TOP_RIGHT
RICON_BOX_RIGHT
RICON_BOX_BOTTOM_RIGHT
RICON_BOX_BOTTOM
RICON_BOX_BOTTOM_LEFT
RICON_BOX_LEFT
RICON_BOX_TOP_LEFT
RICON_BOX_CENTER
RICON_BOX_CIRCLE_MASK
RICON_POT
RICON_ALPHA_MULTIPLY
RICON_ALPHA_CLEAR
RICON_DITHERING
RICON_MIPMAPS
RICON_BOX_GRID
RICON_GRID
RICON_BOX_CORNERS_SMALL
RICON_BOX_CORNERS_BIG
RICON_FOUR_BOXES
RICON_GRID_FILL
RICON_BOX_MULTISIZE
RICON_ZOOM_SMALL
RICON_ZOOM_MEDIUM
RICON_ZOOM_BIG
RICON_ZOOM_ALL
RICON_ZOOM_CENTER
RICON_BOX_DOTS_SMALL
RICON_BOX_DOTS_BIG
RICON_BOX_CONCENTRIC
RICON_BOX_GRID_BIG
RICON_OK_TICK
RICON_CROSS
RICON_ARROW_LEFT
RICON_ARROW_RIGHT
RICON_ARROW_BOTTOM
RICON_ARROW_TOP
RICON_ARROW_LEFT_FILL
RICON_ARROW_RIGHT_FILL
RICON_ARROW_BOTTOM_FILL
RICON_ARROW_TOP_FILL
RICON_AUDIO
RICON_FX
RICON_WAVE
RICON_WAVE_SINUS
RICON_WAVE_SQUARE
RICON_WAVE_TRIANGULAR
RICON_CROSS_SMALL
RICON_PLAYER_PREVIOUS
RICON_PLAYER_PLAY_BACK
RICON_PLAYER_PLAY
RICON_PLAYER_PAUSE
RICON_PLAYER_STOP
RICON_PLAYER_NEXT
RICON_PLAYER_RECORD
RICON_MAGNET
RICON_LOCK_CLOSE
RICON_LOCK_OPEN
RICON_CLOCK
RICON_TOOLS
RICON_GEAR
RICON_GEAR_BIG
RICON_BIN
RICON_HAND_POINTER
RICON_LASER
RICON_COIN
RICON_EXPLOSION
RICON_1UP
RICON_PLAYER
RICON_PLAYER_JUMP
RICON_KEY
RICON_DEMON
RICON_TEXT_POPUP
RICON_GEAR_EX
RICON_CRACK
RICON_CRACK_POINTS
RICON_STAR
RICON_DOOR
RICON_EXIT
RICON_MODE_2D
RICON_MODE_3D
RICON_CUBE
RICON_CUBE_FACE_TOP
RICON_CUBE_FACE_LEFT
RICON_CUBE_FACE_FRONT
RICON_CUBE_FACE_BOTTOM
RICON_CUBE_FACE_RIGHT
RICON_CUBE_FACE_BACK
RICON_CAMERA
RICON_SPECIAL
RICON_LINK_NET
RICON_LINK_BOXES
RICON_LINK_MULTI
RICON_LINK
RICON_LINK_BROKE
RICON_TEXT_NOTES
RICON_NOTEBOOK
RICON_SUITCASE
RICON_SUITCASE_ZIP
RICON_MAILBOX
RICON_MONITOR
RICON_PRINTER
RICON_PHOTO_CAMERA
RICON_PHOTO_CAMERA_FLASH
RICON_HOUSE
RICON_HEART
RICON_CORNER
RICON_VERTICAL_BARS
RICON_VERTICAL_BARS_FILL
RICON_LIFE_BARS
RICON_INFO
RICON_CROSSLINE
RICON_HELP
RICON_FILETYPE_ALPHA
RICON_FILETYPE_HOME
RICON_LAYERS_VISIBLE
RICON_LAYERS
RICON_WINDOW ;

1
extra/raylib/summary.txt Normal file
View File

@ -0,0 +1 @@
Complete bindings for the Raylib video game library.

1
extra/raylib/tags.txt Normal file
View File

@ -0,0 +1 @@
bindings