github.com/jmigpin/editor@v1.6.0/ui/columnsquare.go (about) 1 package ui 2 3 import ( 4 "image" 5 6 "github.com/jmigpin/editor/util/imageutil" 7 "github.com/jmigpin/editor/util/uiutil/event" 8 "github.com/jmigpin/editor/util/uiutil/widget" 9 ) 10 11 type ColumnSquare struct { 12 widget.ENode 13 Size image.Point 14 col *Column 15 } 16 17 func NewColumnSquare(col *Column) *ColumnSquare { 18 sq := &ColumnSquare{col: col, Size: image.Point{5, 5}} 19 sq.Cursor = event.CloseCursor 20 return sq 21 } 22 23 func (sq *ColumnSquare) Measure(hint image.Point) image.Point { 24 return imageutil.MinPoint(sq.Size, hint) 25 } 26 func (sq *ColumnSquare) Paint() { 27 c := sq.TreeThemePaletteColor("columnsquare") 28 imageutil.FillRectangle(sq.col.ui.Image(), sq.Bounds, c) 29 } 30 func (sq *ColumnSquare) OnInputEvent(ev interface{}, p image.Point) event.Handled { 31 switch t := ev.(type) { 32 case *event.MouseClick: 33 switch t.Button { 34 case event.ButtonLeft, event.ButtonMiddle, event.ButtonRight: 35 sq.col.Close() 36 } 37 } 38 return true 39 }