diff --git a/src/viser/_gui_api.py b/src/viser/_gui_api.py index a198ea39..c99bf58d 100644 --- a/src/viser/_gui_api.py +++ b/src/viser/_gui_api.py @@ -1267,6 +1267,7 @@ def add_slider( visible: bool = True, hint: str | None = None, order: float | None = None, + hideControls: bool = True ) -> GuiSliderHandle[IntOrFloat]: """Add a slider to the GUI. Types of the min, max, step, and initial value should match. @@ -1283,6 +1284,7 @@ def add_slider( visible: Whether the slider is visible. hint: Optional hint to display on hover. order: Optional ordering, smallest values will be displayed first. + hideControls: hide the button control in the number input Returns: A handle that can be used to interact with the GUI element. @@ -1325,6 +1327,7 @@ def add_slider( precision=_compute_precision_digits(step), visible=visible, disabled=disabled, + hideControls=hideControls, _marks=tuple( GuiSliderMark(value=float(x[0]), label=x[1]) if isinstance(x, tuple) diff --git a/src/viser/_messages.py b/src/viser/_messages.py index 8ff0faf9..d90ee786 100644 --- a/src/viser/_messages.py +++ b/src/viser/_messages.py @@ -949,6 +949,8 @@ class GuiSliderProps(GuiBaseProps): step: float """Step size for the slider. Synchronized automatically when assigned.""" precision: int + """display the controls on input number""" + hideControls: bool """Number of decimal places to display for the slider value. Synchronized automatically when assigned.""" _marks: Optional[Tuple[GuiSliderMark, ...]] = None """(Private) Optional tuple of GuiSliderMark objects to display custom marks on the slider. Synchronized automatically when assigned.""" diff --git a/src/viser/client/index.html b/src/viser/client/index.html index a40e4e7e..833f8036 100644 --- a/src/viser/client/index.html +++ b/src/viser/client/index.html @@ -1,35 +1,64 @@ - - - - + + - - - - - - - - Viser - - - -
- - - + + Viser + + + + +
+ + + + \ No newline at end of file diff --git a/src/viser/client/src/WebsocketMessages.ts b/src/viser/client/src/WebsocketMessages.ts index 443b11df..cfdd9d91 100644 --- a/src/viser/client/src/WebsocketMessages.ts +++ b/src/viser/client/src/WebsocketMessages.ts @@ -735,6 +735,7 @@ export interface GuiSliderMessage { max: number; step: number; precision: number; + hideControls: boolean; _marks: { value: number; label: string | null }[] | null; }; } diff --git a/src/viser/client/src/components/Slider.tsx b/src/viser/client/src/components/Slider.tsx index 1df1dfe7..d45b2c58 100644 --- a/src/viser/client/src/components/Slider.tsx +++ b/src/viser/client/src/components/Slider.tsx @@ -22,6 +22,7 @@ export default function SliderComponent({ max, precision, step, + hideControls, _marks: marks, }, }: GuiSliderMessage) { @@ -30,7 +31,7 @@ export default function SliderComponent({ const updateValue = (value: number) => setValue(uuid, value); const colorScheme = useMantineColorScheme().colorScheme; const input = ( - +