예제 #1
0
func (w *TextEditLine) Draw(region Region) {
	region.PushClipPlanes()
	defer region.PopClipPlanes()
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(0.3, 0.3, 0.3, 0.9)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(region.X+1, region.Y+1)
	gl.Vertex2i(region.X+1, region.Y-1+region.Dy)
	gl.Vertex2i(region.X-1+region.Dx, region.Y-1+region.Dy)
	gl.Vertex2i(region.X-1+region.Dx, region.Y+1)
	gl.End()
	w.TextLine.preDraw(region)
	w.TextLine.coreDraw(region)
	gl.Disable(gl.TEXTURE_2D)
	if w.cursor.on {
		gl.Color3d(1, 0.3, 0)
	} else {
		gl.Color3d(0.5, 0.3, 0)
	}
	gl.Begin(gl.LINES)
	gl.Vertex2i(region.X+int(w.cursor.pos), region.Y)
	gl.Vertex2i(region.X+int(w.cursor.pos), region.Y+region.Dy)
	gl.End()
	w.TextLine.postDraw(region)
}
예제 #2
0
func (cb *checkBox) Draw(region Region) {
	cb.Render_region = region
	if cb.disabled {
		gl.Color3d(0.6, 0.6, 0.6)
	} else {
		gl.Color3d(1, 1, 1)
	}
	gl.Begin(gl.QUADS)
	gl.Vertex2i(region.X, region.Y)
	gl.Vertex2i(region.X, region.Y+region.Dy)
	gl.Vertex2i(region.X+region.Dx, region.Y+region.Dy)
	gl.Vertex2i(region.X+region.Dx, region.Y)
	if cb.selected == checkBoxUnknown || cb.selected == checkBoxUnselected {
		if cb.selected == checkBoxUnknown {
			gl.Color3d(0.4, 0.4, 0.4)
		} else {
			gl.Color3d(0, 0, 0)
		}
		if region.Dx >= 4 && region.Dy >= 4 {
			gl.Vertex2i(region.X+2, region.Y+2)
			gl.Vertex2i(region.X+2, region.Y+region.Dy-2)
			gl.Vertex2i(region.X+region.Dx-2, region.Y+region.Dy-2)
			gl.Vertex2i(region.X+region.Dx-2, region.Y+2)
		}
	}
	gl.End()
}
예제 #3
0
func (w *TextLine) preDraw(region Region) {
	if !w.initted {
		w.initted = true
		w.texture = gl.GenTexture()
		w.text = w.next_text
		w.figureDims()
	}
	if w.text != w.next_text {
		w.text = w.next_text
		w.figureDims()
	}

	gl.PushMatrix()

	gl.Color3d(0, 0, 0)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(region.X, region.Y)
	gl.Vertex2i(region.X, region.Y+region.Dy)
	gl.Vertex2i(region.X+region.Dx, region.Y+region.Dy)
	gl.Vertex2i(region.X+region.Dx, region.Y)
	gl.End()

	gl.PushAttrib(gl.TEXTURE_BIT)
	gl.Enable(gl.TEXTURE_2D)
	w.texture.Bind(gl.TEXTURE_2D)

	gl.PushAttrib(gl.COLOR_BUFFER_BIT)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
}