Esempio n. 1
0
func scalerValueCallback(r *gtk.Scale, v *ScaledView) {
	oldScale := v.scale
	oldX := v.scene.hadj.GetValue()
	oldY := v.scene.vadj.GetValue()
	visMx := float64(v.layoutBox.GetAllocatedWidth()) / 2.0
	visMy := float64(v.layoutBox.GetAllocatedHeight()) / 2.0
	v.scale = math.Exp2(r.GetValue())
	newW, newH := v.guest.Update()
	v.scene.hadj.SetUpper(float64(newW))
	v.scene.vadj.SetUpper(float64(newH))
	v.scene.hadj.SetValue((oldX+visMx)*v.scale/oldScale - visMx)
	v.scene.vadj.SetValue((oldY+visMy)*v.scale/oldScale - visMy)
}
Esempio n. 2
0
File: others.go Progetto: sqp/godock
// WrapKeyScale wraps a key scale with its information labels if needed (enough values).
//
// (was _pack_hscale).
func WrapKeyScale(key *cftype.Key, child *gtk.Scale) gtk.IWidget {
	child.Set("width-request", 150)
	if len(key.AuthorizedValues) >= 4 {

		child.Set("value-pos", gtk.POS_TOP)
		// log.DEV("MISSING SubScale options", string(key.Type), key.AuthorizedValues)
		box := newgtk.Box(gtk.ORIENTATION_HORIZONTAL, 0)
		// 	GtkWidget * pAlign = gtk_alignment_new(1., 1., 0., 0.)
		labelLeft := newgtk.Label(key.Translate(key.AuthorizedValues[2]))
		// 	pAlign = gtk_alignment_new(1., 1., 0., 0.)
		labelRight := newgtk.Label(key.Translate(key.AuthorizedValues[3]))

		box.PackStart(labelLeft, false, false, 0)
		box.PackStart(child, false, false, 0)
		box.PackStart(labelRight, false, false, 0)
		return box
	}
	child.Set("value-pos", gtk.POS_LEFT)
	return child
}