mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
all: move Now from system.Config to system.FrameEvent
Then, make layout.Context.Now a field, copied from FrameEvent.Now. API change: gofmt -r 'gtx.Now() -> gtx.Now' Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-4
@@ -80,7 +80,7 @@ func (b *Clickable) Layout(gtx layout.Context) layout.Dimensions {
|
||||
stack.Pop()
|
||||
for len(b.history) > 0 {
|
||||
c := b.history[0]
|
||||
if c.End.IsZero() || gtx.Now().Sub(c.End) < 1*time.Second {
|
||||
if c.End.IsZero() || gtx.Now.Sub(c.End) < 1*time.Second {
|
||||
break
|
||||
}
|
||||
n := copy(b.history, b.history[1:])
|
||||
@@ -104,19 +104,19 @@ func (b *Clickable) update(gtx layout.Context) {
|
||||
NumClicks: e.NumClicks,
|
||||
})
|
||||
if l := len(b.history); l > 0 {
|
||||
b.history[l-1].End = gtx.Now()
|
||||
b.history[l-1].End = gtx.Now
|
||||
}
|
||||
case gesture.TypeCancel:
|
||||
for i := range b.history {
|
||||
b.history[i].Cancelled = true
|
||||
if b.history[i].End.IsZero() {
|
||||
b.history[i].End = gtx.Now()
|
||||
b.history[i].End = gtx.Now
|
||||
}
|
||||
}
|
||||
case gesture.TypePress:
|
||||
b.history = append(b.history, Press{
|
||||
Position: e.Position,
|
||||
Start: gtx.Now(),
|
||||
Start: gtx.Now,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -129,7 +129,7 @@ func (e *Editor) processPointer(gtx layout.Context) {
|
||||
axis = gesture.Vertical
|
||||
smin, smax = sbounds.Min.Y, sbounds.Max.Y
|
||||
}
|
||||
sdist := e.scroller.Scroll(gtx, gtx, gtx.Now(), axis)
|
||||
sdist := e.scroller.Scroll(gtx, gtx, gtx.Now, axis)
|
||||
var soff int
|
||||
if e.SingleLine {
|
||||
e.scrollRel(sdist, 0)
|
||||
@@ -142,7 +142,7 @@ func (e *Editor) processPointer(gtx layout.Context) {
|
||||
switch {
|
||||
case evt.Type == gesture.TypePress && evt.Source == pointer.Mouse,
|
||||
evt.Type == gesture.TypeClick && evt.Source == pointer.Touch:
|
||||
e.blinkStart = gtx.Now()
|
||||
e.blinkStart = gtx.Now
|
||||
e.moveCoord(gtx, image.Point{
|
||||
X: int(math.Round(float64(evt.Position.X))),
|
||||
Y: int(math.Round(float64(evt.Position.Y))),
|
||||
@@ -163,7 +163,7 @@ func (e *Editor) processKey(gtx layout.Context) {
|
||||
e.events = append(e.events, ChangeEvent{})
|
||||
}
|
||||
for _, ke := range gtx.Events(&e.eventKey) {
|
||||
e.blinkStart = gtx.Now()
|
||||
e.blinkStart = gtx.Now
|
||||
switch ke := ke.(type) {
|
||||
case key.FocusEvent:
|
||||
e.focused = ke.Focus
|
||||
@@ -309,7 +309,7 @@ func (e *Editor) layout(gtx layout.Context) layout.Dimensions {
|
||||
e.clicker.Add(gtx.Ops)
|
||||
e.caretOn = false
|
||||
if e.focused {
|
||||
now := gtx.Now()
|
||||
now := gtx.Now
|
||||
dt := now.Sub(e.blinkStart)
|
||||
blinking := dt < maxBlinkDuration
|
||||
const timePerBlink = time.Second / blinksPerSecond
|
||||
|
||||
@@ -198,7 +198,7 @@ func drawInk(gtx layout.Context, c widget.Press) {
|
||||
fadeDuration = float32(0.9)
|
||||
)
|
||||
|
||||
now := gtx.Now()
|
||||
now := gtx.Now
|
||||
|
||||
t := float32(now.Sub(c.Start).Seconds())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user