github.com/jmigpin/editor@v1.6.0/ui/columnseparator.go (about) 1 package ui 2 3 import ( 4 "image" 5 6 "github.com/jmigpin/editor/util/uiutil/event" 7 "github.com/jmigpin/editor/util/uiutil/widget" 8 ) 9 10 type ColSeparator struct { 11 *widget.Separator 12 col *Column 13 } 14 15 func NewColSeparator(col *Column) *ColSeparator { 16 sep := widget.NewSeparator(col.ui, col.Cols.Root.MultiLayer) 17 sep.Size.X = separatorWidth 18 sep.Handle.Left = 3 19 sep.Handle.Right = 3 20 sep.Handle.Cursor = event.WEResizeCursor 21 22 csep := &ColSeparator{Separator: sep, col: col} 23 csep.SetThemePaletteNamePrefix("colseparator_") 24 return csep 25 } 26 func (sh *ColSeparator) OnInputEvent(ev0 interface{}, p image.Point) event.Handled { 27 switch ev := ev0.(type) { 28 case *event.MouseDragMove: 29 switch { 30 case ev.Buttons.Is(event.ButtonLeft): 31 p.X += sh.Handle.DragPad.X 32 sh.col.resizeWithMoveToPoint(&p) 33 } 34 case *event.MouseDown: 35 switch ev.Button { 36 case event.ButtonWheelLeft: 37 sh.col.resizeWithMoveJump(true, &p) 38 case event.ButtonWheelRight: 39 sh.col.resizeWithMoveJump(false, &p) 40 } 41 } 42 return true // no other widget will get the event 43 }