Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

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.

TODO The indirection for BringToFront, TitleFocus, seems a bit fussy. Can I just store some Updates in here?

Constructors

UiDamage 

Fields

Instances

Instances details
Monoid UiDamage Source # 
Instance details

Defined in Ui.Update

Semigroup UiDamage Source # 
Instance details

Defined in Ui.Update

Generics.Generic UiDamage Source # 
Instance details

Defined in Ui.Update

Associated Types

type Generics.Rep UiDamage :: Type -> Type #

Show UiDamage Source # 
Instance details

Defined in Ui.Update

Eq UiDamage Source # 
Instance details

Defined in Ui.Update

Pretty.Pretty UiDamage Source # 
Instance details

Defined in Ui.Update

type Generics.Rep UiDamage Source # 
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
(Show t, Show u) => Show (Update t u) Source # 
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) Source # 
Instance details

Defined in Ui.Update

Methods

rnf :: Update t u -> () #

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

Defined in Ui.Update

Methods

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

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

(Pretty.Pretty t, Pretty.Pretty u) => Pretty.Pretty (Update t u) Source # 
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
Show View Source # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> View -> ShowS #

show :: View -> String #

showList :: [View] -> ShowS #

Eq View Source # 
Instance details

Defined in Ui.Update

Methods

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

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

Pretty.Pretty View Source # 
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 Update, these settings are local to the block, not global to this track in all its blocks.

Instances

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

Defined in Ui.Update

Methods

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

show :: Block t -> String #

showList :: [Block t] -> ShowS #

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

Defined in Ui.Update

Methods

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

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

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

Defined in Ui.Update

data Track Source #

Instances

Instances details
Show Track Source # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> Track -> ShowS #

show :: Track -> String #

showList :: [Track] -> ShowS #

Eq Track Source # 
Instance details

Defined in Ui.Update

Methods

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

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

Pretty.Pretty Track Source # 
Instance details

Defined in Ui.Update

data State Source #

These are updates to State that have no UI presence.

Instances

Instances details
Show State Source # 
Instance details

Defined in Ui.Update

Methods

showsPrec :: Int -> State -> ShowS #

show :: State -> String #

showList :: [State] -> ShowS #

Eq State Source # 
Instance details

Defined in Ui.Update

Methods

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

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

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

Score damage is used by Diff.score_changed to determine if a change has happened which is worthy of saving to disk, or recording for undo.

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.