• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang flags.CreateTheme函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: appMain

func appMain(driver gxui.Driver) {

	d = driver
	source := image.Image(newMandelbrot())

	theme := flags.CreateTheme(driver)

	mx := source.Bounds().Max

	img = theme.CreateImage()

	window = theme.CreateWindow(mx.X, mx.Y, "Image viewer")
	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.OnClick(windowOnClickHandler)
	window.OnClose(driver.Terminate)
}
开发者ID:rustyoz,项目名称:mandelbrot,代码行数:23,代码来源:mandelbrot.go


示例17: appMain

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

	font, err := driver.CreateFont(gxfont.Default, H1_FONT_SIZE)
	catch(err)

	window := theme.CreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, APP_TITLE)
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.White))
	window.SetScale(flags.DefaultScaleFactor)
	window.SetPadding(math.Spacing{L: 10, R: 10, T: 10, B: 10})

	layout := theme.CreateLinearLayout()
	layout.SetSizeMode(gxui.Fill)
	layout.SetHorizontalAlignment(gxui.AlignCenter)
	layout.HorizontalAlignment().AlignCenter()

	fullscreenButton := theme.CreateButton()
	fullscreenButton.SetText("Make Fullscreen")
	fullscreenButton.OnClick(func(ev gxui.MouseEvent) {
		fullscreen := !window.Fullscreen()
		window.SetFullscreen(fullscreen)

		if fullscreen {
			fullscreenButton.SetText("Make Windowed")
		} else {
			fullscreenButton.SetText("Make Fullscreen")
		}
	})

	h1Title := theme.CreateLabel()
	h1Title.SetFont(font)
	h1Title.SetColor(gxui.Color{R: 0, G: 0, B: 0, A: 1})

	KinopoiskLabel := theme.CreateLabel()
	KinopoiskLabel.SetFont(font)
	KinopoiskLabel.SetColor(gxui.Color{R: 0, G: 0, B: 0, A: 1})

	ImdbLabel := theme.CreateLabel()
	ImdbLabel.SetFont(font)
	ImdbLabel.SetColor(gxui.Color{R: 0, G: 0, B: 0, A: 1})

	// https://github.com/google/gxui/blob/master/samples/image_viewer/main.go
	img := theme.CreateImage()

	getFilmButton := theme.CreateButton()
	getFilmButton.SetText("Get Film!")
	getFilmButton.OnClick(func(ev gxui.MouseEvent) {
		getFilm(driver, h1Title, KinopoiskLabel, ImdbLabel, img)
	})

	getFilm(driver, h1Title, KinopoiskLabel, ImdbLabel, img)

	layout.AddChild(fullscreenButton)
	layout.AddChild(h1Title)
	layout.AddChild(KinopoiskLabel)
	layout.AddChild(ImdbLabel)
	layout.AddChild(getFilmButton)
	layout.AddChild(img)
	window.AddChild(layout)

	window.OnClose(driver.Terminate)
}
开发者ID:oOLokiOo,项目名称:random-film,代码行数:62,代码来源:main.go


示例18: appMain

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

	font, err := driver.CreateFont(gxfont.Default, 75)
	if err != nil {
		panic(err)
	}

	window := theme.CreateWindow(800, 480, "Привет")
	window.SetBackgroundBrush(gxui.CreateBrush(gxui.Gray50))
	window.SetBorderPen(gxui.Pen{Width: 5, Color: gxui.Yellow})

	f, err := os.Open("wallpaper.jpg")
	if err != nil {
		fmt.Printf("Failed to open image %v\n", err)
		os.Exit(1)
	}

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

	wallpaper := theme.CreateImage()
	window.AddChild(wallpaper)

	// Copy the image to a RGBA format before handing to a gxui.Texture
	rgba := image.NewRGBA(source.Bounds())
	draw.Draw(rgba, source.Bounds(), source, image.ZP, draw.Src)
	texture := driver.CreateTexture(rgba, 1)
	wallpaper.SetTexture(texture)

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

	label := theme.CreateLabel()
	label.SetFont(font)
	label.SetText("Здравствуй мир")
	label.OnMouseMove(func(e gxui.MouseEvent) {
		fmt.Printf("X=%d; Y=%d\n", e.Point.X, e.Point.Y)
	})
	layout.AddChild(label)

	lTimer := theme.CreateLabel()
	lTimer.SetFont(font)
	lTimer.SetColor(gxui.Green30)
	layout.AddChild(lTimer)

	button := theme.CreateButton()
	button.SetText("Exit")
	button.SetPadding(math.Spacing{20, 10, 20, 10})
	button.SetMargin(math.Spacing{20, 10, 20, 10})
	button.OnClick(func(e gxui.MouseEvent) {
		window.Close()
	})
	layout.AddChild(button)

	ticker := time.NewTicker(time.Millisecond * 30)
	go func() {
		phase := float32(0)
		for _ = range ticker.C {
			c := gxui.Color{
				R: 0.75 + 0.25*math.Cosf((phase+0.000)*math.TwoPi),
				G: 0.75 + 0.25*math.Cosf((phase+0.333)*math.TwoPi),
				B: 0.75 + 0.25*math.Cosf((phase+0.666)*math.TwoPi),
				A: 0.50 + 0.50*math.Cosf(phase*10),
			}
			phase += 0.01
			driver.Call(func() {
				label.SetColor(c)
			})
		}
	}()

	ticker2 := time.NewTicker(time.Millisecond * 100)
	go func() {
		for t := range ticker.C {
			driver.Call(func() {
				lTimer.SetText(t.Format(time.Stamp))
			})
		}
	}()

	window.OnClose(ticker.Stop)
	window.OnClose(ticker2.Stop)
	window.OnClose(driver.Terminate)
}
开发者ID:plumbum,项目名称:go-samples,代码行数:89,代码来源:main.go


示例19: appMain

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

	from := theme.CreateTextBox()
	from.SetDesiredWidth(500)
	from.SetText("from")
	from.OnGainedFocus(func() {
		if from.Text() == "from" {
			from.SetText("")
		}
	})
	from.OnLostFocus(func() {
		if from.Text() == "" {
			from.SetText("from")
		}
	})

	password := theme.CreateTextBox()
	password.SetDesiredWidth(500)
	password.SetText("password")
	password.OnGainedFocus(func() {
		if password.Text() == "password" {
			password.SetText("")
		}
	})
	password.OnLostFocus(func() {
		if password.Text() == "" {
			password.SetText("password")
		}
	})

	to := theme.CreateTextBox()
	to.SetDesiredWidth(500)
	to.SetText("to")
	to.OnGainedFocus(func() {
		if to.Text() == "to" {
			to.SetText("")
		}
	})
	to.OnLostFocus(func() {
		if to.Text() == "" {
			to.SetText("to")
		}
	})

	host := theme.CreateTextBox()
	host.SetDesiredWidth(500)
	host.SetText("host")
	host.OnGainedFocus(func() {
		if host.Text() == "host" {
			host.SetText("")
		}
	})
	host.OnLostFocus(func() {
		if host.Text() == "" {
			host.SetText("host")
		}
	})

	port := theme.CreateTextBox()
	port.SetDesiredWidth(500)
	port.SetText("port")
	port.OnGainedFocus(func() {
		if port.Text() == "port" {
			port.SetText("")
		}
	})
	port.OnLostFocus(func() {
		if port.Text() == "" {
			port.SetText("port")
		}
	})

	result := theme.CreateLabel()
	result.SetText("")

	message := theme.CreateTextBox()
	message.SetDesiredWidth(500)
	message.SetMultiline(true)
	message.SetText("message")
	message.OnGainedFocus(func() {
		if message.Text() == "message" {
			message.SetText("")
		}
	})
	message.OnLostFocus(func() {
		if message.Text() == "" {
			message.SetText("message")
		}
	})

	sendButton := theme.CreateButton()
	sendButton.SetText("Send")
	sendButton.OnClick(func(ev gxui.MouseEvent) {
		result.SetText("Processing...")
		_from := from.Text()
		_pass := password.Text()
		_to := to.Text()
		_host := host.Text()
		_port := port.Text()
//.........这里部分代码省略.........
开发者ID:fiddenmar,项目名称:netlabs,代码行数:101,代码来源:smtp.go


示例20: appMain

func appMain(driver gxui.Driver) {
	theme := flags.CreateTheme(driver)
	window := theme.CreateWindow(800, 600, "navmesh")
	canvas := driver.CreateCanvas(math.Size{W: 800, H: 600})

	// mouse
	isStart := true
	var src_id, dest_id int32 // source & dest triangle id
	var src, dest Point3
	window.OnMouseDown(func(me gxui.MouseEvent) {
		pt := Point3{X: float32(me.Point.X) / SCALE_FACTOR, Y: float32(me.Point.Y) / SCALE_FACTOR}
		id := getTriangleId(pt)
		if isStart {
			src_id = id
			src = pt
		} else {
			dest_id = id
			dest = pt
		}
		if !isStart {
			if src_id != -1 && dest_id != -1 {
				canvas := route(driver, src_id, dest_id, src, dest)
				image := theme.CreateImage()
				image.SetCanvas(canvas)
				window.AddChild(image)
			}
		}
		isStart = !isStart
	})

	// draw mesh
	for k := 0; k < len(triangles); k++ {
		poly := []gxui.PolygonVertex{
			gxui.PolygonVertex{
				Position: math.Point{
					int(SCALE_FACTOR * vertices[triangles[k][0]].X),
					int(SCALE_FACTOR * vertices[triangles[k][0]].Y),
				}},

			gxui.PolygonVertex{
				Position: math.Point{
					int(SCALE_FACTOR * vertices[triangles[k][1]].X),
					int(SCALE_FACTOR * vertices[triangles[k][1]].Y),
				}},

			gxui.PolygonVertex{
				Position: math.Point{
					int(SCALE_FACTOR * vertices[triangles[k][2]].X),
					int(SCALE_FACTOR * vertices[triangles[k][2]].Y),
				}},
		}
		canvas.DrawPolygon(poly, gxui.CreatePen(3, gxui.Gray80), gxui.CreateBrush(gxui.Gray40))
		//canvas.DrawPolygon(poly, 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:lazytiger,项目名称:navmesh,代码行数:61,代码来源:main.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang testing.AssertEquals函数代码示例发布时间:2022-05-23
下一篇:
Golang math.Size类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap