Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone

Ui.Ruler

Contents

Synopsis

Ruler

data Ruler Source #

A Ruler contains all the data to display a ruler.

Constructors

Ruler 

Fields

Instances
Eq Ruler # 
Instance details

Defined in Ui.Ruler

Methods

(==) :: Ruler -> Ruler -> Bool #

(/=) :: Ruler -> Ruler -> Bool #

Show Ruler # 
Instance details

Defined in Ui.Ruler

Methods

showsPrec :: Int -> Ruler -> ShowS #

show :: Ruler -> String #

showList :: [Ruler] -> ShowS #

DeepSeq.NFData Ruler # 
Instance details

Defined in Ui.Ruler

Methods

rnf :: Ruler -> () #

CStorable Ruler # 
Instance details

Defined in Ui.RulerC

Methods

sizeOf :: Ruler -> Int #

alignment :: Ruler -> Int #

peekElemOff :: Ptr Ruler -> Int -> IO Ruler #

pokeElemOff :: Ptr Ruler -> Int -> Ruler -> IO () #

peekByteOff :: Ptr b -> Int -> IO Ruler #

pokeByteOff :: Ptr b -> Int -> Ruler -> IO () #

peek :: Ptr Ruler -> IO Ruler #

poke :: Ptr Ruler -> Ruler -> IO () #

Pretty.Pretty Ruler # 
Instance details

Defined in Ui.Ruler

Serialize Ruler # 
Instance details

Defined in Cmd.Serialize

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.

Constructors

MeterConfig 

Fields

  • 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
     
Instances
Eq MeterConfig # 
Instance details

Defined in Ui.Ruler

Show MeterConfig # 
Instance details

Defined in Ui.Ruler

Pretty.Pretty MeterConfig # 
Instance details

Defined in Ui.Ruler

Serialize MeterConfig # 
Instance details

Defined in Cmd.Serialize

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

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

data Marklist Source #

Instances
Eq Marklist # 
Instance details

Defined in Ui.Ruler

Show Marklist # 
Instance details

Defined in Ui.Ruler

Pretty.Pretty Marklist # 
Instance details

Defined in Ui.Ruler

Serialize Marklist # 
Instance details

Defined in Cmd.Serialize

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.

modification

Mark

data Mark Source #

Constructors

Mark 

Fields

  • 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.

Instances
Eq Mark # 
Instance details

Defined in Ui.Ruler

Methods

(==) :: Mark -> Mark -> Bool #

(/=) :: Mark -> Mark -> Bool #

Read Mark # 
Instance details

Defined in Ui.Ruler

Show Mark # 
Instance details

Defined in Ui.Ruler

Methods

showsPrec :: Int -> Mark -> ShowS #

show :: Mark -> String #

showList :: [Mark] -> ShowS #

DeepSeq.NFData Mark # 
Instance details

Defined in Ui.Ruler

Methods

rnf :: Mark -> () #

CStorable Mark # 
Instance details

Defined in Ui.RulerC

Methods

sizeOf :: Mark -> Int #

alignment :: Mark -> Int #

peekElemOff :: Ptr Mark -> Int -> IO Mark #

pokeElemOff :: Ptr Mark -> Int -> Mark -> IO () #

peekByteOff :: Ptr b -> Int -> IO Mark #

pokeByteOff :: Ptr b -> Int -> Mark -> IO () #

peek :: Ptr Mark -> IO Mark #

poke :: Ptr Mark -> Mark -> IO () #

Pretty.Pretty Mark # 
Instance details

Defined in Ui.Ruler

Serialize Mark # 
Instance details

Defined in Cmd.Serialize

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.