Skip to content

Commit

Permalink
formatterMetrics as member in TickContext
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Sep 11, 2021
1 parent 01d3add commit 07e3252
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/tickcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class TickContext {
protected preFormatted: boolean = false;
protected postFormatted: boolean = false;
protected width: number;
protected formatterMetrics: FormatterMetrics;

static getNextContext(tContext: TickContext): TickContext | undefined {
const contexts = tContext.tContexts;
Expand Down Expand Up @@ -83,6 +84,27 @@ export class TickContext {
this.tContexts = []; // Parent array of tick contexts

this.width = 0;
this.formatterMetrics = {
// The freedom of a tickable is the distance it can move without colliding
// with neighboring elements. A formatter can set these values during its
// formatting pass, which a different formatter can then use to fine tune.
freedom: { left: 0, right: 0 },

// The simplified rational duration of this tick as a string. It can be
// used as an index to a map or hashtable.
duration: '',

// The number of formatting iterations undergone.
iterations: 0,

// The space in pixels allocated by this formatter, along with the mean space
// for tickables of this duration, and the deviation from the mean.
space: {
used: 0,
mean: 0,
deviation: 0,
},
};
}

getTickID(): number {
Expand Down Expand Up @@ -268,26 +290,6 @@ export class TickContext {
}

getFormatterMetrics(): FormatterMetrics {
return {
// The freedom of a tickable is the distance it can move without colliding
// with neighboring elements. A formatter can set these values during its
// formatting pass, which a different formatter can then use to fine tune.
freedom: { left: 0, right: 0 },

// The simplified rational duration of this tick as a string. It can be
// used as an index to a map or hashtable.
duration: '',

// The number of formatting iterations undergone.
iterations: 0,

// The space in pixels allocated by this formatter, along with the mean space
// for tickables of this duration, and the deviation from the mean.
space: {
used: 0,
mean: 0,
deviation: 0,
},
};
return this.formatterMetrics;
}
}

0 comments on commit 07e3252

Please sign in to comment.