Documentation
¶
Overview ¶
Package activity is the logic of the ActNow apps' activity cards: the stack at the foot of the sidebar that says what is going on (the family's window spec §2). It has no UI: the app hands it its unfinished jobs and the ones that end, and draws the cards it returns, in its own words and look.
The rules, the same in every app:
- Jobs of one kind make one card: a single job shows its own title and how far it is (Frac, or Waiting while queued); several show the kind's title and "done/total", counting the jobs of the kind that ended while others of it still ran.
- When the last job of a kind ends and some of them succeeded, the kind shows a finished card (Finished, Done items) for DoneFor (3 s), then goes.
- Kinds keep the order in which their first job was listed (the app lists running jobs first, then by age), finished cards after them.
- The app puts its own cards around these: one that needs the user (an engine that stopped) first, then what the user started (a recording, a project being made), then these, then downloads.
Stack (stack.go) is where each card sits, closed (the first in full, two peeking out under it) or open (a list of Show cards).
A Tracker is not safe for concurrent use: keep it with the window's state, on the UI thread. Its zero value is ready.
Index ¶
Constants ¶
const ( CardHeight = 44 // a card CardGap = 6 // between cards laid out (open) CardPeek = 5 // how much of each card behind the first shows (closed) Behind = 2 // how many cards peek out under the first (closed) Show = 4 // how many cards the open stack lists ("View all" the rest) // ShrinkStep is how much smaller each card behind is (closed). ShrinkStep = 0.06 )
Measures of the stack.
const DoneFor = 3 * time.Second
DoneFor is how long a finished card stays, unless a Tracker says.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Card ¶
type Card struct {
// Key is stable while the card shows: "job-" and its kind.
Key string
Kind string
// Title is the job's title (one job) or the kind's (several, or
// finished; the job's when the kind has no title of its own).
Title string
// Done of Total jobs of the kind are done (several: Total > 1; one job:
// Total is 1 and Done 0).
Done, Total int
// Frac is how far it is, 0–1; -1 going on without a known fraction; 2
// none (a finished card).
Frac float64
// Waiting: a single job, queued.
Waiting bool
// Finished: the kind's last job ended; Done jobs succeeded. The card
// goes after DoneFor.
Finished bool
// Jobs are the ids of the card's unfinished jobs (to cancel them).
Jobs []string
}
Card is one card of jobs.
type Job ¶
type Job struct {
ID, Kind, Title string
Running bool
// Fraction is how far a running job is, 0–1; below 0 not known.
Fraction float64
}
Job is an unfinished job as the cards see it.
type Pose ¶
Pose is where card i sits: Top its place in the open list; closed, Y moves it from there (up under the first) and Scale shrinks it, Fade hides it (beyond Behind). The first card's pose is the identity.
type Tracker ¶
type Tracker struct {
// DoneFor is how long a finished card stays; 0: DoneFor.
DoneFor time.Duration
// contains filtered or unexported fields
}
Tracker remembers, by kind, the jobs that ended while others of the kind ran (for "done/total") and when a kind's last job ended (its finished card).
func (*Tracker) Cards ¶
Cards are the cards of the jobs: one a kind of active (in the order of their first job), then the kinds that finished less than DoneFor before now. kindTitle names a kind's jobs when there are several ("" when it has no name of its own: the first job's title). It forgets the kinds whose finished card has gone.