Skip to content

Commit

Permalink
improve wire colors and wavesim
Browse files Browse the repository at this point in the history
More context menus for wavesim
Change SelectWires logic to prevent anomalous Error wires
  • Loading branch information
tomcl committed Sep 20, 2023
1 parent a252e01 commit f2d0076
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Renderer/DrawBlock/BusWireUpdate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ let update (msg : Msg) (issieModel : ModelType.Model) : ModelType.Model*Cmd<Mode
{wire with Color = HighLightColor.DarkSlateGrey}
)

{issieModel with Sheet={ issieModel.Sheet with Wire={ model with Wires = newWires ; ErrorWires = connectionIds }}} |> withNoMsg
{issieModel with Sheet={ issieModel.Sheet with Wire={ model with Wires = newWires ; ErrorWires = []}}} |> withNoMsg


| DeleteWires (connectionIds : list<ConnectionId>) ->
Expand Down
7 changes: 6 additions & 1 deletion src/Renderer/UI/UpdateHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ let getContextMenu (e: Browser.Types.MouseEvent) (model: Model) : string =

rightClickElement <- // mutable so that we have this info also in the callback from main
match drawOn, htmlId, elType with
| _, "refreshButton", _
| _, "selectButton", _
| _, "selectRamButton", _
| _, "startEndButton", _ ->
WaveSimHelp
| _, elId, _ when String.startsWith "SheetMenuBreadcrumb:" elId ->
let nameParts = elId.Split(":",System.StringSplitOptions.RemoveEmptyEntries)
//printfn "NameParts: %A"nameParts
Expand All @@ -311,7 +316,7 @@ let getContextMenu (e: Browser.Types.MouseEvent) (model: Model) : string =
|> Option.defaultValue NoMenu

| SheetT.MouseOn.Canvas, _ , "path"
| SheetT.MouseOn.Canvas, "WaveSimHelp", _ ->
| _, "WaveSimHelp", _ ->
WaveSimHelp
| SheetT.MouseOn.Canvas, "DrawBlockSVGTop", _ ->
printfn "Draw block sheet 'canvas'"
Expand Down
4 changes: 2 additions & 2 deletions src/Renderer/UI/WaveSim/WaveSim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ let topHalf canvasState (model: Model) dispatch : ReactElement =
let wbo = getWaveSimButtonOptions canvasState model wsModel
let startEndButton =
button
(topHalfButtonProps wbo.StartEndColor)
(topHalfButtonProps wbo.StartEndColor "startEndButton")
(fun ev -> if wbo.IsRunning then waveEnd ev else startOrRenew ev)
(str wbo.StartEndMsg)
let needsRefresh = wbo.IsDirty && wbo.IsRunning
Expand All @@ -1047,7 +1047,7 @@ let topHalf canvasState (model: Model) dispatch : ReactElement =
else [
if needsRefresh then
button
(topHalfButtonProps IsSuccess)
(topHalfButtonProps IsSuccess "RefreshButton")
startOrRenew
refreshButtonSvg
startEndButton
Expand Down
8 changes: 4 additions & 4 deletions src/Renderer/UI/WaveSim/WaveSimSelect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ let selectWavesButton (wsModel: WaveSimModel) (dispatch: Msg -> unit) : ReactEle
let waveCount = Map.count wsModel.AllWaves
let props, buttonFunc =
if waveCount > 0 && wsModel.State=Success then
selectWavesButtonProps, (fun _ -> dispatch <| UpdateWSModel (fun ws -> {wsModel with WaveModalActive = true}))
else selectWavesButtonPropsLight, (fun _ -> ())
selectWavesButtonProps "selectButton", (fun _ -> dispatch <| UpdateWSModel (fun ws -> {wsModel with WaveModalActive = true}))
else selectWavesButtonPropsLight "selectButton", (fun _ -> ())
button
props
buttonFunc
Expand Down Expand Up @@ -690,8 +690,8 @@ let selectRamButton (wsModel: WaveSimModel) (dispatch: Msg -> unit) : ReactEleme
let ramCount = List.length wsModel.RamComps
let props, buttonFunc =
if ramCount > 0 && wsModel.State=Success then
selectRamButtonProps, (fun _ -> dispatch <| UpdateWSModel (fun ws -> {wsModel with RamModalActive = true}))
else selectRamButtonPropsLight, (fun _ -> ())
selectRamButtonProps "selectRamButton", (fun _ -> dispatch <| UpdateWSModel (fun ws -> {wsModel with RamModalActive = true}))
else selectRamButtonPropsLight "selectRamButton", (fun _ -> ())
button
props
buttonFunc
Expand Down
18 changes: 9 additions & 9 deletions src/Renderer/UI/WaveSim/WaveSimStyle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,30 @@ let infoButtonProps color = [
]
]

let topHalfButtonProps color = [
let topHalfButtonProps color buttonId = [
Button.Color color
Button.Props [topRowButtonStyle]
Button.Props [HTMLAttr.Id buttonId ; topRowButtonStyle]
]

let selectRamButtonProps = topHalfButtonProps IsInfo
let selectRamButtonProps buttonId = topHalfButtonProps IsInfo buttonId

/// Props for selectRamButton when no RAMs are selectable
let selectRamButtonPropsLight =
selectRamButtonProps @ [Button.IsLight]
let selectRamButtonPropsLight buttonId =
selectRamButtonProps buttonId @ [Button.IsLight]


let topHalfButtonPropsWithWidth color = [
let topHalfButtonPropsWithWidth buttonId color = [
Button.Color color
Button.Props [topRowButtonStyle]
Button.Props [HTMLAttr.Id buttonId ; topRowButtonStyle]
]

/// Props for selectWavesButton
let selectWavesButtonProps = topHalfButtonProps IsInfo


/// Props for selectWavesButton when no waves are selectable
let selectWavesButtonPropsLight =
selectWavesButtonProps @ [Button.IsLight]
let selectWavesButtonPropsLight buttonId =
selectWavesButtonProps buttonId @ [Button.IsLight]

let centerAlignStyle = Style [
TextAlign TextAlignOptions.Center
Expand Down

0 comments on commit f2d0076

Please sign in to comment.