예제 #1
0
파일: ui.go 프로젝트: krig/podcast-studio
// Draw a popup menu
func (menu *PopupMenu) Draw(rend *sdl.Renderer) {
	if !menu.Visible {
		return
	}
	rend.SetDrawColor(hexcolor(0x303030))
	rend.FillRect(&menu.Pos)
	rend.SetDrawColor(hexcolor(0x363636))
	rend.DrawRect(&menu.Pos)
	if menu.hover != -1 && menu.hover < len(menu.entries) {
		rend.SetDrawColor(hexcolor(0x406f40))
		rend.FillRect(&menu.entries[menu.hover].label.Pos)
	}
	for _, e := range menu.entries {
		e.Draw(rend)
	}
}
예제 #2
0
func (tb *TopBar) Draw(rend *sdl.Renderer) {
	rend.SetDrawColor(tb.BackgroundColor)
	rend.FillRect(&tb.Pos)
	rend.SetDrawColor(lighten(tb.BackgroundColor, 9))
	rend.DrawLine(tb.Pos.X, tb.Pos.Y+tb.Pos.H-1, tb.Pos.X+tb.Pos.W, tb.Pos.Y+tb.Pos.H-1)
	rend.SetDrawColor(darken(tb.BackgroundColor, 9))
	rend.DrawLine(tb.Pos.X, tb.Pos.Y+tb.Pos.H, tb.Pos.X+tb.Pos.W, tb.Pos.Y+tb.Pos.H)

	for _, w := range tb.elements_left {
		w.Draw(rend)
	}
	if tb.element_center != nil {
		tb.element_center.Draw(rend)
	}
	for _, w := range tb.elements_right {
		w.Draw(rend)
	}
}
예제 #3
0
func (node *Node) Draw(rend *sdl.Renderer) {
	if node.dragging {
		node.curr.X += (node.goal.X - node.curr.X) * (15.0 / 30.0)
		node.curr.Y += (node.goal.Y - node.curr.Y) * (15.0 / 30.0)
		node.Pos.X = int32(node.curr.X)
		node.Pos.Y = int32(node.curr.Y)
		node.label.Pos = node.Pos
	}

	clr := node.color
	if !node.dragging {
		rend.SetDrawColor(clr)
		rend.FillRect(&node.Pos)
	}
	rend.SetDrawColor(lighten(clr, 19))
	rend.DrawRect(&node.Pos)
	node.label.Draw(rend)

	if node.menu.Visible {
		node.menu.Draw(rend)
	}
}