Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
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 UiDamage Source #

This collects damaged Ui.State elements, manually added by the various Ui functions. I use Ui.Diff to get the exact changes, but it's too slow to compare the entire Ui.State, so UiDamage is used to restrict the diff to just parts that may have changed.

There are also a few mutations that correspond directly UiUpdates which I just emit directly rather than relying on diff. Those are converted from UiDamage by to_ui.

Constructors

UiDamage 

Fields

Instances

Instances details
Eq UiDamage # 
Instance details

Defined in Ui.Update

Show UiDamage # 
Instance details

Defined in Ui.Update

Semigroup UiDamage # 
Instance details

Defined in Ui.Update

Monoid UiDamage # 
Instance details

Defined in Ui.Update

Pretty.Pretty UiDamage # 
Instance details

Defined in Ui.Update

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

Instances details
(Eq t, Eq u) => Eq (Update t u) # 
Instance details

Defined in Ui.Update

Methods

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

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

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

Defined in Ui.Update

Methods

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

show :: Update t u -> String #

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

DeepSeq.NFData (Update t u) # 
Instance details

Defined in Ui.Update

Methods

rnf :: Update t u -> () #

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

Defined in Ui.Update

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

Instances details
Eq View # 
Instance details

Defined in Ui.Update

Methods

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

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

Show View # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> View -> ShowS #

show :: View -> String #

showList :: [View] -> ShowS #

Pretty.Pretty View # 
Instance details

Defined in Ui.Update

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

Instances details
Eq t => Eq (Block t) # 
Instance details

Defined in Ui.Update

Methods

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

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

Show t => Show (Block t) # 
Instance details

Defined in Ui.Update

Methods

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

show :: Block t -> String #

showList :: [Block t] -> ShowS #

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

Defined in Ui.Update

data Track Source #

Instances

Instances details
Eq Track # 
Instance details

Defined in Ui.Update

Methods

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

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

Show Track # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> Track -> ShowS #

show :: Track -> String #

showList :: [Track] -> ShowS #

Pretty.Pretty Track # 
Instance details

Defined in Ui.Update

data State Source #

These are updates to State that have no UI presence.

Instances

Instances details
Eq State # 
Instance details

Defined in Ui.Update

Methods

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

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

Show State # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> State -> ShowS #

show :: State -> String #

showList :: [State] -> ShowS #

Pretty.Pretty State # 
Instance details

Defined in Ui.Update

to_display :: UiUpdate -> Maybe DisplayUpdate Source #

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

to_damage :: UiUpdate -> UiDamage Source #

Reduce a UiUpdate to its corresponding UiDamage. UiUpdates are more specific, so this is discarding information, which I'll have to recover later via Diff.

This seems silly, and maybe it is. It's because I originally used only diff for updates, but then added UiDamage to make diff more efficient. Perhaps I should move entirely to collecting updates and get rid of diff. But as long as diff is fairly efficient, when directed to the appropriate places via UiDamage, then it still seems less error prone to do the diff.

functions

is_view_update :: UiUpdate -> Bool Source #

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

is_score_damage :: UiDamage -> Bool Source #

True if this UiDamage implies score damage.

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.