Safe Haskell | Safe-Inferred |
---|
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
- type DisplayUpdate = Update Block.DisplayTrack ()
- type UiUpdate = Update Block.Track State
- data UiDamage = UiDamage {}
- view_damage :: Id.ViewId -> UiDamage
- block_damage :: Id.BlockId -> UiDamage
- track_damage :: Id.TrackId -> Ranges.Ranges TrackTime -> UiDamage
- ruler_damage :: Id.RulerId -> UiDamage
- data Update t u
- = View Id.ViewId View
- | Block Id.BlockId (Block t)
- | Track Id.TrackId Track
- | Ruler Id.RulerId
- | State u
- data View
- data Block t
- data Track
- data State
- update_id :: Update t State -> Maybe Id.Id
- to_display :: UiUpdate -> Maybe DisplayUpdate
- to_ui :: UiDamage -> [UiUpdate]
- to_damage :: UiUpdate -> UiDamage
- is_view_update :: UiUpdate -> Bool
- is_score_damage :: UiDamage -> Bool
- track_changed :: UiUpdate -> Maybe (Id.TrackId, Ranges.Ranges ScoreTime)
- sort :: [DisplayUpdate] -> [DisplayUpdate]
- sort_key :: DisplayUpdate -> Int
Documentation
type DisplayUpdate = Update Block.DisplayTrack () Source #
DisplayUpdate
s 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 #
UiUpdate
s reflect all changes to the underlying UI state. They're
used for incremental save, and by the deriver to determine ScoreDamage.
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 UiUpdate
s 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?
UiDamage | |
|
Instances
view_damage :: Id.ViewId -> UiDamage Source #
block_damage :: Id.BlockId -> UiDamage Source #
track_damage :: Id.TrackId -> Ranges.Ranges TrackTime -> UiDamage Source #
ruler_damage :: Id.RulerId -> UiDamage Source #
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 |
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. |
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 |
TrackEvents ScoreTime ScoreTime | Low pos, high pos. |
TrackAllEvents | Update the entire track. |
TrackTitle Text | |
TrackBg Color.Color | |
TrackRender Track.RenderConfig |
These are updates to State
that have no UI presence.
Config UiConfig.Config | |
CreateBlock Id.BlockId Block.Block | |
DestroyBlock Id.BlockId | |
CreateTrack Id.TrackId Track.Track | |
DestroyTrack Id.TrackId | |
CreateRuler Id.RulerId Ruler.Ruler | |
DestroyRuler Id.RulerId |
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.
sort_key :: DisplayUpdate -> Int Source #