Skip to content

Commit 4168d72

Browse files
committed
expose configuration options of Graphviz, make cfg zoomable and fitting in size
1 parent f653e1e commit 4168d72

File tree

5 files changed

+55
-24
lines changed

5 files changed

+55
-24
lines changed

src/Graphviz.mli

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1+
open Js_of_ocaml
2+
13
val makeProps :
2-
dot:Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t
4+
dot: Js.js_string Js.t
5+
-> options: <fit: bool Js.t Js.readonly_prop
6+
; height: Js.js_string Js.t
7+
; width: Js.js_string Js.t
8+
; zoom: bool Js.t Js.readonly_prop > Js.t
9+
-> className: Js.js_string Js.t
310
-> unit
4-
-> < dot:
5-
Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t Js_of_ocaml.Js.readonly_prop >
6-
Js_of_ocaml.Js.t
11+
-> < dot: Js.js_string Js.t Js.readonly_prop
12+
; options: <fit: bool Js.t Js.readonly_prop
13+
; height: Js.js_string Js.t
14+
; width: Js.js_string Js.t
15+
; zoom: bool Js.t Js.readonly_prop > Js.t Js.readonly_prop
16+
; className: Js.js_string Js.t Js.readonly_prop > Js.t
717
[@@js.custom
8-
let makeProps ~dot () =
18+
let makeProps ~dot ~options ~className () =
919
object%js
1020
val dot = dot
21+
val options = options
22+
val className = className
1123
end]
1224

1325
val make :
14-
< dot: Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t Js_of_ocaml.Js.readonly_prop >
15-
Js_of_ocaml.Js.t
26+
< dot: Js.js_string Js.t Js.readonly_prop
27+
; options: <fit: bool Js.t Js.readonly_prop
28+
; height: Js.js_string Js.t
29+
; width: Js.js_string Js.t
30+
; zoom: bool Js.t Js.readonly_prop > Js.t Js.readonly_prop
31+
; className: Js.js_string Js.t Js.readonly_prop > Js.t
1632
React.component
1733
[@@js.custom
1834
external to_component :
1935
Ojs.t
20-
-> < dot:
21-
Js_of_ocaml.Js.js_string Js_of_ocaml.Js.t
22-
Js_of_ocaml.Js.readonly_prop >
23-
Js_of_ocaml.Js.t
36+
-> < dot: Js.js_string Js.t Js.readonly_prop
37+
; options: <fit: bool Js.t Js.readonly_prop
38+
; height: Js.js_string Js.t
39+
; width: Js.js_string Js.t
40+
; zoom: bool Js.t Js.readonly_prop > Js.t Js.readonly_prop
41+
; className: Js.js_string Js.t Js.readonly_prop > Js.t
2442
React.component = "%identity"
2543

2644
val make_internal : Ojs.t [@@js.global "Graphviz"]

src/Main.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let make = (~cil, ~goblint, ~warnings, ~meta, ~stats, ~file_loc) => {
6161
cil={state.cil}
6262
/>
6363
</div>
64-
<div className="col-6 d-flex flex-column">
64+
<div className="col-6 d-flex flex-column h-100">
6565
{switch (state.display) {
6666
| None => <div className="d-flex flex-column h-75 overflow-auto p-4" />
6767
| Some(f) => <Content state display=f dispatch />

src/stylesheet.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@ ol, ul {
186186
.main {
187187
padding-top: 48px;
188188
}
189+
190+
.fun-cfg {
191+
min-height: 0;
192+
flex-grow: 1;
193+
}

src/ui/content/Content.re

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ let make = (~state: State.t, ~display: GvDisplay.t, ~dispatch) => {
88
| _ => None
99
};
1010

11-
<div className="d-flex flex-column h-75 overflow-auto p-4">
11+
<div className="d-flex flex-column h-75 p-4">
1212
<GvBreadcrumb display={state.display} dispatch />
1313
{switch display {
14-
| File(file) =>
15-
<GvFileView
16-
goblint={state.goblint}
17-
warnings={state.warnings}
18-
file
19-
line
20-
dispatch
21-
/>
22-
| Func(func) => <GvFuncView func dispatch />
23-
}}
14+
| File(file) =>
15+
<GvFileView
16+
goblint={state.goblint}
17+
warnings={state.warnings}
18+
file
19+
line
20+
dispatch
21+
/>
22+
| Func(func) => <GvFuncView func dispatch />
23+
}}
2424
</div>;
2525
};

src/ui/content/gvFuncView.re

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ let make = (~func: GvDisplay.func, ~dispatch) => {
2525
"Cannot display the function graph. The generated DOT file is probably too large."
2626
|> Js.string
2727
}>
28-
<Graphviz dot={dot |> Js.string} />
28+
<Graphviz
29+
dot={dot |> Js.string}
30+
options={Js.Unsafe.obj([|
31+
("height", Js.Unsafe.inject("100%")),
32+
("width", Js.Unsafe.inject("100%")),
33+
("zoom", Js.Unsafe.inject(true)),
34+
|])}
35+
className={"fun-cfg" |> Js.string}
36+
/>
2937
</ErrorBoundary>
3038
| _ => React.null
3139
};

0 commit comments

Comments
 (0)