Skip to content

Commit

Permalink
Refactor WaveSim to more files. Small zoom fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcl committed Aug 15, 2024
1 parent 13ede9b commit c1aa348
Show file tree
Hide file tree
Showing 12 changed files with 1,459 additions and 1,325 deletions.
6 changes: 5 additions & 1 deletion src/Renderer/Renderer.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@
<Compile Include="UI\BuildView.fs" />
<Compile Include="UI\CatalogueView.fs" />
<Compile Include="UI\SelectedComponentView.fs" />
<Compile Include="UI\WaveSim/WaveSimHelpers.fs" />
<Compile Include="UI\WaveSim/WaveSimStyle.fs" />
<Compile Include="UI\WaveSim/WaveSimHelpers.fs" />
<Compile Include="UI\WaveSim\WaveSimNavigation.fs" />
<Compile Include="UI\WaveSim\WaveSimSelect.fs" />
<Compile Include="UI\WaveSim\WaveSimWaves.fs" />
<Compile Include="UI\WaveSim\WaveSimWaveforms.fs" />
<Compile Include="UI\WaveSim\WaveSimRams.fs" />
<Compile Include="UI\WaveSim/WaveSim.fs" />
<Compile Include="UI\MainView.fs" />
<Compile Include="UI\ContextMenus.fs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/UI/MainView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ let displayView model dispatch =
newWidth
|> max minViewerWidth
|> min (windowX - minEditorWidth())
setViewerWidthInWaveSim w dispatch
WaveSimNavigation.setViewerWidthInWaveSim w dispatch
dispatch <| SetDragMode DragModeOff
dispatch <| SetViewerWidth w
| _ -> ()
Expand Down
13 changes: 7 additions & 6 deletions src/Renderer/UI/Update.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ open Optics
open Optics.Optic
open Optics.Operators


//---------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------//
//---------------------------------- Update Model ---------------------------------------------//
Expand Down Expand Up @@ -67,7 +68,7 @@ let update (msg : Msg) oldModel =

match testMsg with
| ChangeWaveSimMultiplier key ->
let table = WaveSimHelpers.Constants.multipliers
let table = WaveSimStyle.Constants.multipliers
if key < 0 || key >= table.Length then
printf $"Warning: Can't chnage multiplier to key = {key}"
model, Cmd.none
Expand All @@ -80,7 +81,7 @@ let update (msg : Msg) oldModel =
model
|> Optic.map waveSim_ (fun ws ->
let wsModel = ws[sheet]
Map.add sheet (WaveSimHelpers.changeMultiplier (table[key]) wsModel) ws)
Map.add sheet (WaveSimNavigation.changeMultiplier (table[key]) wsModel) ws)
|> (fun m -> m, Cmd.none)
| CheckMemory ->
if JSHelpers.loggingMemory then
Expand Down Expand Up @@ -256,18 +257,18 @@ let update (msg : Msg) oldModel =

| SetWaveComponentSelectionOpen (fIdL, show) ->
model
|> updateWSModel (fun ws -> WaveSimHelpers.setWaveComponentSelectionOpen ws fIdL show)
|> updateWSModel (fun ws -> WaveSimStyle.setWaveComponentSelectionOpen ws fIdL show)
|> withNoMsg

| SetWaveGroupSelectionOpen (fIdL, show) ->
model
|> updateWSModel (fun ws -> WaveSimHelpers.setWaveGroupSelectionOpen ws fIdL show)
|> updateWSModel (fun ws -> WaveSimStyle.setWaveGroupSelectionOpen ws fIdL show)
|> withNoMsg


| SetWaveSheetSelectionOpen (fIdL, show) ->
model
|> updateWSModel (fun ws -> WaveSimHelpers.setWaveSheetSelectionOpen ws fIdL show)
|> updateWSModel (fun ws -> WaveSimStyle.setWaveSheetSelectionOpen ws fIdL show)
|> withNoMsg

| TryStartSimulationAfterErrorFix simType ->
Expand Down Expand Up @@ -609,7 +610,7 @@ let update (msg : Msg) oldModel =

| ScrollbarMouseMsg (cursor: float, action: ScrollbarMouseAction, dispatch: Msg->unit) ->
let wsm = Map.find (Option.get model.WaveSimSheet) model.WaveSim
WaveSim.updateScrollbar wsm dispatch cursor action
WaveSimNavigation.updateScrollbar wsm dispatch cursor action
model, Cmd.none

// Various messages here that are not implemented as yet, or are no longer used
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer/UI/UpdateHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let shortDWSM (ws: WaveSimModel) =
let shortDisplayMsg (msg:Msg) =
match msg with
| ChangeWaveSimMultiplier n ->
List.tryItem n WaveSimHelpers.Constants.multipliers
List.tryItem n WaveSimStyle.Constants.multipliers
|> Option.map (fun n -> $"Set WS multiplier to {n}")
|> Option.defaultValue $"Invalid Ws mult key of {n}"
|> Some
Expand Down
Loading

0 comments on commit c1aa348

Please sign in to comment.