Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Ui.Update

Contents

Description

Updates are diffs against Ui.State and are used in a number of contexts. They are produced by Ui.Diff. The different uses all require slightly different data, and I capture the major differences in separate types.

Synopsis

Documentation

type DisplayUpdate = Update Block.DisplayTrack () Source #

DisplayUpdates are sent to the UI to update the windows. Since the UI only has Views, and has a lower level version of tracks, this includes only updates that directly affect display.

type UiUpdate = Update Block.Track State Source #

UiUpdates reflect all changes to the underlying UI state. They're used for incremental save, and by the deriver to determine ScoreDamage.

data CmdUpdate Source #

For efficiency, TrackEvents updates are collected directly in Ui.State as the changes are made. This is because I'm afraid a complete diff against all the events in a score would be too expensive to run after every cmd. To express that there are only a few kinds of these updates, and since they are the only ones saved with their cmds, they are given their own type, CmdUpdate. These are also saved with the undo history.

Constructors

CmdTrackEvents Id.TrackId ScoreTime ScoreTime 
CmdTrackAllEvents Id.TrackId 
CmdRuler Id.RulerId 
CmdBringToFront Id.ViewId 
CmdTitleFocus Id.ViewId (Maybe Types.TrackNum)

If the TrackNum is set, set keyboard focus on that track's title. Otherwise, focus on the block title.

data Update t u Source #

Constructors

View !Id.ViewId !View 
Block !Id.BlockId !(Block t) 
Track !Id.TrackId !Track 
Ruler !Id.RulerId

Since I expect rulers to be changed infrequently, the only kind of ruler update is a full update.

State !u 

Instances

(Eq u, Eq t) => Eq (Update t u) # 

Methods

(==) :: Update t u -> Update t u -> Bool #

(/=) :: Update t u -> Update t u -> Bool #

(Show u, Show t) => Show (Update t u) # 

Methods

showsPrec :: Int -> Update t u -> ShowS #

show :: Update t u -> String #

showList :: [Update t u] -> ShowS #

DeepSeq.NFData (Update t u) # 

Methods

rnf :: Update t u -> () #

(Pretty.Pretty t, Pretty.Pretty u) => Pretty.Pretty (Update t u) # 

Methods

pretty :: Update t u -> Text Source #

format :: Update t u -> Doc Source #

formatList :: [Update t u] -> Doc Source #

data View Source #

Constructors

CreateView 
DestroyView 
ViewSize !Rect.Rect 
Status !(Map (Int, Text) Text) !Color.Color

background color

TrackScroll !Types.Width 
Zoom !Zoom.Zoom 
Selection !Sel.Num !(Maybe Sel.Selection) 
BringToFront

Bring the window to the front. Unlike most other updates, this is recorded directly and is not reflected in Ui.State.

TitleFocus !(Maybe Types.TrackNum)

Similar to BringToFront, but sets keyboard focus in a track title. If the TrackNum is not given, focus on the block title.

Instances

Eq View # 

Methods

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

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

Show View # 

Methods

showsPrec :: Int -> View -> ShowS #

show :: View -> String #

showList :: [View] -> ShowS #

Pretty.Pretty View # 

data Block t Source #

Constructors

BlockTitle !Text 
BlockConfig !Block.Config 
BlockSkeleton !Skeleton.Skeleton ![(Color.Color, [(Types.TrackNum, Types.TrackNum)])]

The second is the "integrate skeleton", which is drawn in the same place. It could be Skeleton too, but since it never was a skeleton it seems pointless to convert it to one just so it can be flattened again. Arguably it's the first arg which should be edges, but at least this way the two args can't be mixed up.

RemoveTrack !Types.TrackNum 
InsertTrack !Types.TrackNum !t 
BlockTrack !Types.TrackNum !t

Unlike Track, these settings are local to the block, not global to this track in all its blocks.

Instances

Eq t => Eq (Block t) # 

Methods

(==) :: Block t -> Block t -> Bool #

(/=) :: Block t -> Block t -> Bool #

Show t => Show (Block t) # 

Methods

showsPrec :: Int -> Block t -> ShowS #

show :: Block t -> String #

showList :: [Block t] -> ShowS #

Pretty.Pretty t => Pretty.Pretty (Block t) # 

data Track Source #

Constructors

TrackEvents !ScoreTime !ScoreTime

Low pos, high pos.

TrackAllEvents

Update the entire track.

TrackTitle !Text 
TrackBg !Color.Color 
TrackRender !Track.RenderConfig 

Instances

to_display :: UiUpdate -> Maybe DisplayUpdate Source #

Convert a UiUpdate to a DisplayUpdate by stripping out all the UiUpdate parts.

to_cmd :: UiUpdate -> Maybe CmdUpdate Source #

Pull the CmdUpdate out of a UiUpdate, if any. Discard BringToFront and TitleFocus since they're just instructions to Sync and I don't need to remember them.

functions

is_view_update :: UiUpdate -> Bool Source #

Updates which purely manipulate the view are not recorded by undo.

is_score_update :: CmdUpdate -> Bool Source #

True if this CmdUpdate implies score damage.

collapse_updates :: [Update t u] -> [Update t u] Source #

TrackUpdates can overlap. Merge them together here. Technically I can also cancel out all TrackUpdates that only apply to newly created views, but this optimization is probably not worth it.

track_changed :: UiUpdate -> Maybe (Id.TrackId, Ranges.Ranges ScoreTime) Source #

Does an update imply a change which would require rederiving?

sort :: [DisplayUpdate] -> [DisplayUpdate] Source #

Some Updates have to happen before others.