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

Safe HaskellNone

Ui.Events

Contents

Description

The Events type contains the events of a track.

This is the largest part of the score and also the part most often modified, so there is a plethora of access functions.

Synopsis

range

data Range Source #

Constructors

Range !ScoreTime.TrackTime !ScoreTime.TrackTime

A range between the given points. It will select a positive event at the start time, or a negative one at the end time. Effectively it's half-open from the start for Positive events, and half-open from the end for Negative ones.

Point !ScoreTime.TrackTime !Types.Orientation

Select an event at exactly the given time and orientation.

Instances
Eq Range # 
Instance details

Defined in Ui.Events

Methods

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

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

Show Range # 
Instance details

Defined in Ui.Events

Methods

showsPrec :: Int -> Range -> ShowS #

show :: Range -> String #

showList :: [Range] -> ShowS #

Pretty.Pretty Range # 
Instance details

Defined in Ui.Events

events

data Events Source #

This is the underlying storage for a sequence of events. The invariant is that events start + duration don't overlap.

This type should remain abstract, and you should manipulate events using functions in this module.

Instances
Eq Events # 
Instance details

Defined in Ui.Events

Methods

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

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

Read Events # 
Instance details

Defined in Ui.Events

Show Events # 
Instance details

Defined in Ui.Events

Semigroup Events # 
Instance details

Defined in Ui.Events

Monoid Events # 
Instance details

Defined in Ui.Events

DeepSeq.NFData Events # 
Instance details

Defined in Ui.Events

Methods

rnf :: Events -> () #

Pretty.Pretty Events # 
Instance details

Defined in Ui.Events

Serialize.Serialize Events # 
Instance details

Defined in Ui.Events

list conversion

ascending :: Events -> [Event.Event] Source #

Get all events in ascending order.

transformation

map_events :: (Event.Event -> Event.Event) -> Events -> Events Source #

Map a function across the events in Events.

move :: ScoreTime.ScoreTime -> Events -> Events Source #

Move events by a constant amount. It's more efficient than map_events because it doesn't have to sort and clip the events.

clip :: Bool -> ScoreTime.ScoreTime -> [Event.Event] -> [Event.Event] Source #

Clip off the events after the given end time. Also shorten the last event so it doesn't cross the end, if necessary.

insert / remove

insert :: [Event.Event] -> Events -> Events Source #

Merge events into the given Events. Events that overlap will have their tails clipped until they don't, and given events that start at the same place as existing events will replace the existing ones.

This should be the the only way to create a Events, short of debugging, since it enforces that events don't overlap.

remove :: Range -> Events -> Events Source #

Remove events in the range.

merge :: Events -> Events -> Events Source #

Merge evts2 into evts1. Events that overlap other events will be clipped so they don't overlap. If events occur simultaneously, the event from evts1 wins.

lookup

at :: ScoreTime.ScoreTime -> Types.Orientation -> Events -> Maybe Event.Event Source #

An event exactly at the given pos, or Nothing. TODO this is just in_range (Point ...), merge them?

overlapping :: ScoreTime.ScoreTime -> Events -> Maybe Event.Event Source #

Like at, but return an event that overlaps the given pos.

last :: Events -> Maybe Event.Event Source #

Final event, if there is one.

split

events

split :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Split at the given time. A positive event that starts at the given time will appear in the after events, a negative event in the previous events.

split_exclude :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Like split, but a positive event that matches exactly is excluded from the result.

in_range :: Range -> Events -> Events Source #

Like split_range, but only return the middle part.

around :: ScoreTime.ScoreTime -> ScoreTime.ScoreTime -> Events -> Events Source #

Get events in the given range, plus surrounding. If there is no event at start, the previous event will be included. The event after end is always included.

List [Event]

at_after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is at or after pos.

after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is strictly after pos.

before :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start before pos.

split_at_before :: ScoreTime.ScoreTime -> Events -> ([Event.Event], [Event.Event]) Source #

This is like split, but if there isn't an event exactly at the pos then put the previous one in the post list.