-
Notifications
You must be signed in to change notification settings - Fork 4
Raygui Bindings #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BrownNPC
wants to merge
11
commits into
master
Choose a base branch
from
raygui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Raygui Bindings #10
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f217da2
raygui bindings intitial commit
BrownNPC f73030e
add runtime
BrownNPC 7c24b2d
add js side of runtime
BrownNPC ec1897a
initial bindings
BrownNPC b10b967
Draft of the raygui bindings implementation
kerudev 3c999a0
Merge pull request #11 from kerudev/raygui
BrownNPC 1349317
base bindings with memory corruption bugs
BrownNPC 3d41c53
fix: apply CodeRabbit auto-fixes
coderabbitai[bot] 77e9773
Merge pull request #12 from BrownNPC/coderabbitai/autofix/1349317
BrownNPC 41b8e6e
Update raygui/raygui.go
BrownNPC 74fc632
fix: apply CodeRabbit auto-fixes
coderabbitai[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,20 @@ | ||
| module github.com/BrownNPC/Raylib-Go-Wasm/examples | ||
|
|
||
| go 1.24.1 | ||
| go 1.26.1 | ||
|
|
||
| replace github.com/gen2brain/raylib-go/raylib => ../raylib | ||
| require ( | ||
| github.com/gen2brain/raylib-go/raygui v0.0.0-00010101000000-000000000000 | ||
| github.com/gen2brain/raylib-go/raylib v0.55.1 | ||
| ) | ||
|
|
||
| require github.com/gen2brain/raylib-go/raylib v0.0.0-00010101000000-000000000000 | ||
| replace ( | ||
| github.com/BrownNPC/Raylib-Go-Wasm/wasm-runtime => ../wasm-runtime | ||
|
|
||
| require github.com/BrownNPC/wasm-ffi-go v1.1.0 // indirect | ||
| github.com/gen2brain/raylib-go/raygui => ../raygui | ||
| github.com/gen2brain/raylib-go/raylib => ../raylib | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/BrownNPC/Raylib-Go-Wasm/wasm-runtime v0.0.0-20260421110350-7c24b2d5e6d3 // indirect | ||
| github.com/BrownNPC/wasm-ffi-go v1.2.0 // indirect | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| github.com/BrownNPC/wasm-ffi-go v1.1.0 h1:oashfuQflpB+qx/xI71Gvim3YN/0iIny5TMIpzEFz0Y= | ||
| github.com/BrownNPC/wasm-ffi-go v1.1.0/go.mod h1:D5+RBMb672fgw6vPz4HOWYxpyrmPrIao8VqlXihOFFg= | ||
| github.com/BrownNPC/wasm-ffi-go v1.2.0 h1:Lknst90sTLTkE870OKNP/Vw36TohQIJ4ln8W1IG9Zl0= | ||
| github.com/BrownNPC/wasm-ffi-go v1.2.0/go.mod h1:D5+RBMb672fgw6vPz4HOWYxpyrmPrIao8VqlXihOFFg= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,284 @@ | ||
| //go:build js | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| gui "github.com/gen2brain/raylib-go/raygui" | ||
| rl "github.com/gen2brain/raylib-go/raylib" | ||
| ) | ||
|
|
||
| /******************************************************************************************* | ||
| * | ||
| * raygui - controls test suite | ||
| * | ||
| * TEST CONTROLS: | ||
| * - gui.DropdownBox() | ||
| * - gui.CheckBox() | ||
| * - gui.Spinner() | ||
| * - gui.ValueBox() | ||
| * - gui.TextBox() | ||
| * - gui.Button() | ||
| * - gui.ComboBox() | ||
| * - gui.ListView() | ||
| * - gui.ToggleGroup() | ||
| * - gui.ColorPicker() | ||
| * - gui.Slider() | ||
| * - gui.SliderBar() | ||
| * - gui.ProgressBar() | ||
| * - gui.ColorBarAlpha() | ||
| * - gui.ScrollPanel() | ||
| * | ||
| * | ||
| * DEPENDENCIES: | ||
| * raylib 4.0 - Windowing/input management and drawing. | ||
| * raygui 3.2 - Immediate-mode GUI controls. | ||
| * | ||
| * COMPILATION (Windows - MinGW): | ||
| * gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99 | ||
| * | ||
| * LICENSE: zlib/libpng | ||
| * | ||
| * Copyright (c) 2016-2022 Ramon Santamaria (@raysan5) | ||
| * | ||
| **********************************************************************************************/ | ||
|
|
||
| //#define RAYGUI_CUSTOM_ICONS // It requires providing gui_icons.h in the same directory | ||
| //#include "gui_icons.h" // External icons data provided, it can be generated with rGuiIcons tool | ||
|
|
||
| // ------------------------------------------------------------------------------------ | ||
| // Program main entry point | ||
| // ------------------------------------------------------------------------------------ | ||
| func main() { | ||
| // Initialization | ||
| //--------------------------------------------------------------------------------------- | ||
| const ( | ||
| screenWidth = 690 | ||
| screenHeight = 560 | ||
| ) | ||
|
|
||
| rl.InitWindow(screenWidth, screenHeight, "raygui - controls test suite") | ||
| rl.SetExitKey(0) | ||
|
|
||
| // GUI controls initialization | ||
| //---------------------------------------------------------------------------------- | ||
| var ( | ||
| dropdownBox000Active int32 = 0 | ||
| dropDown000EditMode bool = false | ||
|
|
||
| dropdownBox001Active int32 = 0 | ||
| dropDown001EditMode bool = false | ||
|
|
||
| spinner001Value int32 = 0 | ||
| spinnerEditMode bool = false | ||
|
|
||
| valueBox002Value int32 = 0 | ||
| valueBoxEditMode bool = false | ||
|
|
||
| textBoxText = "Text box" | ||
| textBoxEditMode bool = false | ||
|
|
||
| // listViewScrollIndex int32 = 0 | ||
| // listViewActive int32 = -1 | ||
|
|
||
| // listViewExScrollIndex int32 = 0 | ||
| // listViewExActive int32 = 2 | ||
| // listViewExFocus int32 = -1 | ||
| // listViewExList = []string{"This", "is", "a", "list view", "with", "disable", "elements", "amazing!"} | ||
|
|
||
| colorPickerValue = rl.Red | ||
|
|
||
| sliderValue float32 = 50 | ||
| sliderBarValue float32 = 60 | ||
| progressValue float32 = 0.4 | ||
|
|
||
| forceSquaredChecked bool = false | ||
|
|
||
| alphaValue float32 = 0.5 | ||
|
|
||
| comboBoxActive int32 = 1 | ||
|
|
||
| toggleGroupActive int32 = 0 | ||
|
|
||
| viewScroll = rl.Vector2{0, 0} | ||
|
|
||
| //---------------------------------------------------------------------------------- | ||
|
|
||
| // Custom GUI font loading | ||
| //Font font = LoadFontEx("fonts/rainyhearts16.ttf", 12, 0, 0); | ||
| //GuiSetFont(font); | ||
|
|
||
| exitWindow bool = false | ||
| showMessageBox bool = false | ||
|
|
||
| textInput string | ||
| showTextInputBox bool = false | ||
|
|
||
| // TODO textInputFileName string | ||
| ) | ||
|
|
||
| rl.SetTargetFPS(60) | ||
| //-------------------------------------------------------------------------------------- | ||
|
|
||
| // Main game loop | ||
| update := func() { // Detect window close button or ESC key | ||
| _ = exitWindow | ||
| // Update | ||
| //---------------------------------------------------------------------------------- | ||
|
|
||
| if rl.IsKeyPressed(rl.KeyEscape) { | ||
| showMessageBox = !showMessageBox | ||
| } | ||
|
|
||
| if rl.IsKeyDown(rl.KeyLeftControl) && rl.IsKeyPressed(rl.KeyS) { | ||
| showTextInputBox = true | ||
| } | ||
|
|
||
| // TODO if rl.IsFileDropped() { | ||
| // TODO var droppedFiles gui.FilePathList = rl.LoadDroppedFiles() | ||
| // TODO if (droppedFiles.count > 0) && rl.IsFileExtension(droppedFiles.paths[0], ".rgs") { | ||
| // TODO gui.LoadStyle(droppedFiles.paths[0]) | ||
| // TODO } | ||
| // TODO rl.UnloadDroppedFiles(droppedFiles) // Clear internal buffers | ||
| // TODO } | ||
| //---------------------------------------------------------------------------------- | ||
|
|
||
| // Draw | ||
| //---------------------------------------------------------------------------------- | ||
| rl.BeginDrawing() | ||
|
|
||
| rl.ClearBackground(rl.GetColor(uint(gui.GetStyle(gui.DEFAULT, gui.BACKGROUND_COLOR)))) | ||
|
|
||
| // raygui: controls drawing | ||
| //---------------------------------------------------------------------------------- | ||
| if dropDown000EditMode || dropDown001EditMode { | ||
| gui.Lock() | ||
| } else if !dropDown000EditMode && !dropDown001EditMode { | ||
| gui.Unlock() | ||
| } | ||
| //GuiDisable(); | ||
|
|
||
| // First GUI column | ||
| //GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); | ||
| forceSquaredChecked = gui.CheckBox(rl.Rectangle{25, 108, 15, 15}, "FORCE CHECK!", forceSquaredChecked) | ||
|
|
||
| gui.SetStyle(gui.TEXTBOX, gui.TEXT_ALIGNMENT, gui.TEXT_ALIGN_CENTER) | ||
| //GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); | ||
| gui.Spinner(rl.Rectangle{25, 135, 125, 30}, "", &spinner001Value, 0, 100, spinnerEditMode) | ||
|
|
||
| if gui.ValueBox(rl.Rectangle{25, 175, 125, 30}, "", &valueBox002Value, 0, 100, valueBoxEditMode) { | ||
| valueBoxEditMode = !valueBoxEditMode | ||
| } | ||
| gui.SetStyle(gui.TEXTBOX, gui.TEXT_ALIGNMENT, gui.TEXT_ALIGN_LEFT) | ||
| if gui.TextBox(rl.Rectangle{25, 215, 125, 30}, &textBoxText, 64, textBoxEditMode) { | ||
| textBoxEditMode = !textBoxEditMode | ||
| } | ||
|
|
||
| gui.SetStyle(gui.BUTTON, gui.TEXT_ALIGNMENT, gui.TEXT_ALIGN_CENTER) | ||
|
|
||
| if gui.Button(rl.Rectangle{25, 255, 125, 30}, gui.IconText(gui.ICON_FILE_SAVE, "Save File")) { | ||
| showTextInputBox = true | ||
| } | ||
|
|
||
| gui.GroupBox(rl.Rectangle{25, 310, 125, 150}, "STATES") | ||
| //GuiLock(); | ||
| gui.SetState(gui.STATE_NORMAL) | ||
| if gui.Button(rl.Rectangle{30, 320, 115, 30}, "NORMAL") { | ||
| } | ||
| gui.SetState(gui.STATE_FOCUSED) | ||
| if gui.Button(rl.Rectangle{30, 355, 115, 30}, "FOCUSED") { | ||
| } | ||
| gui.SetState(gui.STATE_PRESSED) | ||
| if gui.Button(rl.Rectangle{30, 390, 115, 30}, "#15#PRESSED") { | ||
| } | ||
| gui.SetState(gui.STATE_DISABLED) | ||
| if gui.Button(rl.Rectangle{30, 425, 115, 30}, "DISABLED") { | ||
| } | ||
| gui.SetState(gui.STATE_NORMAL) | ||
| //GuiUnlock(); | ||
|
|
||
| comboBoxActive = gui.ComboBox(rl.Rectangle{25, 470, 125, 30}, "ONE;TWO;THREE;FOUR", comboBoxActive) | ||
|
|
||
| // NOTE: gui.DropdownBox must draw after any other control that can be covered on unfolding | ||
| gui.SetStyle(gui.DROPDOWNBOX, gui.TEXT_ALIGNMENT, gui.TEXT_ALIGN_LEFT) | ||
| if gui.DropdownBox(rl.Rectangle{25, 65, 125, 30}, "#01#ONE;#02#TWO;#03#THREE;#04#FOUR", &dropdownBox001Active, dropDown001EditMode) { | ||
| dropDown001EditMode = !dropDown001EditMode | ||
| } | ||
|
|
||
| gui.SetStyle(gui.DROPDOWNBOX, gui.TEXT_ALIGNMENT, gui.TEXT_ALIGN_CENTER) | ||
| if gui.DropdownBox(rl.Rectangle{25, 25, 125, 30}, "ONE;TWO;THREE", &dropdownBox000Active, dropDown000EditMode) { | ||
| dropDown000EditMode = !dropDown000EditMode | ||
| } | ||
|
|
||
| // Second GUI column | ||
| // listViewActive = gui.ListView(rl.Rectangle{165, 25, 140, 140}, "Charmander;Bulbasaur;#18#Squirtel;Pikachu;Eevee;Pidgey", &listViewScrollIndex, listViewActive) | ||
| // listViewExActive = gui.ListViewEx(rl.Rectangle{165, 180, 140, 200}, listViewExList, &listViewExFocus, &listViewExScrollIndex, listViewExActive) | ||
|
|
||
| toggleGroupActive = gui.ToggleGroup(rl.Rectangle{165, 400, 140, 25}, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive) | ||
|
|
||
| // Third GUI column | ||
| gui.Panel(rl.NewRectangle(320, 25, 225, 140), "Panel Info") | ||
| colorPickerValue = gui.ColorPicker(rl.Rectangle{320, 185, 196, 192}, "", colorPickerValue) | ||
|
|
||
| sliderValue = gui.Slider(rl.Rectangle{355, 400, 165, 20}, "TEST", | ||
| fmt.Sprintf("%2.2f", sliderValue), sliderValue, -50, 100) | ||
| sliderBarValue = gui.SliderBar(rl.Rectangle{320, 430, 200, 20}, "", | ||
| fmt.Sprintf("%2.2f", sliderBarValue), sliderBarValue, 0, 100) | ||
| progressValue = gui.ProgressBar(rl.Rectangle{320, 460, 200, 20}, "", "", progressValue, 0, 1) | ||
|
|
||
| // NOTE: View rectangle could be used to perform some scissor test | ||
| var view rl.Rectangle | ||
| gui.ScrollPanel(rl.Rectangle{560, 25, 102, 354}, "", rl.Rectangle{560, 25, 300, 1200}, &viewScroll, &view) | ||
|
|
||
| var mouseCell rl.Vector2 | ||
| gui.Grid(rl.Rectangle{560, 25 + 180 + 195, 100, 120}, "", 20, 3, &mouseCell) | ||
|
|
||
| alphaValue = gui.ColorBarAlpha(rl.Rectangle{320, 490, 200, 30}, "", alphaValue) | ||
|
|
||
| gui.StatusBar(rl.Rectangle{0, float32(rl.GetScreenHeight()) - 20, float32(rl.GetScreenWidth()), 20}, "This is a status bar") | ||
|
|
||
| if showMessageBox { | ||
| rl.DrawRectangle(0, 0, int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()), rl.Fade(rl.RayWhite, 0.8)) | ||
| var result int32 = gui.MessageBox(rl.Rectangle{float32(rl.GetScreenWidth())/2 - 125, float32(rl.GetScreenHeight())/2 - 50, 250, 100}, gui.IconText(gui.ICON_EXIT, "Close Window"), "Do you really want to exit?", "Yes;No") | ||
|
|
||
| if (result == 0) || (result == 2) { | ||
| showMessageBox = false | ||
| } else if result == 1 { | ||
| exitWindow = true | ||
| } | ||
| } | ||
|
|
||
| if showTextInputBox { | ||
| rl.DrawRectangle(0, 0, int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()), rl.Fade(rl.RayWhite, 0.8)) | ||
| var secretViewActive bool | ||
| var result int32 = gui.TextInputBox( | ||
| rl.Rectangle{float32(rl.GetScreenWidth())/2 - 120, float32(rl.GetScreenHeight())/2 - 60, 240, 140}, | ||
| "Save", | ||
| gui.IconText(gui.ICON_FILE_SAVE, "Save file as..."), | ||
| "Ok;Cancel", | ||
| &textInput, 255, &secretViewActive) | ||
|
|
||
| if result == 1 { | ||
| // TODO: Validate textInput value and save | ||
| // strcpy(textInputFileName, textInput) | ||
| // TODO textInputFileName = textInput | ||
| } | ||
| if (result == 0) || (result == 1) || (result == 2) { | ||
| showTextInputBox = false | ||
| //strcpy(textInput, "\0"); | ||
| textInput = "" | ||
| } | ||
| } | ||
| //---------------------------------------------------------------------------------- | ||
|
|
||
| rl.EndDrawing() | ||
| //---------------------------------------------------------------------------------- | ||
| } | ||
| rl.SetMain(update) | ||
|
|
||
| // De-Initialization | ||
| //-------------------------------------------------------------------------------------- | ||
| rl.CloseWindow() // Close window and OpenGL context | ||
| //-------------------------------------------------------------------------------------- | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: BrownNPC/Raylib-Go-Wasm
Length of output: 1066
🏁 Script executed:
Repository: BrownNPC/Raylib-Go-Wasm
Length of output: 557
🏁 Script executed:
Repository: BrownNPC/Raylib-Go-Wasm
Length of output: 274
Example imports the wrong module — uses upstream
gen2brain/raylib-goinstead of this fork.This PR's whole point is adding raygui bindings under
BrownNPC/Raylib-Go-Wasm, and the example must import from that fork, not the upstream package. The example currently importsgithub.com/gen2brain/raylib-go/rayguiandgithub.com/gen2brain/raylib-go/raylibbut callsrl.SetMain()on line 18, which is defined only in this fork'sraylib/raylib_wasm.go. The upstreamgen2brain/raylib-godoes not haveSetMain, so this file will not compile with the current imports.🛠 Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents