func createWindow(controllerManager *glfwController.ControllerManager) (window *ui.Window, content *ui.Container) { // Create window with size window = ui.NewWindow() window.SetScale(mgl32.Vec2{300, 0}.Vec3(0)) // create a click and drag tab tab := ui.NewContainer() tab.SetBackgroundColor(70, 70, 170, 255) tab.SetHeight(40) // create a content container content = ui.NewContainer() content.SetBackgroundColor(200, 200, 200, 255) content.SetPadding(ui.NewMargin(10)) // Add all the containers to the window mainContainer := ui.NewContainer() mainContainer.AddChildren(tab, content) window.SetElement(mainContainer) // create uiController uiController := ui.NewUiController(window) controllerManager.AddController(uiController.(glfwController.Controller)) ui.ClickAndDragWindow(window, tab.Hitbox, uiController) return }
func (engine *EngineImpl) InitFpsDial() { window := ui.NewWindow() window.SetTranslation(mgl32.Vec3{10, 10, 1}) window.SetScale(mgl32.Vec3{400, 0, 1}) window.SetBackgroundColor(0, 0, 0, 0) container := ui.NewContainer() container.SetBackgroundColor(0, 0, 0, 0) window.SetElement(container) text := ui.NewTextElement("0", color.RGBA{255, 0, 0, 255}, 18, nil) container.AddChildren(text) engine.AddUpdatable(UpdatableFunc(func(dt float64) { fps := engine.FPS() text.SetText(fmt.Sprintf("%v", int(fps))) switch { case fps < 20: text.SetTextColor(color.RGBA{255, 0, 0, 255}) case fps < 30: text.SetTextColor(color.RGBA{255, 90, 0, 255}) case fps < 50: text.SetTextColor(color.RGBA{255, 255, 0, 255}) default: text.SetTextColor(color.RGBA{0, 255, 0, 255}) } text.ReRender() })) window.Render() engine.AddOrtho(window) }
func (e *Editor) defaultWindow() (window *ui.Window, container *ui.Container, tab *ui.Container) { window = ui.NewWindow() tab = ui.NewContainer() tab.SetBackgroundColor(70, 70, 70, 255) tab.SetHeight(40) mainContainer := ui.NewContainer() window.SetElement(mainContainer) container = ui.NewContainer() container.SetBackgroundColor(200, 200, 200, 255) mainContainer.AddChildren(tab, container) ui.ClickAndDragWindow(window, tab.Hitbox, e.customController) return }
func (e *Editor) openProgressBar() { if e.progressBar == nil { window := ui.NewWindow() window.SetTranslation(mgl32.Vec3{500, 0, 0}) window.SetScale(mgl32.Vec3{330, 0, 1}) container := ui.NewContainer() container.SetBackgroundColor(200, 200, 200, 255) window.SetElement(container) e.controllerManager.AddController(ui.NewUiController(window).(glfwController.Controller)) ui.LoadHTML(container, strings.NewReader(progressBarHtml), strings.NewReader(globalCss), e.uiAssets) window.Render() e.progressBar = window } e.gameEngine.AddOrtho(e.progressBar) }