aboutsummaryrefslogtreecommitdiffstats
path: root/ui/borders.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-02-26 22:54:39 -0500
committerDrew DeVault <sir@cmpwn.com>2018-02-26 22:54:39 -0500
commit1418e1b9dc41d8f69bccb8de0fe0f1fb6835ce11 (patch)
tree4ae8b3373fdadb6dd3e7b8c8789cf938522b8f8a /ui/borders.go
parent661e3ec2a4dd97d4a8a8eab4f281b088770a6af2 (diff)
downloadaerc-1418e1b9dc41d8f69bccb8de0fe0f1fb6835ce11.tar.gz
Split UI library and widgets
Diffstat (limited to 'ui/borders.go')
-rw-r--r--ui/borders.go73
1 files changed, 0 insertions, 73 deletions
diff --git a/ui/borders.go b/ui/borders.go
deleted file mode 100644
index 08071ad0..00000000
--- a/ui/borders.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package ui
-
-import (
- tb "github.com/nsf/termbox-go"
-)
-
-const (
- BORDER_LEFT = 1 << iota
- BORDER_TOP = 1 << iota
- BORDER_RIGHT = 1 << iota
- BORDER_BOTTOM = 1 << iota
-)
-
-type Bordered struct {
- borders uint
- content Drawable
- onInvalidate func(d Drawable)
-}
-
-func NewBordered(content Drawable, borders uint) *Bordered {
- b := &Bordered{
- borders: borders,
- content: content,
- }
- content.OnInvalidate(b.contentInvalidated)
- return b
-}
-
-func (bordered *Bordered) contentInvalidated(d Drawable) {
- bordered.Invalidate()
-}
-
-func (bordered *Bordered) Invalidate() {
- if bordered.onInvalidate != nil {
- bordered.onInvalidate(bordered)
- }
-}
-
-func (bordered *Bordered) OnInvalidate(onInvalidate func(d Drawable)) {
- bordered.onInvalidate = onInvalidate
-}
-
-func (bordered *Bordered) Draw(ctx *Context) {
- x := 0
- y := 0
- width := ctx.Width()
- height := ctx.Height()
- cell := tb.Cell{
- Ch: ' ',
- Fg: tb.ColorBlack,
- Bg: tb.ColorWhite,
- }
- if bordered.borders&BORDER_LEFT != 0 {
- ctx.Fill(0, 0, 1, ctx.Height(), cell)
- x += 1
- width -= 1
- }
- if bordered.borders&BORDER_TOP != 0 {
- ctx.Fill(0, 0, ctx.Width(), 1, cell)
- y += 1
- height -= 1
- }
- if bordered.borders&BORDER_RIGHT != 0 {
- ctx.Fill(ctx.Width()-1, 0, 1, ctx.Height(), cell)
- width -= 1
- }
- if bordered.borders&BORDER_BOTTOM != 0 {
- ctx.Fill(0, ctx.Height()-1, ctx.Width(), 1, cell)
- height -= 1
- }
- subctx := ctx.Subcontext(x, y, width, height)
- bordered.content.Draw(subctx)
-}