...

Source file src/code.rocketnine.space/tslocum/etk/box.go

Documentation: code.rocketnine.space/tslocum/etk

     1  package etk
     2  
     3  import (
     4  	"image"
     5  	"sync"
     6  )
     7  
     8  type Box struct {
     9  	rect image.Rectangle
    10  
    11  	children []Widget
    12  
    13  	sync.Mutex
    14  }
    15  
    16  func NewBox() *Box {
    17  	return &Box{}
    18  }
    19  
    20  func (b *Box) Rect() image.Rectangle {
    21  	b.Lock()
    22  	defer b.Unlock()
    23  
    24  	return b.rect
    25  }
    26  
    27  func (b *Box) SetRect(r image.Rectangle) {
    28  	b.Lock()
    29  	defer b.Unlock()
    30  
    31  	b.rect = r
    32  }
    33  
    34  func (b *Box) Children() []Widget {
    35  	b.Lock()
    36  	defer b.Unlock()
    37  
    38  	return b.children
    39  }
    40  
    41  func (b *Box) AddChild(w ...Widget) {
    42  	b.Lock()
    43  	defer b.Unlock()
    44  
    45  	b.children = append(b.children, w...)
    46  }
    47  

View as plain text