Add datetime components 196-215; Kit.At; inert stepper arrows
Calendars, date and time inputs, pickers, clocks, timers, a sun dial, a season wheel, an agenda and a day schedule. Kit.At rebuilds at a moment (relative times, midnight). Stepper and NumberInput arrows stop under Inert. DateInput parks a popup focus as its own.
This commit is contained in:
38 files changed
+2651
-5
No files matched your search
@@ -169,3 +169,22 @@ func TestDisabledWhileFocusedTakesNoInput(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInertSteppersTakeNoPress(t *testing.T) {
|
||||
n, v := 5, 5.0
|
||||
tt := ui.NewTester(func(c *ui.Context) {
|
||||
pixel.Use(c, pixel.Settings{Palette: pixel.SpringDay, Inert: true})
|
||||
ui.Row(c).Children(func() {
|
||||
input.Stepper(c, "Lives", &n, input.StepperOptions{Max: 9})
|
||||
input.NumberInput(c, "Speed", &v, input.NumberInputOptions{Max: 10})
|
||||
})
|
||||
}, 600, 100)
|
||||
s, f := find(t, tt, "Lives"), find(t, tt, "Speed")
|
||||
// Arrows sit left of a stepper, right of a field.
|
||||
tt.Press(s.X-12, s.Y+8)
|
||||
tt.Release(s.X-12, s.Y+8)
|
||||
tt.ClickAt(f.X+f.W+10, f.Y+4)
|
||||
if n != 5 || v != 5 {
|
||||
t.Fatalf("inert arrows set %d and %v", n, v)
|
||||
}
|
||||
}
|
||||
@@ -86,8 +86,9 @@ func NumberInput(c *ui.Context, label string, value *float64, o NumberInputOptio
|
||||
|
||||
// arrowBox is a half-height step button the pointer presses.
|
||||
func arrowBox(c *ui.Context, k pixel.Kit, sp *pixel.Sprite, disabled bool) bool {
|
||||
disabled = disabled || pixel.Current(c).Inert
|
||||
b := ui.Box(c).Size(k.D(10), k.D(pixel.LineHeight/2)).Role(ui.RoleNone)
|
||||
down := b.Pressed()
|
||||
down := b.Pressed() && !disabled
|
||||
b.Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
dy := 0
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ type hold struct {
|
||||
// held counts an arrow's steps: one, then ten a second.
|
||||
func held(c *ui.Context, k pixel.Kit, sp *pixel.Sprite, disabled bool) int {
|
||||
b := ui.Box(c).Size(k.D(12), k.D(pixel.LineHeight+4)).Role(ui.RoleNone)
|
||||
down := b.Pressed() && !disabled
|
||||
down := b.Pressed() && !disabled && !pixel.Current(c).Inert
|
||||
h := ui.Local(b, holdKey{}, func() hold { return hold{} })
|
||||
b.Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
|
||||
Reference in new issue
Block a user