2018-10-24 20:43:31 +02:00
|
|
|
package widgets
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gopherjs/vecty"
|
|
|
|
"github.com/gopherjs/vecty/elem"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Graphics represents graphics configuration widget.
|
|
|
|
type Graphics struct {
|
|
|
|
vecty.Core
|
|
|
|
|
|
|
|
rtSwitch *Switch
|
2018-10-24 22:05:23 +02:00
|
|
|
fpsRadio *RadioGroup
|
2018-10-24 20:43:31 +02:00
|
|
|
collapsable *Collapsable
|
2018-10-24 21:04:43 +02:00
|
|
|
|
|
|
|
conf SceneConfigurator
|
2018-10-24 20:43:31 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:04:43 +02:00
|
|
|
// NewGraphics creates a new Graphics widget. It needs to have
|
|
|
|
// access to scene configuration, as it configures mostly things from it.
|
2018-10-24 22:05:23 +02:00
|
|
|
func NewGraphics(conf SceneConfigurator, value int) *Graphics {
|
2018-10-24 21:04:43 +02:00
|
|
|
g := &Graphics{
|
|
|
|
conf: conf,
|
|
|
|
}
|
2018-10-24 21:08:29 +02:00
|
|
|
g.rtSwitch = NewSwitch("Render throttler", true, conf.ToggleRenderThrottler)
|
2018-10-24 22:05:23 +02:00
|
|
|
g.fpsRadio = NewRadioGroup("FPS", value, conf.ChangeFPS, []int{60, 30, 20, 15})
|
2018-10-24 20:43:31 +02:00
|
|
|
g.collapsable = NewCollapsable("Graphics:", false,
|
|
|
|
g.applyButton,
|
2018-10-24 22:05:23 +02:00
|
|
|
g.fpsRadio,
|
2018-10-24 20:43:31 +02:00
|
|
|
g.rtSwitch,
|
|
|
|
)
|
|
|
|
return g
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render implements vecty's Component interface for Graphics.
|
|
|
|
func (g *Graphics) Render() vecty.ComponentOrHTML {
|
|
|
|
return Widget(
|
|
|
|
g.collapsable,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-10-24 22:05:23 +02:00
|
|
|
// FIXME: it exists due to limitations of collapsible.
|
2018-10-24 20:43:31 +02:00
|
|
|
func (g *Graphics) applyButton() vecty.ComponentOrHTML {
|
2018-10-24 22:05:23 +02:00
|
|
|
return elem.Span()
|
2018-10-24 20:43:31 +02:00
|
|
|
}
|