2021-09-09 12:08:31 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-11-17 12:32:37 +03:00
|
|
|
"fmt"
|
|
|
|
|
2021-09-09 12:08:31 +03:00
|
|
|
"github.com/anoshenko/rui"
|
|
|
|
)
|
|
|
|
|
|
|
|
const tabsDemoText = `
|
|
|
|
GridLayout {
|
|
|
|
style = demoPage,
|
|
|
|
content = [
|
2021-11-17 12:32:37 +03:00
|
|
|
TabsLayout { id = tabsLayout, width = 100%, height = 100%, tabs = top, tab-close-button = true,
|
2021-09-09 12:08:31 +03:00
|
|
|
content = [
|
2021-11-17 12:32:37 +03:00
|
|
|
View { width = 300px, height = 200px, background-color = #FFFF0000, title = "Red tab", icon = red_icon.svg },
|
|
|
|
View { width = 400px, height = 250px, background-color = #FF00FF00, title = "Green tab", icon = green_icon.svg },
|
|
|
|
View { width = 100px, height = 400px, background-color = #FF0000FF, title = "Blue tab", icon = blue_icon.svg },
|
|
|
|
View { width = 300px, height = 200px, background-color = #FF000000, title = "Black tab", icon = black_icon.svg },
|
2021-09-09 12:08:31 +03:00
|
|
|
]
|
|
|
|
},
|
|
|
|
ListLayout {
|
|
|
|
style = optionsPanel,
|
|
|
|
content = [
|
|
|
|
GridLayout {
|
|
|
|
style = optionsTable,
|
|
|
|
content = [
|
|
|
|
TextView { row = 0, text = "Tabs location" },
|
2021-11-17 12:32:37 +03:00
|
|
|
DropDownList { row = 0, column = 1, id = tabsTypeList,
|
|
|
|
items = ["top", "bottom", "left", "right", "left list", "right list", "hidden"]
|
2021-09-09 12:08:31 +03:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
func createTabsDemo(session rui.Session) rui.View {
|
|
|
|
view := rui.CreateViewFromText(session, tabsDemoText)
|
|
|
|
if view == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
rui.Set(view, "tabsTypeList", rui.DropDownEvent, func(list rui.DropDownList, number int) {
|
|
|
|
rui.Set(view, "tabsLayout", rui.Tabs, number)
|
|
|
|
})
|
|
|
|
|
2021-11-17 12:32:37 +03:00
|
|
|
rui.Set(view, "tabsLayout", rui.TabCloseEvent, func(index int) {
|
|
|
|
rui.ShowMessage("", fmt.Sprintf(`The close button of the tab "%d" was clicked`, index), session)
|
|
|
|
})
|
2021-09-09 12:08:31 +03:00
|
|
|
return view
|
|
|
|
}
|