diff --git a/dearpygui/_dearpygui.pyi b/dearpygui/_dearpygui.pyi index b821d6276..2559154d4 100644 --- a/dearpygui/_dearpygui.pyi +++ b/dearpygui/_dearpygui.pyi @@ -491,7 +491,7 @@ def add_simple_plot(*, label: str ='', user_data: Any ='', use_internal_label: b """Adds a simple plot for visualization of a 1 dimensional set of values.""" ... -def add_slider_double(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: float ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: float ='', max_value: float ='', format: str ='') -> Union[int, str]: +def add_slider_double(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: float ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: float ='', max_value: float ='', format: str ='', logarithmic: bool ='') -> Union[int, str]: """Adds slider for a single double value. Useful when slider float is not accurate enough. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes.""" ... @@ -499,7 +499,7 @@ def add_slider_doublex(*, label: str ='', user_data: Any ='', use_internal_label """Adds multi slider for up to 4 double values. Usueful for when multi slide float is not accurate enough. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes.""" ... -def add_slider_float(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: float ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: float ='', max_value: float ='', format: str ='') -> Union[int, str]: +def add_slider_float(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: float ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: float ='', max_value: float ='', format: str ='', logarithmic: bool ='') -> Union[int, str]: """Adds slider for a single float value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes.""" ... @@ -507,7 +507,7 @@ def add_slider_floatx(*, label: str ='', user_data: Any ='', use_internal_label: """Adds multi slider for up to 4 float values. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes.""" ... -def add_slider_int(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: int ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: int ='', max_value: int ='', format: str ='') -> Union[int, str]: +def add_slider_int(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', source: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', enabled: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_value: int ='', vertical: bool ='', no_input: bool ='', clamped: bool ='', min_value: int ='', max_value: int ='', format: str ='', logarithmic: bool ='') -> Union[int, str]: """Adds slider for a single int value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes.""" ... diff --git a/dearpygui/_dearpygui_RTD.py b/dearpygui/_dearpygui_RTD.py index be2649027..b6f5351af 100644 --- a/dearpygui/_dearpygui_RTD.py +++ b/dearpygui/_dearpygui_RTD.py @@ -5968,6 +5968,7 @@ def add_slider_double(**kwargs): min_value (float, optional): Applies a limit only to sliding entry only. max_value (float, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the float will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6043,6 +6044,7 @@ def add_slider_float(**kwargs): min_value (float, optional): Applies a limit only to sliding entry only. max_value (float, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the float will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6118,6 +6120,7 @@ def add_slider_int(**kwargs): min_value (int, optional): Applies a limit only to sliding entry only. max_value (int, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the int will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] diff --git a/dearpygui/dearpygui.py b/dearpygui/dearpygui.py index 3fecfaa12..7fcaca7b7 100644 --- a/dearpygui/dearpygui.py +++ b/dearpygui/dearpygui.py @@ -6678,7 +6678,7 @@ def add_simple_plot(*, label: str =None, user_data: Any =None, use_internal_labe return internal_dpg.add_simple_plot(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, overlay=overlay, histogram=histogram, autosize=autosize, min_scale=min_scale, max_scale=max_scale, **kwargs) -def add_slider_double(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: float =0.0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', **kwargs) -> Union[int, str]: +def add_slider_double(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: float =0.0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', logarithmic: bool =False, **kwargs) -> Union[int, str]: """ Adds slider for a single double value. Useful when slider float is not accurate enough. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. Args: @@ -6709,6 +6709,7 @@ def add_slider_double(*, label: str =None, user_data: Any =None, use_internal_la min_value (float, optional): Applies a limit only to sliding entry only. max_value (float, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the float will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6718,7 +6719,7 @@ def add_slider_double(*, label: str =None, user_data: Any =None, use_internal_la warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) tag=kwargs['id'] - return internal_dpg.add_slider_double(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, **kwargs) + return internal_dpg.add_slider_double(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, logarithmic=logarithmic, **kwargs) def add_slider_doublex(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: Any =(0.0, 0.0, 0.0, 0.0), size: int =4, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', **kwargs) -> Union[int, str]: """ Adds multi slider for up to 4 double values. Usueful for when multi slide float is not accurate enough. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. @@ -6761,7 +6762,7 @@ def add_slider_doublex(*, label: str =None, user_data: Any =None, use_internal_l return internal_dpg.add_slider_doublex(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, size=size, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, **kwargs) -def add_slider_float(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: float =0.0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', **kwargs) -> Union[int, str]: +def add_slider_float(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: float =0.0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', logarithmic: bool =False, **kwargs) -> Union[int, str]: """ Adds slider for a single float value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. Args: @@ -6792,6 +6793,7 @@ def add_slider_float(*, label: str =None, user_data: Any =None, use_internal_lab min_value (float, optional): Applies a limit only to sliding entry only. max_value (float, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the float will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6801,7 +6803,7 @@ def add_slider_float(*, label: str =None, user_data: Any =None, use_internal_lab warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) tag=kwargs['id'] - return internal_dpg.add_slider_float(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, **kwargs) + return internal_dpg.add_slider_float(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, logarithmic=logarithmic, **kwargs) def add_slider_floatx(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: Union[List[float], Tuple[float, ...]] =(0.0, 0.0, 0.0, 0.0), size: int =4, no_input: bool =False, clamped: bool =False, min_value: float =0.0, max_value: float =100.0, format: str ='%.3f', **kwargs) -> Union[int, str]: """ Adds multi slider for up to 4 float values. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. @@ -6844,7 +6846,7 @@ def add_slider_floatx(*, label: str =None, user_data: Any =None, use_internal_la return internal_dpg.add_slider_floatx(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, size=size, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, **kwargs) -def add_slider_int(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: int =0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: int =0, max_value: int =100, format: str ='%d', **kwargs) -> Union[int, str]: +def add_slider_int(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, height: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: int =0, vertical: bool =False, no_input: bool =False, clamped: bool =False, min_value: int =0, max_value: int =100, format: str ='%d', logarithmic: bool =False, **kwargs) -> Union[int, str]: """ Adds slider for a single int value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. Args: @@ -6875,6 +6877,7 @@ def add_slider_int(*, label: str =None, user_data: Any =None, use_internal_label min_value (int, optional): Applies a limit only to sliding entry only. max_value (int, optional): Applies a limit only to sliding entry only. format (str, optional): Determines the format the int will be displayed as use python string formatting. + logarithmic (bool, optional): Make the widget logarithmic (linear otherwise). id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6884,7 +6887,7 @@ def add_slider_int(*, label: str =None, user_data: Any =None, use_internal_label warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) tag=kwargs['id'] - return internal_dpg.add_slider_int(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, **kwargs) + return internal_dpg.add_slider_int(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, source=source, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, enabled=enabled, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_value=default_value, vertical=vertical, no_input=no_input, clamped=clamped, min_value=min_value, max_value=max_value, format=format, logarithmic=logarithmic, **kwargs) def add_slider_intx(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, width: int =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, source: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, enabled: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_value: Union[List[int], Tuple[int, ...]] =(0, 0, 0, 0), size: int =4, no_input: bool =False, clamped: bool =False, min_value: int =0, max_value: int =100, format: str ='%d', **kwargs) -> Union[int, str]: """ Adds multi slider for up to 4 int values. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes. diff --git a/src/mvAppItem.cpp b/src/mvAppItem.cpp index b5f393057..8062b53e3 100644 --- a/src/mvAppItem.cpp +++ b/src/mvAppItem.cpp @@ -2176,6 +2176,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Float, "min_value", mvArgType::KEYWORD_ARG, "0.0", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::Float, "max_value", mvArgType::KEYWORD_ARG, "100.0", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::String, "format", mvArgType::KEYWORD_ARG, "'%.3f'", "Determines the format the float will be displayed as use python string formatting." }); + args.push_back({ mvPyDataType::Bool, "logarithmic", mvArgType::KEYWORD_ARG, "False", "Make the widget logarithmic (linear otherwise)." }); setup.about = "Adds slider for a single float value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes."; break; @@ -2208,6 +2209,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Double, "min_value", mvArgType::KEYWORD_ARG, "0.0", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::Double, "max_value", mvArgType::KEYWORD_ARG, "100.0", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::String, "format", mvArgType::KEYWORD_ARG, "'%.3f'", "Determines the format the float will be displayed as use python string formatting." }); + args.push_back({ mvPyDataType::Bool, "logarithmic", mvArgType::KEYWORD_ARG, "False", "Make the widget logarithmic (linear otherwise)." }); setup.about = "Adds slider for a single double value. Useful when slider float is not accurate enough. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes."; break; @@ -2240,6 +2242,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Integer, "min_value", mvArgType::KEYWORD_ARG, "0", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::Integer, "max_value", mvArgType::KEYWORD_ARG, "100", "Applies a limit only to sliding entry only." }); args.push_back({ mvPyDataType::String, "format", mvArgType::KEYWORD_ARG, "'%d'", "Determines the format the int will be displayed as use python string formatting." }); + args.push_back({ mvPyDataType::Bool, "logarithmic", mvArgType::KEYWORD_ARG, "False", "Make the widget logarithmic (linear otherwise)." }); setup.about = "Adds slider for a single int value. Directly entry can be done with double click or CTRL+Click. Min and Max alone are a soft limit for the slider. Use clamped keyword to also apply limits to the direct entry modes."; break; diff --git a/src/mvBasicWidgets.cpp b/src/mvBasicWidgets.cpp index ab9ef1d9c..320500745 100644 --- a/src/mvBasicWidgets.cpp +++ b/src/mvBasicWidgets.cpp @@ -253,7 +253,6 @@ DearPyGui::fill_configuration_dict(const mvSliderIntConfig& inConfig, PyObject* return; PyDict_SetItemString(outDict, "format", mvPyObject(ToPyString(inConfig.format))); - PyDict_SetItemString(outDict, "vertical", mvPyObject(ToPyBool(inConfig.vertical))); PyDict_SetItemString(outDict, "min_value", mvPyObject(ToPyInt(inConfig.minv))); PyDict_SetItemString(outDict, "max_value", mvPyObject(ToPyInt(inConfig.maxv))); @@ -266,6 +265,8 @@ DearPyGui::fill_configuration_dict(const mvSliderIntConfig& inConfig, PyObject* // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); + checkbitset("vertical", ImGuiSliderFlags_Vertical, inConfig.flags); + checkbitset("logarithmic", ImGuiSliderFlags_Logarithmic, inConfig.flags); } void @@ -297,7 +298,6 @@ DearPyGui::fill_configuration_dict(const mvSliderFloatConfig& inConfig, PyObject return; PyDict_SetItemString(outDict, "format", mvPyObject(ToPyString(inConfig.format))); - PyDict_SetItemString(outDict, "vertical", mvPyObject(ToPyBool(inConfig.vertical))); PyDict_SetItemString(outDict, "min_value", mvPyObject(ToPyFloat(inConfig.minv))); PyDict_SetItemString(outDict, "max_value", mvPyObject(ToPyFloat(inConfig.maxv))); @@ -310,6 +310,8 @@ DearPyGui::fill_configuration_dict(const mvSliderFloatConfig& inConfig, PyObject // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); + checkbitset("vertical", ImGuiSliderFlags_Vertical, inConfig.flags); + checkbitset("logarithmic", ImGuiSliderFlags_Logarithmic, inConfig.flags); } void @@ -350,7 +352,6 @@ DearPyGui::fill_configuration_dict(const mvSliderDoubleConfig& inConfig, PyObjec return; PyDict_SetItemString(outDict, "format", mvPyObject(ToPyString(inConfig.format))); - PyDict_SetItemString(outDict, "vertical", mvPyObject(ToPyBool(inConfig.vertical))); PyDict_SetItemString(outDict, "min_value", mvPyObject(ToPyDouble(inConfig.minv))); PyDict_SetItemString(outDict, "max_value", mvPyObject(ToPyDouble(inConfig.maxv))); @@ -363,6 +364,8 @@ DearPyGui::fill_configuration_dict(const mvSliderDoubleConfig& inConfig, PyObjec // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); + checkbitset("vertical", ImGuiSliderFlags_Vertical, inConfig.flags); + checkbitset("logarithmic", ImGuiSliderFlags_Logarithmic, inConfig.flags); } void @@ -975,7 +978,6 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderIntConfig& outConfig, mvA return; if (PyObject* item = PyDict_GetItemString(inDict, "format")) outConfig.format = ToString(item); - if (PyObject* item = PyDict_GetItemString(inDict, "vertical")) outConfig.vertical = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "min_value")) outConfig.minv = ToInt(item); if (PyObject* item = PyDict_GetItemString(inDict, "max_value")) outConfig.maxv = ToInt(item); @@ -1027,6 +1029,10 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderIntMultiConfig& outConfig flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.stor_flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.stor_flags); if (info.enabledLastFrame) { @@ -1049,7 +1055,6 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderFloatConfig& outConfig, m return; if (PyObject* item = PyDict_GetItemString(inDict, "format")) outConfig.format = ToString(item); - if (PyObject* item = PyDict_GetItemString(inDict, "vertical")) outConfig.vertical = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "min_value")) outConfig.minv = ToFloat(item); if (PyObject* item = PyDict_GetItemString(inDict, "max_value")) outConfig.maxv = ToFloat(item); @@ -1102,6 +1107,10 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderFloatMultiConfig& outConf flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.stor_flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.stor_flags); if (info.enabledLastFrame) { @@ -1125,7 +1134,6 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderDoubleConfig& outConfig, return; if (PyObject* item = PyDict_GetItemString(inDict, "format")) outConfig.format = ToString(item); - if (PyObject* item = PyDict_GetItemString(inDict, "vertical")) outConfig.vertical = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "min_value")) outConfig.minv = ToDouble(item); if (PyObject* item = PyDict_GetItemString(inDict, "max_value")) outConfig.maxv = ToDouble(item); @@ -1178,6 +1186,10 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderDoubleMultiConfig& outCon flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.flags); + flagop("vertical", ImGuiSliderFlags_Vertical, outConfig.stor_flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.flags); + flagop("logarithmic", ImGuiSliderFlags_Logarithmic, outConfig.stor_flags); if (info.enabledLastFrame) { @@ -2574,16 +2586,11 @@ DearPyGui::set_data_source(mvAppItem& item, mvUUID dataSource, mvProgressBarConf // [SECTION] draw commands //----------------------------------------------------------------------------- -void -DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimplePlotConfig& config) -{ - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - +bool pre_draw(mvAppItem& item) +{ // show/hide if (!item.config.show) - return; + return false; // focusing if (item.info.focusNextFrame) @@ -2593,7 +2600,7 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl } // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); + item.info.previousCursorPos = ImGui::GetCursorPos(); // set cursor position if user set if (item.info.dirtyPos) @@ -2620,6 +2627,40 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl // themes apply_local_theming(&item); + return true; +} + +void post_draw(mvAppItem& item) +{ + // set cursor position to cached position + if (item.info.dirtyPos) + ImGui::SetCursorPos(item.info.previousCursorPos); + + if (item.config.indent > 0.0f) + ImGui::Unindent(item.config.indent); + + // pop font off stack + if (item.font) + ImGui::PopFont(); + + // handle popping themes + cleanup_local_theming(&item); + + if (item.handlerRegistry) + item.handlerRegistry->checkEvents(&item.state); + + // handle drag & drop if used + apply_drag_drop(&item); +} + +void +DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimplePlotConfig& config) +{ + bool is_shown = pre_draw(item); + + if (!is_shown) + return; + //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -2656,79 +2697,19 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl item.state.rectSize = { ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y }; item.state.contextRegionAvail = { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y }; - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_button(ImDrawList* drawlist, mvAppItem& item, const mvButtonConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - ImGui::PushItemFlag(ImGuiItemFlags_ButtonRepeat, config.repeat); - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -2761,80 +2742,19 @@ DearPyGui::draw_button(ImDrawList* drawlist, mvAppItem& item, const mvButtonConf //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - ImGui::PopItemFlag(); - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_combo(ImDrawList* drawlist, mvAppItem& item, mvComboConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -2878,76 +2798,17 @@ DearPyGui::draw_combo(ImDrawList* drawlist, mvAppItem& item, mvComboConfig& conf } } - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_checkbox(ImDrawList* drawlist, mvAppItem& item, mvCheckboxConfig& config) -{ - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) +{ + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -2973,80 +2834,21 @@ DearPyGui::draw_checkbox(ImDrawList* drawlist, mvAppItem& item, mvCheckboxConfig //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_float(ImDrawList* drawlist, mvAppItem& item, mvDragFloatConfig& config) { ScopedID id(item.uuid); + + bool is_shown = pre_draw(item); + + if (!is_shown) + return; //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) - return; - - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - - //----------------------------------------------------------------------------- - // draw + // draw //----------------------------------------------------------------------------- { @@ -3070,79 +2872,19 @@ DearPyGui::draw_drag_float(ImDrawList* drawlist, mvAppItem& item, mvDragFloatCon //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_double(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleConfig& config) { ScopedID id(item.uuid); - - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3168,77 +2910,17 @@ DearPyGui::draw_drag_double(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleC //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_int(ImDrawList* drawlist, mvAppItem& item, mvDragIntConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3269,78 +2951,17 @@ DearPyGui::draw_drag_int(ImDrawList* drawlist, mvAppItem& item, mvDragIntConfig& //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_intx(ImDrawList* drawlist, mvAppItem& item, mvDragIntMultiConfig& config) { - //----------------------------------------------------------------------------- -// pre draw -//----------------------------------------------------------------------------- - -// show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3386,77 +3007,17 @@ DearPyGui::draw_drag_intx(ImDrawList* drawlist, mvAppItem& item, mvDragIntMultiC //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_floatx(ImDrawList* drawlist, mvAppItem& item, mvDragFloatMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3500,77 +3061,17 @@ DearPyGui::draw_drag_floatx(ImDrawList* drawlist, mvAppItem& item, mvDragFloatMu //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_drag_doublex(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3602,77 +3103,17 @@ DearPyGui::draw_drag_doublex(ImDrawList* drawlist, mvAppItem& item, mvDragDouble //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloatConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3681,7 +3122,7 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa if (!item.config.enabled) config.disabled_value = *config.value; - if (config.vertical) + if (ImHasFlag(config.flags, ImGuiSliderFlags_Vertical)) { if ((float)item.config.height < 1.0f) item.config.height = 100; @@ -3718,77 +3159,17 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDoubleConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -3797,7 +3178,7 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou if (!item.config.enabled) config.disabled_value = *config.value; - if (config.vertical) + if (ImHasFlag(config.flags, ImGuiSliderFlags_Vertical)) { if ((float)item.config.height < 1.0f) item.config.height = 100; @@ -3814,96 +3195,36 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou mvSubmitCallback([&item, value]() { mvAddCallback(item.getCallback(false), item.config.alias, ToPyDouble(value), item.config.user_data); }); } - } - else - { - if (ImGui::SliderScalar(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value.get() : &config.disabled_value, &config.minv, &config.maxv, config.format.c_str(), config.flags)) - { - auto value = *config.value; - if (item.config.alias.empty()) - mvSubmitCallback([&item, value]() {mvAddCallback(item.getCallback(false), item.uuid, ToPyDouble(value), item.config.user_data); }); - else - mvSubmitCallback([&item, value]() {mvAddCallback(item.getCallback(false), item.config.alias, ToPyDouble(value), item.config.user_data); }); - } - - } - } - - //----------------------------------------------------------------------------- - // update state - //----------------------------------------------------------------------------- - UpdateAppItemState(item.state); - - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); -} - -void -DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFloatMultiConfig& config) -{ - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) - return; - - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); + } + else + { + if (ImGui::SliderScalar(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value.get() : &config.disabled_value, &config.minv, &config.maxv, config.format.c_str(), config.flags)) + { + auto value = *config.value; + if (item.config.alias.empty()) + mvSubmitCallback([&item, value]() {mvAddCallback(item.getCallback(false), item.uuid, ToPyDouble(value), item.config.user_data); }); + else + mvSubmitCallback([&item, value]() {mvAddCallback(item.getCallback(false), item.config.alias, ToPyDouble(value), item.config.user_data); }); + } - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); + } } - // themes - apply_local_theming(&item); + //----------------------------------------------------------------------------- + // update state + //----------------------------------------------------------------------------- + UpdateAppItemState(item.state); + + post_draw(item); +} + +void +DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFloatMultiConfig& config) +{ + bool is_shown = pre_draw(item); + + if (!is_shown) + return; //----------------------------------------------------------------------------- // draw @@ -3946,77 +3267,17 @@ DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFlo //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_slider_doublex(ImDrawList* drawlist, mvAppItem& item, mvSliderDoubleMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4046,77 +3307,17 @@ DearPyGui::draw_slider_doublex(ImDrawList* drawlist, mvAppItem& item, mvSliderDo //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4125,7 +3326,7 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon if (!item.config.enabled) config.disabled_value = *config.value; - if (config.vertical) + if (ImHasFlag(config.flags, ImGuiSliderFlags_Vertical)) { if ((float)item.config.height < 1.0f) item.config.height = 100; @@ -4162,77 +3363,17 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_slider_intx(ImDrawList* drawlist, mvAppItem& item, mvSliderIntMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4274,76 +3415,16 @@ DearPyGui::draw_slider_intx(ImDrawList* drawlist, mvAppItem& item, mvSliderIntMu //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_listbox(ImDrawList *drawlist, mvAppItem &item, mvListboxConfig &config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) - return; - - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); + bool is_shown = pre_draw(item); + + if (!is_shown) + return; //----------------------------------------------------------------------------- // draw @@ -4386,77 +3467,17 @@ DearPyGui::draw_listbox(ImDrawList *drawlist, mvAppItem &item, mvListboxConfig & //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_radio_button(ImDrawList* drawlist, mvAppItem& item, mvRadioButtonConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4520,77 +3541,17 @@ DearPyGui::draw_radio_button(ImDrawList* drawlist, mvAppItem& item, mvRadioButto item.state.rectSize = { ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y }; item.state.contextRegionAvail = { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y }; - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_text(ImDrawList* drawlist, mvAppItem& item, mvInputTextConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4633,77 +3594,17 @@ DearPyGui::draw_input_text(ImDrawList* drawlist, mvAppItem& item, mvInputTextCon //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_int(ImDrawList* drawlist, mvAppItem& item, mvInputIntConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4755,77 +3656,17 @@ DearPyGui::draw_input_int(ImDrawList* drawlist, mvAppItem& item, mvInputIntConfi //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_floatx(ImDrawList* drawlist, mvAppItem& item, mvInputFloatMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -4897,85 +3738,24 @@ DearPyGui::draw_input_floatx(ImDrawList* drawlist, mvAppItem& item, mvInputFloat } } - } - - //----------------------------------------------------------------------------- - // update state - //----------------------------------------------------------------------------- - UpdateAppItemState(item.state); - - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); + } - // handle drag & drop if used - apply_drag_drop(&item); + //----------------------------------------------------------------------------- + // update state + //----------------------------------------------------------------------------- + UpdateAppItemState(item.state); + post_draw(item); } void DearPyGui::draw_input_float(ImDrawList* drawlist, mvAppItem& item, mvInputFloatConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5026,77 +3806,17 @@ DearPyGui::draw_input_float(ImDrawList* drawlist, mvAppItem& item, mvInputFloatC //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_knob_float(ImDrawList* drawlist, mvAppItem& item, mvKnobFloatConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5123,77 +3843,17 @@ DearPyGui::draw_knob_float(ImDrawList* drawlist, mvAppItem& item, mvKnobFloatCon //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_double(ImDrawList* drawlist, mvAppItem& item, mvInputDoubleConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //-----------------------------------------------------------------------------(void*)(step > 0 ? &step : NULL), (void*)(step_fast > 0 ? &step_fast : NULL) @@ -5244,77 +3904,17 @@ DearPyGui::draw_input_double(ImDrawList* drawlist, mvAppItem& item, mvInputDoubl //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_doublex(ImDrawList* drawlist, mvAppItem& item, mvInputDoubleMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5367,92 +3967,32 @@ DearPyGui::draw_input_doublex(ImDrawList* drawlist, mvAppItem& item, mvInputDoub mvSubmitCallback([&item, value]() { mvAddCallback(item.getCallback(false), item.uuid, ToPyFloatList(value.data(), (int)value.size()), item.config.user_data); }); - else - mvSubmitCallback([&item, value]() { - mvAddCallback(item.getCallback(false), item.config.alias, ToPyFloatList(value.data(), (int)value.size()), item.config.user_data); - }); - } - } - - } - - //----------------------------------------------------------------------------- - // update state - //----------------------------------------------------------------------------- - UpdateAppItemState(item.state); - - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); + else + mvSubmitCallback([&item, value]() { + mvAddCallback(item.getCallback(false), item.config.alias, ToPyFloatList(value.data(), (int)value.size()), item.config.user_data); + }); + } + } - // handle popping themes - cleanup_local_theming(&item); + } - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); + //----------------------------------------------------------------------------- + // update state + //----------------------------------------------------------------------------- + UpdateAppItemState(item.state); - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_input_intx(ImDrawList* drawlist, mvAppItem& item, mvInputIntMultiConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5530,68 +4070,17 @@ DearPyGui::draw_input_intx(ImDrawList* drawlist, mvAppItem& item, mvInputIntMult //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_text(ImDrawList* drawlist, mvAppItem& item, mvTextConfig& config) { - //----------------------------------------------------------------------------- - // predraw - //----------------------------------------------------------------------------- - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - item.info.previousCursorPos = ImGui::GetCursorPos(); - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5665,76 +4154,17 @@ DearPyGui::draw_text(ImDrawList* drawlist, mvAppItem& item, mvTextConfig& config } } - //----------------------------------------------------------------------------- - // postdraw - //----------------------------------------------------------------------------- - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.info.previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - if (item.font) - { - ImGui::PopFont(); - } - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop payloads - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_selectable(ImDrawList* drawlist, mvAppItem& item, mvSelectableConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5757,77 +4187,17 @@ DearPyGui::draw_selectable(ImDrawList* drawlist, mvAppItem& item, mvSelectableCo //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_tab_button(ImDrawList* drawlist, mvAppItem& item, mvTabButtonConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5838,87 +4208,27 @@ DearPyGui::draw_tab_button(ImDrawList* drawlist, mvAppItem& item, mvTabButtonCon { if (item.config.alias.empty()) mvAddCallback(item.getCallback(false), item.uuid, nullptr, item.config.user_data); - else - mvAddCallback(item.getCallback(false), item.config.alias, nullptr, item.config.user_data); - } - } - - //----------------------------------------------------------------------------- - // update state - //----------------------------------------------------------------------------- - UpdateAppItemState(item.state); - - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); + else + mvAddCallback(item.getCallback(false), item.config.alias, nullptr, item.config.user_data); + } + } - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); + //----------------------------------------------------------------------------- + // update state + //----------------------------------------------------------------------------- + UpdateAppItemState(item.state); - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_menu_item(ImDrawList* drawlist, mvAppItem& item, mvMenuItemConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -5951,77 +4261,17 @@ DearPyGui::draw_menu_item(ImDrawList* drawlist, mvAppItem& item, mvMenuItemConfi //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_progress_bar(ImDrawList* drawlist, mvAppItem& item, mvProgressBarConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -6038,77 +4288,17 @@ DearPyGui::draw_progress_bar(ImDrawList* drawlist, mvAppItem& item, mvProgressBa //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -6150,77 +4340,17 @@ DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& conf //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButtonConfig& config) { - //----------------------------------------------------------------------------- - // pre draw - //----------------------------------------------------------------------------- - - // show/hide - if (!item.config.show) + bool is_shown = pre_draw(item); + + if (!is_shown) return; - // focusing - if (item.info.focusNextFrame) - { - ImGui::SetKeyboardFocusHere(); - item.info.focusNextFrame = false; - } - - // cache old cursor position - ImVec2 previousCursorPos = ImGui::GetCursorPos(); - - // set cursor position if user set - if (item.info.dirtyPos) - ImGui::SetCursorPos(item.state.pos); - - // update widget's position state - item.state.pos = { ImGui::GetCursorPosX(), ImGui::GetCursorPosY() }; - - // set item width - if (item.config.width != 0) - ImGui::SetNextItemWidth((float)item.config.width); - - // set indent - if (item.config.indent > 0.0f) - ImGui::Indent(item.config.indent); - - // push font if a font object is attached - if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } - - // themes - apply_local_theming(&item); - //----------------------------------------------------------------------------- // draw //----------------------------------------------------------------------------- @@ -6276,29 +4406,7 @@ DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButto //----------------------------------------------------------------------------- UpdateAppItemState(item.state); - //----------------------------------------------------------------------------- - // post draw - //----------------------------------------------------------------------------- - - // set cursor position to cached position - if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); - - if (item.config.indent > 0.0f) - ImGui::Unindent(item.config.indent); - - // pop font off stack - if (item.font) - ImGui::PopFont(); - - // handle popping themes - cleanup_local_theming(&item); - - if (item.handlerRegistry) - item.handlerRegistry->checkEvents(&item.state); - - // handle drag & drop if used - apply_drag_drop(&item); + post_draw(item); } void diff --git a/src/mvBasicWidgets.h b/src/mvBasicWidgets.h index 576d14239..71ef1da3b 100644 --- a/src/mvBasicWidgets.h +++ b/src/mvBasicWidgets.h @@ -239,151 +239,123 @@ struct mvCheckboxConfig bool disabled_value = false; }; -struct mvDragFloatConfig +/* To be used with mv<...>GenericConfig */ +template +struct mvSingleValueConfig { - float speed = 1.0f; - float minv = 0.0f; - float maxv = 100.0f; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0.0f); - float disabled_value = 0.0f; + std::shared_ptr value = std::make_shared(0); + T disabled_value = 0; }; -struct mvDragDoubleConfig +/* To be used with mv<...>GenericConfig */ +template +struct mvMultiValueConfig { - float speed = 1.0f; - double minv = 0.0; - double maxv = 100.0; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0.0); - double disabled_value = 0.0; + int size = 4; + std::shared_ptr> value = std::make_shared>(std::array{}); + T disabled_value[4]{}; }; -struct mvDragIntConfig +template +struct mvDragGenericConfig { float speed = 1.0f; - int minv = 0; - int maxv = 100; - std::string format = "%d"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0); - int disabled_value = 0; -}; - -struct mvDragIntMultiConfig -{ - float speed = 1.0f; - int minv = 0; - int maxv = 100; - std::string format = "%d"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0, 0, 0, 0}); - int disabled_value[4]{}; -}; - -struct mvDragFloatMultiConfig -{ - float speed = 1.0f; - float minv = 0.0f; - float maxv = 100.0f; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0.0f, 0.0f, 0.0f, 0.0f}); - float disabled_value[4]{}; -}; - -struct mvDragDoubleMultiConfig -{ - float speed = 1.0f; - double minv = 0.0; - double maxv = 100.0; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr>value = std::make_shared>(std::array{0.0, 0.0, 0.0, 0.0}); - double disabled_value[4]{}; -}; - -struct mvSliderIntConfig -{ - int minv = 0; - int maxv = 100; - std::string format = "%d"; - bool vertical = false; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0); - int disabled_value = 0; -}; - -struct mvSliderFloatConfig -{ - float minv = 0.0f; - float maxv = 100.0f; - std::string format = "%.3f"; - bool vertical = false; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0.0f); - float disabled_value = 0.0f; + ImGuiSliderFlags flags = ImGuiSliderFlags_None; + ImGuiSliderFlags stor_flags = ImGuiSliderFlags_None; + T minv = static_cast(0); + T maxv = static_cast(100); +}; + +template +struct mvSliderGenericConfig +{ + ImGuiSliderFlags flags = ImGuiSliderFlags_None; + ImGuiSliderFlags stor_flags = ImGuiSliderFlags_None; + T minv = static_cast(0); + T maxv = static_cast(100); +}; + +template +struct mvInputGenericConfig +{ + bool min_clamped = false; + bool max_clamped = false; + T minv = 0; + T maxv = 100; + ImGuiInputFlags flags = ImGuiInputFlags_None; + ImGuiInputFlags stor_flags = ImGuiInputFlags_None; +}; + +template +struct mvSingleDragGenericConfig : mvSingleValueConfig, mvDragGenericConfig {}; + +template +struct mvMultiDragGenericConfig : mvMultiValueConfig, mvDragGenericConfig {}; + +struct mvDragFloatConfig : mvSingleDragGenericConfig +{ + std::string format = "%.3f"; +}; + +struct mvDragDoubleConfig : mvSingleDragGenericConfig +{ + std::string format = "%.3f"; +}; + +struct mvDragIntConfig : mvSingleDragGenericConfig +{ + std::string format = "%d"; +}; + +struct mvDragIntMultiConfig : mvMultiDragGenericConfig +{ + std::string format = "%d"; +}; + +struct mvDragFloatMultiConfig : mvMultiDragGenericConfig +{ + std::string format = "%.3f"; +}; + +struct mvDragDoubleMultiConfig : mvMultiDragGenericConfig +{ + std::string format = "%.3f"; +}; + +template +struct mvSingleSliderGenericConfig : mvSingleValueConfig, mvSliderGenericConfig {}; + +template +struct mvMultiSliderGenericConfig : mvMultiValueConfig, mvSliderGenericConfig {}; + +struct mvSliderIntConfig : mvSingleSliderGenericConfig +{ + std::string format = "%d"; +}; + +struct mvSliderFloatConfig : mvSingleSliderGenericConfig +{ + std::string format = "%.3f"; }; -struct mvSliderDoubleConfig +struct mvSliderDoubleConfig : mvSingleSliderGenericConfig { - double minv = 0.0; - double maxv = 100.0; - std::string format = "%.3f"; - bool vertical = false; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - std::shared_ptr value = std::make_shared(0.0); - double disabled_value = 0.0; + std::string format = "%.3f"; }; -struct mvSliderFloatMultiConfig +struct mvSliderFloatMultiConfig : mvMultiSliderGenericConfig { - float minv = 0.0f; - float maxv = 100.0f; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0.0f, 0.0f, 0.0f, 0.0f}); - float disabled_value[4]{}; + std::string format = "%.3f"; }; -struct mvSliderIntMultiConfig +struct mvSliderIntMultiConfig : mvMultiSliderGenericConfig { - int minv = 0; - int maxv = 100; - std::string format = "%d"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0, 0, 0, 0}); - int disabled_value[4]{}; + std::string format = "%d"; }; -struct mvSliderDoubleMultiConfig +struct mvSliderDoubleMultiConfig : mvMultiSliderGenericConfig { - double minv = 0.0; - double maxv = 100.0; - std::string format = "%d"; - ImGuiInputTextFlags flags = ImGuiSliderFlags_None; - ImGuiInputTextFlags stor_flags = ImGuiSliderFlags_None; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0.0, 0.0, 0.0, 0.0}); - double disabled_value[4]{}; + std::string format = "%.3f"; }; struct mvListboxConfig @@ -411,101 +383,57 @@ struct mvInputTextConfig { std::string hint; bool multiline = false; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; + ImGuiInputTextFlags flags = ImGuiInputTextFlags_None; + ImGuiInputTextFlags stor_flags = ImGuiInputTextFlags_None; std::shared_ptr value = std::make_shared(""); std::string disabled_value = ""; }; -struct mvInputIntConfig +template +struct mvSingleInputGenericConfig : mvSingleValueConfig, mvInputGenericConfig +{ + T last_value = 0; +}; + +template +struct mvMultiInputGenericConfig : mvMultiValueConfig, mvInputGenericConfig +{ + std::array last_value = {}; +}; + +struct mvInputIntConfig : mvSingleInputGenericConfig { int step = 1; int step_fast = 100; - int minv = 0; - int maxv = 100; - bool min_clamped = false; - bool max_clamped = false; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - int last_value = 0; - std::shared_ptr value = std::make_shared(0); - int disabled_value = 0; }; -struct mvInputFloatConfig +struct mvInputFloatConfig : mvSingleInputGenericConfig { - float minv = 0.0f; - float maxv = 100.0f; - bool min_clamped = false; - bool max_clamped = false; std::string format = "%.3f"; float step = 0.1f; float step_fast = 1.0f; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - float last_value = 0.0f; - std::shared_ptr value = std::make_shared(0.0f); - float disabled_value = 0.0f; }; -struct mvInputDoubleConfig +struct mvInputDoubleConfig : mvSingleInputGenericConfig { - double minv = 0.0; - double maxv = 100.0; - bool min_clamped = false; - bool max_clamped = false; std::string format = "%.3f"; double step = 0.1; double step_fast = 1.0; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - double last_value = 0.0; - std::shared_ptr value = std::make_shared(0.0); - double disabled_value = 0.0; -}; - -struct mvInputFloatMultiConfig -{ - float minv = 0.0f; - float maxv = 100.0f; - bool min_clamped = false; - bool max_clamped = false; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - std::array last_value = { 0.0f, 0.0f, 0.0f, 0.0f }; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0.0f, 0.0f, 0.0f, 0.0f}); - float disabled_value[4]{}; -}; - -struct mvInputIntMultiConfig -{ - int minv = 0; - int maxv = 100; - bool min_clamped = false; - bool max_clamped = false; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - std::array last_value = { 0, 0, 0, 0 }; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0, 0, 0, 0}); - int disabled_value[4]{}; -}; - -struct mvInputDoubleMultiConfig -{ - double minv = 0.0; - double maxv = 100.0; - bool min_clamped = false; - bool max_clamped = false; - std::string format = "%.3f"; - ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; - std::array last_value = { 0.0f, 0.0f, 0.0f, 0.0f }; - int size = 4; - std::shared_ptr> value = std::make_shared>(std::array{0.0, 0.0, 0.0, 0.0}); - double disabled_value[4]{}; +}; + +struct mvInputFloatMultiConfig : mvMultiInputGenericConfig +{ + std::string format = "%.3f"; +}; + +struct mvInputIntMultiConfig : mvMultiInputGenericConfig +{ + std::string format = "%d"; +}; + +struct mvInputDoubleMultiConfig : mvMultiInputGenericConfig +{ + std::string format = "%.3f"; }; struct mvTextConfig