Karya, built on 2022-03-21T01:30:44 (patch 89d1651424c35e564138d93424a157ff87457245)
Safe HaskellSafe-Inferred

Ui.Events

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 !TrackTime !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.

Start should be <= end.

Point !TrackTime !Types.Orientation

Select an event at exactly the given time and orientation.

Instances

Instances details
Show Range Source # 
Instance details

Defined in Ui.Events

Methods

showsPrec :: Int -> Range -> ShowS #

show :: Range -> String #

showList :: [Range] -> ShowS #

Eq Range Source # 
Instance details

Defined in Ui.Events

Methods

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

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

Pretty.Pretty Range Source # 
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

Instances details
Monoid Events Source # 
Instance details

Defined in Ui.Events

Semigroup Events Source # 
Instance details

Defined in Ui.Events

Read Events Source # 
Instance details

Defined in Ui.Events

Show Events Source # 
Instance details

Defined in Ui.Events

DeepSeq.NFData Events Source # 
Instance details

Defined in Ui.Events

Methods

rnf :: Events -> () #

Eq Events Source # 
Instance details

Defined in Ui.Events

Methods

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

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

Pretty.Pretty Events Source # 
Instance details

Defined in Ui.Events

Serialize.Serialize Events Source # 
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 -> 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 -> Events -> Events Source #

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

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

Like clip, but works on a list.

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 -> 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 -> 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 -> 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 -> 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 -> 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 -> Events -> [Event.Event] Source #

Events with start >= pos.

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

Events with start > pos.

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

Events with start < pos.

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

Events with start <= pos.

split_at_before :: 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.