Beispiel #1
0
func (self VerticalLayout) Layout(bounds geom.Rect, widgets ...Widget) {
	n := len(widgets)

	bounds.H -= float64(n-1) * self.Spacing
	bounds.H /= float64(n)

	for _, w := range widgets {
		w.SetBounds(bounds)
		bounds.Y += bounds.H + self.Spacing
	}
}
Beispiel #2
0
func (self *View) changeMouseSelection(w driver.Window, p geom.Point, b mouse.ButtonSet) {
	if (self.state & viewMouseSelection) == 0 {
		self.state |= viewMouseSelection
		self.mouseSelectionOrigin = p
		self.mouseSelectionButtons = b

		if cur, err := w.Display().NewCursor(driver.CursorIBeam); err != nil {
			fmt.Fprintf(os.Stderr, "WARN: seting default cursor to I-Beam failed: %s\n", err)
		} else {
			self.changeDefaultCursor(cur)
		}
	}

	p0 := self.mouseSelectionOrigin
	p1 := p

	r := geom.Rect{X: p0.X, Y: p0.Y, W: p1.X - p0.X, H: p1.Y - p0.Y}

	if r.W >= 0.0 && r.W < 1.0 {
		r.W = 1.0
	} else if r.W < 0.0 && r.W > -1.0 {
		r.W = -1.0
	}

	if r.H >= 0.0 && r.H < 1.0 {
		r.H = 1.0
	} else if r.H < 0.0 && r.H > -1.0 {
		r.H = -1.0
	}

	if self.content != nil {
		mouseSelection(w, self.content, event.MouseSelection{
			Pressed: b,
			Bounds:  r,
		})
	}
}