imgui的golang绑定----giu的组件案例

组件总实例

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值