示例#1
0
文件: window.go 项目: romovs/viscum
func (win *Window) Draw() {
	log.Debugf("Drawing Window %v", win.Id)

	// window
	gfx.RectFilled(win.Element.Buffer, 0, 0, win.Element.Width, win.Element.Height, win.Element.Width, win.bg.R, win.bg.G, win.bg.B, win.bg.A)
	gfx.Rect(win.Element.Buffer, 0, 0, win.Element.Width-1, win.Element.Height-1, win.Element.Width, 0, 0, 0, gfx.A_OPAQUE)

	// title bar
	if !win.tbHidden {
		gfx.RectFilled(win.Element.Buffer, 1, 1, win.Element.Width-1, win.titleBarHeight, win.Element.Width, 29, 59, 99, gfx.A_OPAQUE)
	}
	// render children
	for v := win.Children.Front(); v != nil; v = v.Next() {
		v.Value.(base.IElement).Draw()
	}
}
示例#2
0
文件: window.go 项目: romovs/viscum
func (win *Window) Deactivate() {
	if !win.tbHidden {
		gfx.RectFilled(win.Element.Buffer, 1, 1, win.Element.Width-1, win.titleBarHeight, win.Element.Width, 29, 59, 99, gfx.A_OPAQUE)
		// redraw titlebar buttons
		win.closeButton.Draw()
	}
}
示例#3
0
文件: checkbox.go 项目: romovs/viscum
func (cb *CheckBox) Draw() {
	var img image.Image

	if cb.checked && cb.mouseIn {
		img = tk.cbCheckedHover
	} else if cb.checked && !cb.mouseIn {
		img = tk.cbChecked
	} else if !cb.checked && cb.mouseIn {
		img = tk.cbUncheckedHover
	} else if !cb.checked && !cb.mouseIn {
		img = tk.cbUnchecked
	}

	gfx.DrawOver(&cb.parent.Element, img, cb.Element.X, cb.Element.Y, cb.Element.Width, cb.Element.Height)

	if cb.txt != "" {
		w, h, _ := fonts.ExpectedSize(cb.Element.Font, cb.txt)
		voffsetTxt := cb.Element.Height/2 - int(h)/2 + 1

		// FIXME: temp solution. instead, parent element should expose region redraw method
		bg := cb.parent.GetBG()
		gfx.RectFilled(cb.parent.Element.Buffer,
			cb.Element.X+cb.Element.Width+ICON_TEXT_SPACE,
			cb.Element.Y+voffsetTxt,
			cb.Element.X+cb.Element.Width+ICON_TEXT_SPACE+int(w),
			cb.Element.Y+voffsetTxt+int(h),
			cb.parent.Element.Width,
			bg.R, bg.G, bg.B, bg.A)

		fonts.Render(&cb.parent.Element, cb.txt,
			cb.Element.X+cb.Element.Width+ICON_TEXT_SPACE, cb.Element.Y+voffsetTxt,
			cb.parent.Element.Width-cb.Element.X-ICON_TEXT_SPACE-cb.Element.Width, cb.Element.Height,
			cb.Element.Font)
	}
}
示例#4
0
文件: window.go 项目: romovs/viscum
func (win *Window) activate() {
	win.cmpWinActHndr(win.Id)

	if !win.tbHidden {
		gfx.RectFilled(win.Element.Buffer, 1, 1, win.Element.Width-1, win.titleBarHeight, win.Element.Width, 55, 109, 181, gfx.A_OPAQUE)
		// redraw titlebar buttons
		win.closeButton.Draw()
	}
}
示例#5
0
// mouse handler
func (but *TitleBarButton) Mouse(x int, y int, deltaX int, deltaY int, flags uint16) {

	if (flags & mouse.F_L_CLICK) != 0 {
		log.Debug("TitleBarButton ms handler: click")
		but.wasClicked = true
		gfx.RectFilled(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width, but.Element.Y+but.Element.Height, but.parent.Element.Width, 49, 80, 0, gfx.A_OPAQUE)
		gfx.Rect(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width-1, but.Element.Y+but.Element.Height-1, but.parent.Element.Width, 0, 0, 0, gfx.A_OPAQUE)
	} else if but.wasClicked && (flags&mouse.F_L_RELEASE) != 0 {
		log.Debug("TitleBarButton ms handler: release")
		but.wasClicked = false
		but.Draw()
		but.clickHndr(false)
	}
}
示例#6
0
文件: button.go 项目: romovs/viscum
func (but *Button) Draw() {
	var r, g, b byte

	if but.pushed {
		r, g, b = 49, 80, 0
	} else {
		r, g, b = 80, 130, 0
	}

	gfx.RectFilled(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width, but.Element.Y+but.Element.Height, but.parent.Element.Width, r, g, b, gfx.A_OPAQUE)
	gfx.Rect(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width-1, but.Element.Y+but.Element.Height-1, but.parent.Element.Width, 0, 0, 0, gfx.A_OPAQUE)

	if but.style&BS_TEXT != 0 {
		w, h, _ := fonts.ExpectedSize(but.Element.Font, but.txt)
		hoffsetTxt := but.Element.Width/2 - int(w)/2
		voffsetTxt := but.Element.Height/2 - int(h)/2 + 1
		fonts.Render(&but.parent.Element, but.txt,
			but.Element.X+hoffsetTxt, but.Element.Y+voffsetTxt,
			but.Element.Width, but.Element.Height, but.Element.Font)
	} else if but.style&BS_ICON_TEXT != 0 {
		iw := but.icon.Bounds().Dx()
		ih := but.icon.Bounds().Dy()
		w, h, _ := fonts.ExpectedSize(but.Element.Font, but.txt)
		hoffsetIcon := but.Element.Width/2 - int(int(w)+iw+ICON_TEXT_SPACE)/2
		voffsetTxt := but.Element.Height/2 - int(h)/2 + 1
		voffsetIcon := but.Element.Height/2 - int(ih)/2
		gfx.DrawOver(&but.parent.Element, but.icon, but.Element.X+hoffsetIcon, but.Element.Y+voffsetIcon, iw, ih)
		fonts.Render(&but.parent.Element, but.txt,
			but.Element.X+hoffsetIcon+iw+ICON_TEXT_SPACE, but.Element.Y+voffsetTxt,
			but.Element.Width, but.Element.Height, but.Element.Font)
	} else if but.style&BS_ICON != 0 {
		iw := but.icon.Bounds().Dx()
		ih := but.icon.Bounds().Dy()
		hoffsetIcon := but.Element.Width/2 - int(iw)/2
		voffsetIcon := but.Element.Height/2 - int(ih)/2
		gfx.DrawOver(&but.parent.Element, but.icon, but.Element.X+hoffsetIcon, but.Element.Y+voffsetIcon, iw, ih)
	}
}
示例#7
0
func (but *TitleBarButton) Draw() {
	log.Debug("    Drawing TitleBarButton")

	gfx.RectFilled(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width, but.Element.Y+but.Element.Height, but.parent.Element.Width, 80, 130, 0, gfx.A_OPAQUE)
	gfx.Rect(but.parent.Element.Buffer, but.Element.X, but.Element.Y, but.Element.X+but.Element.Width-1, but.Element.Y+but.Element.Height-1, but.parent.Element.Width, 0, 0, 0, gfx.A_OPAQUE)
}