示例#1
0
文件: panel_tab.go 项目: liulnn/gxui
func (t *PanelTab) Paint(c gxui.Canvas) {
	s := t.Size()
	var style Style
	switch {
	case t.IsMouseDown(gxui.MouseButtonLeft) && t.IsMouseOver():
		style = t.theme.TabPressedStyle
	case t.IsMouseOver():
		style = t.theme.TabOverStyle
	default:
		style = t.theme.TabDefaultStyle
	}
	if l := t.Label(); l != nil {
		l.SetColor(style.FontColor)
	}

	c.DrawRoundedRect(s.Rect(), 5.0, 5.0, 0.0, 0.0, style.Pen, style.Brush)

	if t.HasFocus() {
		style = t.theme.FocusedStyle
		r := math.CreateRect(1, 1, s.W-1, s.H-1)
		c.DrawRoundedRect(r, 4.0, 4.0, 0.0, 0.0, style.Pen, style.Brush)
	}

	if t.active {
		style = t.theme.TabActiveHighlightStyle
		r := math.CreateRect(1, s.H-1, s.W-1, s.H)
		c.DrawRect(r, style.Brush)
	}

	t.Button.Paint(c)
}
示例#2
0
文件: list.go 项目: linux-mac/gxui
// mixin.List overrides
func (l *List) Paint(c gxui.Canvas) {
	l.List.Paint(c)
	if l.HasFocus() {
		r := l.Size().Rect().ContractI(1)
		c.DrawRoundedRect(r, 3.0, 3.0, 3.0, 3.0, l.theme.FocusedStyle.Pen, l.theme.FocusedStyle.Brush)
	}
}
示例#3
0
func (p *PanelHolder) Paint(c gxui.Canvas) {
	panel := p.SelectedPanel()
	if panel != nil {
		bounds := p.Children().Find(panel).Bounds()
		c.DrawRoundedRect(bounds, 0.0, 0.0, 3.0, 3.0, p.theme.PanelBackgroundStyle.Pen, p.theme.PanelBackgroundStyle.Brush)
	}
	p.PanelHolder.Paint(c)
}
示例#4
0
// mixins.CodeEditor overrides
func (t *CodeEditor) Paint(c gxui.Canvas) {
	t.CodeEditor.Paint(c)

	if t.HasFocus() {
		r := t.Size().Rect()
		c.DrawRoundedRect(r, 3, 3, 3, 3, t.theme.FocusedStyle.Pen, t.theme.FocusedStyle.Brush)
	}
}
示例#5
0
文件: textbox.go 项目: linux-mac/gxui
// mixins.TextBox overrides
func (t *TextBox) Paint(c gxui.Canvas) {
	t.TextBox.Paint(c)

	if t.HasFocus() {
		r := t.Size().Rect()
		s := t.theme.FocusedStyle
		c.DrawRoundedRect(r, 3, 3, 3, 3, s.Pen, s.Brush)
	}
}
func draw(p Pendulum, canvas gxui.Canvas, x, y int) {
	attachment := math.Point{X: ANIMATION_WIDTH/2 + x, Y: y}

	phi := p.GetPhi()
	ball := math.Point{X: x + ANIMATION_WIDTH/2 + math.Round(float32(l*omath.Sin(phi))), Y: y + math.Round(float32(l*omath.Cos(phi)))}

	line := gxui.Polygon{gxui.PolygonVertex{attachment, 0}, gxui.PolygonVertex{ball, 0}}

	canvas.DrawLines(line, gxui.DefaultPen)

	m := math.Point{int(BALL_RADIUS), int(BALL_RADIUS)}
	rect := math.Rect{ball.Sub(m), ball.Add(m)}
	canvas.DrawRoundedRect(rect, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, BALL_RADIUS, gxui.TransparentPen, gxui.CreateBrush(gxui.Yellow))
}
示例#7
0
func (t *CodeEditorLine) PaintBorders(c gxui.Canvas, info CodeEditorLinePaintInfo) {
	start, _ := info.LineSpan.Span()
	offsets := info.GlyphOffsets
	for _, l := range t.ce.layers {
		if l != nil && l.BorderColor() != nil {
			color := *l.BorderColor()
			interval.Visit(l.Spans(), info.LineSpan, func(vs, ve uint64, _ int) {
				s, e := vs-start, ve-start
				r := math.CreateRect(offsets[s].X, 0, offsets[e-1].X+info.GlyphWidth, info.LineHeight)
				c.DrawRoundedRect(r, 3, 3, 3, 3, gxui.CreatePen(0.5, color), gxui.TransparentBrush)
			})
		}
	}
}
示例#8
0
func (t *CodeEditorLine) PaintBackgroundSpans(c gxui.Canvas, info CodeEditorLinePaintInfo) {
	start, _ := info.LineSpan.Span()
	offsets := info.GlyphOffsets
	remaining := interval.IntDataList{info.LineSpan}
	for _, l := range t.ce.layers {
		if l != nil && l.BackgroundColor() != nil {
			color := *l.BackgroundColor()
			for _, span := range l.Spans().Overlaps(info.LineSpan) {
				interval.Visit(&remaining, span, func(vs, ve uint64, _ int) {
					s, e := vs-start, ve-start
					r := math.CreateRect(offsets[s].X, 0, offsets[e-1].X+info.GlyphWidth, info.LineHeight)
					c.DrawRoundedRect(r, 3, 3, 3, 3, gxui.TransparentPen, gxui.Brush{Color: color})
				})
				interval.Remove(&remaining, span)
			}
		}
	}
}
示例#9
0
文件: button.go 项目: langxj/gxui
// Button internal overrides
func (b *Button) Paint(c gxui.Canvas) {
	pen := b.Button.BorderPen()
	brush := b.Button.BackgroundBrush()
	fontColor := b.theme.ButtonDefaultStyle.FontColor

	switch {
	case b.IsMouseDown(gxui.MouseButtonLeft) && b.IsMouseOver():
		pen = b.theme.ButtonPressedStyle.Pen
		brush = b.theme.ButtonPressedStyle.Brush
		fontColor = b.theme.ButtonPressedStyle.FontColor
	case b.IsMouseOver():
		pen = b.theme.ButtonOverStyle.Pen
		brush = b.theme.ButtonOverStyle.Brush
		fontColor = b.theme.ButtonOverStyle.FontColor
	}

	if l := b.Label(); l != nil {
		l.SetColor(fontColor)
	}

	r := b.Size().Rect()

	c.DrawRoundedRect(r, 2, 2, 2, 2, gxui.TransparentPen, brush)

	b.PaintChildren.Paint(c)

	c.DrawRoundedRect(r, 2, 2, 2, 2, pen, gxui.TransparentBrush)

	if b.IsChecked() {
		pen = b.theme.HighlightStyle.Pen
		brush = b.theme.HighlightStyle.Brush
		c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, pen, brush)
	}

	if b.HasFocus() {
		pen = b.theme.FocusedStyle.Pen
		brush = b.theme.FocusedStyle.Brush
		c.DrawRoundedRect(r.ContractI(int(pen.Width)), 3.0, 3.0, 3.0, 3.0, pen, brush)
	}
}
示例#10
0
文件: tree.go 项目: linux-mac/gxui
// mixins.List overrides
func (l *Tree) PaintSelection(c gxui.Canvas, r math.Rect) {
	s := l.theme.HighlightStyle
	c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, s.Pen, s.Brush)
}
示例#11
0
文件: list.go 项目: langxj/gxui
func (l *List) PaintMouseOverBackground(c gxui.Canvas, r math.Rect) {
	c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, gxui.TransparentPen, gxui.CreateBrush(gxui.Gray90))
}
示例#12
0
文件: list.go 项目: langxj/gxui
func (l *List) PaintSelection(c gxui.Canvas, r math.Rect) {
	c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, gxui.WhitePen, gxui.TransparentBrush)
}
示例#13
0
文件: list.go 项目: linux-mac/gxui
func (l *List) PaintSelection(c gxui.Canvas, r math.Rect) {
	c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, l.theme.HighlightStyle.Pen, l.theme.HighlightStyle.Brush)
}
示例#14
0
func (t *DefaultTextBoxLine) PaintSelection(c gxui.Canvas, top, bottom math.Point) {
	r := math.Rect{Min: top, Max: bottom}.ExpandI(t.caretWidth / 2)
	c.DrawRoundedRect(r, 1, 1, 1, 1, gxui.TransparentPen, gxui.Brush{Color: gxui.Gray40})
}
示例#15
0
文件: tree.go 项目: henrylee2cn/gxui
func (t *Tree) PaintUnexpandedSelection(c gxui.Canvas, r math.Rect) {
	c.DrawRoundedRect(r, 2.0, 2.0, 2.0, 2.0, gxui.CreatePen(1, gxui.Gray50), gxui.TransparentBrush)
}
示例#16
0
func (t *DefaultTextBoxLine) PaintCaret(c gxui.Canvas, top, bottom math.Point) {
	r := math.Rect{Min: top, Max: bottom}.ExpandI(t.caretWidth / 2)
	c.DrawRoundedRect(r, 1, 1, 1, 1, gxui.CreatePen(0.5, gxui.Gray70), gxui.WhiteBrush)
}
示例#17
0
文件: scroll_bar.go 项目: langxj/gxui
func (s *ScrollBar) Paint(c gxui.Canvas) {
	c.DrawRoundedRect(s.outer.Size().Rect(), 3, 3, 3, 3, s.railPen, s.railBrush)
	c.DrawRoundedRect(s.barRect, 3, 3, 3, 3, s.barPen, s.barBrush)
}
示例#18
0
func (b *BackgroundBorderPainter) PaintBorder(c gxui.Canvas, r math.Rect) {
	if b.pen.Color.A != 0 && b.pen.Width != 0 {
		w := b.pen.Width
		c.DrawRoundedRect(r, w, w, w, w, b.pen, gxui.TransparentBrush)
	}
}