Karya, built on 2018-02-23T20:23:55 (patch cf8565b7ac832266878af99a942555d139065f12)

Safe HaskellNone





data Ruler Source #

A Ruler contains all the data to display a ruler.





type Marklists = Map Name (Maybe MeterConfig, Marklist) Source #

Each ruler can have multiple named marklists. This means a ruler can have multiple simultaneous meters, or a separate list of ad-hoc cue points. All marks are flattened before display, and are drawn in the sort order of their Names.

type Name = Text Source #

data MeterConfig Source #

Configuration specific to the meter marklist.




  • config_name :: !Text

    The type of meter that this marklist represents. This is looked up in a table of meter types to figure out how to do transformations on the meter, since different meters follow different rules.

  • config_start_measure :: !Int

ruler :: [(Name, (Maybe MeterConfig, Marklist))] -> Ruler Source #

Constructor for "plain" rulers.

meter_ruler :: MeterConfig -> Marklist -> Ruler Source #

Create a ruler with just a meter marklist.

meter :: Name Source #

The meter marklist by convention has marks corresponding to the meter of the piece. Other commands may use this to find out where beats are.

no_ruler :: Ruler Source #

Empty ruler.

modify_marklist :: Name -> (Marklist -> Marklist) -> Ruler -> Ruler Source #

If the marklist isn't set, modify will be given an empty one.

time_end :: Ruler -> ScoreTime Source #

Get the position of the last mark of the ruler.


bounds :: Name Source #

Marks on this marklist given the logical block bounds. If there is one mark, it denotes the logical block end. Two morks mean the first one is the logical block start. The mark text doesn't matter, but s and e are customary.

bounds_of :: Ruler -> (ScoreTime, Maybe ScoreTime) Source #

Get block bounds as defined by the ruler. This uses explicit bounds if there are any, otherwise it uses the meter. Otherwise, the start time can default to 0, but the end time defaults to Nothing so the caller can use the end of the last event.


marklist_fptr :: Marklist -> MarklistPtr Source #

This is a cache for the C-marshalled version of the marklist. It will be allocated if the Marklist is passed to C, and is managed with its own reference count.

I think this should be safe as long as marklist is the only constructor.

ascending :: ScoreTime -> Marklist -> [PosMark] Source #

Marks starting at the first mark >= the given pos, to the end.

descending :: ScoreTime -> Marklist -> [PosMark] Source #

Marks starting at the first mark below the given pos, to the beginning.

marklist_end :: Marklist -> ScoreTime Source #

Get the position of the last mark.



data Mark Source #




  • mark_rank :: !Rank

    An arbitrary low integer. This is the only part of the mark that matters to the code, the rest is purely visual. By convention, the most prominent divisions start at rank 0 and go up from there.

  • mark_width :: !Int

    Width in pixels.

  • mark_color :: !Color.Color
  • mark_name :: !Text

    A bit of text displayed with the mark. This can use backtick symbols.

  • mark_name_zoom_level :: !Double

    The text is only displayed when the zoom factor exceeds this value.

  • mark_zoom_level :: !Double

    The mark itself is only displayed when the zoom factor exeeds this value.

type Rank = Int Source #

for RulerC's eyes only

newtype MarklistPtr Source #

This should be opaque, but it needs to be exported for RulerC. Don't look inside if you're not RulerC, OK?

The Left value is actually not used, but prevents the unsafePerformIO from being floated out of the lambda.

I used to just copy the ruler each time, but it was actually pretty big. Rulers can have lots of marks, there are many rulers per block since each track has one. But many tracks share the same ruler, and they change rarely. All of these differences from Events push for passing by pointer rather than copying over the whole thing each time (as with the signal), or passing a callback that fetches the required range (as with events).

TODO I could share the memory by making MarklistVector into Vector.Storable PosMark. It's otherwise equivalant though, and the number of distinct rulers is probably small, so the memory savings doesn't seem that compelling.