fix example basic_controls
This commit is contained in:
parent
2119963a25
commit
25edfb6ffb
99 changed files with 5046 additions and 827 deletions
|
@ -2,9 +2,10 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raygui"
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
gui "github.com/gen2brain/raylib-go/raygui"
|
||||
rl "github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -19,19 +20,21 @@ func main() {
|
|||
buttonClicked := false
|
||||
checkboxChecked := false
|
||||
|
||||
spinnerValue := 5
|
||||
spinnerValue := int32(5)
|
||||
sliderValue := float32(10)
|
||||
sliderBarValue := float32(70)
|
||||
progressValue := float32(0.5)
|
||||
|
||||
comboActive := 0
|
||||
comboLastActive := 0
|
||||
toggleActive := 0
|
||||
comboActive := int32(0)
|
||||
comboLastActive := int32(0)
|
||||
toggleActive := int32(0)
|
||||
|
||||
toggleText := []string{"Item 1", "Item 2", "Item 3"}
|
||||
comboText := []string{"default_light", "default_dark", "hello_kitty", "monokai", "obsidian", "solarized_light", "solarized", "zahnrad"}
|
||||
|
||||
var inputText string
|
||||
toggleText := "Item 1;Item 2;Item 3"
|
||||
comboText := []string{
|
||||
"ashes", "bluish", "candy", "cherry", "cyber", "dark",
|
||||
"default", "enefete", "jungle", "lavanda", "sunny", "terminal",
|
||||
}
|
||||
comboList := strings.Join(comboText, ";")
|
||||
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
|
@ -47,44 +50,39 @@ func main() {
|
|||
|
||||
rl.ClearBackground(rl.Beige)
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 50, 80, 20), "Label")
|
||||
gui.Label(rl.NewRectangle(50, 50, 80, 20), "Label")
|
||||
|
||||
buttonClicked = raygui.Button(rl.NewRectangle(50, 70, 80, 40), "Button")
|
||||
buttonClicked = gui.Button(rl.NewRectangle(50, 70, 80, 40), "Button")
|
||||
|
||||
raygui.Label(rl.NewRectangle(70, 140, 20, 20), "Checkbox")
|
||||
checkboxChecked = raygui.CheckBox(rl.NewRectangle(50, 140, 20, 20), checkboxChecked)
|
||||
checkboxChecked = gui.CheckBox(rl.NewRectangle(50, 140, 20, 20), "Checkbox", checkboxChecked)
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 190, 200, 20), "ProgressBar")
|
||||
raygui.ProgressBar(rl.NewRectangle(50, 210, 200, 20), progressValue)
|
||||
raygui.Label(rl.NewRectangle(200+50+5, 210, 20, 20), fmt.Sprintf("%.1f", progressValue))
|
||||
gui.ProgressBar(rl.NewRectangle(50, 210, 200, 20),
|
||||
fmt.Sprintf("%.1f", progressValue),
|
||||
"ProgressBar",
|
||||
progressValue, 0, 1)
|
||||
|
||||
raygui.Label(rl.NewRectangle(50, 260, 200, 20), "Slider")
|
||||
sliderValue = raygui.Slider(rl.NewRectangle(50, 280, 200, 20), sliderValue, 0, 100)
|
||||
raygui.Label(rl.NewRectangle(200+50+5, 280, 20, 20), fmt.Sprintf("%.0f", sliderValue))
|
||||
sliderValue = gui.Slider(rl.NewRectangle(50, 280, 200, 20), "Slider", "", sliderValue, 0, 100)
|
||||
gui.Label(rl.NewRectangle(200+50+5, 280, 20, 20), fmt.Sprintf("%.0f", sliderValue))
|
||||
|
||||
buttonToggle = raygui.ToggleButton(rl.NewRectangle(50, 350, 100, 40), "ToggleButton", buttonToggle)
|
||||
buttonToggle = gui.Toggle(rl.NewRectangle(50, 350, 100, 40), "ButtonToggle", buttonToggle)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 50, 200, 20), "ToggleGroup")
|
||||
toggleActive = raygui.ToggleGroup(rl.NewRectangle(500, 70, 60, 30), toggleText, toggleActive)
|
||||
toggleActive = gui.ToggleGroup(rl.NewRectangle(500, 70, 60, 30), toggleText, toggleActive)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 120, 200, 20), "SliderBar")
|
||||
sliderBarValue = raygui.SliderBar(rl.NewRectangle(500, 140, 200, 20), sliderBarValue, 0, 100)
|
||||
raygui.Label(rl.NewRectangle(500+200+5, 140, 20, 20), fmt.Sprintf("%.0f", sliderBarValue))
|
||||
sliderBarValue = gui.SliderBar(rl.NewRectangle(500, 140, 200, 20), "SliderBar", "", sliderBarValue, 0, 100)
|
||||
gui.Label(rl.NewRectangle(500+200+5, 140, 20, 20), fmt.Sprintf("%.0f", sliderBarValue))
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 190, 200, 20), "Spinner")
|
||||
spinnerValue = raygui.Spinner(rl.NewRectangle(500, 210, 200, 20), spinnerValue, 0, 100)
|
||||
_ = gui.Spinner(rl.NewRectangle(500, 210, 200, 20), "Spinner", &spinnerValue, 0, 100, true)
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 260, 200, 20), "ComboBox")
|
||||
comboActive = raygui.ComboBox(rl.NewRectangle(500, 280, 200, 20), comboText, comboActive)
|
||||
gui.Label(rl.NewRectangle(500, 260, 200, 20), "ComboBox")
|
||||
comboActive = gui.ComboBox(rl.NewRectangle(500, 280, 200, 20), comboList, comboActive)
|
||||
|
||||
if comboLastActive != comboActive {
|
||||
raygui.LoadGuiStyle(fmt.Sprintf("styles/%s.style", comboText[comboActive]))
|
||||
ch := comboText[comboActive] // choosed name
|
||||
filename := fmt.Sprintf("styles/%s/%s.rgs", ch, ch)
|
||||
gui.LoadStyle(filename)
|
||||
comboLastActive = comboActive
|
||||
}
|
||||
|
||||
raygui.Label(rl.NewRectangle(500, 330, 200, 20), "TextBox")
|
||||
inputText = raygui.TextBox(rl.NewRectangle(500, 350, 200, 20), inputText)
|
||||
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue