当前位置: 首页>>代码示例>>Golang>>正文


Golang flags.CreateTheme函数代码示例

本文整理汇总了Golang中github.com/google/gxui/samples/flags.CreateTheme函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateTheme函数的具体用法?Golang CreateTheme怎么用?Golang CreateTheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateTheme函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: appMain

func appMain(driver gxui.Driver) {
	file := "./img/block.bmp"
	f, err := os.Open(file)
	if err != nil {
		fmt.Printf("Failed to open image '%s': %v\n", file, err)
		os.Exit(1)
	}

	source, _, err := image.Decode(f)
	if err != nil {
		fmt.Printf("Failed to read image '%s': %v\n", file, err)
		os.Exit(1)
	}

	theme := flags.CreateTheme(driver)
	img := theme.CreateImage()

	//mx := source.Bounds().Max
	window := theme.CreateWindow(1000, 1000, "Tetris")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(img)

	rgba := image.NewRGBA(source.Bounds())
	draw.Draw(rgba, source.Bounds(), source, image.ZP, draw.Src)
	texture := driver.CreateTexture(rgba, 1)
	img.SetTexture(texture)

	window.OnClose(driver.Terminate)
}
开发者ID:delaemon,项目名称:go-tetris,代码行数:29,代码来源:tetris.go

示例2: Initdashboard

func Initdashboard(driver gxui.Driver) {
	Theme = flags.CreateTheme(driver)
	Windashboard = Createwindashboard(Theme)
	data.DBAnakKost = data.Createdbanakkost()
	data.DBSetoran = data.Createdatasetoran()
	data.DBPengeluaran = data.Createdatapengeluaran()
}
开发者ID:jonysugianto,项目名称:adminkost,代码行数:7,代码来源:dashboard.go

示例3: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	label := theme.CreateLabel()
	label.SetText("This is a progress bar:")

	progressBar := theme.CreateProgressBar()
	progressBar.SetDesiredSize(math.Size{W: 400, H: 20})
	progressBar.SetTarget(100)

	layout := theme.CreateLinearLayout()
	layout.AddChild(label)
	layout.AddChild(progressBar)
	layout.SetHorizontalAlignment(gxui.AlignCenter)

	window := theme.CreateWindow(800, 600, "Progress bar")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)

	progress := 0
	pause := time.Millisecond * 500
	var timer *time.Timer
	timer = time.AfterFunc(pause, func() {
		driver.Call(func() {
			progress = (progress + 3) % progressBar.Target()
			progressBar.SetProgress(progress)
			timer.Reset(pause)
		})
	})
}
开发者ID:liulnn,项目名称:gxui,代码行数:31,代码来源:main.go

示例4: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   A   │║│   B   │
	// │       │║│       │
	// └───────┘║└───────┘
	// ═══════════════════
	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   C   │║│   D   │
	// │       │║│       │
	// └───────┘║└───────┘

	splitterAB := theme.CreateSplitterLayout()
	splitterAB.SetOrientation(gxui.Horizontal)
	splitterAB.AddChild(panelHolder("A", theme))
	splitterAB.AddChild(panelHolder("B", theme))

	splitterCD := theme.CreateSplitterLayout()
	splitterCD.SetOrientation(gxui.Horizontal)
	splitterCD.AddChild(panelHolder("C", theme))
	splitterCD.AddChild(panelHolder("D", theme))

	vSplitter := theme.CreateSplitterLayout()
	vSplitter.SetOrientation(gxui.Vertical)
	vSplitter.AddChild(splitterAB)
	vSplitter.AddChild(splitterCD)

	window := theme.CreateWindow(800, 600, "Panels")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(vSplitter)
	window.OnClose(driver.Terminate)
}
开发者ID:langxj,项目名称:gxui,代码行数:35,代码来源:main.go

示例5: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	table := theme.CreateTableLayout()
	table.SetGrid(3, 4)

	Colum1 := theme.CreateLabel()
	Colum1.SetText("Column1")
	Colum2 := theme.CreateLabel()
	Colum2.SetText("Column2")
	Colum3 := theme.CreateLabel()
	Colum3.SetText("Column3")

	table.SetChildAt(0, 0, 1, 1, Colum1)
	table.SetChildAt(1, 0, 1, 1, Colum2)
	table.SetChildAt(2, 0, 1, 1, Colum3)

	for r := 1; r < 4; r++ {
		for c := 0; c < 3; c++ {
			label := theme.CreateLabel()
			label.SetText(strconv.Itoa(r) + "_" + strconv.Itoa(c))
			table.SetChildAt(c, r, 1, 1, label)
			fmt.Println(r, c)
		}
	}

	window := theme.CreateWindow(600, 600, "Table")
	window.AddChild(table)
}
开发者ID:jonysugianto,项目名称:adminkost,代码行数:29,代码来源:tabel.go

示例6: gxuiOpenWindow

func gxuiOpenWindow(width uint, height uint, dblBuf *doublebuffer.DoubleBuffer, commands chan Message, events chan Message) {
	gl.StartDriver(func(driver gxui.Driver) {
		theme := flags.CreateTheme(driver)
		window := theme.CreateWindow(int(width), int(height), "MyGameEngine")
		window.SetScale(flags.DefaultScaleFactor)
		screen := theme.CreateImage()
		window.AddChild(screen)
		window.OnClose(func() {
			driver.Terminate()
			events <- Message{MESSAGE_EXIT, 0}
		})
		window.OnKeyDown(func(e gxui.KeyboardEvent) {
			fmt.Println("keydown") // FIXME: without this line, randomly crash ...
			events <- Message{MESSAGE_KEY_DOWN, int(e.Key)}
		})

		// repaint function
		go func() {
			for {
				<-commands
				last := screen.Texture()
				driver.CallSync(func() {
					texture := driver.CreateTexture(dblBuf.GetPreviousImage().GetBuffer(), 1)
					screen.SetTexture(texture)
					if last != nil {
						last.Release()
					}
				})
			}
		}()
	})
}
开发者ID:reachtheflow,项目名称:gotris,代码行数:32,代码来源:gsxui.go

示例7: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	window := theme.CreateWindow(800, 600, "iMan升级")
	window.OnClose(driver.Terminate)
	window.SetScale(flags.DefaultScaleFactor)
	window.SetPadding(math.Spacing{L: 50, R: 50, T: 50, B: 50})

	button := theme.CreateButton()
	button.SetHorizontalAlignment(gxui.AlignCenter)
	button.SetSizeMode(gxui.Fill)

	toggle := func() {
		fullscreen := !window.Fullscreen()
		window.SetFullscreen(fullscreen)
		if fullscreen {
			button.SetText("窗口化")
		} else {
			button.SetText("全屏")
		}
	}

	box := theme.CreateTextBox()
	box.SetText("盒子")

	button.SetText("全屏")
	button.OnClick(func(gxui.MouseEvent) { toggle() })
	window.AddChild(button)
	window.AddChild(box)
}
开发者ID:CodyGuo,项目名称:Go-Cody,代码行数:30,代码来源:main.go

示例8: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	hSplitter := theme.CreateSplitterLayout()
	hSplitter.SetOrientation(gxui.Horizontal)
	hSplitter.AddChild(panelHolder("L", theme))
	hSplitter.AddChild(panelHolder("R", theme))

	window := theme.CreateWindow(500, 600, "Panels")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(hSplitter)
	window.OnClose(driver.Terminate)
}
开发者ID:melanxolikpofigist,项目名称:gokr,代码行数:13,代码来源:kr.go

示例9: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)
	width := int(nmj.Width)
	height := int(nmj.Heigth)

	window := theme.CreateWindow(width, height, "navmesh")
	canvas := driver.CreateCanvas(math.Size{W: width, H: height})

	ps := nmj.Points

	// mouse
	isStart := true
	x1, y1, x2, y2 := int64(0), int64(0), int64(0), int64(0)

	window.OnMouseDown(func(me gxui.MouseEvent) {
		if nm.IsWalkOfPoint(navmesh.Point{X: int64(me.Point.X), Y: int64(me.Point.Y)}) {
			if isStart {
				x1 = int64(me.Point.X)
				y1 = int64(me.Point.Y)
			} else {
				x2 = int64(me.Point.X)
				y2 = int64(me.Point.Y)
			}
			if !isStart {
				drawWalkPath(window, theme, driver, x1, y1, x2, y2)
			}
			isStart = !isStart
		}
	})

	// draw mesh
	for i := 0; i < len(ps); i++ {
		polys := make([]gxui.PolygonVertex, 0, len(ps[i]))
		for j := 0; j < len(ps[i]); j++ {
			polys = append(polys, gxui.PolygonVertex{
				Position: math.Point{
					int(ps[i][j].X),
					int(ps[i][j].Y),
				}})
		}
		//		canvas.DrawPolygon(polys, gxui.CreatePen(2, gxui.Gray80), gxui.CreateBrush(gxui.Gray40))
		canvas.DrawPolygon(polys, gxui.CreatePen(2, gxui.Red), gxui.CreateBrush(gxui.Yellow))
	}

	canvas.Complete()
	image := theme.CreateImage()
	image.SetCanvas(canvas)
	window.AddChild(image)
	window.OnClose(driver.Terminate)
}
开发者ID:gbember,项目名称:gt,代码行数:50,代码来源:main.go

示例10: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   A   │║│   B   │
	// │       │║│       │
	// └───────┘║└───────┘
	// ═══════════════════
	// ┌───────┐║┌───────┐
	// │       │║│       │
	// │   C   │║│   D   │
	// │       │║│       │
	// └───────┘║└───────┘

	ftData, err := ioutil.ReadFile("static/font/simhei.ttf")
	if err != nil {
		log.Println(err)
	}
	ft, err := driver.CreateFont(ftData, 20)
	if err != nil {
		log.Println(err)
	}
	menu := theme.CreateLinearLayout()
	menu.SetDirection(gxui.LeftToRight)
	logo_label := theme.CreateLabel()
	logo_label.SetColor(gxui.White)
	logo_label.SetFont(ft)
	logo_label.SetText("百度盘")
	logo_label.SetSize(math.Size{300, 200})
	menu.AddChild(logo_label)

	splitterCD := theme.CreateSplitterLayout()
	splitterCD.SetOrientation(gxui.Horizontal)
	splitterCD.AddChild(panelHolder("C", theme))
	splitterCD.AddChild(panelHolder("D", theme))

	vSplitter := theme.CreateSplitterLayout()
	vSplitter.SetOrientation(gxui.Vertical)
	vSplitter.AddChild(menu)
	vSplitter.AddChild(splitterCD)

	window := theme.CreateWindow(800, 600, "百度盘")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(vSplitter)
	window.OnClose(driver.Terminate)
}
开发者ID:kelwang,项目名称:godu-pan,代码行数:47,代码来源:ui.go

示例11: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	overlay := theme.CreateBubbleOverlay()

	holder := theme.CreatePanelHolder()
	holder.AddPanel(overview(theme), "Overview")
	holder.AddPanel(send(theme), "Send")
	holder.AddPanel(receive(theme), "Receive")
	holder.AddPanel(transactions(theme), "Transactions")

	window := theme.CreateWindow(800, 450, "Factoid Wallet")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(holder)
	window.AddChild(overlay)
	window.OnClose(driver.Terminate)
	window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})
}
开发者ID:FactomProject,项目名称:GUIWallet,代码行数:18,代码来源:main.go

示例12: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	canvas := driver.CreateCanvas(math.Size{W: 500, H: 300})

	layout := theme.CreateLinearLayout()
	layout.SetSizeMode(gxui.Fill)
	layout.SetDirection(gxui.TopToBottom)

	buttonsLayout := theme.CreateLinearLayout()
	buttonsLayout.SetSizeMode(gxui.Fill)
	buttonsLayout.SetDirection(gxui.LeftToRight)

	button := func(name string, action func()) gxui.Button {
		b := theme.CreateButton()
		b.SetText(name)
		b.OnClick(func(gxui.MouseEvent) { action() })
		return b
	}

	okayButton := button("Okay", func() { log.Println("Okay") })
	buttonsLayout.AddChild(okayButton)
	cancelButton := button("Cancel", func() { log.Println("Cancel") })
	buttonsLayout.AddChild(cancelButton)

	drawPlot(canvas)
	canvas.Complete()

	image := theme.CreateImage()
	image.SetCanvas(canvas)

	window := theme.CreateWindow(800, 600, "bview")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))
	layout.AddChild(buttonsLayout)
	layout.AddChild(image)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)
	window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})

	window.OnResize(func() { log.Println(layout.Children().String()) })

}
开发者ID:canejune,项目名称:sandbox,代码行数:42,代码来源:bview.go

示例13: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.TopToBottom)

	adapter := &adapter{}

	// hook up node changed function to the adapter OnDataChanged event.
	adapter.changed = adapter.DataChanged

	// add all the species to the 'Animals' root node.
	items := addSpecies(adapter.add("Animals"))

	tree := theme.CreateTree()
	tree.SetAdapter(adapter)
	tree.Select(items["Doves"])
	tree.Show(tree.Selected())

	layout.AddChild(tree)

	row := theme.CreateLinearLayout()
	row.SetDirection(gxui.LeftToRight)
	layout.AddChild(row)

	expandAll := theme.CreateButton()
	expandAll.SetText("Expand All")
	expandAll.OnClick(func(gxui.MouseEvent) { tree.ExpandAll() })
	row.AddChild(expandAll)

	collapseAll := theme.CreateButton()
	collapseAll.SetText("Collapse All")
	collapseAll.OnClick(func(gxui.MouseEvent) { tree.CollapseAll() })
	row.AddChild(collapseAll)

	window := theme.CreateWindow(800, 600, "Tree view")
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(layout)
	window.OnClose(driver.Terminate)
	window.SetPadding(math.Spacing{L: 10, T: 10, R: 10, B: 10})
}
开发者ID:nulijiabei,项目名称:gxui,代码行数:41,代码来源:main.go

示例14: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)

	label := theme.CreateLabel()
	label.SetText("Clou")

	splitterAB := theme.CreateSplitterLayout()
	splitterAB.SetOrientation(gxui.Horizontal)
	splitterAB.AddChild(panelHolder("Local", theme))
	splitterAB.AddChild(panelHolder("Cloud", theme))

	vSplitter := theme.CreateSplitterLayout()
	vSplitter.SetOrientation(gxui.Vertical)
	vSplitter.AddChild(splitterAB)

	window := theme.CreateWindow(800, 600, "Panels")
	window.AddChild(label)
	window.SetScale(flags.DefaultScaleFactor)
	window.AddChild(vSplitter)
	window.OnClose(driver.Terminate)
}
开发者ID:adrien3d,项目名称:gobox,代码行数:21,代码来源:gui.go

示例15: appMain

func appMain(driver gxui.Driver) {
	theDriver = driver
	theme = flags.CreateTheme(driver)

	window := theme.CreateWindow(winW, winH, "Window")
	window.OnClose(driver.Terminate)
	window.SetScale(flags.DefaultScaleFactor)

	layout := theme.CreateLinearLayout()
	layout.SetBackgroundBrush(gxui.CreateBrush(gxui.Black))
	layout.SetDirection(gxui.LeftToRight)
	layout.SetVerticalAlignment(gxui.AlignBottom)

	layout.SetSizeMode(gxui.Fill)

	nums := common.GenerateRandomNumbers(numBars, 0, valNum)
	for _, n := range nums {
		child := createBar()
		setBarHeight(child, n)
		layout.AddChild(child)
		bars = append(bars, child)
	}

	window.AddChild(layout)

	delegate := &GUIDelegate{}

	go func() {
		<-time.After(1 * time.Second)
		fmt.Println("ExecuteSort...")
		// sorting.ExecuteSort(sorting.InsertionSort, nums, delegate)
		// sorting.ExecuteSort(sorting.BubbleSort, nums, delegate)
		// sorting.ExecuteSort(sorting.SelectionSort, nums, delegate)
		// sorting.ExecuteSort(sorting.ShellSort, nums, delegate)
		// sorting.ExecuteSort(sorting.MergeSort, nums, delegate)
		sorting.ExecuteSort(sorting.QuickSort, nums, delegate)
		// fmt.Println(result)
	}()
}
开发者ID:xinhuang327,项目名称:algorithms,代码行数:39,代码来源:test_sorting_ui.go


注:本文中的github.com/google/gxui/samples/flags.CreateTheme函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。