Skip to content

Commit

Permalink
Fix GUI remove
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jun 19, 2023
1 parent b958b64 commit db94cce
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/03_gui_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main() -> None:

@gui_include_z.on_update
def _(_) -> None:
gui_axis.options = ["x", "y", "z"] if gui_include_z.value else ["x", "y"]
gui_axis.options = ("x", "y", "z") if gui_include_z.value else ("x", "y")

with server.gui_folder("Sliders"):
gui_location = server.add_gui_slider(
Expand Down
2 changes: 1 addition & 1 deletion viser/_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def visible(self, visible: bool) -> None:

def remove(self) -> None:
"""Permanently remove this GUI element from the visualizer."""
self._impl.api._queue(GuiRemoveMessage(self._impl.label))
self._impl.api._queue(GuiRemoveMessage(self._impl.id))
assert self._impl.cleanup_cb is not None
self._impl.cleanup_cb()

Expand Down
6 changes: 3 additions & 3 deletions viser/client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.82973013.css",
"main.js": "/static/js/main.679eff5c.js",
"main.js": "/static/js/main.fbdbcf0c.js",
"index.html": "/index.html",
"main.82973013.css.map": "/static/css/main.82973013.css.map",
"main.679eff5c.js.map": "/static/js/main.679eff5c.js.map"
"main.fbdbcf0c.js.map": "/static/js/main.fbdbcf0c.js.map"
},
"entrypoints": [
"static/css/main.82973013.css",
"static/js/main.679eff5c.js"
"static/js/main.fbdbcf0c.js"
]
}
2 changes: 1 addition & 1 deletion viser/client/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Viser</title><script defer="defer" src="/static/js/main.679eff5c.js"></script><link href="/static/css/main.82973013.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Viser</title><script defer="defer" src="/static/js/main.fbdbcf0c.js"></script><link href="/static/css/main.82973013.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions viser/client/src/ControlPanel/Generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,37 @@ export default function Generated() {

return (
<>
<Space h="xs" />
<GeneratedFolder folder={guiTree} />
</>
);
}

function GeneratedFolder({ folder }: { folder: Folder }) {
return (
<Stack spacing="xs">
<Stack spacing="xs" pt="0.25rem">
{folder.inputs.map((conf) => (
<GeneratedInput key={conf.id} conf={conf} />
))}
<Accordion
chevronPosition="right"
multiple
defaultValue={Object.keys(folder.subfolders)}
defaultValue={[...Object.keys(folder.subfolders)]}
styles={(theme) => ({
label: { padding: "0.625rem 0.2rem" },
item: { border: 0 },
control: { paddingLeft: 0 },
content: {
borderLeft: "1px solid",
borderLeftColor: theme.colors.gray[4],
borderLeftColor:
theme.colorScheme == "light"
? theme.colors.gray[3]
: theme.colors.dark[5],
paddingRight: "0",
paddingLeft: "0.5rem",
paddingBottom: 0,
paddingTop: 0,
marginBottom: "0.5rem",
marginLeft: "0.1rem",
marginLeft: "0.05rem",
},
})}
>
Expand Down
8 changes: 5 additions & 3 deletions viser/client/src/ControlPanel/GuiState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface GuiActions {
setGuiValue: (id: string, value: any) => void;
setGuiVisible: (id: string, visible: boolean) => void;
setGuiDisabled: (id: string, visible: boolean) => void;
removeGui: (name: string) => void;
removeGui: (id: string) => void;
resetGui: () => void;
}

Expand Down Expand Up @@ -90,9 +90,11 @@ export function useGuiState(initialServer: string) {
disabled: disabled,
};
}),
removeGui: (name) =>
removeGui: (id) =>
set((state) => {
delete state.guiConfigFromId[name];
delete state.guiConfigFromId[id];
delete state.guiValueFromId[id];
delete state.guiAttributeFromId[id];
}),
resetGui: () =>
set((state) => {
Expand Down
2 changes: 1 addition & 1 deletion viser/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function SingleViewer() {
: theme.colors.dark[4],
})}
>
<ScrollArea type="always" sx={{height: "100%"}}>
<ScrollArea type="always" sx={{ height: "100%" }}>
<Box
p="sm"
sx={(theme) => ({
Expand Down

0 comments on commit db94cce

Please sign in to comment.