组件概览

组件总实例

https://github.com/AllenDang/giu/tree/master/examples/widgets

SingleWindowWithMenuBar
MenuBar
g.MenuBar(
    g.Layout{
        g.Menu("File", g.Layout{
            g.MenuItem("Open", nil),
                g.MenuItem("Save", nil),
                // You could add any kind of widget here, not just menu item.
                g.Menu("Save as ...", 
                	g.Layout{
                        g.MenuItem("Excel file", nil),
                        g.MenuItem("CSV file", nil),
                        g.Button("Button inside menu", nil),
                    },
                ),
            },
    	),
    },
),

image-20201019132244009

Label

g.Label("One line label"),

image-20201019132314733

LabelWrapped

g.LabelWrapped("Auto wrapped label with very long line...............................................this line should be wrapped.")

image-20201019132327266

InputText & Tooltip

Line(
   g.InputText("##name", 0, &name),
   g.Button("Click Me", btnClickMeClicked),
   g.Tooltip("I'm a tooltip"),
),

image-20201019132400437

DatePicker

g.DatePicker("Date Picker", &date, 100, func() {
   fmt.Println(date)
}),

image-20201019132442310

CheckBox & RadioButton

g.Line(
   g.Checkbox("Checkbox", &checked, func() {
      fmt.Println(checked)
   }),
   g.Checkbox("Checkbox 2", &checked2, func() {
      fmt.Println(checked2)
   }),
   g.Dummy(30, 0),
   g.RadioButton("Radio 1", radioOp == 0, func() { radioOp = 0 }),
   g.RadioButton("Radio 2", radioOp == 1, func() { radioOp = 1 }),
   g.RadioButton("Radio 3", radioOp == 2, func() { radioOp = 2 }),
),

image-20201019132456699

ProgressBar

g.ProgressBar(0.8, -1, 0, "Progress"),

image-20201019132513283

DragInt

g.DragInt("DragInt", &dragInt),

image-20201019132534618

SliderInt

g.SliderInt("Slider", &dragInt, 0, 100, ""),

image-20201019132556294

Combo

g.Combo("Combo", items[itemSelected], items, &itemSelected, 0, 0, comboChanged),

image-20201019132619838

PopupModal

g.Line(
   g.Button("Popup Modal", btnPopupCLicked),
   g.PopupModal("Confirm", g.Layout{
      g.Label("Confirm to close me?"),
      g.Line(
         g.Button("Yes", func() { imgui.CloseCurrentPopup() }),
         g.Button("No", nil),
      ),
   }),
   g.Label("Right click me to see the context menu"),
   g.ContextMenu(g.Layout{
      g.Selectable("Context menu 1", contextMenu1Clicked),
      g.Selectable("Context menu 2", contextMenu2Clicked),
   }),
),

image-20201019132652489

TabBar

g.TabBar("Tabbar Input", g.Layout{

image-20201019132802515

TreeNode

g.TreeNode("TreeNode1", imgui.TreeNodeFlagsCollapsingHeader|imgui.TreeNodeFlagsDefaultOpen, g.Layout{
   g.Label("Tree node 1"),
   g.Label("Tree node 1"),
   g.Label("Tree node 1"),
   g.Button("Button inside tree", nil),
}),
g.TreeNode("TreeNode2", 0, g.Layout{
   g.Label("Tree node 2"),
   g.Label("Tree node 2"),
   g.Label("Tree node 2"),
   g.Button("Button inside tree", nil),
}),

image-20201019132906379

ListBox

g.ListBox("ListBox1", []string{"List item 1", "List item 2", "List item 3"}, nil, nil),

image-20201019132945252

Table

g.Table("Table", true, g.Rows{
   g.Row(g.LabelWrapped("Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog"), g.Label("Age"), g.Label("Loc")),
   g.Row(g.LabelWrapped("Second Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog"), g.Label("Age"), g.Label("Loc")),
   g.Row(g.Label("Name"), g.Label("Age"), g.Label("Location")),
   g.Row(g.Label("Allen"), g.Label("33"), g.Label("Shanghai/China")),
   g.Row(g.Checkbox("check me", &checked, nil), g.Button("click me", nil), g.Label("Anything")),
}),

image-20201019132954988

© 2021 hanbaoaaa record.浙ICP备20005263号
asdad
联系方式 asdasd
2021-5-8 4:19
sss
回复数 (0) 点击展开
加载更多

新增评论

称呼
联系方式
邮箱(选填)
内容

提交

取消