Permalink
Browse files

Rename OpenGlStream to OpenGLStream.

This is more idiomatic Go naming.
  • Loading branch information...
dmitshur committed Jan 6, 2018
1 parent 62348e5 commit a57c772cbb6a0b26144c2a199e6fef95b6d5fbbe
Showing with 35 additions and 35 deletions.
  1. +11 −11 font.go
  2. +1 −1 highlight.go
  3. +10 −10 main.go
  4. +11 −11 page/page2/font.go
  5. +2 −2 page/page2/main.go
View
22 font.go
@@ -34,7 +34,7 @@ func (fo FontOptions) IsBold() bool { return fo == Bold || fo == BoldItalic }
// IsItalic returns true if the font has the italic property set.
func (fo FontOptions) IsItalic() bool { return fo == Italic || fo == BoldItalic }
type OpenGlStream struct {
type OpenGLStream struct {
pos mgl64.Vec2
lineStartX float64
advance uint32
@@ -45,23 +45,23 @@ type OpenGlStream struct {
ShowInvisibles bool
}
func NewOpenGlStream(pos mgl64.Vec2) *OpenGlStream {
return &OpenGlStream{pos: pos, lineStartX: pos[0]}
func NewOpenGLStream(pos mgl64.Vec2) *OpenGLStream {
return &OpenGLStream{pos: pos, lineStartX: pos[0]}
}
func (o *OpenGlStream) SetPos(pos mgl64.Vec2) {
func (o *OpenGLStream) SetPos(pos mgl64.Vec2) {
o.pos = pos
o.lineStartX = pos[0]
o.advance = 0
}
func (o *OpenGlStream) SetPosWithExpandedPosition(pos mgl64.Vec2, x, y uint32) {
func (o *OpenGLStream) SetPosWithExpandedPosition(pos mgl64.Vec2, x, y uint32) {
o.pos = pos.Add(mgl64.Vec2{float64(x * fontWidth), float64(y * fontHeight)})
o.lineStartX = pos[0]
o.advance = x
}
func (o *OpenGlStream) PrintText(s string) {
func (o *OpenGLStream) PrintText(s string) {
for {
end := strings.Index(s, "\n")
@@ -84,7 +84,7 @@ func (o *OpenGlStream) PrintText(s string) {
}
// Input shouldn't have newlines
func (o *OpenGlStream) PrintLine(s string) {
func (o *OpenGLStream) PrintLine(s string) {
if o.BorderColor != nil {
gl.PushAttrib(gl.CURRENT_BIT)
@@ -117,20 +117,20 @@ func (o *OpenGlStream) PrintLine(s string) {
}
}
func (o *OpenGlStream) advanceBy(amount uint32) {
func (o *OpenGLStream) advanceBy(amount uint32) {
o.advance += amount
o.afterAdvance()
}
func (o *OpenGlStream) advanceReset() {
func (o *OpenGLStream) advanceReset() {
o.advance = 0
o.afterAdvance()
}
func (o *OpenGlStream) afterAdvance() {
func (o *OpenGLStream) afterAdvance() {
o.pos[0] = o.lineStartX + float64(fontWidth*o.advance)
}
// Shouldn't have tabs nor newlines
func (o *OpenGlStream) PrintSegment(s string) {
func (o *OpenGLStream) PrintSegment(s string) {
if s == "" {
return
}
View
@@ -24,7 +24,7 @@ type TextStyle struct {
ShowInvisibles *bool
}
func (textStyle *TextStyle) Apply(glt *OpenGlStream) {
func (textStyle *TextStyle) Apply(glt *OpenGLStream) {
if textStyle == nil {
return
}
View
20 main.go
@@ -1181,7 +1181,7 @@ func (w *ButtonLabelWidget) Render() {
w.ButtonWidget.Render()
gl.Color3d(0, 0, 0)
NewOpenGlStream(w.Pos().Add(mgl64.Vec2{4, 0})).PrintLine(w.label)
NewOpenGLStream(w.Pos().Add(mgl64.Vec2{4, 0})).PrintLine(w.label)
}
// ---
@@ -1459,7 +1459,7 @@ func (w *WindowWidget) Render() {
// Title
gl.Color3dv(&nearlyBlackColor[0])
NewOpenGlStream(w.pos.Add(mgl64.Vec2{60})).PrintLine(w.Name)
NewOpenGLStream(w.pos.Add(mgl64.Vec2{60})).PrintLine(w.Name)
gl.PushMatrix()
gl.Translated(w.pos[0], w.pos[1], 0)
@@ -2734,7 +2734,7 @@ func (w *UnderscoreSepToCamelCaseWidget) Render() {
gl.Rectd(0, 0, w.size[0], w.size[1])
gl.Color3d(0, 0, 0)
NewOpenGlStream(mgl64.Vec2{0, 0}).PrintText(s)
NewOpenGLStream(mgl64.Vec2{0, 0}).PrintText(s)
}
// ---
@@ -2869,7 +2869,7 @@ func (w *FooWidget) Render() {
DrawNBox(w.pos, w.size)
}
glt := NewOpenGlStream(w.pos)
glt := NewOpenGLStream(w.pos)
gl.Color3d(0, 0, 0)
glt.PrintText(w.text)
@@ -3701,7 +3701,7 @@ func (this *FilterableSliceStringer) Print(filteredIndex uint64, pos mgl64.Vec2,
index := strings.Index(strings.ToLower(entry), strings.ToLower(filter.Content()))
glt := NewOpenGlStream(pos)
glt := NewOpenGLStream(pos)
if !selected {
gl.Color3dv(&veryDarkColor[0])
glt.PrintText(entry[:index])
@@ -4864,7 +4864,7 @@ func (w *TextLabelWidget) Render() {
//DrawBorderlessBox(w.pos, w.size, lightColor)
gl.Color3d(0, 0, 0)
NewOpenGlStream(w.pos).PrintText(w.Content.Content())
NewOpenGLStream(w.pos).PrintText(w.Content.Content())
isHit := len(w.HoverPointers()) > 0
// Tooltip
@@ -4935,7 +4935,7 @@ func (w *StringerWidget) Render() {
gl.Color3d(0, 0, 0)
// TODO: Multiline support?
NewOpenGlStream(w.pos).PrintText(w.content.String())
NewOpenGLStream(w.pos).PrintText(w.content.String())
}
// ---
@@ -5545,7 +5545,7 @@ func (w *TextBoxWidget) Render() {
hlIters = append(hlIters, NewSelectionHighlighterIterator(w.Content.Line(beginLineIndex).Start(), min, max, hasTypingFocus))
}
glt := NewOpenGlStream(w.pos.Add(mgl64.Vec2{0, float64(fontHeight * beginLineIndex)}))
glt := NewOpenGLStream(w.pos.Add(mgl64.Vec2{0, float64(fontHeight * beginLineIndex)}))
for _, hlIter := range hlIters {
textStyle := hlIter.Current()
@@ -5568,15 +5568,15 @@ func (w *TextBoxWidget) Render() {
} else {
for lineIndex := 0; lineIndex < w.Content.LenLines(); lineIndex++ {
contentLine := w.Content.Line(lineIndex)
NewOpenGlStream(mgl64.Vec2{w.pos[0], w.pos[1] + float64(fontHeight*lineIndex)}).PrintLine(strings.Repeat("*", int(contentLine.Length())))
NewOpenGLStream(mgl64.Vec2{w.pos[0], w.pos[1] + float64(fontHeight*lineIndex)}).PrintLine(strings.Repeat("*", int(contentLine.Length())))
}
}
}
// Display Go Errors via line highlighting.
for _, uri := range w.Content.GetAllUris() {
if _, ok := goCompileErrorsManagerTest.All[uri]; ok {
glt := NewOpenGlStream(np)
glt := NewOpenGLStream(np)
for lineIndex, messages := range goCompileErrorsManagerTest.All[uri] {
if lineIndex < beginLineIndex || lineIndex >= endLineIndex {
continue // Skip lines that are offscreen.
View
@@ -37,7 +37,7 @@ func (fo FontOptions) IsBold() bool { return fo == Bold || fo == BoldItalic }
// IsItalic returns true if the font has the italic property set.
func (fo FontOptions) IsItalic() bool { return fo == Italic || fo == BoldItalic }
type OpenGlStream struct {
type OpenGLStream struct {
pos mgl64.Vec2
lineStartX float64
advance uint32
@@ -48,23 +48,23 @@ type OpenGlStream struct {
ShowInvisibles bool
}
func NewOpenGlStream(pos mgl64.Vec2) *OpenGlStream {
return &OpenGlStream{pos: pos, lineStartX: pos[0]}
func NewOpenGLStream(pos mgl64.Vec2) *OpenGLStream {
return &OpenGLStream{pos: pos, lineStartX: pos[0]}
}
func (o *OpenGlStream) SetPos(pos mgl64.Vec2) {
func (o *OpenGLStream) SetPos(pos mgl64.Vec2) {
o.pos = pos
o.lineStartX = pos[0]
o.advance = 0
}
func (o *OpenGlStream) SetPosWithExpandedPosition(pos mgl64.Vec2, x, y uint32) {
func (o *OpenGLStream) SetPosWithExpandedPosition(pos mgl64.Vec2, x, y uint32) {
o.pos = pos.Add(mgl64.Vec2{float64(x) * fontWidth, float64(y) * fontHeight})
o.lineStartX = pos[0]
o.advance = x
}
func (o *OpenGlStream) PrintText(s string) {
func (o *OpenGLStream) PrintText(s string) {
for {
end := strings.Index(s, "\n")
@@ -87,7 +87,7 @@ func (o *OpenGlStream) PrintText(s string) {
}
// Input shouldn't have newlines
func (o *OpenGlStream) PrintLine(s string) {
func (o *OpenGLStream) PrintLine(s string) {
if o.BorderColor != nil {
gl.PushAttrib(gl.CURRENT_BIT)
@@ -120,20 +120,20 @@ func (o *OpenGlStream) PrintLine(s string) {
}
}
func (o *OpenGlStream) advanceBy(amount uint32) {
func (o *OpenGLStream) advanceBy(amount uint32) {
o.advance += amount
o.afterAdvance()
}
func (o *OpenGlStream) advanceReset() {
func (o *OpenGLStream) advanceReset() {
o.advance = 0
o.afterAdvance()
}
func (o *OpenGlStream) afterAdvance() {
func (o *OpenGLStream) afterAdvance() {
o.pos[0] = o.lineStartX + fontWidth*float64(o.advance)
}
// Shouldn't have tabs nor newlines
func (o *OpenGlStream) PrintSegment(s string) {
func (o *OpenGLStream) PrintSegment(s string) {
if s == "" {
return
}
View
@@ -293,7 +293,7 @@ func main() {
drawBox()
gl.Color3d(1, 0, 0)
NewOpenGlStream(mgl64.Vec2{50, 300}).PrintText(` !"#$%&'()*+,-./
NewOpenGLStream(mgl64.Vec2{50, 300}).PrintText(` !"#$%&'()*+,-./
0123456789:;<=>?
@ABCDEFGHIJKLMNO
PQRSTUVWXYZ[\]^_
@@ -437,7 +437,7 @@ func (w *ButtonWidget) Render() {
gl.Color3d(0, 0, 0)
}
NewOpenGlStream(w.pos.Add(mgl64.Vec2{8, 3}).Add(softwareUpdateTextOffset)).PrintText("Software Update...")
NewOpenGLStream(w.pos.Add(mgl64.Vec2{8, 3}).Add(softwareUpdateTextOffset)).PrintText("Software Update...")
}
func (w *ButtonWidget) Hit(ParentPosition mgl64.Vec2) []event.Widgeter {
if len(w.Widget.Hit(ParentPosition)) > 0 {

0 comments on commit a57c772

Please sign in to comment.