Skip to content

Commit

Permalink
improve breadcrumbs, info
Browse files Browse the repository at this point in the history
make breadcrumbs configurable to allow duplicate instances or not.
Show hierarchy without duplicated
Show hierarchy using components currently in draw block

Update info page
  • Loading branch information
tomcl committed Sep 4, 2023
1 parent 11d0dce commit b61cafd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
22 changes: 18 additions & 4 deletions src/Renderer/UI/Breadcrumbs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ open Optics.Optic
*)

type BreadcrumbConfig = {
AllowDuplicateSheets: bool
BreadcrumbIdPrefix: string
ColorFun: SheetTree -> IColor
ClickAction: SheetTree -> (Msg -> unit) -> unit
Expand All @@ -38,6 +39,7 @@ module Constants =
Padding "50px"]

let defaultConfig = {
AllowDuplicateSheets = false
BreadcrumbIdPrefix = "BreadcrumbDefault"
ColorFun = fun _ -> IColor.IsGreyDark
ClickAction = fun _ _ -> ()
Expand Down Expand Up @@ -172,7 +174,7 @@ let hierarchyBreadcrumbs
(model: Model) =
mapOverProject (div [] []) model (fun p ->
let root = Option.defaultValue p.OpenFileName model.WaveSimSheet
let sheetTreeMap = getSheetTrees p
let sheetTreeMap = getSheetTrees cfg.AllowDuplicateSheets p
makeBreadcrumbsFromPositions sheetTreeMap cfg (positionDesignHierarchyInGrid root) dispatch)


Expand All @@ -187,7 +189,7 @@ let hierarchyFromSheetBreadcrumbs
(dispatch: Msg -> unit)
(model: Model) =
mapOverProject (div [] []) model (fun p ->
let sheetTreeMap = getSheetTrees p
let sheetTreeMap = getSheetTrees cfg.AllowDuplicateSheets p
makeBreadcrumbsFromPositions sheetTreeMap cfg (positionDesignHierarchyInGrid rootSheet) dispatch)

/// Breadcrumbs of entire design hierarchy of every root sheet in project
Expand All @@ -199,7 +201,7 @@ let allRootHierarchiesFromProjectBreadcrumbs
(dispatch: Msg -> unit)
(model: Model) =
mapOverProject ([div [] []]) model (fun p ->
let sheetTreeMap = getSheetTrees p
let sheetTreeMap = getSheetTrees cfg.AllowDuplicateSheets p
allRootSheets sheetTreeMap
|> Set.toList
|> List.map (fun root ->
Expand All @@ -209,6 +211,18 @@ let allRootHierarchiesFromProjectBreadcrumbs
] [ td [CellSpacing "50px"] [el]])
|> fun rows -> table [] [tbody [] rows]

/// is there a duplicate sheet name anywhere in hierarchy?
let hierarchiesHaveDuplicates (model: Model) =
mapOverProject false model (fun p ->
getSheetTrees true p
|> Map.toList
|> List.map (fun (_,sheet) ->
let sheetNames =
sheet.SubSheets
|> List.map (fun sheet -> sheet.SheetName)
sheetNames.Length = (List.distinct sheetNames).Length)
|> List.exists id)


/// Breadcrumbs of the focus sheet, with sheets on its path to root, and its children.
/// Provides navigation while occupying small vertical area. Untested.
Expand All @@ -225,6 +239,6 @@ let smallSimulationBreadcrumbs
(model: Model)
: ReactElement =
mapOverProject (div [] []) model (fun p ->
makeBreadcrumbsFromPositions (getSheetTrees p) cfg (positionRootAndFocusChildrenInGrid rootName pathToFocus) dispatch)
makeBreadcrumbsFromPositions (getSheetTrees cfg.AllowDuplicateSheets p) cfg (positionRootAndFocusChildrenInGrid rootName pathToFocus) dispatch)


4 changes: 2 additions & 2 deletions src/Renderer/UI/FileMenuHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ let rec foldOverTree (isSubSheet: bool) (folder: bool -> SheetTree -> Model -> M

/// Get the subsheet tree for all sheets in the current project.
/// Returns a map from sheet name to tree of SheetTree nodes
let getSheetTrees (p:Project): Map<string,SheetTree> =
let getSheetTrees (allowAllInstances: bool) (p:Project): Map<string,SheetTree> =
let ldcMap =
p.LoadedComponents
|> List.map (fun ldc -> ldc.Name,ldc)
Expand Down Expand Up @@ -338,7 +338,7 @@ let getSheetTrees (p:Project): Map<string,SheetTree> =
|> fun l -> 0 :: l
|> List.max
Size = List.sumBy (fun sub -> sub.Size) subs + 1;
SubSheets = subs
SubSheets = if allowAllInstances then subs else (subs |> List.distinctBy (fun sh -> sh.SheetName))
GridArea = None
})
|> makeBreadcrumbNamesUnique
Expand Down
10 changes: 6 additions & 4 deletions src/Renderer/UI/FileMenuView.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,11 @@ let viewTopMenu model dispatch =
let fileTab model =
match model.CurrentProj with
| None -> Navbar.Item.div [] []
| Some project ->
| Some project ->
let updatedProject = getUpdatedLoadedComponents project model
let updatedModel = {model with CurrentProj = Some updatedProject}

let sTrees = getSheetTrees project
let sTrees = getSheetTrees false updatedProject

let allRoots = allRootSheets sTrees
let isSubSheet sh = not <| Set.contains sh allRoots
Expand All @@ -1155,7 +1157,7 @@ let viewTopMenu model dispatch =
openFileInProject (sheet.SheetName) p model dispatch), dispatch)

let sheetColor (sheet:SheetTree) =
match sheet.SheetName = project.OpenFileName, sheetIsLocked sheet.SheetName model with
match sheet.SheetName = project.OpenFileName, sheetIsLocked sheet.SheetName updatedModel with
| true, true -> IColor.IsCustomColor "pink"
| true, false -> IColor.IsCustomColor "lightslategrey"
| false, true -> IColor.IsDanger
Expand All @@ -1170,7 +1172,7 @@ let viewTopMenu model dispatch =

let breadcrumbs = [
div [Style [TextAlign TextAlignOptions.Center; FontSize "15px"]] [str "Sheets with Design Hierarchy"]
Breadcrumbs.allRootHierarchiesFromProjectBreadcrumbs breadcrumbConfig dispatch model
Breadcrumbs.allRootHierarchiesFromProjectBreadcrumbs breadcrumbConfig dispatch updatedModel
]

Navbar.Item.div
Expand Down
8 changes: 8 additions & 0 deletions src/Renderer/UI/ModelHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ open CommonTypes
open Sheet.SheetInterface
open ModelType
open Elmish
open Optics
open Optics.Operators


module Constants =
Expand Down Expand Up @@ -329,3 +331,9 @@ let execOneAsyncJobIfPossible (model: Model,cmd: Cmd<Msg>)=
job.JobWork model
|> (fun (model', cmd') -> model', Cmd.batch [cmd; cmd'])

/// Return the project with with open file contents in loadedcomponents updated according to
/// current Draw Block contents.
let getUpdatedLoadedComponents (project: Project) (model: Model) : Project =
mapOverProject project model ( fun p ->
p
|> Optic.set (loadedComponentOf_ p.OpenFileName >-> canvasState_) (model.Sheet.GetCanvasState()))
19 changes: 9 additions & 10 deletions src/Renderer/UI/UIPopups.fs
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,14 @@ let viewInfoPopup dispatch =
]

let intro = div [] [
str "Issie designs are hierarchical, made of one main sheet and optional subsheets. Include the hardware defined on one sheet in another
by adding a 'custom component' from the 'My Project' section of the Catalog. \
Top-level sheets which are not used as subsheets are bolded on the sheet menu."
str "Issie designs are hierarchical, made of one main sheet and optional subsheets. Include the hardware defined on one sheet in another \
by adding any number of 'custom components' from the 'My Project' section of the Catalog. The Sheet menu shows the hierarchy."
br []; br []
str "Issie supports step simulation for all circuits, and waveform simulation to view the waveforms of clocked circuits.
str "Issie supports step simulation for all circuits, and waveform simulation to view the waveforms of clocked circuits. \
Use whichever works for you."
br []; br [];
str "In Issie all clocked components use the same clock signal Clk. \
Clk connections are not shown: all Clk ports are
str "In Issie all clocked components (blue fill) use the same clock signal Clk. \
Clk connections are not shown: all Clk ports are \
automatically connected together. In the waveform display active clock edges, 1 per clock cycle, are indicated \
by vertical lines through the waveforms."
br [] ; br [];
Expand All @@ -161,8 +160,8 @@ let viewInfoPopup dispatch =
Table.table [] [
tbody [] [
tr [] [
td [] [str "Left-Click Menus"]
td [] [str "Explore the Left-Click Menus to find context-dependent operations"]
td [] [str "Right-Click Menus"]
td [] [str "Explore the Right-Click Menus to find context-dependent operations"]
]

tr [] [
Expand Down Expand Up @@ -249,7 +248,7 @@ let viewInfoPopup dispatch =
let keyOf3 s1 s2 s3 = span [] [bSpan s1; tSpan " + "; bSpan s2 ; tSpan " + "; bSpan s3]
let rule = hr [Style [MarginTop "0.5em"; MarginBottom "0.5em"]]
let keys = div [] [
makeH "Keyboard & mouse gesture shortcuts - also available on top menus and left-click context menus"
makeH "Keyboard & mouse gesture shortcuts - also available on top menus and right-click context menus"
span [Style [FontStyle "Italic"]] [str "On Mac use Cmd instead of Ctrl."]
ul [] [
li [] [rule; tSpan "Save: "; keyOf2 "Ctrl" "S"; rule]
Expand All @@ -258,7 +257,7 @@ let viewInfoPopup dispatch =
li [] [tSpan "Paste diagram items: " ; keyOf2 "Ctrl" "V"; rule]
li [] [tSpan "Undo last diagram action: " ; keyOf2 "Ctrl" "Z"]
li [] [tSpan "Redo last diagram action: " ; keyOf2 "Ctrl" "Y"; rule]
li [] [tSpan "Zoom application in: " ; keyOf3 "Ctrl" "Shift" "="]
li [] [tSpan "Zoom application in: " ; keyOf3 "Ctrl" "Shift" "+"]
li [] [tSpan "Zoom application out: " ; keyOf3 "Ctrl" "Shift" "-"; rule]
li [] [tSpan "Zoom canvas in/out: " ; keyOf2 "Ctrl" "MouseWheel"]
li [] [tSpan "Zoom canvas in: " ; keyOf2 "Alt" "Up"]
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 @@ -303,7 +303,7 @@ let getContextMenu (e: Browser.Types.MouseEvent) (model: Model) : string =
//printfn "NameParts: %A"nameParts
model.CurrentProj
|> Option.map (fun p ->
Map.tryFind nameParts[1] (getSheetTrees p)
Map.tryFind nameParts[1] (getSheetTrees false p)
|> Option.map ( fun sheet ->
SheetMenuBreadcrumb (sheet, nameParts.Length > 2)))
|> Option.flatten
Expand Down

0 comments on commit b61cafd

Please sign in to comment.