diff --git a/CMakeLists.txt b/CMakeLists.txt index adb1bce8d..930317b96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,22 @@ -cmake_minimum_required (VERSION 3.13) +cmake_minimum_required (VERSION 3.16) -project ("DearPyGui") +if(APPLE) + # When using precompiled headers on macOS, we need to enable Objective-C + # as a distinct language. This won't work on other platforms (will fail to + # find the Obj-C compiler), hence the "if APPLE". + project ("DearPyGui" LANGUAGES C CXX OBJC OBJCXX) +else() + project ("DearPyGui") +endif() if(WIN32) - add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig.h") + add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_win32.h") add_definitions(-DMV_PLATFORM="windows") elseif(APPLE) - add_definitions(-DIMGUI_USER_CONFIG="mvImGuiLinuxConfig.h") + add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_apple.h") add_definitions(-DMV_PLATFORM="apple") else() # Linux - add_definitions(-DIMGUI_USER_CONFIG="mvImGuiLinuxConfig.h") + add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_linux.h") add_definitions(-DMV_PLATFORM="linux") endif() diff --git a/dearpygui/_dearpygui.pyi b/dearpygui/_dearpygui.pyi index ad6bdbcf9..c5c1acb16 100644 --- a/dearpygui/_dearpygui.pyi +++ b/dearpygui/_dearpygui.pyi @@ -66,7 +66,7 @@ def add_collapsing_header(*, label: str ='', user_data: Any ='', use_internal_la """Adds a collapsing header to add items to. Must be closed with the end command.""" ... -def add_color_button(default_value : Union[List[int], Tuple[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] ='', 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 ='', no_alpha: bool ='', no_border: bool ='', no_drag_drop: bool ='') -> Union[int, str]: +def add_color_button(default_value : Union[List[int], Tuple[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] ='', 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 ='', no_alpha: bool ='', no_border: bool ='', no_drag_drop: bool ='', alpha_preview: int ='', no_tooltip: bool ='') -> Union[int, str]: """Adds a color button.""" ... @@ -210,22 +210,10 @@ def add_float_vect_value(*, label: str ='', user_data: Any ='', use_internal_lab """Adds a float vect value.""" ... -def add_font(file : str, size : int, *, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', pixel_snapH: bool ='', parent: Union[int, str] ='') -> Union[int, str]: +def add_font(file : str, size : int, *, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', pixel_snapH: bool ='', pixel_snapV: bool ='', parent: Union[int, str] ='') -> Union[int, str]: """Adds font to a font registry.""" ... -def add_font_chars(chars : Union[List[int], Tuple[int, ...]], *, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', parent: Union[int, str] ='') -> Union[int, str]: - """Adds specific font characters to a font.""" - ... - -def add_font_range(first_char : int, last_char : int, *, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', parent: Union[int, str] ='') -> Union[int, str]: - """Adds a range of font characters to a font.""" - ... - -def add_font_range_hint(hint : int, *, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', parent: Union[int, str] ='') -> Union[int, str]: - """Adds a range of font characters (mvFontRangeHint_ constants).""" - ... - def add_font_registry(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', show: bool ='') -> Union[int, str]: """Adds a font registry.""" ... @@ -263,31 +251,31 @@ def add_inf_line_series(x : Union[List[float], Tuple[float, ...]], *, label: str """Adds an infinite line series to a plot.""" ... -def add_input_double(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', format: str ='', min_value: float ='', max_value: float ='', step: float ='', step_fast: float ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_double(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', format: str ='', min_value: float ='', max_value: float ='', step: float ='', step_fast: float ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds input for an double. Useful when input float is not accurate enough. +/- buttons can be activated by setting the value of step.""" ... -def add_input_doublex(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Any ='', format: str ='', min_value: float ='', max_value: float ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_doublex(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Any ='', format: str ='', min_value: float ='', max_value: float ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds multi double input for up to 4 double values. Useful when input float mulit is not accurate enough.""" ... -def add_input_float(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', format: str ='', min_value: float ='', max_value: float ='', step: float ='', step_fast: float ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_float(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', format: str ='', min_value: float ='', max_value: float ='', step: float ='', step_fast: float ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds input for an float. +/- buttons can be activated by setting the value of step.""" ... -def add_input_floatx(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Union[List[float], Tuple[float, ...]] ='', format: str ='', min_value: float ='', max_value: float ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_floatx(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Union[List[float], Tuple[float, ...]] ='', format: str ='', min_value: float ='', max_value: float ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds multi float input for up to 4 float values.""" ... -def add_input_int(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', min_value: int ='', max_value: int ='', step: int ='', step_fast: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_int(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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 ='', min_value: int ='', max_value: int ='', step: int ='', step_fast: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds input for an int. +/- buttons can be activated by setting the value of step.""" ... -def add_input_intx(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Union[List[int], Tuple[int, ...]] ='', min_value: int ='', max_value: int ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='') -> Union[int, str]: +def add_input_intx(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: 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: Union[List[int], Tuple[int, ...]] ='', min_value: int ='', max_value: int ='', size: int ='', min_clamped: bool ='', max_clamped: bool ='', on_enter: bool ='', readonly: bool ='', accept_empty_input: bool ='', display_empty_value: bool ='') -> Union[int, str]: """Adds multi int input for up to 4 integer values.""" ... -def add_input_text(*, 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: str ='', hint: str ='', multiline: bool ='', no_spaces: bool ='', uppercase: bool ='', tab_input: bool ='', decimal: bool ='', hexadecimal: bool ='', readonly: bool ='', password: bool ='', scientific: bool ='', on_enter: bool ='', auto_select_all: bool ='', ctrl_enter_for_new_line: bool ='', no_horizontal_scroll: bool ='', always_overwrite: bool ='', no_undo_redo: bool ='', escape_clears_all: bool ='') -> Union[int, str]: +def add_input_text(*, 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: str ='', hint: str ='', multiline: bool ='', no_spaces: bool ='', uppercase: bool ='', tab_input: bool ='', decimal: bool ='', hexadecimal: bool ='', readonly: bool ='', password: bool ='', scientific: bool ='', on_enter: bool ='', auto_select_all: bool ='', ctrl_enter_for_new_line: bool ='', no_horizontal_scroll: bool ='', always_overwrite: bool ='', no_undo_redo: bool ='', escape_clears_all: bool ='', elide_left: bool ='') -> Union[int, str]: """Adds input for text.""" ... @@ -475,7 +463,7 @@ def add_scatter_series(x : Union[List[float], Tuple[float, ...]], y : Union[List """Adds a scatter series to a plot.""" ... -def add_selectable(*, 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: bool ='', span_columns: bool ='', disable_popup_close: bool ='') -> Union[int, str]: +def add_selectable(*, 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: bool ='', span_columns: bool ='', disable_popup_close: bool ='', select_on_nav: bool ='') -> Union[int, str]: """Adds a selectable. Similar to a button but can indicate its selected state.""" ... @@ -551,15 +539,15 @@ def add_synced_tables(*, label: str ='', user_data: Any ='', use_internal_label: """Links all tables that are immediate children of this container so that they share their state (mostly column sizes). Other children are rendered as is. This is an experimental feature, use with caution.""" ... -def add_tab(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', drop_callback: Callable ='', show: bool ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', closable: bool ='', no_tooltip: bool ='', order_mode: int ='') -> Union[int, str]: +def add_tab(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', drop_callback: Callable ='', show: bool ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', closable: bool ='', no_tooltip: bool ='', order_mode: int ='', unsaved_document: bool ='', no_close_with_middle_click: bool ='', no_reorder: bool ='') -> Union[int, str]: """Adds a tab to a tab bar.""" ... -def add_tab_bar(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', callback: Callable ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', reorderable: bool ='') -> Union[int, str]: +def add_tab_bar(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', callback: Callable ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', reorderable: bool ='', tab_list_popup_button: bool ='', no_close_with_middle_click: bool ='', no_scrolling_buttons: bool ='', no_tooltip: bool ='', draw_selected_overline: bool ='') -> Union[int, str]: """Adds a tab bar.""" ... -def add_tab_button(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', no_reorder: bool ='', leading: bool ='', trailing: bool ='', no_tooltip: bool ='') -> Union[int, str]: +def add_tab_button(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', callback: Callable ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', no_reorder: bool ='', leading: bool ='', trailing: bool ='', no_tooltip: bool ='', unsaved_document: bool ='') -> Union[int, str]: """Adds a tab button to a tab bar.""" ... @@ -619,7 +607,7 @@ def add_tooltip(parent : Union[int, str], *, label: str ='', user_data: Any ='', """Adds a tooltip window.""" ... -def add_tree_node(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_open: bool ='', open_on_double_click: bool ='', open_on_arrow: bool ='', leaf: bool ='', bullet: bool ='', selectable: bool ='', span_text_width: bool ='', span_full_width: bool ='') -> Union[int, str]: +def add_tree_node(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', indent: int ='', parent: Union[int, str] ='', before: Union[int, str] ='', payload_type: str ='', drag_callback: Callable ='', drop_callback: Callable ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', filter_key: str ='', tracked: bool ='', track_offset: float ='', default_open: bool ='', open_on_double_click: bool ='', open_on_arrow: bool ='', leaf: bool ='', bullet: bool ='', selectable: bool ='', span_text_width: bool ='', span_full_width: bool ='', catch_nav_left: bool ='', lines: int ='') -> Union[int, str]: """Adds a tree node to add items to.""" ... @@ -635,7 +623,7 @@ def add_viewport_menu_bar(*, label: str ='', user_data: Any ='', use_internal_la """Adds a menubar to the viewport.""" ... -def add_window(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', min_size: Union[List[int], Tuple[int, ...]] ='', max_size: Union[List[int], Tuple[int, ...]] ='', menubar: bool ='', collapsed: bool ='', autosize: bool ='', no_resize: bool ='', unsaved_document: bool ='', no_title_bar: bool ='', no_move: bool ='', no_scrollbar: bool ='', no_collapse: bool ='', horizontal_scrollbar: bool ='', no_focus_on_appearing: bool ='', no_bring_to_front_on_focus: bool ='', no_close: bool ='', no_background: bool ='', modal: bool ='', popup: bool ='', no_saved_settings: bool ='', no_open_over_existing_popup: bool ='', no_scroll_with_mouse: bool ='', on_close: Callable ='') -> Union[int, str]: +def add_window(*, label: str ='', user_data: Any ='', use_internal_label: bool ='', tag: Union[int, str] ='', width: int ='', height: int ='', indent: int ='', show: bool ='', pos: Union[List[int], Tuple[int, ...]] ='', min_size: Union[List[int], Tuple[int, ...]] ='', max_size: Union[List[int], Tuple[int, ...]] ='', menubar: bool ='', collapsed: bool ='', autosize: bool ='', no_resize: bool ='', unsaved_document: bool ='', no_title_bar: bool ='', no_move: bool ='', no_scrollbar: bool ='', no_collapse: bool ='', horizontal_scrollbar: bool ='', no_focus_on_appearing: bool ='', no_bring_to_front_on_focus: bool ='', no_close: bool ='', no_background: bool ='', modal: bool ='', popup: bool ='', no_saved_settings: bool ='', no_open_over_existing_popup: bool ='', no_scroll_with_mouse: bool ='', no_docking: bool ='', copy_contents_shortcut: bool ='', on_close: Callable ='') -> Union[int, str]: """Creates a new window for following items to be added to.""" ... @@ -679,7 +667,7 @@ def clear_selected_nodes(node_editor : Union[int, str]) -> None: """Clears a node editor's selected nodes.""" ... -def configure_app(*, load_init_file: str ='', docking: bool ='', docking_space: bool ='', docking_shift_only: bool ='', init_file: str ='', auto_save_init_file: bool ='', device: int ='', auto_device: bool ='', allow_alias_overwrites: bool ='', manual_alias_management: bool ='', skip_required_args: bool ='', skip_positional_args: bool ='', skip_keyword_args: bool ='', wait_for_input: bool ='', manual_callback_management: bool ='', keyboard_navigation: bool ='', anti_aliased_lines: bool ='', anti_aliased_lines_use_tex: bool ='', anti_aliased_fill: bool ='', **kwargs) -> None: +def configure_app(*, load_init_file: str ='', docking: bool ='', docking_space: bool ='', docking_shift_only: bool ='', init_file: str ='', auto_save_init_file: bool ='', device: int ='', auto_device: bool ='', allow_alias_overwrites: bool ='', manual_alias_management: bool ='', skip_required_args: bool ='', skip_positional_args: bool ='', skip_keyword_args: bool ='', wait_for_input: bool ='', manual_callback_management: bool ='', keyboard_navigation: bool ='', anti_aliased_lines: bool ='', anti_aliased_lines_use_tex: bool ='', anti_aliased_fill: bool ='', win32_alt_enter_fullscreen: bool ='', **kwargs) -> None: """Configures app.""" ... @@ -1560,6 +1548,9 @@ mvTable_SizingFixedFit=0 mvTable_SizingFixedSame=0 mvTable_SizingStretchProp=0 mvTable_SizingStretchSame=0 +mvTreeLines_None=0 +mvTreeLines_Full=0 +mvTreeLines_ToNodes=0 mvFormat_Float_rgba=0 mvFormat_Float_rgb=0 mvThemeCat_Core=0 @@ -1569,8 +1560,8 @@ mvThemeCol_Text=0 mvThemeCol_TextDisabled=0 mvThemeCol_WindowBg=0 mvThemeCol_ChildBg=0 -mvThemeCol_Border=0 mvThemeCol_PopupBg=0 +mvThemeCol_Border=0 mvThemeCol_BorderShadow=0 mvThemeCol_FrameBg=0 mvThemeCol_FrameBgHovered=0 @@ -1598,11 +1589,14 @@ mvThemeCol_SeparatorActive=0 mvThemeCol_ResizeGrip=0 mvThemeCol_ResizeGripHovered=0 mvThemeCol_ResizeGripActive=0 -mvThemeCol_Tab=0 +mvThemeCol_InputTextCursor=0 mvThemeCol_TabHovered=0 -mvThemeCol_TabActive=0 -mvThemeCol_TabUnfocused=0 -mvThemeCol_TabUnfocusedActive=0 +mvThemeCol_Tab=0 +mvThemeCol_TabSelected=0 +mvThemeCol_TabSelectedOverline=0 +mvThemeCol_TabDimmed=0 +mvThemeCol_TabDimmedSelected=0 +mvThemeCol_TabDimmedSelectedOverline=0 mvThemeCol_DockingPreview=0 mvThemeCol_DockingEmptyBg=0 mvThemeCol_PlotLines=0 @@ -1615,11 +1609,18 @@ mvThemeCol_TableBorderLight=0 mvThemeCol_TableRowBg=0 mvThemeCol_TableRowBgAlt=0 mvThemeCol_TextSelectedBg=0 +mvThemeCol_TreeLines=0 mvThemeCol_DragDropTarget=0 -mvThemeCol_NavHighlight=0 +mvThemeCol_DragDropTargetBg=0 +mvThemeCol_UnsavedMarker=0 +mvThemeCol_NavCursor=0 mvThemeCol_NavWindowingHighlight=0 mvThemeCol_NavWindowingDimBg=0 mvThemeCol_ModalWindowDimBg=0 +mvThemeCol_TabActive=0 +mvThemeCol_TabUnfocused=0 +mvThemeCol_TabUnfocusedActive=0 +mvThemeCol_NavHighlight=0 mvPlotCol_Line=0 mvPlotCol_Fill=0 mvPlotCol_MarkerOutline=0 @@ -1633,11 +1634,12 @@ mvPlotCol_LegendBorder=0 mvPlotCol_LegendText=0 mvPlotCol_TitleText=0 mvPlotCol_InlayText=0 +mvPlotCol_AxisText=0 +mvPlotCol_AxisGrid=0 +mvPlotCol_AxisTick=0 mvPlotCol_AxisBg=0 -mvPlotCol_AxisBgActive=0 mvPlotCol_AxisBgHovered=0 -mvPlotCol_AxisGrid=0 -mvPlotCol_AxisText=0 +mvPlotCol_AxisBgActive=0 mvPlotCol_Selection=0 mvPlotCol_Crosshairs=0 mvNodeCol_NodeBackground=0 @@ -1689,13 +1691,20 @@ mvStyleVar_IndentSpacing=0 mvStyleVar_CellPadding=0 mvStyleVar_ScrollbarSize=0 mvStyleVar_ScrollbarRounding=0 +mvStyleVar_ScrollbarPadding=0 mvStyleVar_GrabMinSize=0 mvStyleVar_GrabRounding=0 +mvStyleVar_ImageBorderSize=0 mvStyleVar_TabRounding=0 mvStyleVar_TabBorderSize=0 +mvStyleVar_TabMinWidthBase=0 +mvStyleVar_TabMinWidthShrink=0 mvStyleVar_TabBarBorderSize=0 +mvStyleVar_TabBarOverlineSize=0 mvStyleVar_TableAngledHeadersAngle=0 mvStyleVar_TableAngledHeadersTextAlign=0 +mvStyleVar_TreeLinesSize=0 +mvStyleVar_TreeLinesRounding=0 mvStyleVar_ButtonTextAlign=0 mvStyleVar_SelectableTextAlign=0 mvStyleVar_SeparatorTextBorderSize=0 @@ -1883,9 +1892,6 @@ mvTheme=0 mvThemeColor=0 mvThemeStyle=0 mvThemeComponent=0 -mvFontRangeHint=0 -mvFontRange=0 -mvFontChars=0 mvCharRemap=0 mvValueRegistry=0 mvIntValue=0 diff --git a/dearpygui/_dearpygui_RTD.py b/dearpygui/_dearpygui_RTD.py index b4e28ab8e..cd869e98e 100644 --- a/dearpygui/_dearpygui_RTD.py +++ b/dearpygui/_dearpygui_RTD.py @@ -1547,6 +1547,58 @@ def set_start_callback(callback): """ deprecated function """ return internal_dpg.set_frame_callback(3, callback) +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_chars(chars : Union[List[int], Tuple[int, ...]], *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds specific font characters to a font. + + Args: + chars (Union[List[int], Tuple[int, ...]]): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range(first_char : int, last_char : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters to a font. + + Args: + first_char (int): + last_char (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range_hint(hint : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters (mvFontRangeHint_ constants). + + Args: + hint (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + ########################################################## # Container Context Managers ########################################################## @@ -1892,7 +1944,8 @@ def font(file, size, **kwargs): user_data (Any, optional): User data for callbacks use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - pixel_snapH (bool, optional): Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font, or rendering text piece-by-piece (e.g. for coloring). + pixel_snapH (bool, optional): Align every glyph to pixel boundary in horizontal direction. Useful if you are rendering text piece-by-piece (e.g. for coloring). + pixel_snapV (bool, optional): Align scaled GlyphOffset.y to pixel boundaries in ImGui. parent (Union[int, str], optional): Parent to add this item to. (runtime adding) id (Union[int, str], optional): (deprecated) default_font (bool, optional): (deprecated) @@ -2383,6 +2436,9 @@ def tab(**kwargs): closable (bool, optional): Creates a button on the tab that can hide the tab. no_tooltip (bool, optional): Disable tooltip for the given tab. order_mode (int, optional): set using a constant: mvTabOrder_Reorderable: allows reordering, mvTabOrder_Fixed: fixed ordering, mvTabOrder_Leading: adds tab to front, mvTabOrder_Trailing: adds tab to back + unsaved_document (bool, optional): Display a dot next to the title. + no_close_with_middle_click (bool, optional): Disable closing this tab (if closable==True) by clicking with middle mouse button. + no_reorder (bool, optional): Disable reordering this tab or having another tab cross over this tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Yields: @@ -2414,6 +2470,11 @@ def tab_bar(**kwargs): tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom reorderable (bool, optional): Allows for the user to change the order of the tabs. + tab_list_popup_button (bool, optional): Show a button to select active tab from a dropdown list. + no_close_with_middle_click (bool, optional): Disable closing tabs (that have closable=True) by clicking with middle mouse button. + no_scrolling_buttons (bool, optional): Disable left/right scrolling buttons when tab buttons don't fit the container width. + no_tooltip (bool, optional): Disable tooltips when hovering a tab with a long name. + draw_selected_overline (bool, optional): Draw selected overline markers over selected tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Yields: @@ -2674,6 +2735,8 @@ def tree_node(**kwargs): selectable (bool, optional): Makes the tree selectable. span_text_width (bool, optional): Makes hitbox and highlight only cover the label. span_full_width (bool, optional): Extend hit box to the left-most and right-most edges (cover the indent area). + catch_nav_left (bool, optional): Keyboard navigation: left arrow within this node's children, if unhandled, moves focus to this node. When setting it to True on a node, better set it on all children nodes in the subtree as well, otherwise it might give unexpected navigation jumps. + lines (int, optional): Experimental. Draw lines connecting tree_node hierarchy. One of dpg.mvTreeLines constants. To work correctly, must be configured the same way in every tree node. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Yields: @@ -2789,6 +2852,8 @@ def window(**kwargs): no_saved_settings (bool, optional): Never load/save settings in .ini file. no_open_over_existing_popup (bool, optional): Don't open if there's already a popup no_scroll_with_mouse (bool, optional): Disable user vertically scrolling with mouse wheel. + no_docking (bool, optional): Disable docking of this window + copy_contents_shortcut (bool, optional): Experimental. If True, window contents can be copied to clipboard by pressing Ctrl+C. Might be useful for message boxes. on_close (Callable, optional): Callback ran when window is closed. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. @@ -3233,6 +3298,8 @@ def add_color_button(default_value=(0, 0, 0, 255), **kwargs): no_alpha (bool, optional): Removes the displayed slider that can change alpha channel. no_border (bool, optional): Disable border around the image. no_drag_drop (bool, optional): Disable ability to drag and drop small preview (color square) to apply colors to other items. + alpha_preview (int, optional): mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf + no_tooltip (bool, optional): Disable tooltip when hovering the button. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4201,7 +4268,8 @@ def add_font(file, size, **kwargs): user_data (Any, optional): User data for callbacks use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - pixel_snapH (bool, optional): Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font, or rendering text piece-by-piece (e.g. for coloring). + pixel_snapH (bool, optional): Align every glyph to pixel boundary in horizontal direction. Useful if you are rendering text piece-by-piece (e.g. for coloring). + pixel_snapV (bool, optional): Align scaled GlyphOffset.y to pixel boundaries in ImGui. parent (Union[int, str], optional): Parent to add this item to. (runtime adding) id (Union[int, str], optional): (deprecated) default_font (bool, optional): (deprecated) @@ -4211,58 +4279,6 @@ def add_font(file, size, **kwargs): return internal_dpg.add_font(file, size, **kwargs) -def add_font_chars(chars, **kwargs): - """ Adds specific font characters to a font. - - Args: - chars (Union[List[int], Tuple[int, ...]]): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - return internal_dpg.add_font_chars(chars, **kwargs) - -def add_font_range(first_char, last_char, **kwargs): - """ Adds a range of font characters to a font. - - Args: - first_char (int): - last_char (int): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - return internal_dpg.add_font_range(first_char, last_char, **kwargs) - -def add_font_range_hint(hint, **kwargs): - """ Adds a range of font characters (mvFontRangeHint_ constants). - - Args: - hint (int): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - return internal_dpg.add_font_range_hint(hint, **kwargs) - def add_font_registry(**kwargs): """ Adds a font registry. @@ -4412,7 +4428,7 @@ def add_image(texture_tag, **kwargs): tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom tint_color (Union[List[float], Tuple[float, ...]], optional): Applies a color tint to the entire texture. - border_color (Union[List[float], Tuple[float, ...]], optional): Displays a border of the specified color around the texture. If the theme style has turned off the border it will not be shown. + border_color (Union[List[float], Tuple[float, ...]], optional): Displays a border of the specified color around the texture. uv_min (Union[List[float], Tuple[float, ...]], optional): Normalized texture coordinates min point. uv_max (Union[List[float], Tuple[float, ...]], optional): Normalized texture coordinates max point. id (Union[int, str], optional): (deprecated) @@ -4538,6 +4554,8 @@ def add_input_double(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4577,6 +4595,8 @@ def add_input_doublex(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4617,6 +4637,8 @@ def add_input_float(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4656,6 +4678,8 @@ def add_input_floatx(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4695,6 +4719,8 @@ def add_input_int(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4733,6 +4759,8 @@ def add_input_intx(**kwargs): max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -4782,6 +4810,7 @@ def add_input_text(**kwargs): always_overwrite (bool, optional): Overwrite mode no_undo_redo (bool, optional): Disable undo/redo. escape_clears_all (bool, optional): Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert) + elide_left (bool, optional): When text doesn't fit an inactive input field, clip it on the left side and ensure the right side stays visible. Useful for path/filenames. Single-line inputs only. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5880,6 +5909,7 @@ def add_selectable(**kwargs): default_value (bool, optional): span_columns (bool, optional): Forces the selectable to span the width of all columns if placed in a table. disable_popup_close (bool, optional): Disable closing a modal or popup window. + select_on_nav (bool, optional): Auto-select when moved into with keyboard navigation, unless Ctrl is held. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6406,6 +6436,9 @@ def add_tab(**kwargs): closable (bool, optional): Creates a button on the tab that can hide the tab. no_tooltip (bool, optional): Disable tooltip for the given tab. order_mode (int, optional): set using a constant: mvTabOrder_Reorderable: allows reordering, mvTabOrder_Fixed: fixed ordering, mvTabOrder_Leading: adds tab to front, mvTabOrder_Trailing: adds tab to back + unsaved_document (bool, optional): Display a dot next to the title. + no_close_with_middle_click (bool, optional): Disable closing this tab (if closable==True) by clicking with middle mouse button. + no_reorder (bool, optional): Disable reordering this tab or having another tab cross over this tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Returns: @@ -6432,6 +6465,11 @@ def add_tab_bar(**kwargs): tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom reorderable (bool, optional): Allows for the user to change the order of the tabs. + tab_list_popup_button (bool, optional): Show a button to select active tab from a dropdown list. + no_close_with_middle_click (bool, optional): Disable closing tabs (that have closable=True) by clicking with middle mouse button. + no_scrolling_buttons (bool, optional): Disable left/right scrolling buttons when tab buttons don't fit the container width. + no_tooltip (bool, optional): Disable tooltips when hovering a tab with a long name. + draw_selected_overline (bool, optional): Draw selected overline markers over selected tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Returns: @@ -6463,6 +6501,7 @@ def add_tab_button(**kwargs): leading (bool, optional): Enforce the tab position to the left of the tab bar (after the tab list popup button). trailing (bool, optional): Enforce the tab position to the right of the tab bar (before the scrolling buttons). no_tooltip (bool, optional): Disable tooltip for the given tab. + unsaved_document (bool, optional): Display a dot next to the title. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6841,6 +6880,8 @@ def add_tree_node(**kwargs): selectable (bool, optional): Makes the tree selectable. span_text_width (bool, optional): Makes hitbox and highlight only cover the label. span_full_width (bool, optional): Extend hit box to the left-most and right-most edges (cover the indent area). + catch_nav_left (bool, optional): Keyboard navigation: left arrow within this node's children, if unhandled, moves focus to this node. When setting it to True on a node, better set it on all children nodes in the subtree as well, otherwise it might give unexpected navigation jumps. + lines (int, optional): Experimental. Draw lines connecting tree_node hierarchy. One of dpg.mvTreeLines constants. To work correctly, must be configured the same way in every tree node. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. Returns: @@ -6936,6 +6977,8 @@ def add_window(**kwargs): no_saved_settings (bool, optional): Never load/save settings in .ini file. no_open_over_existing_popup (bool, optional): Don't open if there's already a popup no_scroll_with_mouse (bool, optional): Disable user vertically scrolling with mouse wheel. + no_docking (bool, optional): Disable docking of this window + copy_contents_shortcut (bool, optional): Experimental. If True, window contents can be copied to clipboard by pressing Ctrl+C. Might be useful for message boxes. on_close (Callable, optional): Callback ran when window is closed. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated)This was used as an optimization hint but is not relevant anymore. @@ -9170,6 +9213,9 @@ def unstage(item): mvTable_SizingFixedSame=internal_dpg.mvTable_SizingFixedSame mvTable_SizingStretchProp=internal_dpg.mvTable_SizingStretchProp mvTable_SizingStretchSame=internal_dpg.mvTable_SizingStretchSame +mvTreeLines_None=internal_dpg.mvTreeLines_None +mvTreeLines_Full=internal_dpg.mvTreeLines_Full +mvTreeLines_ToNodes=internal_dpg.mvTreeLines_ToNodes mvFormat_Float_rgba=internal_dpg.mvFormat_Float_rgba mvFormat_Float_rgb=internal_dpg.mvFormat_Float_rgb mvThemeCat_Core=internal_dpg.mvThemeCat_Core @@ -9179,8 +9225,8 @@ def unstage(item): mvThemeCol_TextDisabled=internal_dpg.mvThemeCol_TextDisabled mvThemeCol_WindowBg=internal_dpg.mvThemeCol_WindowBg mvThemeCol_ChildBg=internal_dpg.mvThemeCol_ChildBg -mvThemeCol_Border=internal_dpg.mvThemeCol_Border mvThemeCol_PopupBg=internal_dpg.mvThemeCol_PopupBg +mvThemeCol_Border=internal_dpg.mvThemeCol_Border mvThemeCol_BorderShadow=internal_dpg.mvThemeCol_BorderShadow mvThemeCol_FrameBg=internal_dpg.mvThemeCol_FrameBg mvThemeCol_FrameBgHovered=internal_dpg.mvThemeCol_FrameBgHovered @@ -9208,11 +9254,14 @@ def unstage(item): mvThemeCol_ResizeGrip=internal_dpg.mvThemeCol_ResizeGrip mvThemeCol_ResizeGripHovered=internal_dpg.mvThemeCol_ResizeGripHovered mvThemeCol_ResizeGripActive=internal_dpg.mvThemeCol_ResizeGripActive -mvThemeCol_Tab=internal_dpg.mvThemeCol_Tab +mvThemeCol_InputTextCursor=internal_dpg.mvThemeCol_InputTextCursor mvThemeCol_TabHovered=internal_dpg.mvThemeCol_TabHovered -mvThemeCol_TabActive=internal_dpg.mvThemeCol_TabActive -mvThemeCol_TabUnfocused=internal_dpg.mvThemeCol_TabUnfocused -mvThemeCol_TabUnfocusedActive=internal_dpg.mvThemeCol_TabUnfocusedActive +mvThemeCol_Tab=internal_dpg.mvThemeCol_Tab +mvThemeCol_TabSelected=internal_dpg.mvThemeCol_TabSelected +mvThemeCol_TabSelectedOverline=internal_dpg.mvThemeCol_TabSelectedOverline +mvThemeCol_TabDimmed=internal_dpg.mvThemeCol_TabDimmed +mvThemeCol_TabDimmedSelected=internal_dpg.mvThemeCol_TabDimmedSelected +mvThemeCol_TabDimmedSelectedOverline=internal_dpg.mvThemeCol_TabDimmedSelectedOverline mvThemeCol_DockingPreview=internal_dpg.mvThemeCol_DockingPreview mvThemeCol_DockingEmptyBg=internal_dpg.mvThemeCol_DockingEmptyBg mvThemeCol_PlotLines=internal_dpg.mvThemeCol_PlotLines @@ -9225,11 +9274,18 @@ def unstage(item): mvThemeCol_TableRowBg=internal_dpg.mvThemeCol_TableRowBg mvThemeCol_TableRowBgAlt=internal_dpg.mvThemeCol_TableRowBgAlt mvThemeCol_TextSelectedBg=internal_dpg.mvThemeCol_TextSelectedBg +mvThemeCol_TreeLines=internal_dpg.mvThemeCol_TreeLines mvThemeCol_DragDropTarget=internal_dpg.mvThemeCol_DragDropTarget -mvThemeCol_NavHighlight=internal_dpg.mvThemeCol_NavHighlight +mvThemeCol_DragDropTargetBg=internal_dpg.mvThemeCol_DragDropTargetBg +mvThemeCol_UnsavedMarker=internal_dpg.mvThemeCol_UnsavedMarker +mvThemeCol_NavCursor=internal_dpg.mvThemeCol_NavCursor mvThemeCol_NavWindowingHighlight=internal_dpg.mvThemeCol_NavWindowingHighlight mvThemeCol_NavWindowingDimBg=internal_dpg.mvThemeCol_NavWindowingDimBg mvThemeCol_ModalWindowDimBg=internal_dpg.mvThemeCol_ModalWindowDimBg +mvThemeCol_TabActive=internal_dpg.mvThemeCol_TabActive +mvThemeCol_TabUnfocused=internal_dpg.mvThemeCol_TabUnfocused +mvThemeCol_TabUnfocusedActive=internal_dpg.mvThemeCol_TabUnfocusedActive +mvThemeCol_NavHighlight=internal_dpg.mvThemeCol_NavHighlight mvPlotCol_Line=internal_dpg.mvPlotCol_Line mvPlotCol_Fill=internal_dpg.mvPlotCol_Fill mvPlotCol_MarkerOutline=internal_dpg.mvPlotCol_MarkerOutline @@ -9243,11 +9299,12 @@ def unstage(item): mvPlotCol_LegendText=internal_dpg.mvPlotCol_LegendText mvPlotCol_TitleText=internal_dpg.mvPlotCol_TitleText mvPlotCol_InlayText=internal_dpg.mvPlotCol_InlayText +mvPlotCol_AxisText=internal_dpg.mvPlotCol_AxisText +mvPlotCol_AxisGrid=internal_dpg.mvPlotCol_AxisGrid +mvPlotCol_AxisTick=internal_dpg.mvPlotCol_AxisTick mvPlotCol_AxisBg=internal_dpg.mvPlotCol_AxisBg -mvPlotCol_AxisBgActive=internal_dpg.mvPlotCol_AxisBgActive mvPlotCol_AxisBgHovered=internal_dpg.mvPlotCol_AxisBgHovered -mvPlotCol_AxisGrid=internal_dpg.mvPlotCol_AxisGrid -mvPlotCol_AxisText=internal_dpg.mvPlotCol_AxisText +mvPlotCol_AxisBgActive=internal_dpg.mvPlotCol_AxisBgActive mvPlotCol_Selection=internal_dpg.mvPlotCol_Selection mvPlotCol_Crosshairs=internal_dpg.mvPlotCol_Crosshairs mvNodeCol_NodeBackground=internal_dpg.mvNodeCol_NodeBackground @@ -9299,13 +9356,20 @@ def unstage(item): mvStyleVar_CellPadding=internal_dpg.mvStyleVar_CellPadding mvStyleVar_ScrollbarSize=internal_dpg.mvStyleVar_ScrollbarSize mvStyleVar_ScrollbarRounding=internal_dpg.mvStyleVar_ScrollbarRounding +mvStyleVar_ScrollbarPadding=internal_dpg.mvStyleVar_ScrollbarPadding mvStyleVar_GrabMinSize=internal_dpg.mvStyleVar_GrabMinSize mvStyleVar_GrabRounding=internal_dpg.mvStyleVar_GrabRounding +mvStyleVar_ImageBorderSize=internal_dpg.mvStyleVar_ImageBorderSize mvStyleVar_TabRounding=internal_dpg.mvStyleVar_TabRounding mvStyleVar_TabBorderSize=internal_dpg.mvStyleVar_TabBorderSize +mvStyleVar_TabMinWidthBase=internal_dpg.mvStyleVar_TabMinWidthBase +mvStyleVar_TabMinWidthShrink=internal_dpg.mvStyleVar_TabMinWidthShrink mvStyleVar_TabBarBorderSize=internal_dpg.mvStyleVar_TabBarBorderSize +mvStyleVar_TabBarOverlineSize=internal_dpg.mvStyleVar_TabBarOverlineSize mvStyleVar_TableAngledHeadersAngle=internal_dpg.mvStyleVar_TableAngledHeadersAngle mvStyleVar_TableAngledHeadersTextAlign=internal_dpg.mvStyleVar_TableAngledHeadersTextAlign +mvStyleVar_TreeLinesSize=internal_dpg.mvStyleVar_TreeLinesSize +mvStyleVar_TreeLinesRounding=internal_dpg.mvStyleVar_TreeLinesRounding mvStyleVar_ButtonTextAlign=internal_dpg.mvStyleVar_ButtonTextAlign mvStyleVar_SelectableTextAlign=internal_dpg.mvStyleVar_SelectableTextAlign mvStyleVar_SeparatorTextBorderSize=internal_dpg.mvStyleVar_SeparatorTextBorderSize @@ -9493,9 +9557,6 @@ def unstage(item): mvThemeColor=internal_dpg.mvThemeColor mvThemeStyle=internal_dpg.mvThemeStyle mvThemeComponent=internal_dpg.mvThemeComponent -mvFontRangeHint=internal_dpg.mvFontRangeHint -mvFontRange=internal_dpg.mvFontRange -mvFontChars=internal_dpg.mvFontChars mvCharRemap=internal_dpg.mvCharRemap mvValueRegistry=internal_dpg.mvValueRegistry mvIntValue=internal_dpg.mvIntValue diff --git a/dearpygui/_deprecated.py b/dearpygui/_deprecated.py index c6335fc48..a59110f87 100644 --- a/dearpygui/_deprecated.py +++ b/dearpygui/_deprecated.py @@ -423,3 +423,55 @@ def is_item_search_delayed(item: Union[int, str]) -> Union[bool, None]: def set_start_callback(callback): """ deprecated function """ return internal_dpg.set_frame_callback(3, callback) + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_chars(chars : Union[List[int], Tuple[int, ...]], *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds specific font characters to a font. + + Args: + chars (Union[List[int], Tuple[int, ...]]): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range(first_char : int, last_char : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters to a font. + + Args: + first_char (int): + last_char (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range_hint(hint : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters (mvFontRangeHint_ constants). + + Args: + hint (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass diff --git a/dearpygui/dearpygui.py b/dearpygui/dearpygui.py index 38f7a6536..e68cd6cdd 100644 --- a/dearpygui/dearpygui.py +++ b/dearpygui/dearpygui.py @@ -1547,6 +1547,58 @@ def set_start_callback(callback): """ deprecated function """ return internal_dpg.set_frame_callback(3, callback) +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_chars(chars : Union[List[int], Tuple[int, ...]], *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds specific font characters to a font. + + Args: + chars (Union[List[int], Tuple[int, ...]]): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range(first_char : int, last_char : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters to a font. + + Args: + first_char (int): + last_char (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + +@deprecated("This call is a no-op because character ranges are now automatic") +def add_font_range_hint(hint : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: + """ (deprecated function) Adds a range of font characters (mvFontRangeHint_ constants). + + Args: + hint (int): + label (str, optional): Overrides 'name' as label. + user_data (Any, optional): User data for callbacks + use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). + tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. + parent (Union[int, str], optional): Parent to add this item to. (runtime adding) + id (Union[int, str], optional): (deprecated) + Returns: + Union[int, str] + """ + pass + ########################################################## # Container Context Managers ########################################################## @@ -1941,7 +1993,7 @@ def filter_set(*, label: str =None, user_data: Any =None, use_internal_label: bo internal_dpg.pop_container_stack() @contextmanager -def font(file : str, size : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, pixel_snapH: bool =False, parent: Union[int, str] =internal_dpg.mvReservedUUID_0, **kwargs) -> Union[int, str]: +def font(file : str, size : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, pixel_snapH: bool =False, pixel_snapV: bool =False, parent: Union[int, str] =internal_dpg.mvReservedUUID_0, **kwargs) -> Union[int, str]: """ Adds font to a font registry. Args: @@ -1951,7 +2003,8 @@ def font(file : str, size : int, *, label: str =None, user_data: Any =None, use_ user_data (Any, optional): User data for callbacks use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - pixel_snapH (bool, optional): Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font, or rendering text piece-by-piece (e.g. for coloring). + pixel_snapH (bool, optional): Align every glyph to pixel boundary in horizontal direction. Useful if you are rendering text piece-by-piece (e.g. for coloring). + pixel_snapV (bool, optional): Align scaled GlyphOffset.y to pixel boundaries in ImGui. parent (Union[int, str], optional): Parent to add this item to. (runtime adding) id (Union[int, str], optional): (deprecated) default_font (bool, optional): (deprecated) @@ -1967,7 +2020,7 @@ def font(file : str, size : int, *, label: str =None, user_data: Any =None, use_ if 'default_font' in kwargs.keys(): warnings.warn('default_font keyword removed', DeprecationWarning, 2) kwargs.pop('default_font', None) - widget = internal_dpg.add_font(file, size, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, pixel_snapH=pixel_snapH, parent=parent, **kwargs) + widget = internal_dpg.add_font(file, size, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, pixel_snapH=pixel_snapH, pixel_snapV=pixel_snapV, parent=parent, **kwargs) internal_dpg.push_container_stack(widget) yield widget finally: @@ -2533,7 +2586,7 @@ def synced_tables(*, label: str =None, user_data: Any =None, use_internal_label: internal_dpg.pop_container_stack() @contextmanager -def tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, closable: bool =False, no_tooltip: bool =False, order_mode: int =0, **kwargs) -> Union[int, str]: +def tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, closable: bool =False, no_tooltip: bool =False, order_mode: int =0, unsaved_document: bool =False, no_close_with_middle_click: bool =False, no_reorder: bool =False, **kwargs) -> Union[int, str]: """ Adds a tab to a tab bar. Args: @@ -2553,6 +2606,9 @@ def tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =Tru closable (bool, optional): Creates a button on the tab that can hide the tab. no_tooltip (bool, optional): Disable tooltip for the given tab. order_mode (int, optional): set using a constant: mvTabOrder_Reorderable: allows reordering, mvTabOrder_Fixed: fixed ordering, mvTabOrder_Leading: adds tab to front, mvTabOrder_Trailing: adds tab to back + unsaved_document (bool, optional): Display a dot next to the title. + no_close_with_middle_click (bool, optional): Disable closing this tab (if closable==True) by clicking with middle mouse button. + no_reorder (bool, optional): Disable reordering this tab or having another tab cross over this tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Yields: @@ -2566,14 +2622,14 @@ def tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =Tru if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - widget = internal_dpg.add_tab(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, closable=closable, no_tooltip=no_tooltip, order_mode=order_mode, **kwargs) + widget = internal_dpg.add_tab(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, closable=closable, no_tooltip=no_tooltip, order_mode=order_mode, unsaved_document=unsaved_document, no_close_with_middle_click=no_close_with_middle_click, no_reorder=no_reorder, **kwargs) internal_dpg.push_container_stack(widget) yield widget finally: internal_dpg.pop_container_stack() @contextmanager -def tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, reorderable: bool =False, **kwargs) -> Union[int, str]: +def tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, reorderable: bool =False, tab_list_popup_button: bool =False, no_close_with_middle_click: bool =False, no_scrolling_buttons: bool =False, no_tooltip: bool =False, draw_selected_overline: bool =False, **kwargs) -> Union[int, str]: """ Adds a tab bar. Args: @@ -2591,6 +2647,11 @@ def tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom reorderable (bool, optional): Allows for the user to change the order of the tabs. + tab_list_popup_button (bool, optional): Show a button to select active tab from a dropdown list. + no_close_with_middle_click (bool, optional): Disable closing tabs (that have closable=True) by clicking with middle mouse button. + no_scrolling_buttons (bool, optional): Disable left/right scrolling buttons when tab buttons don't fit the container width. + no_tooltip (bool, optional): Disable tooltips when hovering a tab with a long name. + draw_selected_overline (bool, optional): Draw selected overline markers over selected tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Yields: @@ -2604,7 +2665,7 @@ def tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - widget = internal_dpg.add_tab_bar(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, callback=callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, reorderable=reorderable, **kwargs) + widget = internal_dpg.add_tab_bar(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, callback=callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, reorderable=reorderable, tab_list_popup_button=tab_list_popup_button, no_close_with_middle_click=no_close_with_middle_click, no_scrolling_buttons=no_scrolling_buttons, no_tooltip=no_tooltip, draw_selected_overline=draw_selected_overline, **kwargs) internal_dpg.push_container_stack(widget) yield widget finally: @@ -2870,7 +2931,7 @@ def tooltip(parent : Union[int, str], *, label: str =None, user_data: Any =None, internal_dpg.pop_container_stack() @contextmanager -def tree_node(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_open: bool =False, open_on_double_click: bool =False, open_on_arrow: bool =False, leaf: bool =False, bullet: bool =False, selectable: bool =False, span_text_width: bool =False, span_full_width: bool =False, **kwargs) -> Union[int, str]: +def tree_node(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_open: bool =False, open_on_double_click: bool =False, open_on_arrow: bool =False, leaf: bool =False, bullet: bool =False, selectable: bool =False, span_text_width: bool =False, span_full_width: bool =False, catch_nav_left: bool =False, lines: int =internal_dpg.mvTreeLines_None, **kwargs) -> Union[int, str]: """ Adds a tree node to add items to. Args: @@ -2897,6 +2958,8 @@ def tree_node(*, label: str =None, user_data: Any =None, use_internal_label: boo selectable (bool, optional): Makes the tree selectable. span_text_width (bool, optional): Makes hitbox and highlight only cover the label. span_full_width (bool, optional): Extend hit box to the left-most and right-most edges (cover the indent area). + catch_nav_left (bool, optional): Keyboard navigation: left arrow within this node's children, if unhandled, moves focus to this node. When setting it to True on a node, better set it on all children nodes in the subtree as well, otherwise it might give unexpected navigation jumps. + lines (int, optional): Experimental. Draw lines connecting tree_node hierarchy. One of dpg.mvTreeLines constants. To work correctly, must be configured the same way in every tree node. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Yields: @@ -2910,7 +2973,7 @@ def tree_node(*, label: str =None, user_data: Any =None, use_internal_label: boo if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - widget = internal_dpg.add_tree_node(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_open=default_open, open_on_double_click=open_on_double_click, open_on_arrow=open_on_arrow, leaf=leaf, bullet=bullet, selectable=selectable, span_text_width=span_text_width, span_full_width=span_full_width, **kwargs) + widget = internal_dpg.add_tree_node(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_open=default_open, open_on_double_click=open_on_double_click, open_on_arrow=open_on_arrow, leaf=leaf, bullet=bullet, selectable=selectable, span_text_width=span_text_width, span_full_width=span_full_width, catch_nav_left=catch_nav_left, lines=lines, **kwargs) internal_dpg.push_container_stack(widget) yield widget finally: @@ -3003,7 +3066,7 @@ def viewport_menu_bar(*, label: str =None, user_data: Any =None, use_internal_la internal_dpg.pop_container_stack() @contextmanager -def window(*, 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, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], min_size: Union[List[int], Tuple[int, ...]] =[100, 100], max_size: Union[List[int], Tuple[int, ...]] =[30000, 30000], menubar: bool =False, collapsed: bool =False, autosize: bool =False, no_resize: bool =False, unsaved_document: bool =False, no_title_bar: bool =False, no_move: bool =False, no_scrollbar: bool =False, no_collapse: bool =False, horizontal_scrollbar: bool =False, no_focus_on_appearing: bool =False, no_bring_to_front_on_focus: bool =False, no_close: bool =False, no_background: bool =False, modal: bool =False, popup: bool =False, no_saved_settings: bool =False, no_open_over_existing_popup: bool =True, no_scroll_with_mouse: bool =False, on_close: Callable =None, **kwargs) -> Union[int, str]: +def window(*, 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, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], min_size: Union[List[int], Tuple[int, ...]] =[100, 100], max_size: Union[List[int], Tuple[int, ...]] =[30000, 30000], menubar: bool =False, collapsed: bool =False, autosize: bool =False, no_resize: bool =False, unsaved_document: bool =False, no_title_bar: bool =False, no_move: bool =False, no_scrollbar: bool =False, no_collapse: bool =False, horizontal_scrollbar: bool =False, no_focus_on_appearing: bool =False, no_bring_to_front_on_focus: bool =False, no_close: bool =False, no_background: bool =False, modal: bool =False, popup: bool =False, no_saved_settings: bool =False, no_open_over_existing_popup: bool =True, no_scroll_with_mouse: bool =False, no_docking: bool =False, copy_contents_shortcut: bool =False, on_close: Callable =None, **kwargs) -> Union[int, str]: """ Creates a new window for following items to be added to. Args: @@ -3037,6 +3100,8 @@ def window(*, label: str =None, user_data: Any =None, use_internal_label: bool = no_saved_settings (bool, optional): Never load/save settings in .ini file. no_open_over_existing_popup (bool, optional): Don't open if there's already a popup no_scroll_with_mouse (bool, optional): Disable user vertically scrolling with mouse wheel. + no_docking (bool, optional): Disable docking of this window + copy_contents_shortcut (bool, optional): Experimental. If True, window contents can be copied to clipboard by pressing Ctrl+C. Might be useful for message boxes. on_close (Callable, optional): Callback ran when window is closed. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. @@ -3051,7 +3116,7 @@ def window(*, label: str =None, user_data: Any =None, use_internal_label: bool = if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - widget = internal_dpg.add_window(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, show=show, pos=pos, min_size=min_size, max_size=max_size, menubar=menubar, collapsed=collapsed, autosize=autosize, no_resize=no_resize, unsaved_document=unsaved_document, no_title_bar=no_title_bar, no_move=no_move, no_scrollbar=no_scrollbar, no_collapse=no_collapse, horizontal_scrollbar=horizontal_scrollbar, no_focus_on_appearing=no_focus_on_appearing, no_bring_to_front_on_focus=no_bring_to_front_on_focus, no_close=no_close, no_background=no_background, modal=modal, popup=popup, no_saved_settings=no_saved_settings, no_open_over_existing_popup=no_open_over_existing_popup, no_scroll_with_mouse=no_scroll_with_mouse, on_close=on_close, **kwargs) + widget = internal_dpg.add_window(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, show=show, pos=pos, min_size=min_size, max_size=max_size, menubar=menubar, collapsed=collapsed, autosize=autosize, no_resize=no_resize, unsaved_document=unsaved_document, no_title_bar=no_title_bar, no_move=no_move, no_scrollbar=no_scrollbar, no_collapse=no_collapse, horizontal_scrollbar=horizontal_scrollbar, no_focus_on_appearing=no_focus_on_appearing, no_bring_to_front_on_focus=no_bring_to_front_on_focus, no_close=no_close, no_background=no_background, modal=modal, popup=popup, no_saved_settings=no_saved_settings, no_open_over_existing_popup=no_open_over_existing_popup, no_scroll_with_mouse=no_scroll_with_mouse, no_docking=no_docking, copy_contents_shortcut=copy_contents_shortcut, on_close=on_close, **kwargs) internal_dpg.push_container_stack(widget) yield widget finally: @@ -3526,7 +3591,7 @@ def add_collapsing_header(*, label: str =None, user_data: Any =None, use_interna return internal_dpg.add_collapsing_header(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, closable=closable, default_open=default_open, open_on_double_click=open_on_double_click, open_on_arrow=open_on_arrow, leaf=leaf, bullet=bullet, **kwargs) -def add_color_button(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, 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, no_alpha: bool =False, no_border: bool =False, no_drag_drop: bool =False, **kwargs) -> Union[int, str]: +def add_color_button(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, 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, no_alpha: bool =False, no_border: bool =False, no_drag_drop: bool =False, alpha_preview: int =internal_dpg.mvColorEdit_AlphaPreviewNone, no_tooltip: bool =False, **kwargs) -> Union[int, str]: """ Adds a color button. Args: @@ -3553,6 +3618,8 @@ def add_color_button(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0 no_alpha (bool, optional): Removes the displayed slider that can change alpha channel. no_border (bool, optional): Disable border around the image. no_drag_drop (bool, optional): Disable ability to drag and drop small preview (color square) to apply colors to other items. + alpha_preview (int, optional): mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf + no_tooltip (bool, optional): Disable tooltip when hovering the button. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -3562,9 +3629,9 @@ def add_color_button(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0 warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) tag=kwargs['id'] - return internal_dpg.add_color_button(default_value, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, 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, no_alpha=no_alpha, no_border=no_border, no_drag_drop=no_drag_drop, **kwargs) + return internal_dpg.add_color_button(default_value, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, parent=parent, before=before, 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, no_alpha=no_alpha, no_border=no_border, no_drag_drop=no_drag_drop, alpha_preview=alpha_preview, no_tooltip=no_tooltip, **kwargs) -def add_color_edit(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, no_alpha: bool =False, no_picker: bool =False, no_options: bool =False, no_small_preview: bool =False, no_inputs: bool =False, no_tooltip: bool =False, no_label: bool =False, no_drag_drop: bool =False, alpha_bar: bool =False, alpha_preview: int =0, display_mode: int =internal_dpg.mvColorEdit_rgb, display_type: int =internal_dpg.mvColorEdit_uint8, input_mode: int =internal_dpg.mvColorEdit_input_rgb, **kwargs) -> Union[int, str]: +def add_color_edit(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, no_alpha: bool =False, no_picker: bool =False, no_options: bool =False, no_small_preview: bool =False, no_inputs: bool =False, no_tooltip: bool =False, no_label: bool =False, no_drag_drop: bool =False, alpha_bar: bool =False, alpha_preview: int =internal_dpg.mvColorEdit_AlphaPreviewNone, display_mode: int =internal_dpg.mvColorEdit_rgb, display_type: int =internal_dpg.mvColorEdit_uint8, input_mode: int =internal_dpg.mvColorEdit_input_rgb, **kwargs) -> Union[int, str]: """ Adds an RGBA color editor. Left clicking the small color preview will provide a color picker. Click and draging the small color preview will copy the color to be applied on any other color widget. Args: @@ -3613,7 +3680,7 @@ def add_color_edit(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, return internal_dpg.add_color_edit(default_value, 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, no_alpha=no_alpha, no_picker=no_picker, no_options=no_options, no_small_preview=no_small_preview, no_inputs=no_inputs, no_tooltip=no_tooltip, no_label=no_label, no_drag_drop=no_drag_drop, alpha_bar=alpha_bar, alpha_preview=alpha_preview, display_mode=display_mode, display_type=display_type, input_mode=input_mode, **kwargs) -def add_color_picker(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, no_alpha: bool =False, no_side_preview: bool =False, no_small_preview: bool =False, no_inputs: bool =False, no_tooltip: bool =False, no_label: bool =False, alpha_bar: bool =False, display_rgb: bool =False, display_hsv: bool =False, display_hex: bool =False, picker_mode: int =internal_dpg.mvColorPicker_bar, alpha_preview: int =0, display_type: int =internal_dpg.mvColorEdit_uint8, input_mode: int =internal_dpg.mvColorEdit_input_rgb, **kwargs) -> Union[int, str]: +def add_color_picker(default_value : Union[List[int], Tuple[int, ...]] =(0, 0, 0, 255), *, 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, no_alpha: bool =False, no_side_preview: bool =False, no_small_preview: bool =False, no_inputs: bool =False, no_tooltip: bool =False, no_label: bool =False, alpha_bar: bool =False, display_rgb: bool =False, display_hsv: bool =False, display_hex: bool =False, picker_mode: int =internal_dpg.mvColorPicker_bar, alpha_preview: int =internal_dpg.mvColorEdit_AlphaPreviewNone, display_type: int =internal_dpg.mvColorEdit_uint8, input_mode: int =internal_dpg.mvColorEdit_input_rgb, **kwargs) -> Union[int, str]: """ Adds an RGB color picker. Right click the color picker for options. Click and drag the color preview to copy the color and drop on any other color widget to apply. Right Click allows the style of the color picker to be changed. Args: @@ -4673,7 +4740,7 @@ def add_float_vect_value(*, label: str =None, user_data: Any =None, use_internal return internal_dpg.add_float_vect_value(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, source=source, default_value=default_value, parent=parent, **kwargs) -def add_font(file : str, size : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, pixel_snapH: bool =False, parent: Union[int, str] =internal_dpg.mvReservedUUID_0, **kwargs) -> Union[int, str]: +def add_font(file : str, size : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, pixel_snapH: bool =False, pixel_snapV: bool =False, parent: Union[int, str] =internal_dpg.mvReservedUUID_0, **kwargs) -> Union[int, str]: """ Adds font to a font registry. Args: @@ -4683,7 +4750,8 @@ def add_font(file : str, size : int, *, label: str =None, user_data: Any =None, user_data (Any, optional): User data for callbacks use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - pixel_snapH (bool, optional): Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font, or rendering text piece-by-piece (e.g. for coloring). + pixel_snapH (bool, optional): Align every glyph to pixel boundary in horizontal direction. Useful if you are rendering text piece-by-piece (e.g. for coloring). + pixel_snapV (bool, optional): Align scaled GlyphOffset.y to pixel boundaries in ImGui. parent (Union[int, str], optional): Parent to add this item to. (runtime adding) id (Union[int, str], optional): (deprecated) default_font (bool, optional): (deprecated) @@ -4701,71 +4769,7 @@ def add_font(file : str, size : int, *, label: str =None, user_data: Any =None, kwargs.pop('default_font', None) - return internal_dpg.add_font(file, size, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, pixel_snapH=pixel_snapH, parent=parent, **kwargs) - -def add_font_chars(chars : Union[List[int], Tuple[int, ...]], *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: - """ Adds specific font characters to a font. - - Args: - chars (Union[List[int], Tuple[int, ...]]): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - if 'id' in kwargs.keys(): - warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) - tag=kwargs['id'] - - return internal_dpg.add_font_chars(chars, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, **kwargs) - -def add_font_range(first_char : int, last_char : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: - """ Adds a range of font characters to a font. - - Args: - first_char (int): - last_char (int): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - if 'id' in kwargs.keys(): - warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) - tag=kwargs['id'] - - return internal_dpg.add_font_range(first_char, last_char, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, **kwargs) - -def add_font_range_hint(hint : int, *, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, parent: Union[int, str] =0, **kwargs) -> Union[int, str]: - """ Adds a range of font characters (mvFontRangeHint_ constants). - - Args: - hint (int): - label (str, optional): Overrides 'name' as label. - user_data (Any, optional): User data for callbacks - use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid). - tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label. - parent (Union[int, str], optional): Parent to add this item to. (runtime adding) - id (Union[int, str], optional): (deprecated) - Returns: - Union[int, str] - """ - - if 'id' in kwargs.keys(): - warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) - tag=kwargs['id'] - - return internal_dpg.add_font_range_hint(hint, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, **kwargs) + return internal_dpg.add_font(file, size, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, pixel_snapH=pixel_snapH, pixel_snapV=pixel_snapV, parent=parent, **kwargs) def add_font_registry(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, show: bool =True, **kwargs) -> Union[int, str]: """ Adds a font registry. @@ -4943,7 +4947,7 @@ def add_image(texture_tag : Union[int, str], *, label: str =None, user_data: Any tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom tint_color (Union[List[float], Tuple[float, ...]], optional): Applies a color tint to the entire texture. - border_color (Union[List[float], Tuple[float, ...]], optional): Displays a border of the specified color around the texture. If the theme style has turned off the border it will not be shown. + border_color (Union[List[float], Tuple[float, ...]], optional): Displays a border of the specified color around the texture. uv_min (Union[List[float], Tuple[float, ...]], optional): Normalized texture coordinates min point. uv_max (Union[List[float], Tuple[float, ...]], optional): Normalized texture coordinates max point. id (Union[int, str], optional): (deprecated) @@ -5055,7 +5059,7 @@ def add_inf_line_series(x : Union[List[float], Tuple[float, ...]], *, label: str return internal_dpg.add_inf_line_series(x, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, before=before, source=source, show=show, horizontal=horizontal, **kwargs) -def add_input_double(*, 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: float =0.0, format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, step: float =0.1, step_fast: float =1.0, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_double(*, 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: float =0.0, format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, step: float =0.1, step_fast: float =1.0, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds input for an double. Useful when input float is not accurate enough. +/- buttons can be activated by setting the value of step. Args: @@ -5088,6 +5092,8 @@ def add_input_double(*, label: str =None, user_data: Any =None, use_internal_lab max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5097,9 +5103,9 @@ def add_input_double(*, 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_input_double(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, format=format, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_double(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, format=format, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_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), format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_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), format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds multi double input for up to 4 double values. Useful when input float mulit is not accurate enough. Args: @@ -5131,6 +5137,8 @@ def add_input_doublex(*, label: str =None, user_data: Any =None, use_internal_la max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5140,9 +5148,9 @@ def add_input_doublex(*, 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_input_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, format=format, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_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, format=format, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_float(*, 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: float =0.0, format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, step: float =0.1, step_fast: float =1.0, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_float(*, 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: float =0.0, format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, step: float =0.1, step_fast: float =1.0, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds input for an float. +/- buttons can be activated by setting the value of step. Args: @@ -5175,6 +5183,8 @@ def add_input_float(*, label: str =None, user_data: Any =None, use_internal_labe max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5184,9 +5194,9 @@ def add_input_float(*, label: str =None, user_data: Any =None, use_internal_labe warnings.warn('id keyword renamed to tag', DeprecationWarning, 2) tag=kwargs['id'] - return internal_dpg.add_input_float(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, format=format, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_float(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, format=format, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_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), format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_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), format: str ='%.3f', min_value: float =0.0, max_value: float =100.0, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds multi float input for up to 4 float values. Args: @@ -5218,6 +5228,8 @@ def add_input_floatx(*, label: str =None, user_data: Any =None, use_internal_lab max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5227,9 +5239,9 @@ def add_input_floatx(*, 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_input_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, format=format, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_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, format=format, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_int(*, 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: int =0, min_value: int =0, max_value: int =100, step: int =1, step_fast: int =100, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_int(*, 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: int =0, min_value: int =0, max_value: int =100, step: int =1, step_fast: int =100, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds input for an int. +/- buttons can be activated by setting the value of step. Args: @@ -5261,6 +5273,8 @@ def add_input_int(*, label: str =None, user_data: Any =None, use_internal_label: max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter key press. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5270,9 +5284,9 @@ def add_input_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_input_int(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, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_int(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, min_value=min_value, max_value=max_value, step=step, step_fast=step_fast, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_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), min_value: int =0, max_value: int =100, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, **kwargs) -> Union[int, str]: +def add_input_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), min_value: int =0, max_value: int =100, size: int =4, min_clamped: bool =False, max_clamped: bool =False, on_enter: bool =False, readonly: bool =False, accept_empty_input: bool =False, display_empty_value: bool =False, **kwargs) -> Union[int, str]: """ Adds multi int input for up to 4 integer values. Args: @@ -5303,6 +5317,8 @@ def add_input_intx(*, label: str =None, user_data: Any =None, use_internal_label max_clamped (bool, optional): Activates and deactivates the enforcment of max_value. on_enter (bool, optional): Only runs callback on enter. readonly (bool, optional): Activates read only mode where no text can be input but text can still be highlighted. + accept_empty_input (bool, optional): Treat empty input as a zero value. + display_empty_value (bool, optional): If True, display an empty input if the value is zero. Generally used together with accept_empty_input. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5312,9 +5328,9 @@ def add_input_intx(*, 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_input_intx(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, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, **kwargs) + return internal_dpg.add_input_intx(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, min_value=min_value, max_value=max_value, size=size, min_clamped=min_clamped, max_clamped=max_clamped, on_enter=on_enter, readonly=readonly, accept_empty_input=accept_empty_input, display_empty_value=display_empty_value, **kwargs) -def add_input_text(*, 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: str ='', hint: str ='', multiline: bool =False, no_spaces: bool =False, uppercase: bool =False, tab_input: bool =False, decimal: bool =False, hexadecimal: bool =False, readonly: bool =False, password: bool =False, scientific: bool =False, on_enter: bool =False, auto_select_all: bool =False, ctrl_enter_for_new_line: bool =False, no_horizontal_scroll: bool =False, always_overwrite: bool =False, no_undo_redo: bool =False, escape_clears_all: bool =False, **kwargs) -> Union[int, str]: +def add_input_text(*, 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: str ='', hint: str ='', multiline: bool =False, no_spaces: bool =False, uppercase: bool =False, tab_input: bool =False, decimal: bool =False, hexadecimal: bool =False, readonly: bool =False, password: bool =False, scientific: bool =False, on_enter: bool =False, auto_select_all: bool =False, ctrl_enter_for_new_line: bool =False, no_horizontal_scroll: bool =False, always_overwrite: bool =False, no_undo_redo: bool =False, escape_clears_all: bool =False, elide_left: bool =False, **kwargs) -> Union[int, str]: """ Adds input for text. Args: @@ -5356,6 +5372,7 @@ def add_input_text(*, label: str =None, user_data: Any =None, use_internal_label always_overwrite (bool, optional): Overwrite mode no_undo_redo (bool, optional): Disable undo/redo. escape_clears_all (bool, optional): Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert) + elide_left (bool, optional): When text doesn't fit an inactive input field, clip it on the left side and ensure the right side stays visible. Useful for path/filenames. Single-line inputs only. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -5365,7 +5382,7 @@ def add_input_text(*, 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_input_text(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, hint=hint, multiline=multiline, no_spaces=no_spaces, uppercase=uppercase, tab_input=tab_input, decimal=decimal, hexadecimal=hexadecimal, readonly=readonly, password=password, scientific=scientific, on_enter=on_enter, auto_select_all=auto_select_all, ctrl_enter_for_new_line=ctrl_enter_for_new_line, no_horizontal_scroll=no_horizontal_scroll, always_overwrite=always_overwrite, no_undo_redo=no_undo_redo, escape_clears_all=escape_clears_all, **kwargs) + return internal_dpg.add_input_text(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, hint=hint, multiline=multiline, no_spaces=no_spaces, uppercase=uppercase, tab_input=tab_input, decimal=decimal, hexadecimal=hexadecimal, readonly=readonly, password=password, scientific=scientific, on_enter=on_enter, auto_select_all=auto_select_all, ctrl_enter_for_new_line=ctrl_enter_for_new_line, no_horizontal_scroll=no_horizontal_scroll, always_overwrite=always_overwrite, no_undo_redo=no_undo_redo, escape_clears_all=escape_clears_all, elide_left=elide_left, **kwargs) def add_int4_value(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, source: Union[int, str] =0, default_value: Union[List[int], Tuple[int, ...]] =(0, 0, 0, 0), parent: Union[int, str] =internal_dpg.mvReservedUUID_3, **kwargs) -> Union[int, str]: """ Adds a int4 value. @@ -6672,7 +6689,7 @@ def add_scatter_series(x : Union[List[float], Tuple[float, ...]], y : Union[List return internal_dpg.add_scatter_series(x, y, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, before=before, source=source, show=show, no_clip=no_clip, **kwargs) -def add_selectable(*, 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: bool =False, span_columns: bool =False, disable_popup_close: bool =False, **kwargs) -> Union[int, str]: +def add_selectable(*, 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: bool =False, span_columns: bool =False, disable_popup_close: bool =False, select_on_nav: bool =False, **kwargs) -> Union[int, str]: """ Adds a selectable. Similar to a button but can indicate its selected state. Args: @@ -6699,6 +6716,7 @@ def add_selectable(*, label: str =None, user_data: Any =None, use_internal_label default_value (bool, optional): span_columns (bool, optional): Forces the selectable to span the width of all columns if placed in a table. disable_popup_close (bool, optional): Disable closing a modal or popup window. + select_on_nav (bool, optional): Auto-select when moved into with keyboard navigation, unless Ctrl is held. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -6708,7 +6726,7 @@ def add_selectable(*, 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_selectable(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, span_columns=span_columns, disable_popup_close=disable_popup_close, **kwargs) + return internal_dpg.add_selectable(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, span_columns=span_columns, disable_popup_close=disable_popup_close, select_on_nav=select_on_nav, **kwargs) def add_separator(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], **kwargs) -> Union[int, str]: """ Adds a horizontal line separator. Use 'label' parameter to add text and mvStyleVar_SeparatorText* elements to style it. @@ -7284,7 +7302,7 @@ def add_synced_tables(*, label: str =None, user_data: Any =None, use_internal_la return internal_dpg.add_synced_tables(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, parent=parent, before=before, show=show, filter_key=filter_key, **kwargs) -def add_tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, closable: bool =False, no_tooltip: bool =False, order_mode: int =0, **kwargs) -> Union[int, str]: +def add_tab(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, closable: bool =False, no_tooltip: bool =False, order_mode: int =0, unsaved_document: bool =False, no_close_with_middle_click: bool =False, no_reorder: bool =False, **kwargs) -> Union[int, str]: """ Adds a tab to a tab bar. Args: @@ -7304,6 +7322,9 @@ def add_tab(*, label: str =None, user_data: Any =None, use_internal_label: bool closable (bool, optional): Creates a button on the tab that can hide the tab. no_tooltip (bool, optional): Disable tooltip for the given tab. order_mode (int, optional): set using a constant: mvTabOrder_Reorderable: allows reordering, mvTabOrder_Fixed: fixed ordering, mvTabOrder_Leading: adds tab to front, mvTabOrder_Trailing: adds tab to back + unsaved_document (bool, optional): Display a dot next to the title. + no_close_with_middle_click (bool, optional): Disable closing this tab (if closable==True) by clicking with middle mouse button. + no_reorder (bool, optional): Disable reordering this tab or having another tab cross over this tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Returns: @@ -7317,9 +7338,9 @@ def add_tab(*, label: str =None, user_data: Any =None, use_internal_label: bool if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - return internal_dpg.add_tab(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, closable=closable, no_tooltip=no_tooltip, order_mode=order_mode, **kwargs) + return internal_dpg.add_tab(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, closable=closable, no_tooltip=no_tooltip, order_mode=order_mode, unsaved_document=unsaved_document, no_close_with_middle_click=no_close_with_middle_click, no_reorder=no_reorder, **kwargs) -def add_tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, reorderable: bool =False, **kwargs) -> Union[int, str]: +def add_tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, reorderable: bool =False, tab_list_popup_button: bool =False, no_close_with_middle_click: bool =False, no_scrolling_buttons: bool =False, no_tooltip: bool =False, draw_selected_overline: bool =False, **kwargs) -> Union[int, str]: """ Adds a tab bar. Args: @@ -7337,6 +7358,11 @@ def add_tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: b tracked (bool, optional): Scroll tracking track_offset (float, optional): 0.0f:top, 0.5f:center, 1.0f:bottom reorderable (bool, optional): Allows for the user to change the order of the tabs. + tab_list_popup_button (bool, optional): Show a button to select active tab from a dropdown list. + no_close_with_middle_click (bool, optional): Disable closing tabs (that have closable=True) by clicking with middle mouse button. + no_scrolling_buttons (bool, optional): Disable left/right scrolling buttons when tab buttons don't fit the container width. + no_tooltip (bool, optional): Disable tooltips when hovering a tab with a long name. + draw_selected_overline (bool, optional): Draw selected overline markers over selected tab. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Returns: @@ -7350,9 +7376,9 @@ def add_tab_bar(*, label: str =None, user_data: Any =None, use_internal_label: b if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - return internal_dpg.add_tab_bar(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, callback=callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, reorderable=reorderable, **kwargs) + return internal_dpg.add_tab_bar(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, callback=callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, reorderable=reorderable, tab_list_popup_button=tab_list_popup_button, no_close_with_middle_click=no_close_with_middle_click, no_scrolling_buttons=no_scrolling_buttons, no_tooltip=no_tooltip, draw_selected_overline=draw_selected_overline, **kwargs) -def add_tab_button(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, no_reorder: bool =False, leading: bool =False, trailing: bool =False, no_tooltip: bool =False, **kwargs) -> Union[int, str]: +def add_tab_button(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', callback: Callable =None, drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, filter_key: str ='', tracked: bool =False, track_offset: float =0.5, no_reorder: bool =False, leading: bool =False, trailing: bool =False, no_tooltip: bool =False, unsaved_document: bool =False, **kwargs) -> Union[int, str]: """ Adds a tab button to a tab bar. Args: @@ -7375,6 +7401,7 @@ def add_tab_button(*, label: str =None, user_data: Any =None, use_internal_label leading (bool, optional): Enforce the tab position to the left of the tab bar (after the tab list popup button). trailing (bool, optional): Enforce the tab position to the right of the tab bar (before the scrolling buttons). no_tooltip (bool, optional): Disable tooltip for the given tab. + unsaved_document (bool, optional): Display a dot next to the title. id (Union[int, str], optional): (deprecated) Returns: Union[int, str] @@ -7384,7 +7411,7 @@ def add_tab_button(*, 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_tab_button(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, no_reorder=no_reorder, leading=leading, trailing=trailing, no_tooltip=no_tooltip, **kwargs) + return internal_dpg.add_tab_button(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, callback=callback, drag_callback=drag_callback, drop_callback=drop_callback, show=show, filter_key=filter_key, tracked=tracked, track_offset=track_offset, no_reorder=no_reorder, leading=leading, trailing=trailing, no_tooltip=no_tooltip, unsaved_document=unsaved_document, **kwargs) def add_table(*, 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, callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', header_row: bool =True, clipper: bool =False, inner_width: int =0, policy: int =0, freeze_rows: int =0, freeze_columns: int =0, sort_multi: bool =False, sort_tristate: bool =False, resizable: bool =False, reorderable: bool =False, hideable: bool =False, sortable: bool =False, context_menu_in_body: bool =False, row_background: bool =False, borders_innerH: bool =False, borders_outerH: bool =False, borders_innerV: bool =False, borders_outerV: bool =False, no_host_extendX: bool =False, no_host_extendY: bool =False, no_keep_columns_visible: bool =False, precise_widths: bool =False, no_clip: bool =False, pad_outerX: bool =False, no_pad_outerX: bool =False, no_pad_innerX: bool =False, scrollX: bool =False, scrollY: bool =False, no_saved_settings: bool =False, **kwargs) -> Union[int, str]: """ Adds a table. @@ -7801,7 +7828,7 @@ def add_tooltip(parent : Union[int, str], *, label: str =None, user_data: Any =N return internal_dpg.add_tooltip(parent, label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, show=show, delay=delay, hide_on_activity=hide_on_activity, **kwargs) -def add_tree_node(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_open: bool =False, open_on_double_click: bool =False, open_on_arrow: bool =False, leaf: bool =False, bullet: bool =False, selectable: bool =False, span_text_width: bool =False, span_full_width: bool =False, **kwargs) -> Union[int, str]: +def add_tree_node(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, indent: int =-1, parent: Union[int, str] =0, before: Union[int, str] =0, payload_type: str ='$$DPG_PAYLOAD', drag_callback: Callable =None, drop_callback: Callable =None, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], filter_key: str ='', tracked: bool =False, track_offset: float =0.5, default_open: bool =False, open_on_double_click: bool =False, open_on_arrow: bool =False, leaf: bool =False, bullet: bool =False, selectable: bool =False, span_text_width: bool =False, span_full_width: bool =False, catch_nav_left: bool =False, lines: int =internal_dpg.mvTreeLines_None, **kwargs) -> Union[int, str]: """ Adds a tree node to add items to. Args: @@ -7828,6 +7855,8 @@ def add_tree_node(*, label: str =None, user_data: Any =None, use_internal_label: selectable (bool, optional): Makes the tree selectable. span_text_width (bool, optional): Makes hitbox and highlight only cover the label. span_full_width (bool, optional): Extend hit box to the left-most and right-most edges (cover the indent area). + catch_nav_left (bool, optional): Keyboard navigation: left arrow within this node's children, if unhandled, moves focus to this node. When setting it to True on a node, better set it on all children nodes in the subtree as well, otherwise it might give unexpected navigation jumps. + lines (int, optional): Experimental. Draw lines connecting tree_node hierarchy. One of dpg.mvTreeLines constants. To work correctly, must be configured the same way in every tree node. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. Returns: @@ -7841,7 +7870,7 @@ def add_tree_node(*, label: str =None, user_data: Any =None, use_internal_label: if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - return internal_dpg.add_tree_node(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_open=default_open, open_on_double_click=open_on_double_click, open_on_arrow=open_on_arrow, leaf=leaf, bullet=bullet, selectable=selectable, span_text_width=span_text_width, span_full_width=span_full_width, **kwargs) + return internal_dpg.add_tree_node(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, before=before, payload_type=payload_type, drag_callback=drag_callback, drop_callback=drop_callback, show=show, pos=pos, filter_key=filter_key, tracked=tracked, track_offset=track_offset, default_open=default_open, open_on_double_click=open_on_double_click, open_on_arrow=open_on_arrow, leaf=leaf, bullet=bullet, selectable=selectable, span_text_width=span_text_width, span_full_width=span_full_width, catch_nav_left=catch_nav_left, lines=lines, **kwargs) def add_value_registry(*, label: str =None, user_data: Any =None, use_internal_label: bool =True, tag: Union[int, str] =0, **kwargs) -> Union[int, str]: """ Adds a value registry. @@ -7914,7 +7943,7 @@ def add_viewport_menu_bar(*, label: str =None, user_data: Any =None, use_interna return internal_dpg.add_viewport_menu_bar(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, indent=indent, parent=parent, show=show, **kwargs) -def add_window(*, 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, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], min_size: Union[List[int], Tuple[int, ...]] =[100, 100], max_size: Union[List[int], Tuple[int, ...]] =[30000, 30000], menubar: bool =False, collapsed: bool =False, autosize: bool =False, no_resize: bool =False, unsaved_document: bool =False, no_title_bar: bool =False, no_move: bool =False, no_scrollbar: bool =False, no_collapse: bool =False, horizontal_scrollbar: bool =False, no_focus_on_appearing: bool =False, no_bring_to_front_on_focus: bool =False, no_close: bool =False, no_background: bool =False, modal: bool =False, popup: bool =False, no_saved_settings: bool =False, no_open_over_existing_popup: bool =True, no_scroll_with_mouse: bool =False, on_close: Callable =None, **kwargs) -> Union[int, str]: +def add_window(*, 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, show: bool =True, pos: Union[List[int], Tuple[int, ...]] =[], min_size: Union[List[int], Tuple[int, ...]] =[100, 100], max_size: Union[List[int], Tuple[int, ...]] =[30000, 30000], menubar: bool =False, collapsed: bool =False, autosize: bool =False, no_resize: bool =False, unsaved_document: bool =False, no_title_bar: bool =False, no_move: bool =False, no_scrollbar: bool =False, no_collapse: bool =False, horizontal_scrollbar: bool =False, no_focus_on_appearing: bool =False, no_bring_to_front_on_focus: bool =False, no_close: bool =False, no_background: bool =False, modal: bool =False, popup: bool =False, no_saved_settings: bool =False, no_open_over_existing_popup: bool =True, no_scroll_with_mouse: bool =False, no_docking: bool =False, copy_contents_shortcut: bool =False, on_close: Callable =None, **kwargs) -> Union[int, str]: """ Creates a new window for following items to be added to. Args: @@ -7948,6 +7977,8 @@ def add_window(*, label: str =None, user_data: Any =None, use_internal_label: bo no_saved_settings (bool, optional): Never load/save settings in .ini file. no_open_over_existing_popup (bool, optional): Don't open if there's already a popup no_scroll_with_mouse (bool, optional): Disable user vertically scrolling with mouse wheel. + no_docking (bool, optional): Disable docking of this window + copy_contents_shortcut (bool, optional): Experimental. If True, window contents can be copied to clipboard by pressing Ctrl+C. Might be useful for message boxes. on_close (Callable, optional): Callback ran when window is closed. id (Union[int, str], optional): (deprecated) delay_search (bool, optional): (deprecated) This was used as an optimization hint but is not relevant anymore. @@ -7962,7 +7993,7 @@ def add_window(*, label: str =None, user_data: Any =None, use_internal_label: bo if 'delay_search' in kwargs.keys(): warnings.warn('delay_search keyword deprecated. ', DeprecationWarning, 2) - return internal_dpg.add_window(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, show=show, pos=pos, min_size=min_size, max_size=max_size, menubar=menubar, collapsed=collapsed, autosize=autosize, no_resize=no_resize, unsaved_document=unsaved_document, no_title_bar=no_title_bar, no_move=no_move, no_scrollbar=no_scrollbar, no_collapse=no_collapse, horizontal_scrollbar=horizontal_scrollbar, no_focus_on_appearing=no_focus_on_appearing, no_bring_to_front_on_focus=no_bring_to_front_on_focus, no_close=no_close, no_background=no_background, modal=modal, popup=popup, no_saved_settings=no_saved_settings, no_open_over_existing_popup=no_open_over_existing_popup, no_scroll_with_mouse=no_scroll_with_mouse, on_close=on_close, **kwargs) + return internal_dpg.add_window(label=label, user_data=user_data, use_internal_label=use_internal_label, tag=tag, width=width, height=height, indent=indent, show=show, pos=pos, min_size=min_size, max_size=max_size, menubar=menubar, collapsed=collapsed, autosize=autosize, no_resize=no_resize, unsaved_document=unsaved_document, no_title_bar=no_title_bar, no_move=no_move, no_scrollbar=no_scrollbar, no_collapse=no_collapse, horizontal_scrollbar=horizontal_scrollbar, no_focus_on_appearing=no_focus_on_appearing, no_bring_to_front_on_focus=no_bring_to_front_on_focus, no_close=no_close, no_background=no_background, modal=modal, popup=popup, no_saved_settings=no_saved_settings, no_open_over_existing_popup=no_open_over_existing_popup, no_scroll_with_mouse=no_scroll_with_mouse, no_docking=no_docking, copy_contents_shortcut=copy_contents_shortcut, on_close=on_close, **kwargs) def apply_transform(item : Union[int, str], transform : Any, **kwargs) -> None: """ New in 1.1. Applies a transformation matrix to a layer. @@ -10275,6 +10306,9 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvTable_SizingFixedSame=internal_dpg.mvTable_SizingFixedSame mvTable_SizingStretchProp=internal_dpg.mvTable_SizingStretchProp mvTable_SizingStretchSame=internal_dpg.mvTable_SizingStretchSame +mvTreeLines_None=internal_dpg.mvTreeLines_None +mvTreeLines_Full=internal_dpg.mvTreeLines_Full +mvTreeLines_ToNodes=internal_dpg.mvTreeLines_ToNodes mvFormat_Float_rgba=internal_dpg.mvFormat_Float_rgba mvFormat_Float_rgb=internal_dpg.mvFormat_Float_rgb mvThemeCat_Core=internal_dpg.mvThemeCat_Core @@ -10284,8 +10318,8 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvThemeCol_TextDisabled=internal_dpg.mvThemeCol_TextDisabled mvThemeCol_WindowBg=internal_dpg.mvThemeCol_WindowBg mvThemeCol_ChildBg=internal_dpg.mvThemeCol_ChildBg -mvThemeCol_Border=internal_dpg.mvThemeCol_Border mvThemeCol_PopupBg=internal_dpg.mvThemeCol_PopupBg +mvThemeCol_Border=internal_dpg.mvThemeCol_Border mvThemeCol_BorderShadow=internal_dpg.mvThemeCol_BorderShadow mvThemeCol_FrameBg=internal_dpg.mvThemeCol_FrameBg mvThemeCol_FrameBgHovered=internal_dpg.mvThemeCol_FrameBgHovered @@ -10313,11 +10347,14 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvThemeCol_ResizeGrip=internal_dpg.mvThemeCol_ResizeGrip mvThemeCol_ResizeGripHovered=internal_dpg.mvThemeCol_ResizeGripHovered mvThemeCol_ResizeGripActive=internal_dpg.mvThemeCol_ResizeGripActive -mvThemeCol_Tab=internal_dpg.mvThemeCol_Tab +mvThemeCol_InputTextCursor=internal_dpg.mvThemeCol_InputTextCursor mvThemeCol_TabHovered=internal_dpg.mvThemeCol_TabHovered -mvThemeCol_TabActive=internal_dpg.mvThemeCol_TabActive -mvThemeCol_TabUnfocused=internal_dpg.mvThemeCol_TabUnfocused -mvThemeCol_TabUnfocusedActive=internal_dpg.mvThemeCol_TabUnfocusedActive +mvThemeCol_Tab=internal_dpg.mvThemeCol_Tab +mvThemeCol_TabSelected=internal_dpg.mvThemeCol_TabSelected +mvThemeCol_TabSelectedOverline=internal_dpg.mvThemeCol_TabSelectedOverline +mvThemeCol_TabDimmed=internal_dpg.mvThemeCol_TabDimmed +mvThemeCol_TabDimmedSelected=internal_dpg.mvThemeCol_TabDimmedSelected +mvThemeCol_TabDimmedSelectedOverline=internal_dpg.mvThemeCol_TabDimmedSelectedOverline mvThemeCol_DockingPreview=internal_dpg.mvThemeCol_DockingPreview mvThemeCol_DockingEmptyBg=internal_dpg.mvThemeCol_DockingEmptyBg mvThemeCol_PlotLines=internal_dpg.mvThemeCol_PlotLines @@ -10330,11 +10367,18 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvThemeCol_TableRowBg=internal_dpg.mvThemeCol_TableRowBg mvThemeCol_TableRowBgAlt=internal_dpg.mvThemeCol_TableRowBgAlt mvThemeCol_TextSelectedBg=internal_dpg.mvThemeCol_TextSelectedBg +mvThemeCol_TreeLines=internal_dpg.mvThemeCol_TreeLines mvThemeCol_DragDropTarget=internal_dpg.mvThemeCol_DragDropTarget -mvThemeCol_NavHighlight=internal_dpg.mvThemeCol_NavHighlight +mvThemeCol_DragDropTargetBg=internal_dpg.mvThemeCol_DragDropTargetBg +mvThemeCol_UnsavedMarker=internal_dpg.mvThemeCol_UnsavedMarker +mvThemeCol_NavCursor=internal_dpg.mvThemeCol_NavCursor mvThemeCol_NavWindowingHighlight=internal_dpg.mvThemeCol_NavWindowingHighlight mvThemeCol_NavWindowingDimBg=internal_dpg.mvThemeCol_NavWindowingDimBg mvThemeCol_ModalWindowDimBg=internal_dpg.mvThemeCol_ModalWindowDimBg +mvThemeCol_TabActive=internal_dpg.mvThemeCol_TabActive +mvThemeCol_TabUnfocused=internal_dpg.mvThemeCol_TabUnfocused +mvThemeCol_TabUnfocusedActive=internal_dpg.mvThemeCol_TabUnfocusedActive +mvThemeCol_NavHighlight=internal_dpg.mvThemeCol_NavHighlight mvPlotCol_Line=internal_dpg.mvPlotCol_Line mvPlotCol_Fill=internal_dpg.mvPlotCol_Fill mvPlotCol_MarkerOutline=internal_dpg.mvPlotCol_MarkerOutline @@ -10348,11 +10392,12 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvPlotCol_LegendText=internal_dpg.mvPlotCol_LegendText mvPlotCol_TitleText=internal_dpg.mvPlotCol_TitleText mvPlotCol_InlayText=internal_dpg.mvPlotCol_InlayText +mvPlotCol_AxisText=internal_dpg.mvPlotCol_AxisText +mvPlotCol_AxisGrid=internal_dpg.mvPlotCol_AxisGrid +mvPlotCol_AxisTick=internal_dpg.mvPlotCol_AxisTick mvPlotCol_AxisBg=internal_dpg.mvPlotCol_AxisBg -mvPlotCol_AxisBgActive=internal_dpg.mvPlotCol_AxisBgActive mvPlotCol_AxisBgHovered=internal_dpg.mvPlotCol_AxisBgHovered -mvPlotCol_AxisGrid=internal_dpg.mvPlotCol_AxisGrid -mvPlotCol_AxisText=internal_dpg.mvPlotCol_AxisText +mvPlotCol_AxisBgActive=internal_dpg.mvPlotCol_AxisBgActive mvPlotCol_Selection=internal_dpg.mvPlotCol_Selection mvPlotCol_Crosshairs=internal_dpg.mvPlotCol_Crosshairs mvNodeCol_NodeBackground=internal_dpg.mvNodeCol_NodeBackground @@ -10404,13 +10449,20 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvStyleVar_CellPadding=internal_dpg.mvStyleVar_CellPadding mvStyleVar_ScrollbarSize=internal_dpg.mvStyleVar_ScrollbarSize mvStyleVar_ScrollbarRounding=internal_dpg.mvStyleVar_ScrollbarRounding +mvStyleVar_ScrollbarPadding=internal_dpg.mvStyleVar_ScrollbarPadding mvStyleVar_GrabMinSize=internal_dpg.mvStyleVar_GrabMinSize mvStyleVar_GrabRounding=internal_dpg.mvStyleVar_GrabRounding +mvStyleVar_ImageBorderSize=internal_dpg.mvStyleVar_ImageBorderSize mvStyleVar_TabRounding=internal_dpg.mvStyleVar_TabRounding mvStyleVar_TabBorderSize=internal_dpg.mvStyleVar_TabBorderSize +mvStyleVar_TabMinWidthBase=internal_dpg.mvStyleVar_TabMinWidthBase +mvStyleVar_TabMinWidthShrink=internal_dpg.mvStyleVar_TabMinWidthShrink mvStyleVar_TabBarBorderSize=internal_dpg.mvStyleVar_TabBarBorderSize +mvStyleVar_TabBarOverlineSize=internal_dpg.mvStyleVar_TabBarOverlineSize mvStyleVar_TableAngledHeadersAngle=internal_dpg.mvStyleVar_TableAngledHeadersAngle mvStyleVar_TableAngledHeadersTextAlign=internal_dpg.mvStyleVar_TableAngledHeadersTextAlign +mvStyleVar_TreeLinesSize=internal_dpg.mvStyleVar_TreeLinesSize +mvStyleVar_TreeLinesRounding=internal_dpg.mvStyleVar_TreeLinesRounding mvStyleVar_ButtonTextAlign=internal_dpg.mvStyleVar_ButtonTextAlign mvStyleVar_SelectableTextAlign=internal_dpg.mvStyleVar_SelectableTextAlign mvStyleVar_SeparatorTextBorderSize=internal_dpg.mvStyleVar_SeparatorTextBorderSize @@ -10598,9 +10650,6 @@ def unstage(item : Union[int, str], **kwargs) -> None: mvThemeColor=internal_dpg.mvThemeColor mvThemeStyle=internal_dpg.mvThemeStyle mvThemeComponent=internal_dpg.mvThemeComponent -mvFontRangeHint=internal_dpg.mvFontRangeHint -mvFontRange=internal_dpg.mvFontRange -mvFontChars=internal_dpg.mvFontChars mvCharRemap=internal_dpg.mvCharRemap mvValueRegistry=internal_dpg.mvValueRegistry mvIntValue=internal_dpg.mvIntValue diff --git a/dearpygui/demo.py b/dearpygui/demo.py index 679c7a26b..44686bcec 100644 --- a/dearpygui/demo.py +++ b/dearpygui/demo.py @@ -476,7 +476,7 @@ def _color_picker_configs(sender, value, user_data): dpg.add_radio_button(("mvColorEdit_input_rgb", "mvColorEdit_input_hsv"), callback=_color_picker_configs, user_data=_color_picker_id, horizontal=True) - dpg.add_color_picker((255, 0, 255, 200), label="Color Picker", alpha_preview=True, no_alpha=False, alpha_bar=True, + dpg.add_color_picker((255, 0, 255, 200), label="Color Picker", alpha_preview=dpg.mvColorEdit_AlphaPreviewNone, no_alpha=False, alpha_bar=True, width=200, tag=_color_picker_id) _add_config_options(_color_picker_id, 3, diff --git a/docs/source/documentation/fonts.rst b/docs/source/documentation/fonts.rst index d3aff0cb9..2653ed90b 100644 --- a/docs/source/documentation/fonts.rst +++ b/docs/source/documentation/fonts.rst @@ -13,10 +13,11 @@ folder you can find an example of a otf font. Readme First ------------ -All loaded fonts glyphs are rendered into a single texture atlas ahead of time. -Adding/Removing/Modifying fonts will cause the font atlas to be rebuilt. +All loaded fonts glyphs are rendered into a single texture atlas. Rendering occurs +on-the-fly as characters are encountered in UI strings (item labels, input contents, etc. - +anything that gets displayed in the viewport). -You can use the style editor +You can use the Fonts Manager tool :py:func:`show_font_manager ` to browse your fonts and understand what's going on if you have an issue. @@ -24,8 +25,14 @@ Font Loading Instructions ------------------------- To add your own fonts, you must first create a font registry to -add fonts to. Next, add fonts to the registry. By default only basic latin -and latin supplement glyphs are added (0x0020 - 0x00FF). +add fonts to. Next, add fonts to the registry. + +For a font to take effect, it must be either bound globally with :py:func:`bind_font ` +or bound to a particular item with :py:func:`bind_item_font `. +In the latter case, the font is "inherited" by all child item if it is bound to +a container. To remove font binding and revert to the default font (or inherit from +the parent item), call `bind_font`/`bind_item_font` again, passing 0 in the `font` +argument. .. code-block:: python @@ -39,13 +46,14 @@ and latin supplement glyphs are added (0x0020 - 0x00FF). default_font = dpg.add_font("NotoSerifCJKjp-Medium.otf", 20) second_font = dpg.add_font("NotoSerifCJKjp-Medium.otf", 10) + dpg.bind_font(default_font) + with dpg.window(label="Font Example", height=200, width=200): dpg.add_button(label="Default font") b2 = dpg.add_button(label="Secondary font") dpg.add_button(label="default") # set font of specific widget - dpg.bind_font(default_font) dpg.bind_item_font(b2, second_font) dpg.show_font_manager() @@ -59,8 +67,19 @@ and latin supplement glyphs are added (0x0020 - 0x00FF). Loading Specific Unicode Characters ----------------------------------- -There are several ways to add specific characters from a font file. -You can use range hints, ranges, and specific characters. You can also remap characters. +.. note:: + This section previously described how to load specific characters from font file + so that they are displayed in the UI correctly. Since DPG version 2.3, character + glyphs are rendered automatically and there is no need to specify them in advance. + This section is no longer relevant, and the functions `add_font_chars`, `add_font_range`, + and `add_font_range_hint` are obsolete and do nothing if you call them. + +Remapping Characters +----------------------------------- + +For convenience, you can remap a character to a different character code and use +this replacement in your text strings. In particular, it might be useful with icon +fonts. Here is an example of how to do such remapping. .. code-block:: python @@ -71,26 +90,6 @@ You can use range hints, ranges, and specific characters. You can also remap cha with dpg.font_registry(): with dpg.font("NotoSerifCJKjp-Medium.otf", 20) as font1: - # add the default font range - dpg.add_font_range_hint(dpg.mvFontRangeHint_Default) - - # helper to add range of characters - # Options: - # mvFontRangeHint_Japanese - # mvFontRangeHint_Korean - # mvFontRangeHint_Chinese_Full - # mvFontRangeHint_Chinese_Simplified_Common - # mvFontRangeHint_Cyrillic - # mvFontRangeHint_Thai - # mvFontRangeHint_Vietnamese - dpg.add_font_range_hint(dpg.mvFontRangeHint_Japanese) - - # add specific range of glyphs - dpg.add_font_range(0x3100, 0x3ff0) - - # add specific glyphs - dpg.add_font_chars([0x3105, 0x3107, 0x3108]) - # remap や to % dpg.add_char_remap(0x3084, 0x0025) diff --git a/sandbox/CMakeLists.txt b/sandbox/CMakeLists.txt index fb2ed5302..f3a24d9d3 100644 --- a/sandbox/CMakeLists.txt +++ b/sandbox/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.13) +cmake_minimum_required (VERSION 3.16) add_executable (DearSandbox) diff --git a/sandbox/sandbox.py b/sandbox/sandbox.py index b172f0727..d490a59e3 100644 --- a/sandbox/sandbox.py +++ b/sandbox/sandbox.py @@ -16,8 +16,7 @@ log.log_critical("log critical") with dpg.font_registry(): - with dpg.font("../../assets/NotoSerifCJKjp-Medium.otf", 20, tag="custom font"): - dpg.add_font_range_hint(dpg.mvFontRangeHint_Default) + dpg.add_font("../../assets/NotoSerifCJKjp-Medium.otf", 20, tag="custom font") dpg.bind_font(dpg.last_container()) demo.show_demo() diff --git a/scripts/GenItemFlagOps.py b/scripts/GenItemFlagOps.py new file mode 100644 index 000000000..314717ca2 --- /dev/null +++ b/scripts/GenItemFlagOps.py @@ -0,0 +1,212 @@ +# Takes a specific item's flags (a ImGuiSomethingFlags_ enum) from imgui.h and outputs +# boilerplate to copy-paste into handleSpecificKeywordArgs / getSpecificConfiguration. +# Run with --all to get updates for all known flags. +# Redirect output to a file for better reading / copy-pasting. + +import argparse +import itertools +from pathlib import Path +import re +from string import Template +from typing import List, Set, Tuple + + +imgui_h = Path(__file__).parent.parent / "thirdparty" / "imgui" / "imgui.h" +src_path = Path(__file__).parent.parent / "src" +# implot_h = Path(__file__).parent.parent / "thirdparty" / "implot" / "implot.h" +# imnodes_h = Path(__file__).parent.parent / "thirdparty" / "imnodes" / "imnodes.h" + + +# We extract both set_configuration and handleSpecificKeywordArgs +dpg_func_re = re.compile( + r"^(?:DearPyGui::set_configuration\(.*? (mv\w+?)Config&|" + r"(?:void\s+)?(mv\w+)::handleSpecificKeywordArgs).*?\n\{(.*?)^\}", + re.MULTILINE | re.DOTALL +) + + +def get_existing_flags(src_file: Path) -> List[Tuple[str, Set[str], str]]: + text = src_file.read_text("utf-8") + func_defs = dpg_func_re.findall(text) + + # We don't care what the destination flags variable is named + declarationRe = re.compile(r'\s*flagop\("\w+",\s*(ImGui\w+),') + + def extract_flags(text: str) -> Set[str]: + parsed = [declarationRe.match(l) for l in text.splitlines()] + return set([m[1] for m in parsed if m is not None]) + + def get_indentation(text: str) -> str: + # Note: we can't use \s in the pattern because it also matches newlines + m = re.search(r"^([ \t]*)flagop", text, re.MULTILINE) + return "\t" if m is None else m[1] + + # The widget name is either in the group 1 or group 2, which are 0th and 1st elements + # of the find_all result, respectively. + return [ (d[0] or d[1], extract_flags(d[2]), get_indentation(d[2])) for d in func_defs ] + + +def gen_py_name(imgui_name: str) -> str: + return re.sub("([^A-Z])([A-Z])", r"\1_\2", imgui_name).lower() + # return re.sub("([A-Z])", r"_\1", imgui_name).lstrip("_").lower() + + +# Returns a list of (imgui_name, py_name, comment) tuples +def read_enum(src_file: Path, enum_name: str, existing_flags: Set[str]) -> List[Tuple[str, str, str]]: + prefix = enum_name + "_" + + text = src_file.read_text("utf-8") + m = re.search(r"^enum\s+" + prefix + r"\b.*?\n\{(.*?)^\};", text, re.MULTILINE | re.DOTALL) + if m is None: + print(f"Can't find enum {enum_name}.") + return [] + + text = m[1] + text = re.sub(r"^#ifndef\s+IMGUI_DISABLE_OBSOLETE_FUNCTIONS.*?^#endif.*?\n", "", text, flags=re.MULTILINE | re.DOTALL) + lines = text.splitlines() + # drop all commented lines + # lines = list(filter(lambda l: not l.lstrip().startswith("//"), lines)) + declarationRe = re.compile(r"\s*" + prefix + r"(\w+)\s*=\s*1\s*<<\s*\d+,\s*(?://\s*(.*))") + parsed = [declarationRe.match(l) for l in lines] + + return [ + (prefix + m[1], gen_py_name(m[1]), m[2]) + for m in parsed + if m is not None and (prefix + m[1]) not in existing_flags + ] + + +def conv_set_config(flags: List[Tuple[str, str]], indent: str) -> List[str]: + template = Template('flagop("$py_name", $imgui_name, outConfig.flags);') + return [ + indent + template.substitute(py_name=py_name, imgui_name=imgui_name) + for imgui_name, py_name, comment in flags + ] + + +def conv_get_config(flags: List[Tuple[str, str]], indent: str) -> List[str]: + template = Template('checkbitset("$py_name", $imgui_name, inConfig.flags);') + return [ + indent + template.substitute(py_name=py_name, imgui_name=imgui_name) + for imgui_name, py_name, comment in flags + ] + + +def conv_parser(flags: List[Tuple[str, str]]) -> List[str]: + template = Template(' args.push_back({ mvPyDataType::Bool, "$py_name", mvArgType::KEYWORD_ARG, "False", "$desc" });') + return [ + template.substitute(py_name=py_name, desc=comment) + for imgui_name, py_name, comment in flags + ] + + +def process_enum(enum_name: str, existing_flags: Set[str], widget_name: str, indent: str) -> List[str]: + enum_name = enum_name.rstrip("_") + flags = read_enum(imgui_h, enum_name, existing_flags) + if not flags: + return [] + + if widget_name: + widget_name += ": " + + return ( + [ + f"=== {widget_name}{enum_name} ===", + "", + "Copy this to parser definitions in mvAppItem.cpp:", + "", + ] + + conv_parser(flags) + + [ + "", + "Copy this to handleSpecificKeywordArgs() / DearPyGui::set_configuration():", + "", + ] + + conv_set_config(flags, indent) + + [ + "", + "Copy this to getSpecificConfiguration() / DearPyGui::fill_configuration_dict():", + "", + ] + + conv_get_config(flags, indent) + + ["", ""] + ) + + +parser = argparse.ArgumentParser(description="Convert item flags into DPG boilerplate.") +parser.add_argument("enums", metavar="enum-name", nargs="*", + help="enum name, with or without the trailing underscore") +parser.add_argument("--all", action="store_true", help="refresh all known enums found in DPG source") + +args = parser.parse_args() + +# A list of (widget_name, imgui_flags, indentation) tuples +widget_defs = ( + get_existing_flags(src_path / "mvBasicWidgets.cpp") + + get_existing_flags(src_path / "mvColors.cpp") + + get_existing_flags(src_path / "mvContainers.cpp") + + # get_existing_flags(src_path / "mvNodes.cpp") + + # get_existing_flags(src_path / "mvPlotting.cpp") + + get_existing_flags(src_path / "mvTables.cpp") +) + +# This dict maps widget name to a list of ImGui flags +existing = {name: flags for name, flags, indentation in widget_defs} + +# Just squashing all prefixes in each sub-list into a set. +# The resulting dict maps widget name to a set of ImGui enum prefixes, ideally just +# one enum per widget (but who knows). +existing_prefixes = { + widget: set([ e.partition("_")[0] for e in flags ]) for widget, flags in existing.items() +} + +# This will keep a (widget, enum) list, where widget may be empty e.g. if we only +# have an enum name but it's not used in any known widget +enums: List[Tuple[str, str]] + +if args.all or not args.enums: + # Here we get all combinations of (widget, prefix) pairs + enums = sorted([ + (widget, prefix) + for widget, prefixes in existing_prefixes.items() + for prefix in prefixes + ], key=lambda item: (item[1], item[0])) + +else: + # Here we're only given enum prefixes, let's find the corresponding widgets + prefixes = [e.rstrip("_") for e in args.enums] + # We only need this mapping to make sure we don't lose prefixes that are not + # found anywhere in existing_prefixes (i.e. something new). For these, we add + # an empty widget name in their list so they are not lost. + widgets_per_pref = { + prefix: (sorted([w for w, p in existing_prefixes.items() if prefix in p]) or [""]) + for prefix in prefixes + } + # Now reverse the mapping + enums = [ + (w, p) + for p, widgets in widgets_per_pref.items() + for w in widgets + ] + +# Double check if we might be missing some widgets + +no_eyecatcher = [name for name, flags in existing.items() if not flags] +if no_eyecatcher: + print( + "=== No flags detected ===\n\n" + "The following items seem to not have any flags (or, rather, flagop() calls)\n" + "and are not included into the report below:\n") + print("\n".join(no_eyecatcher) + "\n") + +# Go compare the flags +widget_indents = {name: indentation for name, flags, indentation in widget_defs} + +lines = itertools.chain.from_iterable( + [ + process_enum(enum_name, existing[widget], widget, widget_indents[widget]) + for widget, enum_name in enums + ] +) + +print("\n".join(lines)) diff --git a/scripts/GenStyleConstants.py b/scripts/GenStyleConstants.py new file mode 100644 index 000000000..1ac7e0312 --- /dev/null +++ b/scripts/GenStyleConstants.py @@ -0,0 +1,83 @@ +# Takes ImGuiStyleVar declarations from imgui.h and outputs a set of corresponding DPG styles + +from itertools import dropwhile, takewhile +from pathlib import Path +import re +from string import Template +from typing import Callable, List, Set, Tuple, Union + + +imgui_h = Path(__file__).parent.parent / "thirdparty" / "imgui" / "imgui.h" +implot_h = Path(__file__).parent.parent / "thirdparty" / "implot" / "implot.h" +imnodes_h = Path(__file__).parent.parent / "thirdparty" / "imnodes" / "imnodes.h" + +# Returns a list of (name, comment) tuples +def read_constants(src_file: Path, enum_name: str) -> List[Tuple[str, str]]: + prefix = enum_name + "_" + end_marker = prefix + "COUNT" + lines = src_file.read_text("utf-8").splitlines() + lines = list( + filter(lambda line: line.strip().startswith(prefix), + takewhile(lambda line: not line.strip().startswith(end_marker), + dropwhile(lambda line: not line.strip().startswith(prefix), lines) + ) + ) + ) + + declarationRe = re.compile(r"\s*" + prefix + r"(\w+)\s*(?:=\s*\w+)?,\s*(.*)") + + parsed = [declarationRe.match(l) for l in lines] + return [(m[1], m[2]) for m in parsed if m is not None] + + +OLD_NODE_COLORS: Set[str] = { + "NodeBackground", + "NodeBackgroundHovered", + "NodeBackgroundSelected", + "NodeOutline", + "TitleBar", + "TitleBarHovered", + "TitleBarSelected", + "Link", + "LinkHovered", + "LinkSelected", + "Pin", + "PinHovered", + "BoxSelector", + "BoxSelectorOutline", + "GridBackground", + "GridLine", +} + + +def convert_constants(src_file: Path, dpg_prefix: Union[str, Callable], enum_name: str, comment_pos: int) -> List[str]: + template = Template('\t\tModuleConstants.push_back({ "${dpg_prefix}_$name", ${imgui_prefix}_$name });') + dpg_prefix_gen = (lambda name: dpg_prefix) if isinstance(dpg_prefix, str) else dpg_prefix + defs = read_constants(src_file, enum_name) + return [ + # Regarding comment_pos: we need to subtract 1 to account for 1-based column number, + # subtract 1 more to account for the space that we add before the comment, + # and subtract 3 twice to account for two tab characters at the start of the template + # (with tab width = 4, these take 4 characters on the screen but 1 character in actual text). + (template.substitute(name=name, dpg_prefix = dpg_prefix_gen(name), imgui_prefix = enum_name).ljust(comment_pos - 8) + " " + comment).rstrip() + for name, comment in defs + ] + + +convert_constants(implot_h, "mvPlotCol", "ImPlotCol", 90) + +lines = ( + convert_constants(imgui_h, "mvThemeCol", "ImGuiCol", 93) + + [""] + + convert_constants(implot_h, "mvPlotCol", "ImPlotCol", 90) + + [""] + + convert_constants(imnodes_h, (lambda name: "mvNodeCol" if name in OLD_NODE_COLORS else "mvNodesCol"), "ImNodesCol", 90) + + [""] + + convert_constants(imgui_h, "mvStyleVar", "ImGuiStyleVar", 109) + + [""] + + convert_constants(implot_h, "mvPlotStyleVar", "ImPlotStyleVar", 112) + + [""] + + convert_constants(imnodes_h, "mvNodesStyleVar", "ImNodesStyleVar", 109) +) + +print("\n".join(lines)) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad7f650cd..cd814106a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.13) +cmake_minimum_required (VERSION 3.16) set(MARVEL_SOURCES diff --git a/src/dearpygui.cpp b/src/dearpygui.cpp index d2bdc28c3..48e10493d 100644 --- a/src/dearpygui.cpp +++ b/src/dearpygui.cpp @@ -1,18 +1,22 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "dearpygui.h" + #include "mvAppItemCommons.h" #include "mvFontManager.h" #include "mvItemRegistry.h" -#include -#include #include "mvToolManager.h" #include "mvCustomTypes.h" -#include "mvPyUtils.h" #include "mvViewport.h" -#include #include "mvProfiler.h" #include "dearpygui_commands.h" #include "dearpygui_parsers.h" +#include +#include +#include + #define MV_ADD_COMMAND(x) methods.push_back({ #x, (PyCFunction)x, METH_VARARGS | METH_KEYWORDS, GetParsers()[#x].documentation.c_str() }); const std::map& @@ -91,8 +95,8 @@ GetModuleConstants() ModuleConstants.push_back({"mvPlatform_Apple", 1L }); ModuleConstants.push_back({"mvPlatform_Linux", 2L }); - ModuleConstants.push_back({"mvColorEdit_AlphaPreviewNone", 0L }); - ModuleConstants.push_back({"mvColorEdit_AlphaPreview", ImGuiColorEditFlags_AlphaPreview }); + ModuleConstants.push_back({"mvColorEdit_AlphaPreviewNone", ImGuiColorEditFlags_AlphaOpaque }); + ModuleConstants.push_back({"mvColorEdit_AlphaPreview", ImGuiColorEditFlags_None }); ModuleConstants.push_back({"mvColorEdit_AlphaPreviewHalf", ImGuiColorEditFlags_AlphaPreviewHalf }); ModuleConstants.push_back({"mvColorEdit_uint8", ImGuiColorEditFlags_Uint8}); ModuleConstants.push_back({"mvColorEdit_float", ImGuiColorEditFlags_Float}); @@ -145,6 +149,10 @@ GetModuleConstants() ModuleConstants.push_back({ "mvCullMode_Back", 1L }); ModuleConstants.push_back({ "mvCullMode_Front", 2L }); + // We no longer need these mvFontRangeHint constants, but since there's no way + // to declare them deprecated, we'll leave them here for a while. + // TODO: decide if we should move definitions entirely to _deprecated.py and + // remove them from the "internal" API of DLL/.so file. ModuleConstants.push_back({ "mvFontRangeHint_Default", 0L }); ModuleConstants.push_back({ "mvFontRangeHint_Japanese", 1L }); ModuleConstants.push_back({ "mvFontRangeHint_Korean", 2L }); @@ -214,6 +222,10 @@ GetModuleConstants() ModuleConstants.push_back({ "mvTable_SizingStretchProp", ImGuiTableFlags_SizingStretchProp}); ModuleConstants.push_back({ "mvTable_SizingStretchSame", ImGuiTableFlags_SizingStretchSame}); + ModuleConstants.push_back({ "mvTreeLines_None", ImGuiTreeNodeFlags_DrawLinesNone }); + ModuleConstants.push_back({ "mvTreeLines_Full", ImGuiTreeNodeFlags_DrawLinesFull }); + ModuleConstants.push_back({ "mvTreeLines_ToNodes", ImGuiTreeNodeFlags_DrawLinesToNodes }); + ModuleConstants.push_back({ "mvFormat_Float_rgba", 0L }); ModuleConstants.push_back({ "mvFormat_Float_rgb", 1L }); @@ -221,70 +233,88 @@ GetModuleConstants() ModuleConstants.push_back({ "mvThemeCat_Plots", 1L}); ModuleConstants.push_back({ "mvThemeCat_Nodes", 2L}); + // Note: color and style constants are generated - see /scripts/GenStyleConstants.py. + // Avoid editing them manually. Update with caution, some entries have edits upon + // the script-generated version (commented-out lines or old constants kept for compatibility). + ModuleConstants.push_back({ "mvThemeCol_Text", ImGuiCol_Text }); ModuleConstants.push_back({ "mvThemeCol_TextDisabled", ImGuiCol_TextDisabled }); ModuleConstants.push_back({ "mvThemeCol_WindowBg", ImGuiCol_WindowBg }); // Background of normal windows ModuleConstants.push_back({ "mvThemeCol_ChildBg", ImGuiCol_ChildBg }); // Background of child windows - ModuleConstants.push_back({ "mvThemeCol_Border", ImGuiCol_Border }); // Background of popups, menus, tooltips windows ModuleConstants.push_back({ "mvThemeCol_PopupBg", ImGuiCol_PopupBg }); // Background of popups, menus, tooltips windows + ModuleConstants.push_back({ "mvThemeCol_Border", ImGuiCol_Border }); ModuleConstants.push_back({ "mvThemeCol_BorderShadow", ImGuiCol_BorderShadow }); - ModuleConstants.push_back({ "mvThemeCol_FrameBg", ImGuiCol_FrameBg }); // Background of checkbox, radio button, plot, slider, text input + ModuleConstants.push_back({ "mvThemeCol_FrameBg", ImGuiCol_FrameBg }); // Background of checkbox, radio button, plot, slider, text input ModuleConstants.push_back({ "mvThemeCol_FrameBgHovered", ImGuiCol_FrameBgHovered }); ModuleConstants.push_back({ "mvThemeCol_FrameBgActive", ImGuiCol_FrameBgActive }); - ModuleConstants.push_back({ "mvThemeCol_TitleBg", ImGuiCol_TitleBg }); - ModuleConstants.push_back({ "mvThemeCol_TitleBgActive", ImGuiCol_TitleBgActive }); - ModuleConstants.push_back({ "mvThemeCol_TitleBgCollapsed", ImGuiCol_TitleBgCollapsed }); + ModuleConstants.push_back({ "mvThemeCol_TitleBg", ImGuiCol_TitleBg }); // Title bar + ModuleConstants.push_back({ "mvThemeCol_TitleBgActive", ImGuiCol_TitleBgActive }); // Title bar when focused + ModuleConstants.push_back({ "mvThemeCol_TitleBgCollapsed", ImGuiCol_TitleBgCollapsed }); // Title bar when collapsed ModuleConstants.push_back({ "mvThemeCol_MenuBarBg", ImGuiCol_MenuBarBg }); ModuleConstants.push_back({ "mvThemeCol_ScrollbarBg", ImGuiCol_ScrollbarBg }); ModuleConstants.push_back({ "mvThemeCol_ScrollbarGrab", ImGuiCol_ScrollbarGrab }); ModuleConstants.push_back({ "mvThemeCol_ScrollbarGrabHovered", ImGuiCol_ScrollbarGrabHovered }); ModuleConstants.push_back({ "mvThemeCol_ScrollbarGrabActive", ImGuiCol_ScrollbarGrabActive }); - ModuleConstants.push_back({ "mvThemeCol_CheckMark", ImGuiCol_CheckMark }); + ModuleConstants.push_back({ "mvThemeCol_CheckMark", ImGuiCol_CheckMark }); // Checkbox tick and RadioButton circle ModuleConstants.push_back({ "mvThemeCol_SliderGrab", ImGuiCol_SliderGrab }); ModuleConstants.push_back({ "mvThemeCol_SliderGrabActive", ImGuiCol_SliderGrabActive }); ModuleConstants.push_back({ "mvThemeCol_Button", ImGuiCol_Button }); ModuleConstants.push_back({ "mvThemeCol_ButtonHovered", ImGuiCol_ButtonHovered }); ModuleConstants.push_back({ "mvThemeCol_ButtonActive", ImGuiCol_ButtonActive }); - ModuleConstants.push_back({ "mvThemeCol_Header", ImGuiCol_Header }); // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem + ModuleConstants.push_back({ "mvThemeCol_Header", ImGuiCol_Header }); // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem ModuleConstants.push_back({ "mvThemeCol_HeaderHovered", ImGuiCol_HeaderHovered }); ModuleConstants.push_back({ "mvThemeCol_HeaderActive", ImGuiCol_HeaderActive }); ModuleConstants.push_back({ "mvThemeCol_Separator", ImGuiCol_Separator }); ModuleConstants.push_back({ "mvThemeCol_SeparatorHovered", ImGuiCol_SeparatorHovered }); ModuleConstants.push_back({ "mvThemeCol_SeparatorActive", ImGuiCol_SeparatorActive }); - ModuleConstants.push_back({ "mvThemeCol_ResizeGrip", ImGuiCol_ResizeGrip }); + ModuleConstants.push_back({ "mvThemeCol_ResizeGrip", ImGuiCol_ResizeGrip }); // Resize grip in lower-right and lower-left corners of windows. ModuleConstants.push_back({ "mvThemeCol_ResizeGripHovered", ImGuiCol_ResizeGripHovered }); ModuleConstants.push_back({ "mvThemeCol_ResizeGripActive", ImGuiCol_ResizeGripActive }); - ModuleConstants.push_back({ "mvThemeCol_Tab", ImGuiCol_Tab }); - ModuleConstants.push_back({ "mvThemeCol_TabHovered", ImGuiCol_TabHovered }); - ModuleConstants.push_back({ "mvThemeCol_TabActive", ImGuiCol_TabActive }); - ModuleConstants.push_back({ "mvThemeCol_TabUnfocused", ImGuiCol_TabUnfocused }); - ModuleConstants.push_back({ "mvThemeCol_TabUnfocusedActive", ImGuiCol_TabUnfocusedActive }); - ModuleConstants.push_back({ "mvThemeCol_DockingPreview", ImGuiCol_DockingPreview }); - ModuleConstants.push_back({ "mvThemeCol_DockingEmptyBg", ImGuiCol_DockingEmptyBg }); + ModuleConstants.push_back({ "mvThemeCol_InputTextCursor", ImGuiCol_InputTextCursor }); // InputText cursor/caret + ModuleConstants.push_back({ "mvThemeCol_TabHovered", ImGuiCol_TabHovered }); // Tab background, when hovered + ModuleConstants.push_back({ "mvThemeCol_Tab", ImGuiCol_Tab }); // Tab background, when tab-bar is focused & tab is unselected + ModuleConstants.push_back({ "mvThemeCol_TabSelected", ImGuiCol_TabSelected }); // Tab background, when tab-bar is focused & tab is selected + ModuleConstants.push_back({ "mvThemeCol_TabSelectedOverline", ImGuiCol_TabSelectedOverline }); // Tab horizontal overline, when tab-bar is focused & tab is selected + ModuleConstants.push_back({ "mvThemeCol_TabDimmed", ImGuiCol_TabDimmed }); // Tab background, when tab-bar is unfocused & tab is unselected + ModuleConstants.push_back({ "mvThemeCol_TabDimmedSelected", ImGuiCol_TabDimmedSelected }); // Tab background, when tab-bar is unfocused & tab is selected + ModuleConstants.push_back({ "mvThemeCol_TabDimmedSelectedOverline", ImGuiCol_TabDimmedSelectedOverline }); //..horizontal overline, when tab-bar is unfocused & tab is selected + ModuleConstants.push_back({ "mvThemeCol_DockingPreview", ImGuiCol_DockingPreview }); // Preview overlay color when about to docking something + ModuleConstants.push_back({ "mvThemeCol_DockingEmptyBg", ImGuiCol_DockingEmptyBg }); // Background color for empty node (e.g. CentralNode with no window docked into it) ModuleConstants.push_back({ "mvThemeCol_PlotLines", ImGuiCol_PlotLines }); ModuleConstants.push_back({ "mvThemeCol_PlotLinesHovered", ImGuiCol_PlotLinesHovered }); ModuleConstants.push_back({ "mvThemeCol_PlotHistogram", ImGuiCol_PlotHistogram }); ModuleConstants.push_back({ "mvThemeCol_PlotHistogramHovered", ImGuiCol_PlotHistogramHovered }); - ModuleConstants.push_back({ "mvThemeCol_TableHeaderBg", ImGuiCol_TableHeaderBg }); // Table header background - ModuleConstants.push_back({ "mvThemeCol_TableBorderStrong", ImGuiCol_TableBorderStrong }); // Table outer and header borders (prefer using Alpha=1.0 here) - ModuleConstants.push_back({ "mvThemeCol_TableBorderLight", ImGuiCol_TableBorderLight }); // Table inner borders (prefer using Alpha=1.0 here) - ModuleConstants.push_back({ "mvThemeCol_TableRowBg", ImGuiCol_TableRowBg }); // Table row background (even rows) - ModuleConstants.push_back({ "mvThemeCol_TableRowBgAlt", ImGuiCol_TableRowBgAlt }); // Table row background (odd rows) - ModuleConstants.push_back({ "mvThemeCol_TextSelectedBg", ImGuiCol_TextSelectedBg }); - ModuleConstants.push_back({ "mvThemeCol_DragDropTarget", ImGuiCol_DragDropTarget }); - ModuleConstants.push_back({ "mvThemeCol_NavHighlight", ImGuiCol_NavHighlight }); // Gamepad/keyboard: current highlighted item - ModuleConstants.push_back({ "mvThemeCol_NavWindowingHighlight", ImGuiCol_NavWindowingHighlight }); // Highlight window when using CTRL+TAB - ModuleConstants.push_back({ "mvThemeCol_NavWindowingDimBg", ImGuiCol_NavWindowingDimBg }); // Darken/colorize entire screen behind the CTRL+TAB window list", when active - ModuleConstants.push_back({ "mvThemeCol_ModalWindowDimBg", ImGuiCol_ModalWindowDimBg }); // Darken/colorize entire screen behind a modal window", when one is active + ModuleConstants.push_back({ "mvThemeCol_TableHeaderBg", ImGuiCol_TableHeaderBg }); // Table header background + ModuleConstants.push_back({ "mvThemeCol_TableBorderStrong", ImGuiCol_TableBorderStrong }); // Table outer and header borders (prefer using Alpha=1.0 here) + ModuleConstants.push_back({ "mvThemeCol_TableBorderLight", ImGuiCol_TableBorderLight }); // Table inner borders (prefer using Alpha=1.0 here) + ModuleConstants.push_back({ "mvThemeCol_TableRowBg", ImGuiCol_TableRowBg }); // Table row background (even rows) + ModuleConstants.push_back({ "mvThemeCol_TableRowBgAlt", ImGuiCol_TableRowBgAlt }); // Table row background (odd rows) + // We don't have TextLink widget yet + // ModuleConstants.push_back({ "mvThemeCol_TextLink", ImGuiCol_TextLink }); // Hyperlink color + ModuleConstants.push_back({ "mvThemeCol_TextSelectedBg", ImGuiCol_TextSelectedBg }); // Selected text inside an InputText + ModuleConstants.push_back({ "mvThemeCol_TreeLines", ImGuiCol_TreeLines }); // Tree node hierarchy outlines when using ImGuiTreeNodeFlags_DrawLines + ModuleConstants.push_back({ "mvThemeCol_DragDropTarget", ImGuiCol_DragDropTarget }); // Rectangle border highlighting a drop target + ModuleConstants.push_back({ "mvThemeCol_DragDropTargetBg", ImGuiCol_DragDropTargetBg }); // Rectangle background highlighting a drop target + ModuleConstants.push_back({ "mvThemeCol_UnsavedMarker", ImGuiCol_UnsavedMarker }); // Unsaved Document marker (in window title and tabs) + ModuleConstants.push_back({ "mvThemeCol_NavCursor", ImGuiCol_NavCursor }); // Color of keyboard/gamepad navigation cursor/rectangle, when visible + ModuleConstants.push_back({ "mvThemeCol_NavWindowingHighlight", ImGuiCol_NavWindowingHighlight }); // Highlight window when using Ctrl+Tab + ModuleConstants.push_back({ "mvThemeCol_NavWindowingDimBg", ImGuiCol_NavWindowingDimBg }); // Darken/colorize entire screen behind the Ctrl+Tab window list, when active + ModuleConstants.push_back({ "mvThemeCol_ModalWindowDimBg", ImGuiCol_ModalWindowDimBg }); // Darken/colorize entire screen behind a modal window, when one is active + + // old names for colors that have been renamed in ImGui - keeping them for compatibility + ModuleConstants.push_back({ "mvThemeCol_TabActive", ImGuiCol_TabSelected }); + ModuleConstants.push_back({ "mvThemeCol_TabUnfocused", ImGuiCol_TabDimmed }); + ModuleConstants.push_back({ "mvThemeCol_TabUnfocusedActive", ImGuiCol_TabDimmedSelected }); + ModuleConstants.push_back({ "mvThemeCol_NavHighlight", ImGuiCol_NavCursor }); // Gamepad/keyboard: current highlighted item // plotting // item styling colors - ModuleConstants.push_back({ "mvPlotCol_Line", ImPlotCol_Line }); // plot line/outline color (defaults to next unused color in current colormap) - ModuleConstants.push_back({ "mvPlotCol_Fill", ImPlotCol_Fill }); // plot fill color for bars (defaults to the current line color) + ModuleConstants.push_back({ "mvPlotCol_Line", ImPlotCol_Line }); // plot line/outline color (defaults to next unused color in current colormap) + ModuleConstants.push_back({ "mvPlotCol_Fill", ImPlotCol_Fill }); // plot fill color for bars (defaults to the current line color) ModuleConstants.push_back({ "mvPlotCol_MarkerOutline", ImPlotCol_MarkerOutline }); // marker outline color (defaults to the current line color) - ModuleConstants.push_back({ "mvPlotCol_MarkerFill", ImPlotCol_MarkerFill }); // marker fill color (defaults to the current line color) - ModuleConstants.push_back({ "mvPlotCol_ErrorBar", ImPlotCol_ErrorBar }); // error bar color (defaults to ImGuiCol_Text) + ModuleConstants.push_back({ "mvPlotCol_MarkerFill", ImPlotCol_MarkerFill }); // marker fill color (defaults to the current line color) + ModuleConstants.push_back({ "mvPlotCol_ErrorBar", ImPlotCol_ErrorBar }); // error bar color (defaults to ImGuiCol_Text) // plot styling colors ModuleConstants.push_back({ "mvPlotCol_FrameBg", ImPlotCol_FrameBg }); // plot frame background color (defaults to ImGuiCol_FrameBg) @@ -295,11 +325,12 @@ GetModuleConstants() ModuleConstants.push_back({ "mvPlotCol_LegendText", ImPlotCol_LegendText }); // legend text color (defaults to ImPlotCol_InlayText) ModuleConstants.push_back({ "mvPlotCol_TitleText", ImPlotCol_TitleText }); // plot title text color (defaults to ImGuiCol_Text) ModuleConstants.push_back({ "mvPlotCol_InlayText", ImPlotCol_InlayText }); // color of text appearing inside of plots (defaults to ImGuiCol_Text) + ModuleConstants.push_back({ "mvPlotCol_AxisText", ImPlotCol_AxisText }); // axis label and tick labels color (defaults to ImGuiCol_Text) + ModuleConstants.push_back({ "mvPlotCol_AxisGrid", ImPlotCol_AxisGrid }); // axis grid color (defaults to 25% ImPlotCol_AxisText) + ModuleConstants.push_back({ "mvPlotCol_AxisTick", ImPlotCol_AxisTick }); // axis tick color (defaults to AxisGrid) ModuleConstants.push_back({ "mvPlotCol_AxisBg", ImPlotCol_AxisBg }); // background color of axis hover region (defaults to transparent) + ModuleConstants.push_back({ "mvPlotCol_AxisBgHovered", ImPlotCol_AxisBgHovered }); // axis hover color (defaults to ImGuiCol_ButtonHovered) ModuleConstants.push_back({ "mvPlotCol_AxisBgActive", ImPlotCol_AxisBgActive }); // axis active color (defaults to ImGuiCol_ButtonActive) - ModuleConstants.push_back({ "mvPlotCol_AxisBgHovered", ImPlotCol_AxisBgHovered});// axis hover color (defaults to ImGuiCol_ButtonHovered) - ModuleConstants.push_back({ "mvPlotCol_AxisGrid", ImPlotCol_AxisGrid }); // axis tick lables color (defaults to ImGuiCol_Text) - ModuleConstants.push_back({ "mvPlotCol_AxisText", ImPlotCol_AxisText }); // axis label color (defaults to ImGuiCol_Text) ModuleConstants.push_back({ "mvPlotCol_Selection", ImPlotCol_Selection }); // box-selection color (defaults to yellow) ModuleConstants.push_back({ "mvPlotCol_Crosshairs", ImPlotCol_Crosshairs }); // crosshairs color (defaults to ImPlotCol_PlotBorder) @@ -355,30 +386,37 @@ GetModuleConstants() ModuleConstants.push_back({ "mvStyleVar_CellPadding", ImGuiStyleVar_CellPadding }); // ImVec2 CellPadding ModuleConstants.push_back({ "mvStyleVar_ScrollbarSize", ImGuiStyleVar_ScrollbarSize }); // float ScrollbarSize ModuleConstants.push_back({ "mvStyleVar_ScrollbarRounding", ImGuiStyleVar_ScrollbarRounding }); // float ScrollbarRounding + ModuleConstants.push_back({ "mvStyleVar_ScrollbarPadding", ImGuiStyleVar_ScrollbarPadding }); // float ScrollbarPadding ModuleConstants.push_back({ "mvStyleVar_GrabMinSize", ImGuiStyleVar_GrabMinSize }); // float GrabMinSize ModuleConstants.push_back({ "mvStyleVar_GrabRounding", ImGuiStyleVar_GrabRounding }); // float GrabRounding + ModuleConstants.push_back({ "mvStyleVar_ImageBorderSize", ImGuiStyleVar_ImageBorderSize }); // float ImageBorderSize ModuleConstants.push_back({ "mvStyleVar_TabRounding", ImGuiStyleVar_TabRounding }); // float TabRounding - ModuleConstants.push_back({ "mvStyleVar_TabBorderSize", ImGuiStyleVar_TabBorderSize }); // float TabBorderSize - ModuleConstants.push_back({ "mvStyleVar_TabBarBorderSize", ImGuiStyleVar_TabBarBorderSize }); // float TabBarBorderSize - ModuleConstants.push_back({ "mvStyleVar_TableAngledHeadersAngle", ImGuiStyleVar_TableAngledHeadersAngle }); // float TableAngledHeadersAngle - ModuleConstants.push_back({ "mvStyleVar_TableAngledHeadersTextAlign", ImGuiStyleVar_TableAngledHeadersTextAlign }); // ImVec2 TableAngledHeadersTextAlign + ModuleConstants.push_back({ "mvStyleVar_TabBorderSize", ImGuiStyleVar_TabBorderSize }); // float TabBorderSize + ModuleConstants.push_back({ "mvStyleVar_TabMinWidthBase", ImGuiStyleVar_TabMinWidthBase }); // float TabMinWidthBase + ModuleConstants.push_back({ "mvStyleVar_TabMinWidthShrink", ImGuiStyleVar_TabMinWidthShrink }); // float TabMinWidthShrink + ModuleConstants.push_back({ "mvStyleVar_TabBarBorderSize", ImGuiStyleVar_TabBarBorderSize }); // float TabBarBorderSize + ModuleConstants.push_back({ "mvStyleVar_TabBarOverlineSize", ImGuiStyleVar_TabBarOverlineSize }); // float TabBarOverlineSize + ModuleConstants.push_back({ "mvStyleVar_TableAngledHeadersAngle", ImGuiStyleVar_TableAngledHeadersAngle }); // float TableAngledHeadersAngle + ModuleConstants.push_back({ "mvStyleVar_TableAngledHeadersTextAlign", ImGuiStyleVar_TableAngledHeadersTextAlign }); // ImVec2 TableAngledHeadersTextAlign + ModuleConstants.push_back({ "mvStyleVar_TreeLinesSize", ImGuiStyleVar_TreeLinesSize }); // float TreeLinesSize + ModuleConstants.push_back({ "mvStyleVar_TreeLinesRounding", ImGuiStyleVar_TreeLinesRounding }); // float TreeLinesRounding ModuleConstants.push_back({ "mvStyleVar_ButtonTextAlign", ImGuiStyleVar_ButtonTextAlign }); // ImVec2 ButtonTextAlign ModuleConstants.push_back({ "mvStyleVar_SelectableTextAlign", ImGuiStyleVar_SelectableTextAlign }); // ImVec2 SelectableTextAlign - ModuleConstants.push_back({ "mvStyleVar_SeparatorTextBorderSize", ImGuiStyleVar_SeparatorTextBorderSize }); // float SeparatorTextBorderSize - ModuleConstants.push_back({ "mvStyleVar_SeparatorTextAlign", ImGuiStyleVar_SeparatorTextAlign }); // ImVec2 SeparatorTextAlign - ModuleConstants.push_back({ "mvStyleVar_SeparatorTextPadding", ImGuiStyleVar_SeparatorTextPadding }); // ImVec2 SeparatorTextPadding - ModuleConstants.push_back({ "mvStyleVar_DockingSeparatorSize", ImGuiStyleVar_DockingSeparatorSize }); // float DockingSeparatorSize + ModuleConstants.push_back({ "mvStyleVar_SeparatorTextBorderSize", ImGuiStyleVar_SeparatorTextBorderSize }); // float SeparatorTextBorderSize + ModuleConstants.push_back({ "mvStyleVar_SeparatorTextAlign", ImGuiStyleVar_SeparatorTextAlign }); // ImVec2 SeparatorTextAlign + ModuleConstants.push_back({ "mvStyleVar_SeparatorTextPadding", ImGuiStyleVar_SeparatorTextPadding }); // ImVec2 SeparatorTextPadding + ModuleConstants.push_back({ "mvStyleVar_DockingSeparatorSize", ImGuiStyleVar_DockingSeparatorSize }); // float DockingSeparatorSize // item styling variables - ModuleConstants.push_back({ "mvPlotStyleVar_LineWeight", ImPlotStyleVar_LineWeight }); // float, plot item line weight in pixels - ModuleConstants.push_back({ "mvPlotStyleVar_Marker", ImPlotStyleVar_Marker }); // int, marker specification - ModuleConstants.push_back({ "mvPlotStyleVar_MarkerSize", ImPlotStyleVar_MarkerSize }); // float, marker size in pixels (roughly the marker's "radius") - ModuleConstants.push_back({ "mvPlotStyleVar_MarkerWeight", ImPlotStyleVar_MarkerWeight }); // float, plot outline weight of markers in pixels - ModuleConstants.push_back({ "mvPlotStyleVar_FillAlpha", ImPlotStyleVar_FillAlpha }); // float, alpha modifier applied to all plot item fills - ModuleConstants.push_back({ "mvPlotStyleVar_ErrorBarSize", ImPlotStyleVar_ErrorBarSize }); // float, error bar whisker width in pixels - ModuleConstants.push_back({ "mvPlotStyleVar_ErrorBarWeight", ImPlotStyleVar_ErrorBarWeight }); // float, error bar whisker weight in pixels - ModuleConstants.push_back({ "mvPlotStyleVar_DigitalBitHeight", ImPlotStyleVar_DigitalBitHeight }); // float, digital channels bit height (at 1) in pixels - ModuleConstants.push_back({ "mvPlotStyleVar_DigitalBitGap", ImPlotStyleVar_DigitalBitGap }); // float, digital channels bit padding gap in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_LineWeight", ImPlotStyleVar_LineWeight }); // float, plot item line weight in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_Marker", ImPlotStyleVar_Marker }); // int, marker specification + ModuleConstants.push_back({ "mvPlotStyleVar_MarkerSize", ImPlotStyleVar_MarkerSize }); // float, marker size in pixels (roughly the marker's "radius") + ModuleConstants.push_back({ "mvPlotStyleVar_MarkerWeight", ImPlotStyleVar_MarkerWeight }); // float, plot outline weight of markers in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_FillAlpha", ImPlotStyleVar_FillAlpha }); // float, alpha modifier applied to all plot item fills + ModuleConstants.push_back({ "mvPlotStyleVar_ErrorBarSize", ImPlotStyleVar_ErrorBarSize }); // float, error bar whisker width in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_ErrorBarWeight", ImPlotStyleVar_ErrorBarWeight }); // float, error bar whisker weight in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_DigitalBitHeight", ImPlotStyleVar_DigitalBitHeight }); // float, digital channels bit height (at 1) in pixels + ModuleConstants.push_back({ "mvPlotStyleVar_DigitalBitGap", ImPlotStyleVar_DigitalBitGap }); // float, digital channels bit padding gap in pixels // plot styling variables ModuleConstants.push_back({ "mvPlotStyleVar_PlotBorderSize", ImPlotStyleVar_PlotBorderSize }); // float, thickness of border around plot area diff --git a/src/dearpygui_commands.h b/src/dearpygui_commands.h index 06ab363ce..331e71d26 100644 --- a/src/dearpygui_commands.h +++ b/src/dearpygui_commands.h @@ -704,34 +704,30 @@ bind_font(PyObject* self, PyObject* args, PyObject* kwargs) mvPySafeLockGuard lk(GContext->mutex); - mvUUID item = GetIDFromPyObject(itemraw); + mvUUID itemId = GetIDFromPyObject(itemraw); - if (item == 0) + if (itemId == 0) { - for (auto& reg : GContext->itemRegistry->fontRegistryRoots) - static_cast(reg.get())->resetFont(); + mvToolManager::GetFontManager().clearDefaultFont(); return GetPyNone(); } - auto aplot = GetItem((*GContext->itemRegistry), item); - if (aplot == nullptr) + auto item = GetRefItem((*GContext->itemRegistry), itemId); + if (item == nullptr) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_font", - "Item not found: " + std::to_string(item), nullptr); + "Item not found: " + std::to_string(itemId), nullptr); return nullptr; } - if (aplot->type != mvAppItemType::mvFont) + if (item->type != mvAppItemType::mvFont) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_font", - "Incompatible type. Expected types include: mvFont", aplot); + "Incompatible type. Expected types include: mvFont", item.get()); return nullptr; } - mvFont* graph = static_cast(aplot); - - graph->_default = true; - mvToolManager::GetFontManager()._newDefault = true; + mvToolManager::GetFontManager().setDefaultFont(item); return GetPyNone(); } @@ -2571,9 +2567,16 @@ create_context(PyObject* self, PyObject* args, PyObject* kwargs) ImGui::CreateContext(); ImPlot::CreateContext(); ImNodes::CreateContext(); - } - mvToolManager::GetFontManager()._dirty = true; + // Configure some defaults that are common across platforms + ImGuiIO &io = ImGui::GetIO(); + io.ConfigErrorRecoveryEnableAssert = true; + // We disable the log by default so that if something goes awry and ImGui + // starts spitting an error every frame, the DebugLogBuf doesn't grow unlimited + // in production code. Logging can always be enabled via show_imgui_demo -> Configuration. + io.ConfigErrorRecoveryEnableDebugLog = false; + io.ConfigErrorRecoveryEnableTooltip = false; + } Py_END_ALLOW_THREADS; return GetPyNone(); @@ -2733,6 +2736,8 @@ configure_app(PyObject* self, PyObject* args, PyObject* kwargs) if (PyObject* item = PyDict_GetItemString(kwargs, "anti_aliased_lines_use_tex")) style.AntiAliasedLinesUseTex = ToBool(item); if (PyObject* item = PyDict_GetItemString(kwargs, "anti_aliased_fill")) style.AntiAliasedFill = ToBool(item); + if (PyObject* item = PyDict_GetItemString(kwargs, "win32_alt_enter_fullscreen")) GContext->IO.altEnterFullscreen = ToBool(item); + return GetPyNone(); } @@ -2768,6 +2773,8 @@ get_app_configuration(PyObject* self, PyObject* args, PyObject* kwargs) PyDict_SetItemString(pdict, "anti_aliased_lines_use_tex", mvPyObject(ToPyBool(style.AntiAliasedLinesUseTex))); PyDict_SetItemString(pdict, "anti_aliased_fill", mvPyObject(ToPyBool(style.AntiAliasedFill))); + PyDict_SetItemString(pdict, "win32_alt_enter_fullscreen", mvPyObject(ToPyBool(GContext->IO.altEnterFullscreen))); + return pdict; } diff --git a/src/dearpygui_parsers.h b/src/dearpygui_parsers.h index 8446225ed..45ca82536 100644 --- a/src/dearpygui_parsers.h +++ b/src/dearpygui_parsers.h @@ -1,4 +1,3 @@ -#include "mvAppItemCommons.h" #include "mvFontManager.h" #include "mvItemRegistry.h" #include @@ -539,6 +538,7 @@ InsertParser_Block1(std::map& parsers) args.push_back({ mvPyDataType::Bool, "anti_aliased_lines", mvArgType::KEYWORD_ARG, "False", "Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame." }); args.push_back({ mvPyDataType::Bool, "anti_aliased_lines_use_tex", mvArgType::KEYWORD_ARG, "False", "Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering (NOT point/nearest filtering). Latched at the beginning of the frame." }); args.push_back({ mvPyDataType::Bool, "anti_aliased_fill", mvArgType::KEYWORD_ARG, "False", "Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame." }); + args.push_back({ mvPyDataType::Bool, "win32_alt_enter_fullscreen", mvArgType::KEYWORD_ARG, "False", "Windows only: configures Alt+Enter as a fullscreen hotkey." }); mvPythonParserSetup setup; setup.about = "Configures app."; diff --git a/src/distribution.cmake b/src/distribution.cmake index b8583840a..c94305365 100644 --- a/src/distribution.cmake +++ b/src/distribution.cmake @@ -1,3 +1,4 @@ +cmake_minimum_required (VERSION 3.16) find_package (Python ${MV_PY_VERSION} EXACT COMPONENTS Development) if(NOT Python_Development_FOUND) @@ -34,7 +35,11 @@ target_compile_definitions(_dearpygui $<$:MV_RELEASE> ) -add_definitions(-DIMGUI_DEFINE_MATH_OPERATORS) +if(WIN32) + target_precompile_headers(_dearpygui + PRIVATE mvPyUtils.h + ) +endif() if(WIN32) diff --git a/src/embedded.cmake b/src/embedded.cmake index 9a5707689..5614ecf91 100644 --- a/src/embedded.cmake +++ b/src/embedded.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.13) +cmake_minimum_required (VERSION 3.16) add_library(coreemb STATIC) @@ -20,7 +20,12 @@ target_compile_definitions(coreemb # Add sources target_sources(coreemb PRIVATE ${MARVEL_SOURCES}) -add_definitions(-DIMGUI_DEFINE_MATH_OPERATORS) + +if(WIN32) + target_precompile_headers(coreemb + PRIVATE mvPyUtils.h + ) +endif() ############################################################################### # Windows Specifics diff --git a/src/mvAboutWindow.cpp b/src/mvAboutWindow.cpp index 897458cbf..9e1f9953f 100644 --- a/src/mvAboutWindow.cpp +++ b/src/mvAboutWindow.cpp @@ -1,4 +1,5 @@ #include "mvAboutWindow.h" + #include "mvContext.h" static std::vector founders = @@ -121,10 +122,10 @@ void mvAboutWindow::drawWidgets() ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags); if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard"); if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad"); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos"); - if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard"); if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse"); if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange"); + if (io.ConfigNavMoveSetMousePos) ImGui::Text("io.ConfigNavMoveSetMousePos"); + if (io.ConfigNavCaptureKeyboard) ImGui::Text("io.ConfigNavCaptureKeyboard"); if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor"); if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors"); if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink"); @@ -136,7 +137,7 @@ void mvAboutWindow::drawWidgets() if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos"); if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset"); ImGui::Separator(); - ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); + ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexData->Width, io.Fonts->TexData->Height); ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); ImGui::Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); ImGui::Separator(); diff --git a/src/mvAppItem.cpp b/src/mvAppItem.cpp index eed1026f3..1723072b2 100644 --- a/src/mvAppItem.cpp +++ b/src/mvAppItem.cpp @@ -1,9 +1,12 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvAppItem.h" + +#include "mvCore.h" #include "mvContext.h" #include "mvItemRegistry.h" -#include "mvCore.h" #include "mvAppItemCommons.h" -#include "mvPyUtils.h" static void UpdateLocations(std::vector>* children, i32 slots) @@ -1088,7 +1091,6 @@ DearPyGui::GetEntityTargetSlot(mvAppItemType type) switch (type) { case mvAppItemType::mvFileExtension: - case mvAppItemType::mvFontRangeHint: case mvAppItemType::mvNodeLink: case mvAppItemType::mvAnnotation: case mvAppItemType::mvDragLine: @@ -1493,9 +1495,6 @@ DearPyGui::GetAllowableParents(mvAppItemType type) MV_ADD_PARENT(mvAppItemType::mvHandlerRegistry) MV_END_PARENTS - case mvAppItemType::mvFontChars: - case mvAppItemType::mvFontRange: - case mvAppItemType::mvFontRangeHint: case mvAppItemType::mvCharRemap: MV_START_PARENTS MV_ADD_PARENT(mvAppItemType::mvFont), @@ -1733,10 +1732,7 @@ DearPyGui::GetAllowableChildren(mvAppItemType type) case mvAppItemType::mvFont: MV_START_CHILDREN - MV_ADD_CHILD(mvAppItemType::mvFontChars), - MV_ADD_CHILD(mvAppItemType::mvFontRange), MV_ADD_CHILD(mvAppItemType::mvCharRemap), - MV_ADD_CHILD(mvAppItemType::mvFontRangeHint), MV_ADD_CHILD(mvAppItemType::mvTemplateRegistry), MV_END_CHILDREN @@ -1983,6 +1979,10 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "always_overwrite", mvArgType::KEYWORD_ARG, "False", "Overwrite mode" }); args.push_back({ mvPyDataType::Bool, "no_undo_redo", mvArgType::KEYWORD_ARG, "False", "Disable undo/redo." }); args.push_back({ mvPyDataType::Bool, "escape_clears_all", mvArgType::KEYWORD_ARG, "False", "Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert)" }); + args.push_back({ mvPyDataType::Bool, "elide_left", mvArgType::KEYWORD_ARG, "False", + "When text doesn't fit an inactive input field, clip it on the left side " + "and ensure the right side stays visible. Useful for path/filenames. " + "Single-line inputs only." }); setup.about = "Adds input for text."; break; @@ -2030,6 +2030,11 @@ DearPyGui::GetEntityParser(mvAppItemType type) ); args.push_back({ mvPyDataType::Bool, "reorderable", mvArgType::KEYWORD_ARG, "False", "Allows for the user to change the order of the tabs." }); + args.push_back({ mvPyDataType::Bool, "tab_list_popup_button", mvArgType::KEYWORD_ARG, "False", "Show a button to select active tab from a dropdown list." }); + args.push_back({ mvPyDataType::Bool, "no_close_with_middle_click", mvArgType::KEYWORD_ARG, "False", "Disable closing tabs (that have closable=True) by clicking with middle mouse button." }); + args.push_back({ mvPyDataType::Bool, "no_scrolling_buttons", mvArgType::KEYWORD_ARG, "False", "Disable left/right scrolling buttons when tab buttons don't fit the container width." }); + args.push_back({ mvPyDataType::Bool, "no_tooltip", mvArgType::KEYWORD_ARG, "False", "Disable tooltips when hovering a tab with a long name." }); + args.push_back({ mvPyDataType::Bool, "draw_selected_overline", mvArgType::KEYWORD_ARG, "False", "Draw selected overline markers over selected tab." }); setup.about = "Adds a tab bar."; setup.category = { "Containers", "Widgets" }; @@ -2054,6 +2059,9 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "closable", mvArgType::KEYWORD_ARG, "False", "Creates a button on the tab that can hide the tab." }); args.push_back({ mvPyDataType::Bool, "no_tooltip", mvArgType::KEYWORD_ARG, "False", "Disable tooltip for the given tab." }); args.push_back({ mvPyDataType::Integer, "order_mode", mvArgType::KEYWORD_ARG, "0", "set using a constant: mvTabOrder_Reorderable: allows reordering, mvTabOrder_Fixed: fixed ordering, mvTabOrder_Leading: adds tab to front, mvTabOrder_Trailing: adds tab to back" }); + args.push_back({ mvPyDataType::Bool, "unsaved_document", mvArgType::KEYWORD_ARG, "False", "Display a dot next to the title." }); + args.push_back({ mvPyDataType::Bool, "no_close_with_middle_click", mvArgType::KEYWORD_ARG, "False", "Disable closing this tab (if closable==True) by clicking with middle mouse button." }); + args.push_back({ mvPyDataType::Bool, "no_reorder", mvArgType::KEYWORD_ARG, "False", "Disable reordering this tab or having another tab cross over this tab." }); setup.about = "Adds a tab to a tab bar."; setup.category = { "Containers", "Widgets" }; @@ -2081,7 +2089,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::UUID, "texture_tag", mvArgType::REQUIRED_ARG, "", "The texture_tag should come from a texture that was added to a texture registry." }); args.push_back({ mvPyDataType::FloatList, "tint_color", mvArgType::KEYWORD_ARG, "(255, 255, 255, 255)", "Applies a color tint to the entire texture." }); - args.push_back({ mvPyDataType::FloatList, "border_color", mvArgType::KEYWORD_ARG, "(0, 0, 0, 0)", "Displays a border of the specified color around the texture. If the theme style has turned off the border it will not be shown." }); + args.push_back({ mvPyDataType::FloatList, "border_color", mvArgType::KEYWORD_ARG, "(0, 0, 0, 0)", "Displays a border of the specified color around the texture." }); args.push_back({ mvPyDataType::FloatList, "uv_min", mvArgType::KEYWORD_ARG, "(0.0, 0.0)", "Normalized texture coordinates min point." }); args.push_back({ mvPyDataType::FloatList, "uv_max", mvArgType::KEYWORD_ARG, "(1.0, 1.0)", "Normalized texture coordinates max point." }); @@ -2472,6 +2480,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter key press." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds input for an float. +/- buttons can be activated by setting the value of step."; break; @@ -2506,6 +2516,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter key press." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds input for an double. Useful when input float is not accurate enough. +/- buttons can be activated by setting the value of step."; break; @@ -2539,6 +2551,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter key press." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds input for an int. +/- buttons can be activated by setting the value of step."; break; @@ -2574,7 +2588,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "no_label", mvArgType::KEYWORD_ARG, "False", "Disable display of inline text label." }); args.push_back({ mvPyDataType::Bool, "no_drag_drop", mvArgType::KEYWORD_ARG, "False", "Disable ability to drag and drop small preview (color square) to apply colors to other items." }); args.push_back({ mvPyDataType::Bool, "alpha_bar", mvArgType::KEYWORD_ARG, "False", "Show vertical alpha bar/gradient in picker." }); - args.push_back({ mvPyDataType::Long, "alpha_preview", mvArgType::KEYWORD_ARG, "0", "mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf" }); + args.push_back({ mvPyDataType::Long, "alpha_preview", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_AlphaPreviewNone", "mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf" }); args.push_back({ mvPyDataType::Long, "display_mode", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_rgb", "mvColorEdit_rgb, mvColorEdit_hsv, or mvColorEdit_hex" }); args.push_back({ mvPyDataType::Long, "display_type", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_uint8", "mvColorEdit_uint8 or mvColorEdit_float" }); args.push_back({ mvPyDataType::Long, "input_mode", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_input_rgb", "mvColorEdit_input_* values" }); @@ -2633,7 +2647,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "display_hsv", mvArgType::KEYWORD_ARG, "False", "Override _display_ type among RGB/HSV/Hex." }); args.push_back({ mvPyDataType::Bool, "display_hex", mvArgType::KEYWORD_ARG, "False", "Override _display_ type among RGB/HSV/Hex." }); args.push_back({ mvPyDataType::Long, "picker_mode", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorPicker_bar", "mvColorPicker_bar or mvColorPicker_wheel" }); - args.push_back({ mvPyDataType::Long, "alpha_preview", mvArgType::KEYWORD_ARG, "0", "mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf" }); + args.push_back({ mvPyDataType::Long, "alpha_preview", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_AlphaPreviewNone", "mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf" }); args.push_back({ mvPyDataType::Long, "display_type", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_uint8", "mvColorEdit_uint8 or mvColorEdit_float" }); args.push_back({ mvPyDataType::Long, "input_mode", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_input_rgb", "mvColorEdit_input_* values."}); @@ -2901,6 +2915,9 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "no_saved_settings", mvArgType::KEYWORD_ARG, "False", "Never load/save settings in .ini file." }); args.push_back({ mvPyDataType::Bool, "no_open_over_existing_popup", mvArgType::KEYWORD_ARG, "True", "Don't open if there's already a popup" }); args.push_back({ mvPyDataType::Bool, "no_scroll_with_mouse", mvArgType::KEYWORD_ARG, "False", "Disable user vertically scrolling with mouse wheel." }); + args.push_back({ mvPyDataType::Bool, "no_docking", mvArgType::KEYWORD_ARG, "False", "Disable docking of this window" }); + + args.push_back({ mvPyDataType::Bool, "copy_contents_shortcut", mvArgType::KEYWORD_ARG, "False", "Experimental. If True, window contents can be copied to clipboard by pressing Ctrl+C. Might be useful for message boxes." }); args.push_back({ mvPyDataType::Callable, "on_close", mvArgType::KEYWORD_ARG, "None", "Callback ran when window is closed." }); @@ -2933,6 +2950,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "default_value", mvArgType::KEYWORD_ARG, "False" }); args.push_back({ mvPyDataType::Bool, "span_columns", mvArgType::KEYWORD_ARG, "False", "Forces the selectable to span the width of all columns if placed in a table." }); args.push_back({ mvPyDataType::Bool, "disable_popup_close", mvArgType::KEYWORD_ARG, "False", "Disable closing a modal or popup window." }); + args.push_back({ mvPyDataType::Bool, "select_on_nav", mvArgType::KEYWORD_ARG, "False", "Auto-select when moved into with keyboard navigation, unless Ctrl is held." }); setup.about = "Adds a selectable. Similar to a button but can indicate its selected state."; break; @@ -2962,9 +2980,17 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "selectable", mvArgType::KEYWORD_ARG, "False", "Makes the tree selectable." }); args.push_back({ mvPyDataType::Bool, "span_text_width", mvArgType::KEYWORD_ARG, "False", "Makes hitbox and highlight only cover the label." }); args.push_back({ mvPyDataType::Bool, "span_full_width", mvArgType::KEYWORD_ARG, "False", "Extend hit box to the left-most and right-most edges (cover the indent area)." }); + args.push_back({ mvPyDataType::Bool, "catch_nav_left", mvArgType::KEYWORD_ARG, "False", + "Keyboard navigation: left arrow within this node's children, if unhandled, " + "moves focus to this node. When setting it to True on a node, better set it " + "on all children nodes in the subtree as well, otherwise it might give unexpected " + "navigation jumps."}); // TODO: Test these 2 arguments // args.push_back({ mvPyDataType::Bool, "span_available_width", mvArgType::KEYWORD_ARG, "False", "Extend hit box to the right-most edge, even if not framed." }); // args.push_back({ mvPyDataType::Bool, "span_all_columns", mvArgType::KEYWORD_ARG, "False", "Frame will span all columns of its container table (text will still fit in current column)." }); + args.push_back({ mvPyDataType::Integer, "lines", mvArgType::KEYWORD_ARG, "internal_dpg.mvTreeLines_None", + "Experimental. Draw lines connecting tree_node hierarchy. One of dpg.mvTreeLines " + "constants. To work correctly, must be configured the same way in every tree node." }); setup.about = "Adds a tree node to add items to."; setup.category = { "Containers", "Widgets" }; @@ -3114,6 +3140,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "no_alpha", mvArgType::KEYWORD_ARG, "False", "Removes the displayed slider that can change alpha channel." }); args.push_back({ mvPyDataType::Bool, "no_border", mvArgType::KEYWORD_ARG, "False", "Disable border around the image." }); args.push_back({ mvPyDataType::Bool, "no_drag_drop", mvArgType::KEYWORD_ARG, "False", "Disable ability to drag and drop small preview (color square) to apply colors to other items." }); + args.push_back({ mvPyDataType::Long, "alpha_preview", mvArgType::KEYWORD_ARG, "internal_dpg.mvColorEdit_AlphaPreviewNone", "mvColorEdit_AlphaPreviewNone, mvColorEdit_AlphaPreview, or mvColorEdit_AlphaPreviewHalf" }); + args.push_back({ mvPyDataType::Bool, "no_tooltip", mvArgType::KEYWORD_ARG, "False", "Disable tooltip when hovering the button." }); setup.about = "Adds a color button."; setup.category = { "Widgets", "Colors" }; @@ -3163,6 +3191,7 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "leading", mvArgType::KEYWORD_ARG, "False", "Enforce the tab position to the left of the tab bar (after the tab list popup button)." }); args.push_back({ mvPyDataType::Bool, "trailing", mvArgType::KEYWORD_ARG, "False", "Enforce the tab position to the right of the tab bar (before the scrolling buttons)." }); args.push_back({ mvPyDataType::Bool, "no_tooltip", mvArgType::KEYWORD_ARG, "False", "Disable tooltip for the given tab." }); + args.push_back({ mvPyDataType::Bool, "unsaved_document", mvArgType::KEYWORD_ARG, "False", "Display a dot next to the title." }); setup.about = "Adds a tab button to a tab bar."; break; @@ -3872,6 +3901,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds multi int input for up to 4 integer values."; break; @@ -3905,6 +3936,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter key press." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds multi float input for up to 4 float values."; break; @@ -3938,6 +3971,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::Bool, "max_clamped", mvArgType::KEYWORD_ARG, "False", "Activates and deactivates the enforcment of max_value." }); args.push_back({ mvPyDataType::Bool, "on_enter", mvArgType::KEYWORD_ARG, "False", "Only runs callback on enter key press." }); args.push_back({ mvPyDataType::Bool, "readonly", mvArgType::KEYWORD_ARG, "False", "Activates read only mode where no text can be input but text can still be highlighted." }); + args.push_back({ mvPyDataType::Bool, "accept_empty_input", mvArgType::KEYWORD_ARG, "False", "Treat empty input as a zero value." }); + args.push_back({ mvPyDataType::Bool, "display_empty_value", mvArgType::KEYWORD_ARG, "False", "If True, display an empty input if the value is zero. Generally used together with accept_empty_input." }); setup.about = "Adds multi double input for up to 4 double values. Useful when input float mulit is not accurate enough."; break; @@ -5116,7 +5151,8 @@ DearPyGui::GetEntityParser(mvAppItemType type) args.push_back({ mvPyDataType::String, "file" }); args.push_back({ mvPyDataType::Integer, "size" }); - args.push_back({ mvPyDataType::Bool, "pixel_snapH", mvArgType::KEYWORD_ARG, "False", "Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font, or rendering text piece-by-piece (e.g. for coloring)." }); + args.push_back({ mvPyDataType::Bool, "pixel_snapH", mvArgType::KEYWORD_ARG, "False", "Align every glyph to pixel boundary in horizontal direction. Useful if you are rendering text piece-by-piece (e.g. for coloring)." }); + args.push_back({ mvPyDataType::Bool, "pixel_snapV", mvArgType::KEYWORD_ARG, "False", "Align scaled GlyphOffset.y to pixel boundaries in ImGui." }); args.push_back({ mvPyDataType::UUID, "parent", mvArgType::KEYWORD_ARG, "internal_dpg.mvReservedUUID_0", "Parent to add this item to. (runtime adding)" }); args.push_back({ mvPyDataType::Bool, "default_font", mvArgType::DEPRECATED_REMOVE_KEYWORD_ARG }); @@ -5197,46 +5233,6 @@ DearPyGui::GetEntityParser(mvAppItemType type) setup.createContextManager = true; break; } - case mvAppItemType::mvFontRangeHint: - { - AddCommonArgs(args, (CommonParserArgs)( - MV_PARSER_ARG_ID | - MV_PARSER_ARG_PARENT) - ); - - args.push_back({ mvPyDataType::Integer, "hint" }); - - setup.about = "Adds a range of font characters (mvFontRangeHint_ constants)."; - setup.category = { "Fonts", "Widgets" }; - break; - } - case mvAppItemType::mvFontRange: - { - AddCommonArgs(args, (CommonParserArgs)( - MV_PARSER_ARG_ID | - MV_PARSER_ARG_PARENT) - ); - - args.push_back({ mvPyDataType::Integer, "first_char" }); - args.push_back({ mvPyDataType::Integer, "last_char" }); - - setup.about = "Adds a range of font characters to a font."; - setup.category = { "Fonts", "Widgets" }; - break; - } - case mvAppItemType::mvFontChars: - { - AddCommonArgs(args, (CommonParserArgs)( - MV_PARSER_ARG_ID | - MV_PARSER_ARG_PARENT) - ); - - args.push_back({ mvPyDataType::IntList, "chars" }); - - setup.about = "Adds specific font characters to a font."; - setup.category = { "Fonts", "Widgets" }; - break; - } case mvAppItemType::mvCharRemap: { AddCommonArgs(args, (CommonParserArgs)( @@ -5694,3 +5690,15 @@ DearPyGui::OnChildRemoved(mvAppItem* item, std::shared_ptr child) return; } } + +void +DearPyGui::RestoreImGuiCursor(const ImVec2& prev_pos) +{ + ImGui::SetCursorPos(prev_pos); + // Since ImGui 1.92.0, it is necessary to add an item, say a Dummy, if we do + // a SetCursorPos at the end of a group or a window (see issue #5548 in Dear ImGui). + // To prevent the Dummy from actually moving the cursor, we also zero out item spacing. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::Dummy(ImVec2(0, 0)); + ImGui::PopStyleVar(); +} diff --git a/src/mvAppItem.h b/src/mvAppItem.h index 2c576d454..69edfe275 100644 --- a/src/mvAppItem.h +++ b/src/mvAppItem.h @@ -9,12 +9,10 @@ #include #include -#include #include #include "mvAppItemState.h" #include "mvCallbackRegistry.h" #include "mvPyUtils.h" -#include #include "mvAppItemTypes.inc" // forward declarations @@ -71,7 +69,7 @@ struct ScopedID namespace DearPyGui { - std::shared_ptr CreateEntity (mvAppItemType type, mvUUID id); + std::shared_ptr CreateEntity (mvAppItemType type, mvUUID id); int GetEntityDesciptionFlags (mvAppItemType type); int GetEntityTargetSlot (mvAppItemType type); StorageValueTypes GetEntityValueType (mvAppItemType type); @@ -79,11 +77,14 @@ namespace DearPyGui int GetApplicableState (mvAppItemType type); const std::vector>& GetAllowableParents (mvAppItemType type); const std::vector>& GetAllowableChildren (mvAppItemType type); - std::shared_ptr& GetClassThemeComponent (mvAppItemType type); - std::shared_ptr& GetDisabledClassThemeComponent (mvAppItemType type); + std::shared_ptr& GetClassThemeComponent (mvAppItemType type); + std::shared_ptr& GetDisabledClassThemeComponent (mvAppItemType type); mvPythonParser GetEntityParser (mvAppItemType type); void OnChildAdded (mvAppItem* item, std::shared_ptr child); void OnChildRemoved (mvAppItem* item, std::shared_ptr child); + // This is purely a helper function that restores cursor position so that subsequent + // items follow the normal item flow. Use it in place of ImGui::SetCursorPos(). + void RestoreImGuiCursor (const ImVec2& prev_pos); } struct mvAppItemInfo @@ -175,7 +176,7 @@ class mvAppItem : public std::enable_shared_from_this std::shared_ptr drawInfo = nullptr; // slots - // * 0 : mvFileExtension, mvFontRangeHint, mvNodeLink, mvAnnotation, mvAxisTag + // * 0 : mvFileExtension, mvNodeLink, mvAnnotation, mvAxisTag // mvDragLine, mvDragPoint, mvDragRect, mvLegend, mvTableColumn // * 1 : Most widgets // * 2 : Draw Commands @@ -429,9 +430,6 @@ GetEntityCommand(mvAppItemType type) case mvAppItemType::mvThemeColor: return "add_theme_color"; case mvAppItemType::mvThemeStyle: return "add_theme_style"; case mvAppItemType::mvThemeComponent: return "add_theme_component"; - case mvAppItemType::mvFontRangeHint: return "add_font_range_hint"; - case mvAppItemType::mvFontRange: return "add_font_range"; - case mvAppItemType::mvFontChars: return "add_font_chars"; case mvAppItemType::mvCharRemap: return "add_char_remap"; case mvAppItemType::mvValueRegistry: return "add_value_registry"; case mvAppItemType::mvIntValue: return "add_int_value"; @@ -508,6 +506,7 @@ GetEntityCommand(mvAppItemType type) #define mvImGuiCol_TabActive MV_BASE_COL_panelActiveColor #define mvImGuiCol_TabUnfocused MV_BASE_COL_panelColor #define mvImGuiCol_TabUnfocusedActive MV_BASE_COL_panelActiveColor +#define mvImGuiCol_TabUnfocusedActiveOverline mvColor(0, 119, 200, 0) #define mvImGuiCol_DockingPreview MV_BASE_COL_panelActiveColor #define mvImGuiCol_DockingEmptyBg mvColor(51, 51, 51, 255) #define mvImGuiCol_PlotLines MV_BASE_COL_panelActiveColor @@ -515,6 +514,7 @@ GetEntityCommand(mvAppItemType type) #define mvImGuiCol_PlotHistogram MV_BASE_COL_panelActiveColor #define mvImGuiCol_PlotHistogramHovered MV_BASE_COL_panelHoverColor #define mvImGuiCol_DragDropTarget mvColor(255, 255, 0, 179) +#define mvImGuiCol_DragDropTargetBg mvColor(0, 0, 0, 0) #define mvImGuiCol_NavHighlight MV_BASE_COL_bgColor #define mvImGuiCol_NavWindowingHighlight mvColor(255, 255, 255, 179) #define mvImGuiCol_NavWindowingDimBg mvColor(204, 204, 204, 51) diff --git a/src/mvAppItemState.cpp b/src/mvAppItemState.cpp index 4c636a5ae..768a4800a 100644 --- a/src/mvAppItemState.cpp +++ b/src/mvAppItemState.cpp @@ -1,8 +1,13 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvAppItemState.h" -#include + #include "mvAppItem.h" #include "mvContext.h" -#include "mvPyUtils.h" +#include +// For ImGuiWindow +#include void ResetAppItemState(mvAppItemState& state) diff --git a/src/mvAppItemTypes.inc b/src/mvAppItemTypes.inc index 88c48f07e..68a2f73ea 100644 --- a/src/mvAppItemTypes.inc +++ b/src/mvAppItemTypes.inc @@ -140,9 +140,6 @@ X( mvThemeColor ) \ X( mvThemeStyle ) \ X( mvThemeComponent ) \ - X( mvFontRangeHint ) \ - X( mvFontRange ) \ - X( mvFontChars ) \ X( mvCharRemap ) \ X( mvValueRegistry ) \ X( mvIntValue ) \ diff --git a/src/mvBasicWidgets.cpp b/src/mvBasicWidgets.cpp index 6cf58f269..43a87df0f 100644 --- a/src/mvBasicWidgets.cpp +++ b/src/mvBasicWidgets.cpp @@ -1,12 +1,17 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvBasicWidgets.h" + #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" -#include "mvPyUtils.h" #include "mvItemHandlers.h" -#include #include "mvTextureItems.h" +#include +#include + static bool KnobFloat(const char* label, float* p_value, float v_min, float v_max, float v_step = 50.f); //----------------------------------------------------------------------------- @@ -61,7 +66,7 @@ DearPyGui::fill_configuration_dict(const mvComboConfig& inConfig, PyObject* outD checkbitset("no_preview", ImGuiComboFlags_NoPreview, inConfig.flags); checkbitset("fit_width", ImGuiComboFlags_WidthFitPreview, inConfig.flags); - mvUUID mode = (long)mvComboHeightMode::mvComboHeight_Largest; + long mode = (long)mvComboHeightMode::mvComboHeight_Largest; if (inConfig.flags & ImGuiComboFlags_HeightSmall) mode = (long)mvComboHeightMode::mvComboHeight_Small; else if (inConfig.flags & ImGuiComboFlags_HeightRegular) mode = (long)mvComboHeightMode::mvComboHeight_Regular; else if (inConfig.flags & ImGuiComboFlags_HeightLarge) mode = (long)mvComboHeightMode::mvComboHeight_Large; @@ -95,7 +100,6 @@ DearPyGui::fill_configuration_dict(const mvDragFloatConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -123,7 +127,6 @@ DearPyGui::fill_configuration_dict(const mvDragDoubleConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -151,7 +154,6 @@ DearPyGui::fill_configuration_dict(const mvDragIntConfig& inConfig, PyObject* ou PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -181,7 +183,6 @@ DearPyGui::fill_configuration_dict(const mvDragIntMultiConfig& inConfig, PyObjec PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -211,7 +212,6 @@ DearPyGui::fill_configuration_dict(const mvDragFloatMultiConfig& inConfig, PyObj PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -241,7 +241,6 @@ DearPyGui::fill_configuration_dict(const mvDragDoubleMultiConfig& inConfig, PyOb PyDict_SetItemString(outDict, keyword, py_result); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -263,7 +262,6 @@ DearPyGui::fill_configuration_dict(const mvSliderIntConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -285,7 +283,6 @@ DearPyGui::fill_configuration_dict(const mvSliderIntMultiConfig& inConfig, PyObj PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -307,7 +304,6 @@ DearPyGui::fill_configuration_dict(const mvSliderFloatConfig& inConfig, PyObject PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -329,7 +325,6 @@ DearPyGui::fill_configuration_dict(const mvSliderFloatMultiConfig& inConfig, PyO PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -360,7 +355,6 @@ DearPyGui::fill_configuration_dict(const mvSliderDoubleConfig& inConfig, PyObjec PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -382,7 +376,6 @@ DearPyGui::fill_configuration_dict(const mvSliderDoubleMultiConfig& inConfig, Py PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("clamped", ImGuiSliderFlags_AlwaysClamp, inConfig.flags); checkbitset("no_input", ImGuiSliderFlags_NoInput, inConfig.flags); } @@ -412,7 +405,6 @@ DearPyGui::fill_configuration_dict(const mvInputTextConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("no_spaces", ImGuiInputTextFlags_CharsNoBlank, inConfig.flags); checkbitset("uppercase", ImGuiInputTextFlags_CharsUppercase, inConfig.flags); checkbitset("decimal", ImGuiInputTextFlags_CharsDecimal, inConfig.flags); @@ -429,6 +421,7 @@ DearPyGui::fill_configuration_dict(const mvInputTextConfig& inConfig, PyObject* checkbitset("always_overwrite", ImGuiInputTextFlags_AlwaysOverwrite, inConfig.flags); // Overwrite mode checkbitset("no_undo_redo", ImGuiInputTextFlags_NoUndoRedo, inConfig.flags); // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). checkbitset("escape_clears_all", ImGuiInputTextFlags_EscapeClearsAll, inConfig.flags); // Escape key clears content if not empty, and deactivate otherwise (contrast to default behavior of Escape to revert) + checkbitset("elide_left", ImGuiInputTextFlags_ElideLeft, inConfig.flags); // TODO: Implement all of these (they seem really useful) // Search this: ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback); @@ -447,14 +440,23 @@ DearPyGui::fill_configuration_dict(const mvInputIntConfig& inConfig, PyObject* o if (outDict == nullptr) return; - PyDict_SetItemString(outDict, "on_enter", mvPyObject(ToPyBool(inConfig.flags & ImGuiInputTextFlags_EnterReturnsTrue))); - PyDict_SetItemString(outDict, "readonly", mvPyObject(ToPyBool(inConfig.flags & ImGuiInputTextFlags_ReadOnly))); PyDict_SetItemString(outDict, "step", mvPyObject(ToPyInt(inConfig.step))); PyDict_SetItemString(outDict, "step_fast", mvPyObject(ToPyInt(inConfig.step_fast))); PyDict_SetItemString(outDict, "min_value", mvPyObject(ToPyInt(inConfig.minv))); PyDict_SetItemString(outDict, "max_value", mvPyObject(ToPyInt(inConfig.maxv))); PyDict_SetItemString(outDict, "min_clamped", mvPyObject(ToPyBool(inConfig.min_clamped))); PyDict_SetItemString(outDict, "max_clamped", mvPyObject(ToPyBool(inConfig.max_clamped))); + + // helper to check and set bit + auto checkbitset = [outDict](const char* keyword, int flag, const int& flags) + { + PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); + }; + + checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); + checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -477,9 +479,10 @@ DearPyGui::fill_configuration_dict(const mvInputFloatConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -502,9 +505,10 @@ DearPyGui::fill_configuration_dict(const mvInputDoubleConfig& inConfig, PyObject PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -526,9 +530,10 @@ DearPyGui::fill_configuration_dict(const mvInputFloatMultiConfig& inConfig, PyOb PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -550,9 +555,10 @@ DearPyGui::fill_configuration_dict(const mvInputDoubleMultiConfig& inConfig, PyO PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -561,13 +567,22 @@ DearPyGui::fill_configuration_dict(const mvInputIntMultiConfig& inConfig, PyObje if (outDict == nullptr) return; - PyDict_SetItemString(outDict, "on_enter", mvPyObject(ToPyBool(inConfig.flags & ImGuiInputTextFlags_EnterReturnsTrue))); - PyDict_SetItemString(outDict, "readonly", mvPyObject(ToPyBool(inConfig.flags & ImGuiInputTextFlags_ReadOnly))); PyDict_SetItemString(outDict, "min_value", mvPyObject(ToPyInt(inConfig.minv))); PyDict_SetItemString(outDict, "max_value", mvPyObject(ToPyInt(inConfig.maxv))); PyDict_SetItemString(outDict, "min_clamped", mvPyObject(ToPyBool(inConfig.min_clamped))); PyDict_SetItemString(outDict, "max_clamped", mvPyObject(ToPyBool(inConfig.max_clamped))); PyDict_SetItemString(outDict, "size", mvPyObject(ToPyInt(inConfig.size))); + + // helper to check and set bit + auto checkbitset = [outDict](const char* keyword, int flag, const int& flags) + { + PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); + }; + + checkbitset("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, inConfig.flags); + checkbitset("readonly", ImGuiInputTextFlags_ReadOnly, inConfig.flags); + checkbitset("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, inConfig.flags); + checkbitset("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, inConfig.flags); } void @@ -590,14 +605,14 @@ DearPyGui::fill_configuration_dict(const mvSelectableConfig& inConfig, PyObject* // helper to check and set bit - auto checkbitset = [outDict](const char* keyword, int flag, const int& flags, bool flip) + auto checkbitset = [outDict](const char* keyword, int flag, const int& flags) { PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags - checkbitset("span_columns", ImGuiSelectableFlags_SpanAllColumns, inConfig.flags, false); - checkbitset("disable_popup_close", ImGuiSelectableFlags_DontClosePopups, inConfig.flags, false); + checkbitset("span_columns", ImGuiSelectableFlags_SpanAllColumns, inConfig.flags); + checkbitset("disable_popup_close", ImGuiSelectableFlags_NoAutoClosePopups, inConfig.flags); + checkbitset("select_on_nav", ImGuiSelectableFlags_SelectOnNav, inConfig.flags); } void @@ -613,11 +628,11 @@ DearPyGui::fill_configuration_dict(const mvTabButtonConfig& inConfig, PyObject* PyDict_SetItemString(outDict, keyword, mvPyObject(ToPyBool(flags & flag))); }; - // window flags checkbitset("no_reorder", ImGuiTabBarFlags_Reorderable, inConfig.flags); checkbitset("leading", ImGuiTabItemFlags_Leading, inConfig.flags); checkbitset("trailing", ImGuiTabItemFlags_Trailing, inConfig.flags); checkbitset("no_tooltip", ImGuiTabItemFlags_NoTooltip, inConfig.flags); + checkbitset("unsaved_document", ImGuiTabItemFlags_UnsavedDocument, inConfig.flags); } void @@ -762,22 +777,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragFloatConfig& outConfig, mvA // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -799,22 +799,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragDoubleConfig& outConfig, mv // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -836,22 +821,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragIntConfig& outConfig, mvApp // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -874,22 +844,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragIntMultiConfig& outConfig, // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -912,22 +867,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragFloatMultiConfig& outConfig // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -950,22 +890,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvDragDoubleMultiConfig& outConfi // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -987,22 +912,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderIntConfig& outConfig, mvA // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -1024,22 +934,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderIntMultiConfig& outConfig // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -1061,22 +956,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderFloatConfig& outConfig, m // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -1099,23 +979,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderFloatMultiConfig& outConf // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } - } void @@ -1137,22 +1001,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderDoubleConfig& outConfig, // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } } void @@ -1175,23 +1024,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvSliderDoubleMultiConfig& outCon // flags flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.flags); - flagop("clamped", ImGuiSliderFlags_AlwaysClamp, outConfig.stor_flags); flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.flags); - flagop("no_input", ImGuiSliderFlags_NoInput, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiSliderFlags_NoInput; - } - } void @@ -1312,21 +1145,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputTextConfig& outConfig, mvA flagop("always_overwrite", ImGuiInputTextFlags_AlwaysOverwrite, outConfig.flags); flagop("no_undo_redo", ImGuiInputTextFlags_NoUndoRedo, outConfig.flags); flagop("escape_clears_all", ImGuiInputTextFlags_EscapeClearsAll, outConfig.flags); - - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("elide_left", ImGuiInputTextFlags_ElideLeft, outConfig.flags); } void @@ -1335,10 +1154,6 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputIntConfig& outConfig, mvAp if (inDict == nullptr) return; - if (PyObject* item = PyDict_GetItemString(inDict, "on_enter")) ToBool(item) ? outConfig.flags |= ImGuiInputTextFlags_EnterReturnsTrue : outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - if (PyObject* item = PyDict_GetItemString(inDict, "on_enter")) ToBool(item) ? outConfig.stor_flags |= ImGuiInputTextFlags_EnterReturnsTrue : outConfig.stor_flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - if (PyObject* item = PyDict_GetItemString(inDict, "readonly")) ToBool(item) ? outConfig.flags |= ImGuiInputTextFlags_ReadOnly : outConfig.flags &= ~ImGuiInputTextFlags_ReadOnly; - if (PyObject* item = PyDict_GetItemString(inDict, "readonly")) ToBool(item) ? outConfig.stor_flags |= ImGuiInputTextFlags_ReadOnly : outConfig.stor_flags &= ~ImGuiInputTextFlags_ReadOnly; if (PyObject* item = PyDict_GetItemString(inDict, "step")) outConfig.step = ToInt(item); if (PyObject* item = PyDict_GetItemString(inDict, "step_fast")) outConfig.step_fast = ToInt(item); @@ -1357,19 +1172,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputIntConfig& outConfig, mvAp if (PyObject* item = PyDict_GetItemString(inDict, "min_clamped")) outConfig.min_clamped = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "max_clamped")) outConfig.max_clamped = ToBool(item); - if (info.enabledLastFrame) + // helper for bit flipping + auto flagop = [inDict](const char* keyword, int flag, int& flags) { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } + if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; + }; - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); + flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1407,23 +1219,9 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputFloatConfig& outConfig, mv // flags flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); - flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.stor_flags); flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); - flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1461,23 +1259,9 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputDoubleConfig& outConfig, m // flags flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); - flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.stor_flags); flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); - flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1512,23 +1296,9 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputFloatMultiConfig& outConfi // flags flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); - flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.stor_flags); flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); - flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1563,23 +1333,9 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputDoubleMultiConfig& outConf // flags flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); - flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.stor_flags); flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); - flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.stor_flags); - - if (info.enabledLastFrame) - { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } - - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1588,10 +1344,6 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputIntMultiConfig& outConfig, if (inDict == nullptr) return; - if (PyObject* item = PyDict_GetItemString(inDict, "on_enter")) ToBool(item) ? outConfig.flags |= ImGuiInputTextFlags_EnterReturnsTrue : outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - if (PyObject* item = PyDict_GetItemString(inDict, "on_enter")) ToBool(item) ? outConfig.stor_flags |= ImGuiInputTextFlags_EnterReturnsTrue : outConfig.stor_flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - if (PyObject* item = PyDict_GetItemString(inDict, "readonly")) ToBool(item) ? outConfig.flags |= ImGuiInputTextFlags_ReadOnly : outConfig.flags &= ~ImGuiInputTextFlags_ReadOnly; - if (PyObject* item = PyDict_GetItemString(inDict, "readonly")) ToBool(item) ? outConfig.stor_flags |= ImGuiInputTextFlags_ReadOnly : outConfig.stor_flags &= ~ImGuiInputTextFlags_ReadOnly; if (PyObject* item = PyDict_GetItemString(inDict, "size")) outConfig.size = ToInt(item); if (PyObject* item = PyDict_GetItemString(inDict, "min_value")) @@ -1609,19 +1361,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvInputIntMultiConfig& outConfig, if (PyObject* item = PyDict_GetItemString(inDict, "min_clamped")) outConfig.min_clamped = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "max_clamped")) outConfig.max_clamped = ToBool(item); - if (info.enabledLastFrame) + // helper for bit flipping + auto flagop = [inDict](const char* keyword, int flag, int& flags) { - info.enabledLastFrame = false; - outConfig.flags = outConfig.stor_flags; - } + if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; + }; - if (info.disabledLastFrame) - { - info.disabledLastFrame = false; - outConfig.stor_flags = outConfig.flags; - outConfig.flags |= ImGuiInputTextFlags_ReadOnly; - outConfig.flags &= ~ImGuiInputTextFlags_EnterReturnsTrue; - } + flagop("on_enter", ImGuiInputTextFlags_EnterReturnsTrue, outConfig.flags); + flagop("readonly", ImGuiInputTextFlags_ReadOnly, outConfig.flags); + flagop("accept_empty_input", ImGuiInputTextFlags_ParseEmptyRefVal, outConfig.flags); + flagop("display_empty_value", ImGuiInputTextFlags_DisplayEmptyRefVal, outConfig.flags); } void @@ -1644,14 +1393,14 @@ DearPyGui::set_configuration(PyObject* inDict, mvSelectableConfig& outConfig, mv // helper for bit flipping - auto flagop = [inDict](const char* keyword, int flag, int& flags, bool flip) + auto flagop = [inDict](const char* keyword, int flag, int& flags) { if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; }; - // window flags - flagop("span_columns", ImGuiSelectableFlags_SpanAllColumns, outConfig.flags, false); - flagop("disable_popup_close", ImGuiSelectableFlags_DontClosePopups, outConfig.flags, false); + flagop("span_columns", ImGuiSelectableFlags_SpanAllColumns, outConfig.flags); + flagop("disable_popup_close", ImGuiSelectableFlags_NoAutoClosePopups, outConfig.flags); + flagop("select_on_nav", ImGuiSelectableFlags_SelectOnNav, outConfig.flags); if (info.enabledLastFrame) { @@ -1679,11 +1428,11 @@ DearPyGui::set_configuration(PyObject* inDict, mvTabButtonConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; }; - // window flags flagop("no_reorder", ImGuiTabItemFlags_NoReorder, outConfig.flags); flagop("leading", ImGuiTabItemFlags_Leading, outConfig.flags); flagop("trailing", ImGuiTabItemFlags_Trailing, outConfig.flags); flagop("no_tooltip", ImGuiTabItemFlags_NoTooltip, outConfig.flags); + flagop("unsaved_document", ImGuiTabItemFlags_UnsavedDocument, outConfig.flags); if (outConfig.flags & ImGuiTabItemFlags_Leading && outConfig.flags & ImGuiTabItemFlags_Trailing) outConfig.flags &= ~ImGuiTabItemFlags_Leading; @@ -1721,19 +1470,15 @@ DearPyGui::set_configuration(PyObject* inDict, mvImageConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "texture_tag")) { outConfig.textureUUID = GetIDFromPyObject(item); - outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig.texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; - } - else if (outConfig.texture) - { - outConfig._internalTexture = false; } else { - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImage), "Texture not found.", nullptr); + outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig.texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImage), "Texture not found.", nullptr); } } } @@ -1752,19 +1497,15 @@ DearPyGui::set_configuration(PyObject* inDict, mvImageButtonConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "texture_tag")) { outConfig.textureUUID = GetIDFromPyObject(item); - outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig.texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; - } - else if (outConfig.texture) - { - outConfig._internalTexture = false; } else { - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageButton), "Texture not found.", nullptr); + outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig.texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageButton), "Texture not found.", nullptr); } } } @@ -1809,16 +1550,16 @@ DearPyGui::set_required_configuration(PyObject* inDict, mvImageConfig& outConfig return; outConfig.textureUUID = GetIDFromPyObject(PyTuple_GetItem(inDict, 0)); - outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); - if (outConfig.texture) - return; - else if (outConfig.textureUUID == MV_ATLAS_UUID) + if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig.texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; } else - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImage), "Texture not found.", nullptr); + { + outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig.texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImage), "Texture not found.", nullptr); + } } void @@ -1828,16 +1569,16 @@ DearPyGui::set_required_configuration(PyObject* inDict, mvImageButtonConfig& out return; outConfig.textureUUID = GetIDFromPyObject(PyTuple_GetItem(inDict, 0)); - outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); - if (outConfig.texture) - return; - else if (outConfig.textureUUID == MV_ATLAS_UUID) + if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig.texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; } else - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageButton), "Texture not found.", nullptr); + { + outConfig.texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig.texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageButton), "Texture not found.", nullptr); + } } //----------------------------------------------------------------------------- @@ -2612,10 +2353,7 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2663,7 +2401,7 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -2722,10 +2460,7 @@ DearPyGui::draw_button(ImDrawList* drawlist, mvAppItem& item, const mvButtonConf // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2765,7 +2500,7 @@ DearPyGui::draw_button(ImDrawList* drawlist, mvAppItem& item, const mvButtonConf // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -2825,10 +2560,7 @@ DearPyGui::draw_combo(ImDrawList* drawlist, mvAppItem& item, mvComboConfig& conf // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2877,7 +2609,7 @@ DearPyGui::draw_combo(ImDrawList* drawlist, mvAppItem& item, mvComboConfig& conf // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -2934,10 +2666,7 @@ DearPyGui::draw_checkbox(ImDrawList* drawlist, mvAppItem& item, mvCheckboxConfig // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); apply_local_theming(&item); @@ -2967,7 +2696,7 @@ DearPyGui::draw_checkbox(ImDrawList* drawlist, mvAppItem& item, mvCheckboxConfig // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3025,10 +2754,7 @@ DearPyGui::draw_drag_float(ImDrawList* drawlist, mvAppItem& item, mvDragFloatCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3040,9 +2766,11 @@ DearPyGui::draw_drag_float(ImDrawList* drawlist, mvAppItem& item, mvDragFloatCon if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (ImGui::DragFloat(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, - config.speed, config.minv, config.maxv, config.format.c_str(), config.flags)) + config.speed, config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3059,7 +2787,7 @@ DearPyGui::draw_drag_float(ImDrawList* drawlist, mvAppItem& item, mvDragFloatCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3118,10 +2846,7 @@ DearPyGui::draw_drag_double(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleC // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3133,9 +2858,11 @@ DearPyGui::draw_drag_double(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleC if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (ImGui::DragScalar(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value.get() : &config.disabled_value, - config.speed, &config.minv, &config.maxv, config.format.c_str(), config.flags)) + config.speed, &config.minv, &config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3152,7 +2879,7 @@ DearPyGui::draw_drag_double(ImDrawList* drawlist, mvAppItem& item, mvDragDoubleC // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3209,10 +2936,7 @@ DearPyGui::draw_drag_int(ImDrawList* drawlist, mvAppItem& item, mvDragIntConfig& // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3226,9 +2950,11 @@ DearPyGui::draw_drag_int(ImDrawList* drawlist, mvAppItem& item, mvDragIntConfig& if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (ImGui::DragInt(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, config.speed, - config.minv, config.maxv, config.format.c_str(), config.flags)) + config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3245,7 +2971,7 @@ DearPyGui::draw_drag_int(ImDrawList* drawlist, mvAppItem& item, mvDragIntConfig& // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3302,10 +3028,7 @@ DearPyGui::draw_drag_intx(ImDrawList* drawlist, mvAppItem& item, mvDragIntMultiC // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3322,16 +3045,18 @@ DearPyGui::draw_drag_intx(ImDrawList* drawlist, mvAppItem& item, mvDragIntMultiC if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 2, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + switch (config.size) { case 2: - activated = ImGui::DragInt2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragInt2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; case 3: - activated = ImGui::DragInt3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragInt3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; case 4: - activated = ImGui::DragInt4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragInt4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; default: break; @@ -3354,7 +3079,7 @@ DearPyGui::draw_drag_intx(ImDrawList* drawlist, mvAppItem& item, mvDragIntMultiC // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3411,10 +3136,7 @@ DearPyGui::draw_drag_floatx(ImDrawList* drawlist, mvAppItem& item, mvDragFloatMu // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3429,16 +3151,18 @@ DearPyGui::draw_drag_floatx(ImDrawList* drawlist, mvAppItem& item, mvDragFloatMu if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 2, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + switch (config.size) { case 2: - activated = ImGui::DragFloat2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragFloat2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; case 3: - activated = ImGui::DragFloat3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragFloat3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; case 4: - activated = ImGui::DragFloat4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragFloat4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.speed, config.minv, config.maxv, config.format.c_str(), flags); break; default: break; @@ -3460,7 +3184,7 @@ DearPyGui::draw_drag_floatx(ImDrawList* drawlist, mvAppItem& item, mvDragFloatMu // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3517,10 +3241,7 @@ DearPyGui::draw_drag_doublex(ImDrawList* drawlist, mvAppItem& item, mvDragDouble // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3535,8 +3256,10 @@ DearPyGui::draw_drag_doublex(ImDrawList* drawlist, mvAppItem& item, mvDragDouble if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 2, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if(config.size > 1 && config.size < 5) - activated = ImGui::DragScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value->data() : &config.disabled_value[0], config.size, config.speed, &config.minv, &config.maxv, config.format.c_str(), config.flags); + activated = ImGui::DragScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value->data() : &config.disabled_value[0], config.size, config.speed, &config.minv, &config.maxv, config.format.c_str(), flags); if (activated) { @@ -3554,7 +3277,7 @@ DearPyGui::draw_drag_doublex(ImDrawList* drawlist, mvAppItem& item, mvDragDouble // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3611,10 +3334,7 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3627,6 +3347,8 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (config.vertical) { if ((float)item.config.height < 1.0f) @@ -3634,7 +3356,7 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa if ((float)item.config.width < 1.0f) item.config.width = 20; - if (ImGui::VSliderFloat(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str())) + if (ImGui::VSliderFloat(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3642,7 +3364,7 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa } else { - if (ImGui::SliderFloat(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), config.flags)) + if (ImGui::SliderFloat(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3661,7 +3383,7 @@ DearPyGui::draw_slider_float(ImDrawList* drawlist, mvAppItem& item, mvSliderFloa // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3718,10 +3440,7 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3734,6 +3453,8 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (config.vertical) { if ((float)item.config.height < 1.0f) @@ -3741,7 +3462,7 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou if ((float)item.config.width < 1.0f) item.config.width = 20; - if (ImGui::VSliderScalar(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), ImGuiDataType_Double, item.config.enabled ? config.value.get() : &config.disabled_value, &config.minv, &config.maxv, config.format.c_str())) + if (ImGui::VSliderScalar(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), ImGuiDataType_Double, item.config.enabled ? config.value.get() : &config.disabled_value, &config.minv, &config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -3749,7 +3470,7 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou } 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)) + 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(), flags)) { item.submitCallback(*config.value); } @@ -3768,7 +3489,7 @@ DearPyGui::draw_slider_double(ImDrawList* drawlist, mvAppItem& item, mvSliderDou // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3825,10 +3546,7 @@ DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFlo // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3843,16 +3561,18 @@ DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFlo if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 4, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + switch (config.size) { case 2: - activated = ImGui::SliderFloat2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderFloat2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; case 3: - activated = ImGui::SliderFloat3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderFloat3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; case 4: - activated = ImGui::SliderFloat4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderFloat4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; default: break; @@ -3875,7 +3595,7 @@ DearPyGui::draw_slider_floatx(ImDrawList* drawlist, mvAppItem& item, mvSliderFlo // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -3932,10 +3652,7 @@ DearPyGui::draw_slider_doublex(ImDrawList* drawlist, mvAppItem& item, mvSliderDo // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -3950,8 +3667,10 @@ DearPyGui::draw_slider_doublex(ImDrawList* drawlist, mvAppItem& item, mvSliderDo if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 4, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (config.size > 1 && config.size < 5) - activated = ImGui::SliderScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value->data() : &config.disabled_value[0], config.size, &config.minv, &config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, item.config.enabled ? config.value->data() : &config.disabled_value[0], config.size, &config.minv, &config.maxv, config.format.c_str(), flags); if (activated) { @@ -3970,7 +3689,7 @@ DearPyGui::draw_slider_doublex(ImDrawList* drawlist, mvAppItem& item, mvSliderDo // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4027,10 +3746,7 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4043,6 +3759,8 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon if (!item.config.enabled) config.disabled_value = *config.value; + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + if (config.vertical) { if ((float)item.config.height < 1.0f) @@ -4050,7 +3768,7 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon if ((float)item.config.width < 1.0f) item.config.width = 20; - if (ImGui::VSliderInt(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str())) + if (ImGui::VSliderInt(item.info.internalLabel.c_str(), ImVec2((float)item.config.width, (float)item.config.height), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -4058,7 +3776,7 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon } else { - if (ImGui::SliderInt(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), config.flags)) + if (ImGui::SliderInt(item.info.internalLabel.c_str(), item.config.enabled ? config.value.get() : &config.disabled_value, config.minv, config.maxv, config.format.c_str(), flags)) { item.submitCallback(*config.value); } @@ -4077,7 +3795,7 @@ DearPyGui::draw_slider_int(ImDrawList* drawlist, mvAppItem& item, mvSliderIntCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4134,10 +3852,7 @@ DearPyGui::draw_slider_intx(ImDrawList* drawlist, mvAppItem& item, mvSliderIntMu // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4152,16 +3867,18 @@ DearPyGui::draw_slider_intx(ImDrawList* drawlist, mvAppItem& item, mvSliderIntMu if (!item.config.enabled) std::copy(config.value->data(), config.value->data() + 4, config.disabled_value); + auto flags = config.flags | (item.config.enabled? 0 : ImGuiSliderFlags_NoInput); + switch (config.size) { case 2: - activated = ImGui::SliderInt2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderInt2(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; case 3: - activated = ImGui::SliderInt3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderInt3(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; case 4: - activated = ImGui::SliderInt4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), config.flags); + activated = ImGui::SliderInt4(item.info.internalLabel.c_str(), item.config.enabled ? config.value->data() : &config.disabled_value[0], config.minv, config.maxv, config.format.c_str(), flags); break; default: break; @@ -4184,7 +3901,7 @@ DearPyGui::draw_slider_intx(ImDrawList* drawlist, mvAppItem& item, mvSliderIntMu // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4241,10 +3958,7 @@ DearPyGui::draw_listbox(ImDrawList *drawlist, mvAppItem &item, mvListboxConfig & // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4287,7 +4001,7 @@ DearPyGui::draw_listbox(ImDrawList *drawlist, mvAppItem &item, mvListboxConfig & // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4344,10 +4058,7 @@ DearPyGui::draw_radio_button(ImDrawList* drawlist, mvAppItem& item, mvRadioButto // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4397,7 +4108,7 @@ DearPyGui::draw_radio_button(ImDrawList* drawlist, mvAppItem& item, mvRadioButto // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4454,10 +4165,7 @@ DearPyGui::draw_input_text(ImDrawList* drawlist, mvAppItem& item, mvInputTextCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4471,18 +4179,20 @@ DearPyGui::draw_input_text(ImDrawList* drawlist, mvAppItem& item, mvInputTextCon bool activated = false; + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + if (config.multiline) config.hint.clear(); if (config.hint.empty()) { if (config.multiline) - activated = ImGui::InputTextMultiline(item.info.internalLabel.c_str(), config.value.get(), ImVec2((float)item.config.width, (float)item.config.height), config.flags); + activated = ImGui::InputTextMultiline(item.info.internalLabel.c_str(), config.value.get(), ImVec2((float)item.config.width, (float)item.config.height), flags); else - activated = ImGui::InputText(item.info.internalLabel.c_str(), config.value.get(), config.flags); + activated = ImGui::InputText(item.info.internalLabel.c_str(), config.value.get(), flags); } else - activated = ImGui::InputTextWithHint(item.info.internalLabel.c_str(), config.hint.c_str(), config.value.get(), config.flags); + activated = ImGui::InputTextWithHint(item.info.internalLabel.c_str(), config.hint.c_str(), config.value.get(), flags); if (activated) { @@ -4502,7 +4212,7 @@ DearPyGui::draw_input_text(ImDrawList* drawlist, mvAppItem& item, mvInputTextCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4559,10 +4269,7 @@ DearPyGui::draw_input_int(ImDrawList* drawlist, mvAppItem& item, mvInputIntConfi // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4574,7 +4281,9 @@ DearPyGui::draw_input_int(ImDrawList* drawlist, mvAppItem& item, mvInputIntConfi ScopedID id(item.uuid); - if (ImGui::InputInt(item.info.internalLabel.c_str(), config.value.get(), config.step, config.step_fast, config.flags)) + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + + if (ImGui::InputInt(item.info.internalLabel.c_str(), config.value.get(), config.step, config.step_fast, flags)) { // determines clamped cases if (config.min_clamped && config.max_clamped) @@ -4615,7 +4324,7 @@ DearPyGui::draw_input_int(ImDrawList* drawlist, mvAppItem& item, mvInputIntConfi // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4672,10 +4381,7 @@ DearPyGui::draw_input_floatx(ImDrawList* drawlist, mvAppItem& item, mvInputFloat // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4689,16 +4395,18 @@ DearPyGui::draw_input_floatx(ImDrawList* drawlist, mvAppItem& item, mvInputFloat bool res = false; + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + switch (config.size) { case 2: - res = ImGui::InputFloat2(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), config.flags); + res = ImGui::InputFloat2(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), flags); break; case 3: - res = ImGui::InputFloat3(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), config.flags); + res = ImGui::InputFloat3(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), flags); break; case 4: - res = ImGui::InputFloat4(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), config.flags); + res = ImGui::InputFloat4(item.info.internalLabel.c_str(), config.value->data(), config.format.c_str(), flags); break; default: break; @@ -4755,7 +4463,7 @@ DearPyGui::draw_input_floatx(ImDrawList* drawlist, mvAppItem& item, mvInputFloat // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4813,10 +4521,7 @@ DearPyGui::draw_input_float(ImDrawList* drawlist, mvAppItem& item, mvInputFloatC // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4828,7 +4533,9 @@ DearPyGui::draw_input_float(ImDrawList* drawlist, mvAppItem& item, mvInputFloatC ScopedID id(item.uuid); - if (ImGui::InputFloat(item.info.internalLabel.c_str(), config.value.get(), config.step, config.step_fast, config.format.c_str(), config.flags)) + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + + if (ImGui::InputFloat(item.info.internalLabel.c_str(), config.value.get(), config.step, config.step_fast, config.format.c_str(), flags)) { // determines clamped cases if (config.min_clamped && config.max_clamped) @@ -4868,7 +4575,7 @@ DearPyGui::draw_input_float(ImDrawList* drawlist, mvAppItem& item, mvInputFloatC // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -4925,10 +4632,7 @@ DearPyGui::draw_knob_float(ImDrawList* drawlist, mvAppItem& item, mvKnobFloatCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -4959,7 +4663,7 @@ DearPyGui::draw_knob_float(ImDrawList* drawlist, mvAppItem& item, mvKnobFloatCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5016,10 +4720,7 @@ DearPyGui::draw_input_double(ImDrawList* drawlist, mvAppItem& item, mvInputDoubl // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5031,7 +4732,9 @@ DearPyGui::draw_input_double(ImDrawList* drawlist, mvAppItem& item, mvInputDoubl ScopedID id(item.uuid); - if (ImGui::InputScalar(item.info.internalLabel.c_str(), ImGuiDataType_Double, (void*)config.value.get(), (void*)(config.step > 0 ? &config.step : NULL), (void*)(config.step_fast > 0 ? &config.step_fast : NULL), config.format.c_str(), config.flags)) + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + + if (ImGui::InputScalar(item.info.internalLabel.c_str(), ImGuiDataType_Double, (void*)config.value.get(), (void*)(config.step > 0 ? &config.step : NULL), (void*)(config.step_fast > 0 ? &config.step_fast : NULL), config.format.c_str(), flags)) { // determines clamped cases if (config.min_clamped && config.max_clamped) @@ -5071,7 +4774,7 @@ DearPyGui::draw_input_double(ImDrawList* drawlist, mvAppItem& item, mvInputDoubl // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5128,10 +4831,7 @@ DearPyGui::draw_input_doublex(ImDrawList* drawlist, mvAppItem& item, mvInputDoub // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5145,8 +4845,10 @@ DearPyGui::draw_input_doublex(ImDrawList* drawlist, mvAppItem& item, mvInputDoub bool res = false; + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + if (config.size > 1 && config.size < 5) - res = ImGui::InputScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, config.value->data(), config.size, NULL, NULL, config.format.c_str(), config.flags); + res = ImGui::InputScalarN(item.info.internalLabel.c_str(), ImGuiDataType_Double, config.value->data(), config.size, NULL, NULL, config.format.c_str(), flags); if (res) { @@ -5199,7 +4901,7 @@ DearPyGui::draw_input_doublex(ImDrawList* drawlist, mvAppItem& item, mvInputDoub // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5257,10 +4959,7 @@ DearPyGui::draw_input_intx(ImDrawList* drawlist, mvAppItem& item, mvInputIntMult // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5273,16 +4972,18 @@ DearPyGui::draw_input_intx(ImDrawList* drawlist, mvAppItem& item, mvInputIntMult bool res = false; + auto flags = item.config.enabled? config.flags : (config.flags & ~ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_ReadOnly); + switch (config.size) { case 2: - res = ImGui::InputInt2(item.info.internalLabel.c_str(), config.value->data(), config.flags); + res = ImGui::InputInt2(item.info.internalLabel.c_str(), config.value->data(), flags); break; case 3: - res = ImGui::InputInt3(item.info.internalLabel.c_str(), config.value->data(), config.flags); + res = ImGui::InputInt3(item.info.internalLabel.c_str(), config.value->data(), flags); break; case 4: - res = ImGui::InputInt4(item.info.internalLabel.c_str(), config.value->data(), config.flags); + res = ImGui::InputInt4(item.info.internalLabel.c_str(), config.value->data(), flags); break; default: break; @@ -5339,7 +5040,7 @@ DearPyGui::draw_input_intx(ImDrawList* drawlist, mvAppItem& item, mvInputIntMult // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5387,10 +5088,7 @@ DearPyGui::draw_text(ImDrawList* drawlist, mvAppItem& item, mvTextConfig& config ImGui::Indent(item.config.indent); if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5530,10 +5228,7 @@ DearPyGui::draw_selectable(ImDrawList* drawlist, mvAppItem& item, mvSelectableCo // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5561,7 +5256,7 @@ DearPyGui::draw_selectable(ImDrawList* drawlist, mvAppItem& item, mvSelectableCo // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5618,10 +5313,7 @@ DearPyGui::draw_tab_button(ImDrawList* drawlist, mvAppItem& item, mvTabButtonCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5649,7 +5341,7 @@ DearPyGui::draw_tab_button(ImDrawList* drawlist, mvAppItem& item, mvTabButtonCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5706,10 +5398,7 @@ DearPyGui::draw_menu_item(ImDrawList* drawlist, mvAppItem& item, mvMenuItemConfi // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5747,7 +5436,7 @@ DearPyGui::draw_menu_item(ImDrawList* drawlist, mvAppItem& item, mvMenuItemConfi // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5804,10 +5493,7 @@ DearPyGui::draw_progress_bar(ImDrawList* drawlist, mvAppItem& item, mvProgressBa // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5834,7 +5520,7 @@ DearPyGui::draw_progress_bar(ImDrawList* drawlist, mvAppItem& item, mvProgressBa // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -5891,10 +5577,7 @@ DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& conf // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -5903,14 +5586,8 @@ DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& conf // draw //----------------------------------------------------------------------------- { - if (config.texture) + if (config.texture && config.texture->state.ok) { - if (config._internalTexture) - config.texture->draw(drawlist, 0.0f, 0.0f); - - if (!config.texture->state.ok) - return; - // if width/height is not set by user, use texture dimensions if (item.config.width == 0) item.config.width = config.texture->config.width; @@ -5918,19 +5595,25 @@ DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& conf if (item.config.height == 0) item.config.height = config.texture->config.height; - void* texture = nullptr; - - if (config.texture->type == mvAppItemType::mvStaticTexture) - texture = static_cast(config.texture.get())->_texture; - else if (config.texture->type == mvAppItemType::mvRawTexture) - texture = static_cast(config.texture.get())->_texture; - else - texture = static_cast(config.texture.get())->_texture; - - ImGui::Image(texture, ImVec2((float)item.config.width, (float)item.config.height), ImVec2(config.uv_min.x, config.uv_min.y), ImVec2(config.uv_max.x, config.uv_max.y), - ImVec4((float)config.tintColor.r, (float)config.tintColor.g, (float)config.tintColor.b, (float)config.tintColor.a), - ImVec4((float)config.borderColor.r, (float)config.borderColor.g, (float)config.borderColor.b, (float)config.borderColor.a)); - + auto type = config.texture->type; + if (type == mvAppItemType::mvStaticTexture || + type == mvAppItemType::mvDynamicTexture || + type == mvAppItemType::mvRawTexture) + { + ImTextureRef texture = static_cast(config.texture.get())->getTexRef(); + ImGuiContext& g = *GImGui; + ImGui::PushStyleVar(ImGuiStyleVar_ImageBorderSize, (config.borderColor.a > 0.0f) ? ImMax(1.0f, g.Style.ImageBorderSize) : 0.0f); + ImGui::PushStyleColor(ImGuiCol_Border, config.borderColor.toVec4()); + ImGui::ImageWithBg( + texture, + ImVec2((float)item.config.width, (float)item.config.height), + ImVec2(config.uv_min.x, config.uv_min.y), + ImVec2(config.uv_max.x, config.uv_max.y), + ImVec4(0, 0, 0, 0), + config.tintColor.toVec4()); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); + } } } @@ -5946,7 +5629,7 @@ DearPyGui::draw_image(ImDrawList* drawlist, mvAppItem& item, mvImageConfig& conf // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -6003,10 +5686,7 @@ DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButto // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -6016,15 +5696,8 @@ DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButto //----------------------------------------------------------------------------- { - if (config.texture) + if (config.texture && config.texture->state.ok) { - - if (config._internalTexture) - config.texture->draw(drawlist, 0.0f, 0.0f); - - if (!config.texture->state.ok) - return; - // if width/height is not set by user, use texture dimensions if (item.config.width == 0) item.config.width = config.texture->config.width; @@ -6032,29 +5705,28 @@ DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButto if (item.config.height == 0) item.config.height = config.texture->config.height; - void* texture = nullptr; - - if (config.texture->type == mvAppItemType::mvStaticTexture) - texture = static_cast(config.texture.get())->_texture; - else if (config.texture->type == mvAppItemType::mvRawTexture) - texture = static_cast(config.texture.get())->_texture; - else - texture = static_cast(config.texture.get())->_texture; - - if (config.framePadding >= 0) - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2((float)config.framePadding, (float)config.framePadding)); - - ImGui::PushID(item.uuid); - if (ImGui::ImageButton(item.info.internalLabel.c_str(), texture, ImVec2((float)item.config.width, (float)item.config.height), - ImVec2(config.uv_min.x, config.uv_min.y), ImVec2(config.uv_max.x, config.uv_max.y), - config.backgroundColor, config.tintColor)) + auto type = config.texture->type; + if (type == mvAppItemType::mvStaticTexture || + type == mvAppItemType::mvDynamicTexture || + type == mvAppItemType::mvRawTexture) { - item.submitCallback(); - } - ImGui::PopID(); + ScopedID id(item.uuid); + + ImTextureRef texture = static_cast(config.texture.get())->getTexRef(); + + if (config.framePadding >= 0) + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2((float)config.framePadding, (float)config.framePadding)); + + if (ImGui::ImageButton(item.info.internalLabel.c_str(), texture, ImVec2((float)item.config.width, (float)item.config.height), + ImVec2(config.uv_min.x, config.uv_min.y), ImVec2(config.uv_max.x, config.uv_max.y), + config.backgroundColor, config.tintColor)) + { + item.submitCallback(); + } - if (config.framePadding >= 0) - ImGui::PopStyleVar(); + if (config.framePadding >= 0) + ImGui::PopStyleVar(); + } } } @@ -6069,7 +5741,7 @@ DearPyGui::draw_image_button(ImDrawList* drawlist, mvAppItem& item, mvImageButto // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -6221,12 +5893,10 @@ DearPyGui::draw_tooltip(ImDrawList* drawlist, mvAppItem& item) if (GContext->time - tooltip->change_time >= tooltip->configData.activation_delay) { if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); apply_local_theming(&item); + // TODO: we should probably be using ImGuiTooltipFlags_OverridePrevious if(ImGui::BeginTooltip()) { item.state.visible = true; diff --git a/src/mvBasicWidgets.h b/src/mvBasicWidgets.h index 576d14239..16d909338 100644 --- a/src/mvBasicWidgets.h +++ b/src/mvBasicWidgets.h @@ -246,7 +246,6 @@ struct mvDragFloatConfig 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; }; @@ -258,7 +257,6 @@ struct mvDragDoubleConfig 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; }; @@ -270,7 +268,6 @@ struct mvDragIntConfig 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; }; @@ -282,7 +279,6 @@ struct mvDragIntMultiConfig 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]{}; @@ -295,7 +291,6 @@ struct mvDragFloatMultiConfig 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]{}; @@ -308,7 +303,6 @@ struct mvDragDoubleMultiConfig 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]{}; @@ -321,7 +315,6 @@ struct mvSliderIntConfig 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; }; @@ -333,7 +326,6 @@ struct mvSliderFloatConfig 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; }; @@ -345,7 +337,6 @@ struct mvSliderDoubleConfig 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; }; @@ -356,7 +347,6 @@ struct mvSliderFloatMultiConfig 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]{}; @@ -368,7 +358,6 @@ struct mvSliderIntMultiConfig 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]{}; @@ -380,7 +369,6 @@ struct mvSliderDoubleMultiConfig 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]{}; @@ -412,7 +400,6 @@ struct mvInputTextConfig std::string hint; bool multiline = false; ImGuiInputTextFlags flags = 0; - ImGuiInputTextFlags stor_flags = 0; std::shared_ptr value = std::make_shared(""); std::string disabled_value = ""; }; @@ -426,7 +413,6 @@ struct mvInputIntConfig 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; @@ -442,7 +428,6 @@ struct mvInputFloatConfig 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; @@ -458,7 +443,6 @@ struct mvInputDoubleConfig 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; @@ -472,7 +456,6 @@ struct mvInputFloatMultiConfig 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}); @@ -486,7 +469,6 @@ struct mvInputIntMultiConfig 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}); @@ -501,7 +483,6 @@ struct mvInputDoubleMultiConfig 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}); @@ -554,7 +535,6 @@ struct mvImageConfig mvVec2 uv_max = { 1.0f, 1.0f }; mvColor tintColor = { 1.0f, 1.0f, 1.0f, 1.0f }; mvColor borderColor = { 0.0f, 0.0f, 0.0f, 0.0f }; - bool _internalTexture = false; // create a local texture if necessary }; struct mvImageButtonConfig @@ -567,7 +547,6 @@ struct mvImageButtonConfig mvColor tintColor = { 1.0f, 1.0f, 1.0f, 1.0f }; mvColor backgroundColor = { 0.0f, 0.0f, 0.0f, 0.0f }; int framePadding = -1; - bool _internalTexture = false; // create a local texture if necessary }; struct mvFilterSetConfig diff --git a/src/mvCallbackRegistry.cpp b/src/mvCallbackRegistry.cpp index c28943f74..0a98ed3ec 100644 --- a/src/mvCallbackRegistry.cpp +++ b/src/mvCallbackRegistry.cpp @@ -1,18 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvCallbackRegistry.h" -#include "mvProfiler.h" + #include "mvContext.h" -#include #include "mvItemRegistry.h" -#include "mvAppItemCommons.h" -#include "mvPyUtils.h" -void mvRunTasks() +void mvRunTasks(bool early /* = false */) { - while (!GContext->callbackRegistry->tasks.empty()) + auto& tasks = early? GContext->callbackRegistry->earlyTasks : GContext->callbackRegistry->tasks; + while (!tasks.empty()) { mvFunctionWrapper t; - GContext->callbackRegistry->tasks.wait_and_pop(t); + tasks.wait_and_pop(t); t(); } } diff --git a/src/mvCallbackRegistry.h b/src/mvCallbackRegistry.h index 701aa419e..323d11fe0 100644 --- a/src/mvCallbackRegistry.h +++ b/src/mvCallbackRegistry.h @@ -215,6 +215,9 @@ struct mvCallbackRegistry std::vector jobs; mvQueue tasks; + // These are like `tasks` but they run very early at the start of the frame, + // whereas `tasks` can be run mid-frame either before or after Render(). + mvQueue earlyTasks; mvQueue calls; std::atomic running = false; std::atomic callCount = 0; @@ -231,7 +234,8 @@ struct mvCallbackRegistry }; void mvFrameCallback(i32 frame); -void mvRunTasks(); +// Runs either `tasks` or `earlyTasks` from mvCallbackRegistry, depending on the `early` flag. +void mvRunTasks(bool early = false); // All PyObject references here are borrowed references - caller must release them after this call void mvRunCallback(PyObject* callback, PyObject* user_data, mvUUID sender = 0, const std::string& sender_alias = "", PyObject* app_data = nullptr); // This version checks if owner is still alive (by obtaining shared_ptr), and if it is, @@ -309,7 +313,7 @@ void mvAddOwnerlessCallback(const std::shared_ptr& callback, bool mvRunCallbacks(); template -std::future::type> mvSubmitTask(F f) +std::future::type> mvSubmitTask(F f, bool runEarlyInFrame = false) { typedef typename std::invoke_result::type result_type; @@ -317,7 +321,10 @@ std::future::type> mvSubmitTask(F f) std::future res(task.get_future()); if (GContext->running) - GContext->callbackRegistry->tasks.push(std::move(task)); + { + auto& tasks = runEarlyInFrame? GContext->callbackRegistry->earlyTasks : GContext->callbackRegistry->tasks; + tasks.push(std::move(task)); + } else task(); diff --git a/src/mvColors.cpp b/src/mvColors.cpp index beffd8572..9d94777f8 100644 --- a/src/mvColors.cpp +++ b/src/mvColors.cpp @@ -1,13 +1,17 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvColors.h" + #include "mvContext.h" -#include #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" #include "mvItemHandlers.h" +#include + void DearPyGui::draw_color_button(ImDrawList* drawlist, mvAppItem& item, mvColorButtonConfig& config) { @@ -47,10 +51,7 @@ DearPyGui::draw_color_button(ImDrawList* drawlist, mvAppItem& item, mvColorButto // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -81,7 +82,7 @@ DearPyGui::draw_color_button(ImDrawList* drawlist, mvAppItem& item, mvColorButto // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -139,10 +140,7 @@ DearPyGui::draw_color_edit(ImDrawList* drawlist, mvAppItem& item, mvColorEditCon // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -173,7 +171,7 @@ DearPyGui::draw_color_edit(ImDrawList* drawlist, mvAppItem& item, mvColorEditCon // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -239,10 +237,7 @@ DearPyGui::draw_color_map_button(ImDrawList* drawlist, mvAppItem& item, mvColorM // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -269,7 +264,7 @@ DearPyGui::draw_color_map_button(ImDrawList* drawlist, mvAppItem& item, mvColorM // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -327,10 +322,7 @@ DearPyGui::draw_color_map_scale(ImDrawList* drawlist, mvAppItem& item, mvColorMa // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -355,7 +347,7 @@ DearPyGui::draw_color_map_scale(ImDrawList* drawlist, mvAppItem& item, mvColorMa // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -413,10 +405,7 @@ DearPyGui::draw_color_picker(ImDrawList* drawlist, mvAppItem& item, mvColorPicke // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -447,7 +436,7 @@ DearPyGui::draw_color_picker(ImDrawList* drawlist, mvAppItem& item, mvColorPicke // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -505,10 +494,7 @@ DearPyGui::draw_color_map_slider(ImDrawList* drawlist, mvAppItem& item, mvColorM // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -536,7 +522,7 @@ DearPyGui::draw_color_map_slider(ImDrawList* drawlist, mvAppItem& item, mvColorM // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -917,6 +903,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorButtonConfig& outConfig) flagop("no_alpha", ImGuiColorEditFlags_NoAlpha, outConfig.flags); flagop("no_border", ImGuiColorEditFlags_NoBorder, outConfig.flags); flagop("no_drag_drop", ImGuiColorEditFlags_NoDragDrop, outConfig.flags); + flagop("no_tooltip", ImGuiColorEditFlags_NoTooltip, outConfig.flags); + + if (PyObject* item = PyDict_GetItemString(inDict, "alpha_preview")) + { + long mode = ToLong(item); + + // reset target flags + outConfig.flags &= ~(ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + outConfig.flags |= mode; + } } void @@ -944,28 +940,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorEditConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "alpha_preview")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags - outConfig.flags &= ~ImGuiColorEditFlags_AlphaPreview; - outConfig.flags &= ~ImGuiColorEditFlags_AlphaPreviewHalf; - - switch (mode) - { - case ImGuiColorEditFlags_AlphaPreview: - outConfig.flags |= ImGuiColorEditFlags_AlphaPreview; - break; - case ImGuiColorEditFlags_AlphaPreviewHalf: - outConfig.flags |= ImGuiColorEditFlags_AlphaPreviewHalf; - break; - default: - break; - } + outConfig.flags &= ~(ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + outConfig.flags |= mode; } if (PyObject* item = PyDict_GetItemString(inDict, "display_mode")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags outConfig.flags &= ~ImGuiColorEditFlags_DisplayRGB; @@ -988,7 +972,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorEditConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "display_type")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags outConfig.flags &= ~ImGuiColorEditFlags_Uint8; @@ -1051,7 +1035,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorPickerConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "picker_mode")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags outConfig.flags &= ~ImGuiColorEditFlags_PickerHueBar; @@ -1070,28 +1054,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorPickerConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "alpha_preview")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags - outConfig.flags &= ~ImGuiColorEditFlags_AlphaPreview; - outConfig.flags &= ~ImGuiColorEditFlags_AlphaPreviewHalf; - - switch (mode) - { - case ImGuiColorEditFlags_AlphaPreview: - outConfig.flags |= ImGuiColorEditFlags_AlphaPreview; - break; - case ImGuiColorEditFlags_AlphaPreviewHalf: - outConfig.flags |= ImGuiColorEditFlags_AlphaPreviewHalf; - break; - default: - break; - } + outConfig.flags &= ~(ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + outConfig.flags |= mode; } if (PyObject* item = PyDict_GetItemString(inDict, "display_type")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags outConfig.flags &= ~ImGuiColorEditFlags_Uint8; @@ -1110,7 +1082,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvColorPickerConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "input_mode")) { - long mode = ToUUID(item); + long mode = ToLong(item); // reset target flags outConfig.flags &= ~ImGuiColorEditFlags_InputRGB; @@ -1184,6 +1156,11 @@ DearPyGui::fill_configuration_dict(const mvColorButtonConfig& inConfig, PyObject checkbitset("no_alpha", ImGuiColorEditFlags_NoAlpha, inConfig.flags); checkbitset("no_border", ImGuiColorEditFlags_NoBorder, inConfig.flags); checkbitset("no_drag_drop", ImGuiColorEditFlags_NoDragDrop, inConfig.flags); + checkbitset("no_tooltip", ImGuiColorEditFlags_NoTooltip, inConfig.flags); + + // alpha_preview + auto alphaMode = inConfig.flags & (ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(alphaMode))); } void @@ -1215,12 +1192,8 @@ DearPyGui::fill_configuration_dict(const mvColorEditConfig& inConfig, PyObject* PyDict_SetItemString(outDict, "input_mode", mvPyObject(ToPyLong(ImGuiColorEditFlags_InputHSV))); // alpha_preview - if (inConfig.flags & ImGuiColorEditFlags_AlphaPreview) - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(ImGuiColorEditFlags_AlphaPreview))); - else if (inConfig.flags & ImGuiColorEditFlags_AlphaPreviewHalf) - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(ImGuiColorEditFlags_AlphaPreviewHalf))); - else - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(0l))); + auto alphaMode = inConfig.flags & (ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(alphaMode))); // display_mode if (inConfig.flags & ImGuiColorEditFlags_DisplayHSV) @@ -1268,12 +1241,8 @@ DearPyGui::fill_configuration_dict(const mvColorPickerConfig& inConfig, PyObject PyDict_SetItemString(outDict, "input_mode", mvPyObject(ToPyLong(ImGuiColorEditFlags_InputHSV))); // alpha_preview - if (inConfig.flags & ImGuiColorEditFlags_AlphaPreview) - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(ImGuiColorEditFlags_AlphaPreview))); - else if (inConfig.flags & ImGuiColorEditFlags_AlphaPreviewHalf) - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(ImGuiColorEditFlags_AlphaPreviewHalf))); - else - PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(0))); + auto alphaMode = inConfig.flags & (ImGuiColorEditFlags_AlphaOpaque | ImGuiColorEditFlags_AlphaPreviewHalf); + PyDict_SetItemString(outDict, "alpha_preview", mvPyObject(ToPyLong(alphaMode))); // display_type if (inConfig.flags & ImGuiColorEditFlags_Uint8) diff --git a/src/mvContainers.cpp b/src/mvContainers.cpp index 367c9f39c..3410b2a18 100644 --- a/src/mvContainers.cpp +++ b/src/mvContainers.cpp @@ -1,13 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvContainers.h" + #include "mvViewport.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" -#include "mvPyUtils.h" #include "mvItemHandlers.h" -#include #include "mvTextureItems.h" +#include +// For ImGuiWindow +#include + //----------------------------------------------------------------------------- // [SECTION] get_item_configuration(...) specifics //----------------------------------------------------------------------------- @@ -36,6 +42,9 @@ DearPyGui::fill_configuration_dict(const mvTabConfig& inConfig, PyObject* outDic }; checkbitset("no_tooltip", ImGuiTabItemFlags_NoTooltip, inConfig._flags); + checkbitset("unsaved_document", ImGuiTabItemFlags_UnsavedDocument, inConfig._flags); + checkbitset("no_close_with_middle_click", ImGuiTabItemFlags_NoCloseWithMiddleMouseButton, inConfig._flags); + checkbitset("no_reorder", ImGuiTabItemFlags_NoReorder, inConfig._flags); if (inConfig._flags & ImGuiTabItemFlags_Leading) PyDict_SetItemString(outDict, "order_mode", mvPyObject(ToPyLong((long)TabOrdering::mvTabOrder_Leading))); @@ -68,10 +77,9 @@ DearPyGui::fill_configuration_dict(const mvChildWindowConfig& inConfig, PyObject checkbitset("horizontal_scrollbar", ImGuiWindowFlags_HorizontalScrollbar, inConfig.windowflags); checkbitset("menubar", ImGuiWindowFlags_MenuBar, inConfig.windowflags); checkbitset("no_scroll_with_mouse", ImGuiWindowFlags_NoScrollWithMouse, inConfig.windowflags); - checkbitset("flattened_navigation", ImGuiWindowFlags_NavFlattened, inConfig.windowflags); // child flags - checkbitset("border", ImGuiChildFlags_Border, inConfig.childFlags); + checkbitset("border", ImGuiChildFlags_Borders, inConfig.childFlags); checkbitset("always_auto_resize", ImGuiChildFlags_AlwaysAutoResize, inConfig.childFlags); checkbitset("always_use_window_padding", ImGuiChildFlags_AlwaysUseWindowPadding, inConfig.childFlags); checkbitset("auto_resize_x", ImGuiChildFlags_AutoResizeX, inConfig.childFlags); @@ -79,6 +87,7 @@ DearPyGui::fill_configuration_dict(const mvChildWindowConfig& inConfig, PyObject checkbitset("frame_style", ImGuiChildFlags_FrameStyle, inConfig.childFlags); checkbitset("resizable_x", ImGuiChildFlags_ResizeX, inConfig.childFlags); checkbitset("resizable_y", ImGuiChildFlags_ResizeY, inConfig.childFlags); + checkbitset("flattened_navigation", ImGuiChildFlags_NavFlattened, inConfig.childFlags); } void @@ -125,10 +134,13 @@ DearPyGui::fill_configuration_dict(const mvTreeNodeConfig& inConfig, PyObject* o checkbitset("open_on_arrow", ImGuiTreeNodeFlags_OpenOnArrow, inConfig.flags); checkbitset("leaf", ImGuiTreeNodeFlags_Leaf, inConfig.flags); checkbitset("bullet", ImGuiTreeNodeFlags_Bullet, inConfig.flags); - checkbitset("span_text_width", ImGuiTreeNodeFlags_SpanTextWidth, inConfig.flags); + checkbitset("span_text_width", ImGuiTreeNodeFlags_SpanLabelWidth, inConfig.flags); // checkbitset("span_available_width", ImGuiTreeNodeFlags_SpanAvailWidth, inConfig.flags); checkbitset("span_full_width", ImGuiTreeNodeFlags_SpanFullWidth, inConfig.flags); // checkbitset("span_all_columns", ImGuiTreeNodeFlags_SpanAllColumns, inConfig.flags); + checkbitset("catch_nav_left", ImGuiTreeNodeFlags_NavLeftJumpsToParent, inConfig.flags); + + PyDict_SetItemString(outDict, "lines", mvPyObject(ToPyInt(inConfig.flags & (ImGuiTreeNodeFlags_DrawLinesNone | ImGuiTreeNodeFlags_DrawLinesFull | ImGuiTreeNodeFlags_DrawLinesToNodes)))); } void @@ -143,6 +155,11 @@ DearPyGui::fill_configuration_dict(const mvTabBarConfig& inConfig, PyObject* out }; checkbitset("reorderable", ImGuiTabBarFlags_Reorderable, inConfig.flags); + checkbitset("tab_list_popup_button", ImGuiTabBarFlags_TabListPopupButton, inConfig.flags); + checkbitset("no_close_with_middle_click", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton, inConfig.flags); + checkbitset("no_scrolling_buttons", ImGuiTabBarFlags_NoTabListScrollingButtons, inConfig.flags); + checkbitset("no_tooltip", ImGuiTabBarFlags_NoTooltip, inConfig.flags); + checkbitset("draw_selected_overline", ImGuiTabBarFlags_DrawSelectedOverline, inConfig.flags); } void @@ -151,7 +168,6 @@ DearPyGui::fill_configuration_dict(const mvCollapsingHeaderConfig& inConfig, PyO if (outDict == nullptr) return; - PyDict_SetItemString(outDict, "closable", mvPyObject(ToPyBool(*inConfig.value))); PyDict_SetItemString(outDict, "closable", mvPyObject(ToPyBool(inConfig.closable))); // helper to check and set bit @@ -178,8 +194,9 @@ DearPyGui::fill_configuration_dict(const mvWindowAppItemConfig& inConfig, PyObje PyDict_SetItemString(outDict, "popup", mvPyObject(ToPyBool(inConfig.popup))); PyDict_SetItemString(outDict, "no_close", mvPyObject(ToPyBool(inConfig.no_close))); PyDict_SetItemString(outDict, "collapsed", mvPyObject(ToPyBool(inConfig.collapsed))); - PyDict_SetItemString(outDict, "min_size", mvPyObject(ToPyPairII(inConfig.min_size.x, inConfig.min_size.y))); - PyDict_SetItemString(outDict, "max_size", mvPyObject(ToPyPairII(inConfig.max_size.x, inConfig.max_size.y))); + PyDict_SetItemString(outDict, "min_size", mvPyObject(ToPyPairII((int)inConfig.min_size.x, (int)inConfig.min_size.y))); + PyDict_SetItemString(outDict, "max_size", mvPyObject(ToPyPairII((int)inConfig.max_size.x, (int)inConfig.max_size.y))); + PyDict_SetItemString(outDict, "copy_contents_shortcut", mvPyObject(ToPyBool(inConfig.copy_contents_shortcut))); PyObject* on_close = inConfig.on_close; PyDict_SetItemString(outDict, "on_close", on_close? on_close : Py_None); @@ -205,6 +222,7 @@ DearPyGui::fill_configuration_dict(const mvWindowAppItemConfig& inConfig, PyObje checkbitset("no_saved_settings", ImGuiWindowFlags_NoSavedSettings, inConfig.windowflags); checkbitset("no_scroll_with_mouse", ImGuiWindowFlags_NoScrollWithMouse, inConfig.windowflags); checkbitset("unsaved_document", ImGuiWindowFlags_UnsavedDocument, inConfig.windowflags); + checkbitset("no_docking", ImGuiWindowFlags_NoDocking, inConfig.windowflags); } //----------------------------------------------------------------------------- @@ -244,14 +262,16 @@ DearPyGui::set_configuration(PyObject* inDict, mvTabConfig& outConfig) outConfig._flags = ImGuiTabItemFlags_None; } - if (PyObject* item = PyDict_GetItemString(inDict, "no_tooltip")) + // helper for bit flipping + auto flagop = [inDict](const char* keyword, int flag, int& flags) { - bool value = ToBool(item); - if (value) - outConfig._flags |= ImGuiTabItemFlags_NoTooltip; - else - outConfig._flags &= ~ImGuiTabItemFlags_NoTooltip; - } + if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; + }; + + flagop("no_tooltip", ImGuiTabItemFlags_NoTooltip, outConfig._flags); + flagop("unsaved_document", ImGuiTabItemFlags_UnsavedDocument, outConfig._flags); + flagop("no_close_with_middle_click", ImGuiTabItemFlags_NoCloseWithMiddleMouseButton, outConfig._flags); + flagop("no_reorder", ImGuiTabItemFlags_NoReorder, outConfig._flags); } void @@ -274,10 +294,9 @@ DearPyGui::set_configuration(PyObject* inDict, mvChildWindowConfig& outConfig) flagop("horizontal_scrollbar", ImGuiWindowFlags_HorizontalScrollbar, outConfig.windowflags); flagop("menubar", ImGuiWindowFlags_MenuBar, outConfig.windowflags); flagop("no_scroll_with_mouse", ImGuiWindowFlags_NoScrollWithMouse, outConfig.windowflags); - flagop("flattened_navigation", ImGuiWindowFlags_NavFlattened, outConfig.windowflags); // child flags - flagop("border", ImGuiChildFlags_Border, outConfig.childFlags); + flagop("border", ImGuiChildFlags_Borders, outConfig.childFlags); flagop("always_auto_resize", ImGuiChildFlags_AlwaysAutoResize, outConfig.childFlags); flagop("always_use_window_padding", ImGuiChildFlags_AlwaysUseWindowPadding, outConfig.childFlags); flagop("auto_resize_x", ImGuiChildFlags_AutoResizeX, outConfig.childFlags); @@ -285,6 +304,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvChildWindowConfig& outConfig) flagop("frame_style", ImGuiChildFlags_FrameStyle, outConfig.childFlags); flagop("resizable_x", ImGuiChildFlags_ResizeX, outConfig.childFlags); flagop("resizable_y", ImGuiChildFlags_ResizeY, outConfig.childFlags); + flagop("flattened_navigation", ImGuiChildFlags_NavFlattened, outConfig.childFlags); } void @@ -338,10 +358,17 @@ DearPyGui::set_configuration(PyObject* inDict, mvTreeNodeConfig& outConfig) flagop("open_on_arrow", ImGuiTreeNodeFlags_OpenOnArrow, outConfig.flags); flagop("leaf", ImGuiTreeNodeFlags_Leaf, outConfig.flags); flagop("bullet", ImGuiTreeNodeFlags_Bullet, outConfig.flags); - flagop("span_text_width", ImGuiTreeNodeFlags_SpanTextWidth, outConfig.flags); + flagop("span_text_width", ImGuiTreeNodeFlags_SpanLabelWidth, outConfig.flags); // flagop("span_available_width", ImGuiTreeNodeFlags_SpanAvailWidth, outConfig.flags); flagop("span_full_width", ImGuiTreeNodeFlags_SpanFullWidth, outConfig.flags); // flagop("span_all_columns", ImGuiTreeNodeFlags_SpanAllColumns, outConfig.flags); + flagop("catch_nav_left", ImGuiTreeNodeFlags_NavLeftJumpsToParent, outConfig.flags); + + if (PyObject* item = PyDict_GetItemString(inDict, "lines")) + { + outConfig.flags &= ~(ImGuiTreeNodeFlags_DrawLinesNone | ImGuiTreeNodeFlags_DrawLinesFull | ImGuiTreeNodeFlags_DrawLinesToNodes); + outConfig.flags |= ToInt(item); + } } void @@ -354,6 +381,11 @@ DearPyGui::set_configuration(PyObject* inDict, mvTabBarConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, keyword)) ToBool(item) ? flags |= flag : flags &= ~flag; }; flagop("reorderable", ImGuiTabBarFlags_Reorderable, outConfig.flags); + flagop("tab_list_popup_button", ImGuiTabBarFlags_TabListPopupButton, outConfig.flags); + flagop("no_close_with_middle_click", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton, outConfig.flags); + flagop("no_scrolling_buttons", ImGuiTabBarFlags_NoTabListScrollingButtons, outConfig.flags); + flagop("no_tooltip", ImGuiTabBarFlags_NoTooltip, outConfig.flags); + flagop("draw_selected_overline", ImGuiTabBarFlags_DrawSelectedOverline, outConfig.flags); } void @@ -407,6 +439,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvAppItem& itemc, mvWindowAppItem if (PyObject* item = PyDict_GetItemString(inDict, "no_open_over_existing_popup")) outConfig.no_open_over_existing_popup = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "no_close")) outConfig.no_close = ToBool(item); + if (PyObject* item = PyDict_GetItemString(inDict, "copy_contents_shortcut")) outConfig.copy_contents_shortcut = ToBool(item); if (PyObject* item = PyDict_GetItemString(inDict, "collapsed")) { outConfig._collapsedDirty = true; @@ -451,6 +484,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvAppItem& itemc, mvWindowAppItem flagop("no_saved_settings", ImGuiWindowFlags_NoSavedSettings, outConfig.windowflags); flagop("no_scroll_with_mouse", ImGuiWindowFlags_NoScrollWithMouse, outConfig.windowflags); flagop("unsaved_document", ImGuiWindowFlags_UnsavedDocument, outConfig.windowflags); + flagop("no_docking", ImGuiWindowFlags_NoDocking, outConfig.windowflags); outConfig._oldxpos = itemc.state.pos.x; @@ -620,10 +654,7 @@ DearPyGui::draw_menu(ImDrawList* drawlist, mvAppItem& item, mvMenuConfig& config // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -699,7 +730,7 @@ DearPyGui::draw_menu(ImDrawList* drawlist, mvAppItem& item, mvMenuConfig& config // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -756,10 +787,7 @@ DearPyGui::draw_tab(ImDrawList* drawlist, mvAppItem& item, mvTabConfig& config) // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -856,7 +884,7 @@ DearPyGui::draw_tab(ImDrawList* drawlist, mvAppItem& item, mvTabConfig& config) // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -913,10 +941,7 @@ DearPyGui::draw_child_window(ImDrawList* drawlist, mvAppItem& item, mvChildWindo // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -982,7 +1007,7 @@ DearPyGui::draw_child_window(ImDrawList* drawlist, mvAppItem& item, mvChildWindo // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -1039,10 +1064,7 @@ DearPyGui::draw_group(ImDrawList* drawlist, mvAppItem& item, mvGroupConfig& conf // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1098,7 +1120,7 @@ DearPyGui::draw_group(ImDrawList* drawlist, mvAppItem& item, mvGroupConfig& conf // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -1197,10 +1219,7 @@ DearPyGui::draw_tree_node(ImDrawList* drawlist, mvAppItem& item, mvTreeNodeConfi // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1257,7 +1276,7 @@ DearPyGui::draw_tree_node(ImDrawList* drawlist, mvAppItem& item, mvTreeNodeConfi // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -1351,10 +1370,7 @@ DearPyGui::draw_collapsing_header(ImDrawList* drawlist, mvAppItem& item, mvColla // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1399,7 +1415,7 @@ DearPyGui::draw_collapsing_header(ImDrawList* drawlist, mvAppItem& item, mvColla // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (item.config.indent > 0.0f) ImGui::Unindent(item.config.indent); @@ -1443,10 +1459,7 @@ DearPyGui::draw_window(ImDrawList* drawlist, mvAppItem& item, mvWindowAppItemCon // handle fonts if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1560,6 +1573,9 @@ DearPyGui::draw_window(ImDrawList* drawlist, mvAppItem& item, mvWindowAppItemCon else { + ImGuiIO &io = ImGui::GetIO(); + io.ConfigWindowsCopyContentsWithCtrlC = config.copy_contents_shortcut; + if (!ImGui::Begin(item.info.internalLabel.c_str(), config.no_close ? nullptr : &item.config.show, config.windowflags)) { if (config.mainWindow) diff --git a/src/mvContainers.h b/src/mvContainers.h index a5390c7fc..142e029d2 100644 --- a/src/mvContainers.h +++ b/src/mvContainers.h @@ -1,7 +1,6 @@ #pragma once #include "mvItemRegistry.h" -#include // check_drop_event() implements the typical contents of Dear ImGui's drop target // (ImGui::BeginDragDropTarget()) tied to DearPyGui's drop callback. You usually @@ -97,10 +96,10 @@ enum class TabOrdering { struct mvChildWindowConfig { - ImGuiChildFlags childFlags = ImGuiChildFlags_Border; + ImGuiChildFlags childFlags = ImGuiChildFlags_Borders|ImGuiChildFlags_NavFlattened; bool autosize_x = false; bool autosize_y = false; - ImGuiWindowFlags windowflags = ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NavFlattened; + ImGuiWindowFlags windowflags = ImGuiWindowFlags_NoSavedSettings; }; struct mvTreeNodeConfig @@ -146,24 +145,13 @@ struct mvWindowAppItemConfig { ImGuiWindowFlags windowflags = ImGuiWindowFlags_None; bool mainWindow = false; - bool closing = true; bool resized = false; bool modal = false; bool popup = false; - bool autosize = false; - bool no_resize = false; - bool no_title_bar = false; - bool no_move = false; - bool no_scrollbar = false; - bool no_collapse = false; - bool horizontal_scrollbar = false; - bool no_focus_on_appearing = false; - bool no_bring_to_front_on_focus = false; - bool menubar = false; bool no_close = false; - bool no_background = false; bool collapsed = false; bool no_open_over_existing_popup = true; + bool copy_contents_shortcut = false; mvPyObject on_close = nullptr; mvVec2 min_size = { 100.0f, 100.0f }; mvVec2 max_size = { 30000.0f, 30000.0f }; diff --git a/src/mvContext.cpp b/src/mvContext.cpp index cc41d22bc..4f8de0808 100644 --- a/src/mvContext.cpp +++ b/src/mvContext.cpp @@ -1,24 +1,26 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvContext.h" + #include "dearpygui.h" #include "mvViewport.h" #include "mvCallbackRegistry.h" -#include -#include -#include #include "mvProfiler.h" -#include #include "mvFontManager.h" #include "mvCallbackRegistry.h" -#include "mvPyUtils.h" -#include #include "mvToolManager.h" -#include -#include -#include #include "mvCustomTypes.h" -#include "mvAppItemCommons.h" #include "mvItemRegistry.h" +#include +#include +#include +#include +#include +#include +#include + mvContext* GContext = nullptr; static void @@ -115,11 +117,14 @@ SetDefaultTheme() colors[ImGuiCol_ResizeGrip] = mvImGuiCol_ResizeGrip; colors[ImGuiCol_ResizeGripHovered] = mvImGuiCol_ResizeGripHovered; colors[ImGuiCol_ResizeGripActive] = mvImGuiCol_ResizeGripHovered; + colors[ImGuiCol_InputTextCursor] = MV_BASE_COL_textColor; colors[ImGuiCol_Tab] = mvImGuiCol_Tab; colors[ImGuiCol_TabHovered] = mvImGuiCol_TabHovered; - colors[ImGuiCol_TabActive] = mvImGuiCol_TabActive; - colors[ImGuiCol_TabUnfocused] = mvImGuiCol_TabUnfocused; - colors[ImGuiCol_TabUnfocusedActive] = mvImGuiCol_TabUnfocusedActive; + colors[ImGuiCol_TabSelected] = mvImGuiCol_TabActive; + colors[ImGuiCol_TabSelectedOverline] = mvImGuiCol_HeaderActive; + colors[ImGuiCol_TabDimmed] = mvImGuiCol_TabUnfocused; + colors[ImGuiCol_TabDimmedSelected] = mvImGuiCol_TabUnfocusedActive; + colors[ImGuiCol_TabDimmedSelectedOverline] = mvImGuiCol_TabUnfocusedActiveOverline; colors[ImGuiCol_DockingPreview] = mvImGuiCol_DockingPreview; colors[ImGuiCol_DockingEmptyBg] = mvImGuiCol_DockingEmptyBg; colors[ImGuiCol_PlotLines] = mvImGuiCol_PlotLines; @@ -131,9 +136,13 @@ SetDefaultTheme() colors[ImGuiCol_TableBorderLight] = mvImGuiCol_TableBorderLight; // Prefer using Alpha=1.0 here colors[ImGuiCol_TableRowBg] = mvImGuiCol_TableRowBg; colors[ImGuiCol_TableRowBgAlt] = mvImGuiCol_TableRowBgAlt; + colors[ImGuiCol_TextLink] = mvImGuiCol_HeaderActive; colors[ImGuiCol_TextSelectedBg] = mvImGuiCol_TextSelectedBg; + colors[ImGuiCol_TreeLines] = mvImGuiCol_Border; colors[ImGuiCol_DragDropTarget] = mvImGuiCol_DragDropTarget; - colors[ImGuiCol_NavHighlight] = mvImGuiCol_NavHighlight; + colors[ImGuiCol_DragDropTargetBg] = mvImGuiCol_DragDropTargetBg; + colors[ImGuiCol_UnsavedMarker] = mvImGuiCol_Text; + colors[ImGuiCol_NavCursor] = mvImGuiCol_NavHighlight; colors[ImGuiCol_NavWindowingHighlight] = mvImGuiCol_NavWindowingHighlight; colors[ImGuiCol_NavWindowingDimBg] = mvImGuiCol_NavWindowingDimBg; colors[ImGuiCol_ModalWindowDimBg] = mvImGuiCol_ModalWindowDimBg; @@ -170,7 +179,10 @@ Render() GContext->frame = ImGui::GetFrameCount(); GContext->framerate = (i32)ImGui::GetIO().Framerate; - ImGui::GetIO().FontGlobalScale = mvToolManager::GetFontManager().getGlobalFontScale(); + mvRunTasks(true); // this call runs early tasks only + + ImGuiStyle& style = ImGui::GetStyle(); + style.FontScaleMain = mvToolManager::GetFontManager().getGlobalFontScale(); if (GContext->IO.dockingViewport) ImGui::DockSpaceOverViewport(); diff --git a/src/mvContext.h b/src/mvContext.h index cb2bc864e..5054c62d1 100644 --- a/src/mvContext.h +++ b/src/mvContext.h @@ -2,10 +2,7 @@ #include #include -#include #include -#include -#include #include #include #include @@ -97,6 +94,8 @@ struct mvIO // callback registry bool manualCallbacks = false; + bool altEnterFullscreen = false; + ImWchar decimalPoint = '.'; }; diff --git a/src/mvCustomTypes.cpp b/src/mvCustomTypes.cpp index 7fde8116f..2f933f009 100644 --- a/src/mvCustomTypes.cpp +++ b/src/mvCustomTypes.cpp @@ -1,7 +1,11 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvCustomTypes.h" -#include + #include "mvTypes.h" -#include "mvPyUtils.h" + +#include static void intialize_mvMat4(mvMat4* a, @@ -127,8 +131,8 @@ PymvMat4_getItem(PyObject* obj, Py_ssize_t index) if(index > 15) return Py_BuildValue("f", self->m.cols[3][3]); - i32 column = index/4; - i32 row = index % 4; + i32 column = (i32)index/4; + i32 row = (i32)index % 4; return Py_BuildValue("f", self->m.cols[column][row]); } @@ -139,8 +143,8 @@ PymvMat4_setItem(PyObject* obj, Py_ssize_t index, PyObject* value) if (index > 15) return 0; - i32 column = index/4; - i32 row = index % 4; + i32 column = (i32)index/4; + i32 row = (i32)index % 4; self->m.cols[column][row] = (float)PyFloat_AsDouble(value); return 0; } diff --git a/src/mvDatePicker.cpp b/src/mvDatePicker.cpp index 82dab312a..611fc0888 100644 --- a/src/mvDatePicker.cpp +++ b/src/mvDatePicker.cpp @@ -1,15 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvDatePicker.h" + #include "mvContext.h" -#include -#include -#include #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" #include "mvItemHandlers.h" +#include +#include +#include + void mvDatePicker::draw(ImDrawList* drawlist, float x, float y) { @@ -48,10 +52,7 @@ void mvDatePicker::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -83,7 +84,7 @@ void mvDatePicker::draw(ImDrawList* drawlist, float x, float y) // set cursor position to cached position if (info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (config.indent > 0.0f) ImGui::Unindent(config.indent); diff --git a/src/mvDatePicker.h b/src/mvDatePicker.h index 70bcd40d3..06a664725 100644 --- a/src/mvDatePicker.h +++ b/src/mvDatePicker.h @@ -1,6 +1,8 @@ #pragma once #include "mvItemRegistry.h" +// For ImPlotTime +#include class mvDatePicker : public mvAppItem { diff --git a/src/mvDebugWindow.cpp b/src/mvDebugWindow.cpp index b666fcf20..522936c99 100644 --- a/src/mvDebugWindow.cpp +++ b/src/mvDebugWindow.cpp @@ -1,9 +1,11 @@ #include "mvDebugWindow.h" + #include "mvContext.h" -#include #include "mvItemRegistry.h" #include "dearpygui.h" +#include + mvDebugWindow::mvDebugWindow() { m_windowflags = ImGuiWindowFlags_NoSavedSettings; @@ -28,7 +30,7 @@ void mvDebugWindow::drawWidgets() filter.Draw(); ImGui::PushItemWidth(-1); - ImGui::BeginChild("CommandsChild##debug", ImVec2(400.0f, 400.0f), ImGuiChildFlags_Border); + ImGui::BeginChild("CommandsChild##debug", ImVec2(400.0f, 400.0f), ImGuiChildFlags_Borders); ImGui::PushStyleColor(ImGuiCol_Text, { 1.0f, 1.0f, 0.0f, 1.0f }); for (size_t i = 0; i < m_commands.size(); i++) { @@ -43,7 +45,7 @@ void mvDebugWindow::drawWidgets() ImGui::PopStyleColor(); ImGui::EndChild(); ImGui::SameLine(); - ImGui::BeginChild("CommandsDoc##debug", ImVec2(-1.0f, 400.0f), ImGuiChildFlags_Border); + ImGui::BeginChild("CommandsDoc##debug", ImVec2(-1.0f, 400.0f), ImGuiChildFlags_Borders); ImGui::PushStyleColor(ImGuiCol_Text, { 1.0f, 0.0f, 1.0f, 1.0f }); ImGui::PushTextWrapPos(500); ImGui::Text("%s", commanddoc); diff --git a/src/mvDocWindow.cpp b/src/mvDocWindow.cpp index 5034d8de2..be08cb066 100644 --- a/src/mvDocWindow.cpp +++ b/src/mvDocWindow.cpp @@ -1,8 +1,12 @@ -#include #include "mvPyUtils.h" +#pragma hdrstop + #include "mvDocWindow.h" + #include "dearpygui.h" +#include + mvDocWindow::mvDocWindow() { m_windowflags = ImGuiWindowFlags_NoSavedSettings; @@ -91,7 +95,7 @@ void mvDocWindow::drawWidgets() ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 255, 100)); - ImGui::BeginChild("DocChild", ImVec2(0, 0), ImGuiChildFlags_Border); + ImGui::BeginChild("DocChild", ImVec2(0, 0), ImGuiChildFlags_Borders); ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + 400); ImGui::Text("%s", m_doc); ImGui::PopTextWrapPos(); @@ -111,7 +115,7 @@ void mvDocWindow::drawWidgets() ImGui::PushItemWidth(300); ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100)); - ImGui::BeginChild("CommandsChild##debug", ImVec2(500.0f, 0), ImGuiChildFlags_Border); + ImGui::BeginChild("CommandsChild##debug", ImVec2(500.0f, 0), ImGuiChildFlags_Borders); for (size_t i = 0; i < m_commands.size(); i++) { @@ -127,7 +131,7 @@ void mvDocWindow::drawWidgets() ImGui::EndChild(); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 255, 100)); - ImGui::BeginChild("CommandsDoc##debug", ImVec2(0, 0), ImGuiChildFlags_Border); + ImGui::BeginChild("CommandsDoc##debug", ImVec2(0, 0), ImGuiChildFlags_Borders); ImGui::PushTextWrapPos(500); ImGui::Text("%s", commanddoc); ImGui::PopStyleColor(); diff --git a/src/mvDrawings.cpp b/src/mvDrawings.cpp index bb5d082d1..893cc4729 100644 --- a/src/mvDrawings.cpp +++ b/src/mvDrawings.cpp @@ -1,11 +1,18 @@ -#include "mvDrawings.h" -#include "mvItemRegistry.h" #include "mvPyUtils.h" -#include "mvAppItemCommons.h" -#include +#pragma hdrstop + +#include "mvDrawings.h" + #include "mvContext.h" +#include "mvItemRegistry.h" +#include "mvFontItems.h" +#include "mvItemHandlers.h" +#include "mvTextureItems.h" #include "mvCustomTypes.h" +#include +#include + mvDrawArrow::mvDrawArrow(mvUUID uuid) : mvAppItem(uuid) @@ -91,7 +98,7 @@ void mvDrawArrow::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddTriangleFilled(ImPlot::PlotToPixels(tpp1), ImPlot::PlotToPixels(tpp2), ImPlot::PlotToPixels(tpp3), _color); drawlist->AddLine(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), _color, Mx * _thickness); drawlist->AddTriangle(ImPlot::PlotToPixels(tpp1), ImPlot::PlotToPixels(tpp2), ImPlot::PlotToPixels(tpp3), _color, Mx * _thickness); @@ -184,7 +191,7 @@ void mvDrawBezierCubic::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddBezierCubic(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), ImPlot::PlotToPixels(tp3), ImPlot::PlotToPixels(tp4), _color, Mx * _thickness, _segments); } @@ -273,7 +280,7 @@ void mvDrawBezierQuadratic::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddBezierQuadratic(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), ImPlot::PlotToPixels(tp3), _color, Mx * _thickness, _segments); } @@ -345,10 +352,10 @@ void mvDrawCircle::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); if (_fill.r >= 0.0f) - drawlist->AddCircleFilled(ImPlot::PlotToPixels(tcenter), Mx * _radius, _fill, _segments); - drawlist->AddCircle(ImPlot::PlotToPixels(tcenter), Mx * _radius, _color, Mx * _segments, _thickness); + drawlist->AddCircleFilled(ImPlot::PlotToPixels(tcenter), Mx * _radius, _fill, (int)(Mx * _segments)); + drawlist->AddCircle(ImPlot::PlotToPixels(tcenter), Mx * _radius, _color, (int)(Mx * _segments), _thickness); } else { @@ -471,7 +478,7 @@ void mvDrawEllipse::draw(ImDrawList* drawlist, float x, float y) drawlist->AddConvexPolyFilled(finalpoints.data(), (int)finalpoints.size(), _fill); if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddPolyline(finalpoints.data(), (int)finalpoints.size(), _color, false, Mx * _thickness); } else @@ -523,22 +530,15 @@ void mvDrawEllipse::getSpecificConfiguration(PyObject* dict) void mvDrawImage::draw(ImDrawList* drawlist, float x, float y) { - if (_texture) + if (_texture && _texture->state.ok) { - if (_internalTexture) - _texture->draw(drawlist, x, y); - - if (!_texture->state.ok) + auto type = _texture->type; + if (type != mvAppItemType::mvStaticTexture && + type != mvAppItemType::mvDynamicTexture && + type != mvAppItemType::mvRawTexture) return; - void* texture = nullptr; - - if (_texture->type == mvAppItemType::mvStaticTexture) - texture = static_cast(_texture.get())->_texture; - else if (_texture->type == mvAppItemType::mvRawTexture) - texture = static_cast(_texture.get())->_texture; - else - texture = static_cast(_texture.get())->_texture; + ImTextureRef texture = static_cast(_texture.get())->getTexRef(); mvVec4 tpmin = drawInfo->transform * _pmin; mvVec4 tpmax = drawInfo->transform * _pmax; @@ -577,21 +577,16 @@ void mvDrawImage::handleSpecificRequiredArgs(PyObject* dict) return; _textureUUID = GetIDFromPyObject(PyTuple_GetItem(dict, 0)); - _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); - if (_texture) - { - _pmin = ToVec4(PyTuple_GetItem(dict, 1)); - _pmin.w = 1.0f; - _pmax = ToVec4(PyTuple_GetItem(dict, 2)); - _pmax.w = 1.0f; - } - else if (_textureUUID == MV_ATLAS_UUID) + if (_textureUUID == MV_ATLAS_UUID) { _texture = std::make_shared(_textureUUID); - _internalTexture = true; } else - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + { + _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); + if (!_texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + } _pmin = ToVec4(PyTuple_GetItem(dict, 1)); _pmin.w = 1.0f; @@ -612,19 +607,15 @@ void mvDrawImage::handleSpecificKeywordArgs(PyObject* dict) if (PyObject* item = PyDict_GetItemString(dict, "texture_tag")) { _textureUUID = GetIDFromPyObject(item); - _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); if (_textureUUID == MV_ATLAS_UUID) { _texture = std::make_shared(_textureUUID); - _internalTexture = true; - } - else if (_texture) - { - _internalTexture = false; } else { - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); + if (!_texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); } } @@ -647,22 +638,15 @@ void mvDrawImage::getSpecificConfiguration(PyObject* dict) void mvDrawImageQuad::draw(ImDrawList* drawlist, float x, float y) { - if (_texture) + if (_texture && _texture->state.ok) { - if (_internalTexture) - _texture->draw(drawlist, x, y); - - if (!_texture->state.ok) + auto type = _texture->type; + if (type != mvAppItemType::mvStaticTexture && + type != mvAppItemType::mvDynamicTexture && + type != mvAppItemType::mvRawTexture) return; - void* texture = nullptr; - - if (_texture->type == mvAppItemType::mvStaticTexture) - texture = static_cast(_texture.get())->_texture; - else if (_texture->type == mvAppItemType::mvRawTexture) - texture = static_cast(_texture.get())->_texture; - else - texture = static_cast(_texture.get())->_texture; + ImTextureRef texture = static_cast(_texture.get())->getTexRef(); mvVec4 tp1 = drawInfo->transform * _p1; mvVec4 tp2 = drawInfo->transform * _p2; @@ -713,25 +697,16 @@ void mvDrawImageQuad::handleSpecificRequiredArgs(PyObject* dict) return; _textureUUID = GetIDFromPyObject(PyTuple_GetItem(dict, 0)); - _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); - if (_texture) - { - _p1 = ToVec4(PyTuple_GetItem(dict, 1)); - _p1.w = 1.0f; - _p2 = ToVec4(PyTuple_GetItem(dict, 2)); - _p2.w = 1.0f; - _p3 = ToVec4(PyTuple_GetItem(dict, 3)); - _p3.w = 1.0f; - _p4 = ToVec4(PyTuple_GetItem(dict, 4)); - _p4.w = 1.0f; - } - else if (_textureUUID == MV_ATLAS_UUID) + if (_textureUUID == MV_ATLAS_UUID) { _texture = std::make_shared(_textureUUID); - _internalTexture = true; } else - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + { + _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); + if (!_texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + } _p1 = ToVec4(PyTuple_GetItem(dict, 1)); _p1.w = 1.0f; @@ -761,19 +736,15 @@ void mvDrawImageQuad::handleSpecificKeywordArgs(PyObject* dict) if (PyObject* item = PyDict_GetItemString(dict, "texture_tag")) { _textureUUID = GetIDFromPyObject(item); - _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); if (_textureUUID == MV_ATLAS_UUID) { _texture = std::make_shared(_textureUUID); - _internalTexture = true; - } - else if (_texture) - { - _internalTexture = false; } else { - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); + _texture = GetRefItem(*GContext->itemRegistry, _textureUUID); + if (!_texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(type), "Texture not found.", this); } } @@ -875,7 +846,7 @@ void mvDrawLine::draw(ImDrawList* drawlist, float x, float y) } if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddLine(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), _color, Mx * _thickness); } else @@ -950,7 +921,7 @@ void mvDrawlist::draw(ImDrawList* drawlist, float x, float y) ImGui::PopClipRect(); - if (ImGui::InvisibleButton(info.internalLabel.c_str(), ImVec2((float)config.width, (float)config.height), ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle)) + if (ImGui::InvisibleButton(info.internalLabel.c_str(), ImVec2((float)config.width, (float)config.height), ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle | ImGuiButtonFlags_EnableNav)) { submitCallback(); } @@ -1146,7 +1117,7 @@ void mvDrawPolygon::draw(ImDrawList* drawlist, float x, float y) { if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddLine(ImPlot::PlotToPixels({ (float)polyints[i], (float)y }), ImPlot::PlotToPixels({ (float)polyints[i + 1], (float)y }), _fill, Mx * _thickness); } @@ -1239,7 +1210,7 @@ void mvDrawPolyline::draw(ImDrawList* drawlist, float x, float y) finalpoints.push_back(impoint); } - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddPolyline(finalpoints.data(), (int)finalpoints.size(), _color, _closed, Mx * _thickness); } @@ -1327,7 +1298,7 @@ void mvDrawQuad::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); if (_fill.r >= 0.0f) drawlist->AddQuadFilled(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), ImPlot::PlotToPixels(tp3), ImPlot::PlotToPixels(tp4), _fill); @@ -1418,7 +1389,7 @@ void mvDrawRect::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); if (_multicolor) drawlist->AddRectFilledMultiColor(ImPlot::PlotToPixels(tpmin), ImPlot::PlotToPixels(tpmax), _color_bottom_right, _color_bottom_left, _color_upper_left, _color_upper_right); else if (_fill.r >= 0.0f) @@ -1538,7 +1509,7 @@ void mvDrawText::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); drawlist->AddText(fontptr, Mx * (float)_size, ImPlot::PlotToPixels(tpos), _color, _text.c_str()); } else @@ -1629,7 +1600,7 @@ void mvDrawTriangle::draw(ImDrawList* drawlist, float x, float y) if (ImPlot::GetCurrentContext()->CurrentPlot) { - auto Mx = ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x; + float Mx = (float)(ImPlot::GetPlotSize().x / ImPlot::GetPlotLimits().Size().x); if (_fill.r >= 0.0f) { drawlist->AddTriangleFilled(ImPlot::PlotToPixels(tp1), ImPlot::PlotToPixels(tp2), ImPlot::PlotToPixels(tp3), diff --git a/src/mvDrawings.h b/src/mvDrawings.h index aed112c7d..c98ca955c 100644 --- a/src/mvDrawings.h +++ b/src/mvDrawings.h @@ -215,7 +215,6 @@ class mvDrawImage : public mvAppItem // pointer to existing item or internal std::shared_ptr _texture = nullptr; - bool _internalTexture = false; // create a local texture if necessary }; @@ -248,7 +247,6 @@ class mvDrawImageQuad : public mvAppItem // pointer to existing item or internal std::shared_ptr _texture = nullptr; - bool _internalTexture = false; // create a local texture if necessary }; diff --git a/src/mvFileDialog.cpp b/src/mvFileDialog.cpp index 5f9d7fb8e..1f238cbbf 100644 --- a/src/mvFileDialog.cpp +++ b/src/mvFileDialog.cpp @@ -1,7 +1,10 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvFileDialog.h" + #include "mvFileExtension.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" static void Panel(const char* vFilter, IGFDUserDatas vUserDatas, bool* vCantContinue) { diff --git a/src/mvFileExtension.cpp b/src/mvFileExtension.cpp index 0bc366cbc..547a381ba 100644 --- a/src/mvFileExtension.cpp +++ b/src/mvFileExtension.cpp @@ -1,7 +1,10 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvFileExtension.h" + #include "mvFileDialog.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" void mvFileExtension::draw(ImDrawList* drawlist, float x, float y) { diff --git a/src/mvFontItems.cpp b/src/mvFontItems.cpp index 3b3a270c5..d56f61eca 100644 --- a/src/mvFontItems.cpp +++ b/src/mvFontItems.cpp @@ -1,37 +1,27 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvFontItems.h" + #include "mvTextureItems.h" -#include "mvPyUtils.h" -#include "mvToolManager.h" -#include "mvFontManager.h" -mvFontRegistry::mvFontRegistry(mvUUID uuid) - : - mvAppItem(uuid) +void mvFontRegistry::customAction(void* data) { - config.show = true; -} + if (!_dirty || !config.show) + return; -void mvFontRegistry::resetFont() -{ for (auto& item : childslots[1]) - { - static_cast(item.get())->_default = false; - } + item->customAction(nullptr); - mvToolManager::GetFontManager()._resetDefault = true; + _dirty = false; } void mvFontRegistry::draw(ImDrawList* drawlist, float x, float y) { - //ImGuiIO& io = ImGui::GetIO(); - //io.Fonts->Clear(); - //io.FontDefault = io.Fonts->AddFontDefault(); - for (auto& item : childslots[1]) { item->draw(drawlist, ImGui::GetCursorPosX(), ImGui::GetCursorPosY()); } - config.show = false; } void mvCharRemap::handleSpecificRequiredArgs(PyObject* dict) @@ -43,34 +33,40 @@ void mvCharRemap::handleSpecificRequiredArgs(PyObject* dict) _target = ToInt(PyTuple_GetItem(dict, 1)); } +mvFont::~mvFont() +{ + if (_fontPtr) + { + mvSubmitTask([=]() { + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->RemoveFont(_fontPtr); + }, true); + } +} + void mvFont::customAction(void* data) { + // If add_font arguments are bad, quit. if (!state.ok) return; + // If the font has been already loaded, nothing to do here. + if (_fontPtr) + return; ImGuiIO& io = ImGui::GetIO(); ImFontConfig cfg; - cfg.PixelSnapH = _pixel_snap_h; - _fontPtr = io.Fonts->AddFontFromFileTTF(_file.c_str(), _size, - &cfg, _ranges.Data); + cfg.PixelSnapH = _pixelSnapH; + cfg.PixelSnapV = _pixelSnapV; + _fontPtr = io.Fonts->AddFontFromFileTTF(_file.c_str(), _size, &cfg); if (_fontPtr == nullptr) { + state.ok = false; mvThrowPythonError(mvErrorCode::mvNone, "Font file could not be found"); - io.Fonts->Build(); return; } - // handled by char remaps - //for (auto& item : font.charRemaps) - // _fontPtr->AddRemapChar(item.first, item.second); - - io.Fonts->Build(); - - if (_default) - io.FontDefault = _fontPtr; - // check ranges for (const auto& range : childslots[1]) { @@ -85,81 +81,6 @@ void mvFont::customAction(void* data) } } -void mvFont::draw(ImDrawList* drawlist, float x, float y) -{ - - if (!state.ok) - return; - - ImFontGlyphRangesBuilder builder; - - static ImFontAtlas atlas; - - // check hints - if (childslots[0].empty()) - builder.AddRanges(atlas.GetGlyphRangesDefault()); - - for (const auto& hint : childslots[0]) - { - int hintSelection = static_cast(hint.get())->getHint(); - - switch (hintSelection) - { - case 1: - builder.AddRanges(atlas.GetGlyphRangesJapanese()); - break; - case 2: - builder.AddRanges(atlas.GetGlyphRangesKorean()); - break; - case 3: - builder.AddRanges(atlas.GetGlyphRangesChineseFull()); - break; - case 4: - builder.AddRanges(atlas.GetGlyphRangesChineseSimplifiedCommon()); - break; - case 5: - builder.AddRanges(atlas.GetGlyphRangesCyrillic()); - break; - case 6: - builder.AddRanges(atlas.GetGlyphRangesThai()); - break; - case 7: - builder.AddRanges(atlas.GetGlyphRangesVietnamese()); - break; - default: - builder.AddRanges(atlas.GetGlyphRangesDefault()); - } - - } - - // check ranges and chars - for (const auto& range : childslots[1]) - { - if (range->type == mvAppItemType::mvFontRange) - { - const auto rangePtr = static_cast(range.get()); - builder.AddRanges(rangePtr->getRange().data()); - } - - else if (range->type == mvAppItemType::mvFontChars) - { - const auto rangePtr = static_cast(range.get()); - - for (const auto& specificChar : rangePtr->getCharacters()) - builder.AddChar(specificChar); - } - } - - builder.BuildRanges(&_ranges); // Build the final result (ordered ranges with all the unique characters submitted) - - //_dirty = true; - auto item = GetItem(*GContext->itemRegistry, MV_ATLAS_UUID); - if (item) - static_cast(item)->markDirty(); - - mvToolManager::GetFontManager()._dirty = true; -} - void mvFont::handleSpecificRequiredArgs(PyObject* dict) { if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(type)], dict)) @@ -185,7 +106,9 @@ void mvFont::handleSpecificKeywordArgs(PyObject* dict) if (dict == nullptr) return; - if (PyObject* item = PyDict_GetItemString(dict, "pixel_snapH")) _pixel_snap_h = ToBool(item); + if (PyObject* item = PyDict_GetItemString(dict, "size")) _size = ToFloat(item); + if (PyObject* item = PyDict_GetItemString(dict, "pixel_snapH")) _pixelSnapH = ToBool(item); + if (PyObject* item = PyDict_GetItemString(dict, "pixel_snapV")) _pixelSnapV = ToBool(item); } void mvFont::getSpecificConfiguration(PyObject* dict) @@ -195,35 +118,6 @@ void mvFont::getSpecificConfiguration(PyObject* dict) PyDict_SetItemString(dict, "file", ToPyString(_file)); PyDict_SetItemString(dict, "size", ToPyFloat(_size)); - PyDict_SetItemString(dict, "pixel_snapH", ToPyBool(_pixel_snap_h)); -} - -void mvFontChars::handleSpecificRequiredArgs(PyObject* dict) -{ - if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(type)], dict)) - return; - - auto charVect = ToIntVect(PyTuple_GetItem(dict, 0)); - for (auto& item : charVect) - _chars.push_back((ImWchar)item); - -} - -void mvFontRange::handleSpecificRequiredArgs(PyObject* dict) -{ - if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(type)], dict)) - return; - - _min = ToInt(PyTuple_GetItem(dict, 0)); - _range[0] = (ImWchar)_min; - _max = ToInt(PyTuple_GetItem(dict, 1)); - _range[1] = (ImWchar)_max; -} - -void mvFontRangeHint::handleSpecificRequiredArgs(PyObject* dict) -{ - if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(type)], dict)) - return; - - _hint = ToInt(PyTuple_GetItem(dict, 0)); + PyDict_SetItemString(dict, "pixel_snapH", ToPyBool(_pixelSnapH)); + PyDict_SetItemString(dict, "pixel_snapV", ToPyBool(_pixelSnapV)); } diff --git a/src/mvFontItems.h b/src/mvFontItems.h index 30223a50a..3406fbe11 100644 --- a/src/mvFontItems.h +++ b/src/mvFontItems.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "mvItemRegistry.h" class mvFontRegistry : public mvAppItem @@ -8,13 +8,11 @@ class mvFontRegistry : public mvAppItem public: - explicit mvFontRegistry(mvUUID uuid); + explicit mvFontRegistry(mvUUID uuid) : mvAppItem(uuid) {} void draw(ImDrawList* drawlist, float x, float y) override; - void onChildAdd(std::shared_ptr item) { config.show = true; } - - bool isInvalid() const { return _dirty; } - void resetFont(); + void customAction(void* data = nullptr) override; + void onChildAdd(std::shared_ptr item) { _dirty = true; } private: @@ -47,77 +45,26 @@ class mvFont : public mvAppItem public: explicit mvFont(mvUUID uuid) : mvAppItem(uuid) {} + ~mvFont(); - void draw(ImDrawList* drawlist, float x, float y) override; + void draw(ImDrawList* drawlist, float x, float y) override {} void customAction(void* data = nullptr) override; void handleSpecificRequiredArgs(PyObject* dict) override; void handleSpecificKeywordArgs(PyObject* dict) override; void getSpecificConfiguration(PyObject* dict) override; ImFont* getFontPtr() { return _fontPtr; } + float getSize() { return _size; } + void pushFont() { ImGui::PushFont(_fontPtr, _size); } public: // config std::string _file; float _size = 13.0f; - bool _default = false; - bool _pixel_snap_h = false; + bool _pixelSnapH = false; + bool _pixelSnapV = false; // finalized ImFont* _fontPtr = nullptr; - ImVector _ranges; - -}; - -class mvFontChars : public mvAppItem -{ - -public: - - explicit mvFontChars(mvUUID uuid) : mvAppItem(uuid) {} - - void draw(ImDrawList* drawlist, float x, float y) override {} - void handleSpecificRequiredArgs(PyObject* dict) override; - const std::vector& getCharacters() const { return _chars; } - -private: - - std::vector _chars; - -}; - -class mvFontRange : public mvAppItem -{ - -public: - - explicit mvFontRange(mvUUID uuid) : mvAppItem(uuid) {} - - void draw(ImDrawList* drawlist, float x, float y) override {} - void handleSpecificRequiredArgs(PyObject* dict) override; - const std::array& getRange() const { return _range; } - -private: - - int _min = 0x0370; - int _max = 0x03ff; - std::array _range = { 0x0370, 0x03ff, 0 }; }; - -class mvFontRangeHint : public mvAppItem -{ - -public: - - explicit mvFontRangeHint(mvUUID uuid) : mvAppItem(uuid) {} - - void draw(ImDrawList* drawlist, float x, float y) override {} - void handleSpecificRequiredArgs(PyObject* dict) override; - int getHint() const { return _hint; } - -private: - - int _hint = 0; - -}; \ No newline at end of file diff --git a/src/mvFontManager.cpp b/src/mvFontManager.cpp index a6e2e6437..c9cf932f2 100644 --- a/src/mvFontManager.cpp +++ b/src/mvFontManager.cpp @@ -1,16 +1,21 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvFontManager.h" -#include "mvToolManager.h" -#include -#include -#include + +#include "mvFontItems.h" #include "mvContext.h" #include "mvAppItem.h" #include "mvCore.h" #include "mvItemRegistry.h" #include "mvViewport.h" -#include "mvPyUtils.h" -#include #include "mvTextureItems.h" + +#include +#include +#include +#include +#include #include #include @@ -35,101 +40,103 @@ if (ImGui::IsItemHovered()) } // [Internal] Display details for a single font, called by ShowStyleEditor(). -static void -NodeFont(ImFont* font) +void +mvFontManager::drawFontNode(ImFont* font) { -ImGuiIO& io = ImGui::GetIO(); -ImGuiStyle& style = ImGui::GetStyle(); -bool font_details_opened = ImGui::TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)", - font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); -ImGui::SameLine(); if (ImGui::SmallButton("Set as default")) { io.FontDefault = font; } -if (!font_details_opened) - return; - -ImGui::PushFont(font); -ImGui::Text("The quick brown fox jumps over the lazy dog"); -ImGui::PopFont(); -ImGui::DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); // Scale only this font -ImGui::SameLine(); HelpMarker( - "Note than the default embedded font is NOT meant to be scaled.\n\n" - "Font are currently rendered into bitmaps at a given size at the time of building the atlas. " - "You may oversample them to get some flexibility with scaling. " - "You can also render at multiple sizes and select which one to use at runtime.\n\n" - "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)"); -//ImGui::InputFloat("Font offset", &font->GlyphOffset.y, 1, 1, "%.0f"); -//ImGui::InputInt("Font offset", &font->ConfigData->GlyphOffset.y, 1, 1, "%.0f"); -ImGui::Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); -ImGui::Text("Fallback character: '%c' (U+%04X)", font->FallbackChar, font->FallbackChar); -ImGui::Text("Ellipsis character: '%c' (U+%04X)", font->EllipsisChar, font->EllipsisChar); -const int surface_sqrt = (int)sqrtf((float)font->MetricsTotalSurface); -ImGui::Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt); -for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) - if (font->ConfigData) - if (const ImFontConfig* cfg = &font->ConfigData[config_i]) - ImGui::BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d", - config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH); -if (ImGui::TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) -{ - // Display all glyphs of the fonts in separate pages of 256 characters - const ImU32 glyph_col = ImGui::GetColorU32(ImGuiCol_Text); - for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256) + ImGuiContext& g = *GImGui; + ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; + ImFontAtlas* atlas = font->OwnerAtlas; + bool opened = ImGui::TreeNode(font, "Font: \"%s\": %d sources(s)", font->GetDebugName(), font->Sources.Size); + + // Display preview text + if (!opened) + ImGui::Indent(); + ImGui::Indent(); + if (cfg->ShowFontPreview) + { + ImGui::PushFont(font, 0.0f); + ImGui::Text("The quick brown fox jumps over the lazy dog"); + ImGui::PopFont(); + } + if (!opened) + { + ImGui::Unindent(); + ImGui::Unindent(); + return; + } + if (ImGui::SmallButton("Set as default")) { - // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k) - // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT - // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here) - if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095)) + _updateDefault = false; + _defaultFont.reset(); + ImGui::GetIO().FontDefault = font; + } + ImGui::SameLine(); + if (ImGui::SmallButton("Clear bakes")) + ImFontAtlasFontDiscardBakes(atlas, font, 0); + ImGui::SameLine(); + if (ImGui::SmallButton("Clear unused")) + ImFontAtlasFontDiscardBakes(atlas, font, 2); + + // Display details + char c_str[5]; + ImTextCharToUtf8(c_str, font->FallbackChar); + ImGui::Text("Fallback character: '%s' (U+%04X)", c_str, font->FallbackChar); + ImTextCharToUtf8(c_str, font->EllipsisChar); + ImGui::Text("Ellipsis character: '%s' (U+%04X)", c_str, font->EllipsisChar); + + for (int src_n = 0; src_n < font->Sources.Size; src_n++) + { + ImFontConfig* src = font->Sources[src_n]; + const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader; + if (ImGui::TreeNodeEx(src, ImGuiTreeNodeFlags_Leaf|ImGuiTreeNodeFlags_Bullet, + "Input %d: \'%s\' [%d], Loader: '%s',\nOversample: %d,%d, PixelSnapH: %d, Offset: (%.1f,%.1f)", + src_n, src->Name, src->FontNo, loader->Name ? loader->Name : "N/A", + src->OversampleH, src->OversampleV, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y)) { - base += 4096 - 256; - continue; + ImGui::TreePop(); } + } - int count = 0; - for (unsigned int n = 0; n < 256; n++) - if (font->FindGlyphNoFallback((ImWchar)(base + n))) - count++; - if (count <= 0) - continue; - if (!ImGui::TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) + // TODO: add Glyphs Overlap Detection tool in future + + // Display all glyphs of the fonts in separate pages of 256 characters + for (int baked_n = 0; baked_n < atlas->Builder->BakedPool.Size; baked_n++) + { + ImFontBaked* baked = &atlas->Builder->BakedPool[baked_n]; + if (baked->OwnerFont != font) continue; - float cell_size = font->FontSize * 1; - float cell_spacing = style.ItemSpacing.y; - ImVec2 base_pos = ImGui::GetCursorScreenPos(); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - for (unsigned int n = 0; n < 256; n++) + ImGui::PushID(baked_n); + if (ImGui::TreeNode("Glyphs", "Baked at { %.2fpx, d.%.2f }: %d glyphs%s", baked->Size, baked->RasterizerDensity, baked->Glyphs.Size, (baked->LastUsedFrame < atlas->Builder->FrameCount - 1) ? " *Unused*" : "")) { - // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions - // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string. - ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); - ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size); - const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); - draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50)); - if (glyph) - font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n)); - if (glyph && ImGui::IsMouseHoveringRect(cell_p1, cell_p2)) + if (ImGui::SmallButton("Load all")) + for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base++) + baked->FindGlyph((ImWchar)base); + + const int surface_sqrt = (int)ImSqrt((float)baked->MetricsTotalSurface); + ImGui::Text("Ascent: %f, Descent: %f, Ascent-Descent: %f", baked->Ascent, baked->Descent, baked->Ascent - baked->Descent); + ImGui::Text("Texture Area: about %d px ~%dx%d px", baked->MetricsTotalSurface, surface_sqrt, surface_sqrt); + for (int src_n = 0; src_n < font->Sources.Size; src_n++) { - if(ImGui::BeginTooltip()) { - ImGui::Text("Codepoint: U+%04X", base + n); - ImGui::Separator(); - ImGui::Text("Visible: %d", glyph->Visible); - ImGui::Text("AdvanceX: %.1f", glyph->AdvanceX); - ImGui::Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); - ImGui::Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); - ImGui::EndTooltip(); - } + ImFontConfig* src = font->Sources[src_n]; + int oversample_h, oversample_v; + ImFontAtlasBuildGetOversampleFactors(src, baked, &oversample_h, &oversample_v); + ImGui::BulletText("Input %d: \'%s\', Oversample: (%d=>%d,%d=>%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", + src_n, src->Name, src->OversampleH, oversample_h, src->OversampleV, oversample_v, src->PixelSnapH, src->GlyphOffset.x, src->GlyphOffset.y); } + + ImGui::DebugNodeFontGlyphesForSrcMask(font, baked, ~0); + ImGui::TreePop(); } - ImGui::Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)); - ImGui::TreePop(); + ImGui::PopID(); } ImGui::TreePop(); -} -ImGui::TreePop(); + ImGui::Unindent(); } // Demo helper function to select among loaded fonts. // Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one. -static void -ShowCustomFontSelector(const char* label) +void +mvFontManager::drawFontSelector(const char* label) { ImGuiIO& io = ImGui::GetIO(); ImFont* font_current = ImGui::GetFont(); @@ -140,57 +147,58 @@ if (ImGui::BeginCombo(label, font_current->GetDebugName())) ImFont* font = io.Fonts->Fonts[n]; ImGui::PushID((void*)font); if (ImGui::Selectable(font->GetDebugName(), font == font_current)) + { + _updateDefault = false; + _defaultFont.reset(); io.FontDefault = font; + } ImGui::PopID(); } ImGui::EndCombo(); } } -bool -mvFontManager::isInvalid() const -{ - return _dirty; -} - void -mvFontManager::rebuildAtlas() +mvFontManager::updateAtlas() { - auto& roots = GContext->itemRegistry->fontRegistryRoots; + ImGuiIO& io = ImGui::GetIO(); + + // See if the built-in ProggyClean font is already there. We need it just in case + // all the DPG fonts (mvFont) are deleted and ImGui needs to render a frame. + if (io.Fonts->Sources.Size == 0) + io.Fonts->AddFontDefault(); - if (!roots.empty()) + for (auto& root : GContext->itemRegistry->fontRegistryRoots) { - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->Clear(); - io.FontDefault = io.Fonts->AddFontDefault(); + // Tell the font registry to update any fonts that need it + root->customAction(nullptr); + } - for (auto& item : roots[0]->childslots[1]) + // Reset the current font so that NewFrame can pick up changes immediately + if (_updateDefault) + { + ImGuiContext& g = *GImGui; + auto item = _defaultFont.lock(); + IM_ASSERT(item->type == mvAppItemType::mvFont && "The default font must be a mvFont."); + if (item) { - item->customAction(nullptr); + auto font = static_cast(item.get()); + io.FontDefault = font->getFontPtr(); + g.Style.FontSizeBase = font->getSize(); + } + else + { + io.FontDefault = nullptr; + g.Style.FontSizeBase = 0; } - - // Just to make sure g.Font doesn't point to a font already deleted by - // io.Fonts->Clear(), though ideally ImGui should be doing it on its own. - ImGui::SetCurrentFont(ImGui::GetDefaultFont()); } - - _dirty = false; - -} - -void -mvFontManager::updateAtlas() -{ - auto item = GetItem(*GContext->itemRegistry, MV_ATLAS_UUID); - if (item) - static_cast(item)->markDirty(); } void mvFontManager::drawWidgets() { - ShowCustomFontSelector("Fonts##Selector"); + drawFontSelector("Fonts##Selector"); ImGuiIO& io = ImGui::GetIO(); ImFontAtlas* atlas = io.Fonts; @@ -199,26 +207,37 @@ mvFontManager::drawWidgets() { ImFont* font = atlas->Fonts[i]; ImGui::PushID(font); - NodeFont(font); + drawFontNode(font); ImGui::PopID(); } - if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) + if (ImGui::TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexData->Width, atlas->TexData->Height)) { + if (ImGui::Button("Compact")) + atlas->CompactCache(); + ImGui::SameLine(); + if (ImGui::Button("Grow")) + ImFontAtlasTextureGrow(atlas); + ImGui::SameLine(); + if (ImGui::Button("Clear All")) + ImFontAtlasBuildClear(atlas); + ImGui::SetItemTooltip("Destroy cache and custom rectangles."); + ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); - ImGui::Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0, 0), ImVec2(1, 1), tint_col, border_col); + ImGui::PushStyleVar(ImGuiStyleVar_ImageBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, border_col); + ImGui::ImageWithBg(atlas->TexRef, ImVec2((float)atlas->TexData->Width, (float)atlas->TexData->Height), ImVec2(0, 0), ImVec2(1, 1), ImVec4(0, 0, 0, 0), tint_col); + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); ImGui::TreePop(); } // Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below. // (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds). + // As of ImGui 1.92, things start to change. There's still a global scale factor and we expose it, + // but DPI handling is different. const float MIN_SCALE = 0.3f; const float MAX_SCALE = 2.0f; - HelpMarker( - "Those are old settings provided for convenience.\n" - "However, the _correct_ way of scaling your UI is currently to reload your font at the designed size, " - "rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n" - "Using those settings here will give you poor quality results."); if (ImGui::DragFloat("global scale", &getGlobalFontScale(), 0.005f, MIN_SCALE, MAX_SCALE, "%.2f")) // Scale everything getGlobalFontScale() = IM_MAX(getGlobalFontScale(), MIN_SCALE); ImGui::PopItemWidth(); diff --git a/src/mvFontManager.h b/src/mvFontManager.h index 708a00340..4ed2bed6e 100644 --- a/src/mvFontManager.h +++ b/src/mvFontManager.h @@ -6,34 +6,48 @@ #include "mvContext.h" #include "mvToolWindow.h" -struct ImFont; - class mvFontManager : public mvToolWindow { public: - void rebuildAtlas(); void updateAtlas(); - bool isInvalid() const; float& getGlobalFontScale() { return _globalFontScale; } void setGlobalFontScale(float scale); - void resetDefault() { _resetDefault = true; } + bool isDefaultFont(const std::shared_ptr& item) + { + return (_defaultFont.lock() == item); + } + void setDefaultFont(const std::shared_ptr& font) + { + _defaultFont = font; + _updateDefault = true; + } + void clearDefaultFont() + { + _defaultFont.reset(); + _updateDefault = true; + } mvUUID getUUID() const override { return MV_TOOL_FONT_UUID; } const char* getTitle() const override { return "Font Manager"; } protected: + ImGuiWindowFlags m_windowflags = ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_HorizontalScrollbar; void drawWidgets() override; + void drawFontNode(ImFont* font); + void drawFontSelector(const char* label); public: - // default - ImFont* _font = nullptr; - bool _dirty = false; - float _globalFontScale = 1.0f; - bool _resetDefault = false; - bool _newDefault = false; + // Must be a mvFont (or empty) + std::weak_ptr _defaultFont; + // The only reason we need this _updateDefault flag is for "Set as default" + // buttons work in Font Manager window and in ImGui Style Editor. If not for those + // buttons, we could set the default font every frame all the time. + // Updates are blocked whenever the user clicks one of those "Set as default" buttons. + bool _updateDefault = true; + float _globalFontScale = 1.0f; }; \ No newline at end of file diff --git a/src/mvGlobalHandlers.cpp b/src/mvGlobalHandlers.cpp index 5382f37c0..c450c80b1 100644 --- a/src/mvGlobalHandlers.cpp +++ b/src/mvGlobalHandlers.cpp @@ -1,6 +1,8 @@ -#include "mvGlobalHandlers.h" #include "mvPyUtils.h" -#include "mvUtilities.h" +#pragma hdrstop + +#include "mvGlobalHandlers.h" +#include void mvHandlerRegistry::draw(ImDrawList* drawlist, float x, float y) { diff --git a/src/mvGlobalHandlers.h b/src/mvGlobalHandlers.h index 36cac7ec2..039c97e7b 100644 --- a/src/mvGlobalHandlers.h +++ b/src/mvGlobalHandlers.h @@ -2,7 +2,7 @@ #include "mvAppItem.h" #include "mvItemRegistry.h" -#include "dearpygui.h" +#include class mvHandlerRegistry : public mvAppItem { diff --git a/src/mvGraphics_apple.mm b/src/mvGraphics_apple.mm index f1baa2d92..b6ce2f135 100644 --- a/src/mvGraphics_apple.mm +++ b/src/mvGraphics_apple.mm @@ -1,6 +1,9 @@ #include "mvGraphics.h" + #include "mvAppleSpecifics.h" + #include "mvViewport.h" + #include "imgui_impl_glfw.h" #include "imgui_impl_metal.h" diff --git a/src/mvGraphics_linux.cpp b/src/mvGraphics_linux.cpp index a47187ebf..63f1a0bbc 100644 --- a/src/mvGraphics_linux.cpp +++ b/src/mvGraphics_linux.cpp @@ -1,9 +1,13 @@ #include "mvGraphics.h" + #include "mvLinuxSpecifics.h" + #include "mvViewport.h" +#include "mvProfiler.h" + #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" -#include "mvProfiler.h" + mvGraphics setup_graphics(mvViewport& viewport) { diff --git a/src/mvGraphics_win32.cpp b/src/mvGraphics_win32.cpp index b3592c458..24da2ec19 100644 --- a/src/mvGraphics_win32.cpp +++ b/src/mvGraphics_win32.cpp @@ -1,4 +1,5 @@ #include "mvGraphics.h" + #include "mvWindowsSpecifics.h" static std::vector @@ -104,6 +105,17 @@ setup_graphics(mvViewport& viewport) return graphics; } + if (!GContext->IO.altEnterFullscreen) + { + // Disable DXGI's default Alt+Enter fullscreen behavior. + IDXGIFactory* pSwapChainFactory = nullptr; + if (SUCCEEDED(graphicsData->swapChain->GetParent(IID_PPV_ARGS(&pSwapChainFactory)))) + { + pSwapChainFactory->MakeWindowAssociation(viewportData->handle, DXGI_MWA_NO_ALT_ENTER); + pSwapChainFactory->Release(); + } + } + // create render target graphicsData->swapChain->GetBuffer(0, IID_PPV_ARGS(&graphicsData->backBuffer)); graphicsData->device->CreateRenderTargetView(graphicsData->backBuffer, nullptr, &graphicsData->target); diff --git a/src/mvImGuiConfig.h b/src/mvImGuiConfig.h deleted file mode 100644 index 2c475ae9b..000000000 --- a/src/mvImGuiConfig.h +++ /dev/null @@ -1,10 +0,0 @@ -//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) -#define IMGUI_ENABLE_FREETYPE - -//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. -// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). -// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. -// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. -#define ImDrawIdx unsigned int - -#define IMGUI_USE_WCHAR32 \ No newline at end of file diff --git a/src/mvImGuiConfig_apple.h b/src/mvImGuiConfig_apple.h new file mode 100644 index 000000000..63ec0786f --- /dev/null +++ b/src/mvImGuiConfig_apple.h @@ -0,0 +1,17 @@ +//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. +// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). +// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. +// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. +#define ImDrawIdx unsigned int + +#define IMGUI_USE_WCHAR32 + +// Note: ImTextureID underlying type is backend-specific and is therefore different on different platforms! +// Leaving it defined as void* until we figure out how to declare it properly (like, id?). +// At least void* has been working fine for years. +#define ImTextureID void* + +// We need these operators somewhere, but starting with ImGui 1.89.4, we can't arbitrarily +// enable them before imgui_internal.h - we need to do this before imgui.h itself - or here. +// Taking precompiled headers into account, we'll be better off defining this globally. +#define IMGUI_DEFINE_MATH_OPERATORS diff --git a/src/mvImGuiConfig_linux.h b/src/mvImGuiConfig_linux.h new file mode 100644 index 000000000..315487b25 --- /dev/null +++ b/src/mvImGuiConfig_linux.h @@ -0,0 +1,16 @@ +//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. +// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). +// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. +// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. +#define ImDrawIdx unsigned int + +#define IMGUI_USE_WCHAR32 + +// Note: ImTextureID underlying type is backend-specific and is therefore different on different platforms! +// We don't define ImTextureID here so that it uses the default ImUI64, which is good for +// passing GLuint around (in Linux world, we need a GLuint for texture ID). + +// We need these operators somewhere, but starting with ImGui 1.89.4, we can't arbitrarily +// enable them before imgui_internal.h - we need to do this before imgui.h itself - or here. +// Taking precompiled headers into account, we'll be better off defining this globally. +#define IMGUI_DEFINE_MATH_OPERATORS diff --git a/src/mvImGuiConfig_win32.h b/src/mvImGuiConfig_win32.h new file mode 100644 index 000000000..b8c52f9d3 --- /dev/null +++ b/src/mvImGuiConfig_win32.h @@ -0,0 +1,21 @@ +//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) +#define IMGUI_ENABLE_FREETYPE + +//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. +// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). +// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. +// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. +#define ImDrawIdx unsigned int + +#define IMGUI_USE_WCHAR32 + +// Note: ImTextureID underlying type is backend-specific and is therefore different on different platforms! +// We're using void* so that we can pass ID3D11ShaderResourceView* here. While we could +// define ImTextureID as ID3D11ShaderResourceView* right here, we'd like to avoid including +// the entire d3d11.h (and windows.h) into this header because it is in turn included into imgui.h. +#define ImTextureID void* + +// We need these operators somewhere, but starting with ImGui 1.89.4, we can't arbitrarily +// enable them before imgui_internal.h - we need to do this before imgui.h itself - or here. +// Taking precompiled headers into account, we'll be better off defining this globally. +#define IMGUI_DEFINE_MATH_OPERATORS diff --git a/src/mvImGuiLinuxConfig.h b/src/mvImGuiLinuxConfig.h deleted file mode 100644 index 3d9327543..000000000 --- a/src/mvImGuiLinuxConfig.h +++ /dev/null @@ -1,7 +0,0 @@ -//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. -// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). -// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. -// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. -#define ImDrawIdx unsigned int - -#define IMGUI_USE_WCHAR32 \ No newline at end of file diff --git a/src/mvItemHandlers.cpp b/src/mvItemHandlers.cpp index 2c77ac5b7..9704c4ec7 100644 --- a/src/mvItemHandlers.cpp +++ b/src/mvItemHandlers.cpp @@ -1,5 +1,7 @@ -#include "mvItemHandlers.h" #include "mvPyUtils.h" +#pragma hdrstop + +#include "mvItemHandlers.h" void mvItemHandlerRegistry::checkEvents(void* data) { diff --git a/src/mvItemHandlers.h b/src/mvItemHandlers.h index 08f59bca2..7a5c265c4 100644 --- a/src/mvItemHandlers.h +++ b/src/mvItemHandlers.h @@ -2,7 +2,6 @@ #include "mvAppItem.h" #include "mvItemRegistry.h" -#include "dearpygui.h" class mvItemHandlerRegistry : public mvAppItem { diff --git a/src/mvItemRegistry.cpp b/src/mvItemRegistry.cpp index 2bca82d58..6176ca9c4 100644 --- a/src/mvItemRegistry.cpp +++ b/src/mvItemRegistry.cpp @@ -1,10 +1,16 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvItemRegistry.h" -#include "mvProfiler.h" + #include "mvContext.h" -#include "mvAppItemCommons.h" -#include "mvPyUtils.h" +#include "mvThemes.h" #include "mvToolManager.h" #include "mvFontManager.h" +#include "mvContainers.h" +#include "mvTables.h" + +#include "mvProfiler.h" mvItemRegistry::mvItemRegistry() { @@ -159,6 +165,10 @@ GetRootsList(mvItemRegistry& registry, mvAppItemType type) case mvAppItemType::mvTemplateRegistry: return registry.itemTemplatesRoots; case mvAppItemType::mvItemHandlerRegistry: return registry.itemHandlerRegistryRoots; case mvAppItemType::mvViewportDrawlist: return registry.viewportDrawlistRoots; + default: + // Nothing to do here, this is just to calm down the compiler that will + // otherwise warn about unused enum values. + break; } // We must never end up here IM_ASSERT(false && "A root container does not have a corresponding list in GetRootsList."); @@ -504,39 +514,12 @@ RenderItemRegistry(mvItemRegistry& registry) if(registry.showImPlotDebug) ImPlot::ShowDemoWindow(®istry.showImPlotDebug); - if (mvToolManager::GetFontManager()._resetDefault) - { - ImGuiIO& io = ImGui::GetIO(); - io.FontDefault = nullptr; - mvToolManager::GetFontManager()._resetDefault = false; - } - for (auto& root : registry.fontRegistryRoots) { if (root->config.show) root->draw(nullptr, 0.0f, 0.0f); } - if (mvToolManager::GetFontManager()._newDefault) - { - ImGuiIO& io = ImGui::GetIO(); - io.FontDefault = nullptr; - - for (auto& root : registry.fontRegistryRoots) - { - for (auto& font : root->childslots[1]) - { - if (static_cast(font.get())->_default) - { - io.FontDefault = static_cast(font.get())->getFontPtr(); - break; - } - } - } - - mvToolManager::GetFontManager()._newDefault = false; - } - for (auto& root : registry.handlerRegistryRoots) { if (root->config.show) diff --git a/src/mvItemRegistry.h b/src/mvItemRegistry.h index 65fd44738..71d830049 100644 --- a/src/mvItemRegistry.h +++ b/src/mvItemRegistry.h @@ -3,9 +3,7 @@ #include #include #include -#include #include -#include #include #include "mvAppItem.h" #include "mvPyUtils.h" diff --git a/src/mvLayoutWindow.cpp b/src/mvLayoutWindow.cpp index 1e510f0e9..6092fe227 100644 --- a/src/mvLayoutWindow.cpp +++ b/src/mvLayoutWindow.cpp @@ -1,10 +1,15 @@ #include "mvLayoutWindow.h" -#include + #include "mvContext.h" #include "mvItemRegistry.h" #include "mvFontItems.h" #include "mvThemes.h" +#include "mvToolManager.h" +#include "mvFontManager.h" + +#include #include +#include static void DebugItem(const char* label, const char* item) { @@ -125,7 +130,7 @@ void mvLayoutWindow::renderTreeNode(std::shared_ptr& item) ImGui::SetNextItemOpen(true); } - // TODO: add a flag to GetEntityDesciptionFlags for this + // TODO: add a flag to GetEntityDescriptionFlags for this bool is_bindable = (item->type == mvAppItemType::mvTheme || item->type == mvAppItemType::mvItemHandlerRegistry || item->type == mvAppItemType::mvFont ); @@ -136,10 +141,10 @@ void mvLayoutWindow::renderTreeNode(std::shared_ptr& item) // An extra check for some elements that can have global refs *not* shared // via shared_ptr. // - the global theme is the only one that has config.show == true - // - the global font is the only one having _default == true + // - the global font is stored in mvFontManager and the font manager knows how to check this if (is_lonely && ( (item->type == mvAppItemType::mvTheme && item->config.show) || - (item->type == mvAppItemType::mvFont && (static_cast(item.get()))->_default))) + (item->type == mvAppItemType::mvFont && mvToolManager::GetFontManager().isDefaultFont(item)))) { // It's bound as a global entity and therefore is not lonely is_lonely = false; @@ -661,6 +666,11 @@ void mvLayoutWindow::renderTypeSpecificInfo() renderBindCount(); } break; + + default: + // Nothing to do here, this is just to calm down the compiler that will + // otherwise warn about unused enum values. + break; } } diff --git a/src/mvLoadingIndicator.cpp b/src/mvLoadingIndicator.cpp index 4055602ec..61f593d19 100644 --- a/src/mvLoadingIndicator.cpp +++ b/src/mvLoadingIndicator.cpp @@ -1,4 +1,5 @@ #include "mvLoadingIndicator.h" + #include "mvLoadingIndicatorCustom.h" #include "mvFontItems.h" #include "mvThemes.h" @@ -43,10 +44,7 @@ void mvLoadingIndicator::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -97,7 +95,7 @@ void mvLoadingIndicator::draw(ImDrawList* drawlist, float x, float y) // set cursor position to cached position if (info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (config.indent > 0.0f) ImGui::Unindent(config.indent); diff --git a/src/mvLoadingIndicatorCustom.cpp b/src/mvLoadingIndicatorCustom.cpp index 9c8f53b34..dd2d20905 100644 --- a/src/mvLoadingIndicatorCustom.cpp +++ b/src/mvLoadingIndicatorCustom.cpp @@ -1,4 +1,5 @@ #include "mvLoadingIndicatorCustom.h" + #include #include #include @@ -96,7 +97,7 @@ void LoadingIndicatorCircle2(const char* label, float indicatorRadiusFactor, flo int num_segments = 30; - int start = abs((int)(ImSin(g.Time * 1.8f) * (num_segments - 5))); + int start = abs((int)(ImSin((float)g.Time * 1.8f) * (num_segments - 5))); const float a_min = IM_PI * 2.0f * ((float)start) / (float)num_segments; const float a_max = IM_PI * 2.0f * ((float)num_segments - 3) / (float)num_segments; @@ -105,8 +106,8 @@ void LoadingIndicatorCircle2(const char* label, float indicatorRadiusFactor, flo for (int i = 0; i < num_segments; i++) { const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); - window->DrawList->PathLineTo(ImVec2(centre.x + ImCos(a + g.Time * 8) * indicatorRadiusPixels, - centre.y + ImSin(a + g.Time * 8) * indicatorRadiusPixels)); + window->DrawList->PathLineTo(ImVec2(centre.x + ImCos(a + (float)g.Time * 8) * indicatorRadiusPixels, + centre.y + ImSin(a + (float)g.Time * 8) * indicatorRadiusPixels)); } window->DrawList->PathStroke(color, false, indicatorThicknessPixels); @@ -142,7 +143,7 @@ void LoadingIndicatorRing(const char* label, float size, float thickness, float int num_segments = 30; - float t = g.Time * speed; + float t = (float)g.Time * speed; // With this formula it looks very close to the original LoadingIndicatorCircle2 // but does not have visual artifacts (jitter of the ring tail when it slows down). diff --git a/src/mvMetricsWindow.cpp b/src/mvMetricsWindow.cpp index b4663877d..c6e3beab6 100644 --- a/src/mvMetricsWindow.cpp +++ b/src/mvMetricsWindow.cpp @@ -1,6 +1,8 @@ #include "mvMetricsWindow.h" -#include "mvProfiler.h" + #include "mvContext.h" +#include "mvProfiler.h" + #include "imgui_internal.h" static void diff --git a/src/mvNodes.cpp b/src/mvNodes.cpp index 9b0602baf..9eb13d491 100644 --- a/src/mvNodes.cpp +++ b/src/mvNodes.cpp @@ -1,13 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvNodes.h" -#include + #include "mvContext.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvItemHandlers.h" #include "mvThemes.h" #include "mvContainers.h" #include "mvFontItems.h" +#include +// For ImRect (used by mvEditorGetSize) +#include + static std::string FindRenderedTextEnd(const char* text, const char* text_end = nullptr) { int size = 0; @@ -391,10 +397,7 @@ void mvNode::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -419,6 +422,16 @@ void mvNode::draw(ImDrawList* drawlist, float x, float y) ImGui::TextUnformatted(config.specifiedLabel.c_str()); ImNodes::EndNodeTitleBar(); + // Just in case there are no children items within the node: EndNodeTitleBar() + // above calls SetCursorPos, and it's invalid to call it like that without adding + // yet another item after it (see issue #5548 in Dear ImGui, and also RestoreImGuiCursor + // in mvAppItem.cpp). Once this issue is fixed directly in ImNodes, we can + // remove the following three lines. + // TODO: recheck on the next update of ImNodes. + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::Dummy(ImVec2(0, 0)); + ImGui::PopStyleVar(); + state.lastFrameUpdate = GContext->frame; state.leftclicked = ImGui::IsItemClicked(); state.rightclicked = ImGui::IsItemClicked(1); @@ -523,10 +536,7 @@ void mvNodeAttribute::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); diff --git a/src/mvPlotting.cpp b/src/mvPlotting.cpp index 6eb507e07..bcffcf2fb 100644 --- a/src/mvPlotting.cpp +++ b/src/mvPlotting.cpp @@ -1,15 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvPlotting.h" -#include + #include "mvCore.h" #include "mvContext.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" #include "mvTextureItems.h" #include "mvItemHandlers.h" +#include + static void draw_polygon(const mvAreaSeriesConfig& config) { @@ -92,7 +96,7 @@ draw_polygon(const mvAreaSeriesConfig& config) continue; if (((y >= y1) && (y < y2)) || ((y == maxy) && (y > y1) && (y <= y2))) - polyints[ints++] = (y - y1) * (x2 - x1) / (y2 - y1) + x1; + polyints[ints++] = (int)((y - y1) * (x2 - x1) / (y2 - y1) + x1); } @@ -372,10 +376,7 @@ DearPyGui::draw_plot(ImDrawList* drawlist, mvAppItem& item, mvPlotConfig& config // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -594,8 +595,8 @@ DearPyGui::draw_plot(ImDrawList* drawlist, mvAppItem& item, mvPlotConfig& config if (ImPlot::IsPlotHovered()) { - GContext->input.mousePlotPos.x = ImPlot::GetPlotMousePos().x; - GContext->input.mousePlotPos.y = ImPlot::GetPlotMousePos().y; + GContext->input.mousePlotPos.x = (float)ImPlot::GetPlotMousePos().x; + GContext->input.mousePlotPos.y = (float)ImPlot::GetPlotMousePos().y; } // todo: resolve clipping @@ -644,7 +645,7 @@ DearPyGui::draw_plot(ImDrawList* drawlist, mvAppItem& item, mvPlotConfig& config // set cursor position to cached position if (item.info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); ImPlot::GetInputMap() = config._originalMap; @@ -781,7 +782,7 @@ DearPyGui::draw_drag_line(ImDrawList* drawlist, mvAppItem& item, mvDragLineConfi if (config.vertical) { - if (ImPlot::DragLineX(item.uuid, config.value.get(), config.color, config.thickness, config.flags, nullptr, &hovered, &held)) + if (ImPlot::DragLineX((int)item.uuid, config.value.get(), config.color, config.thickness, config.flags, nullptr, &hovered, &held)) { item.submitCallback(); } @@ -797,7 +798,7 @@ DearPyGui::draw_drag_line(ImDrawList* drawlist, mvAppItem& item, mvDragLineConfi } else { - if (ImPlot::DragLineY(item.uuid, config.value.get(), config.color, config.thickness, config.flags, nullptr, &hovered, &held)) + if (ImPlot::DragLineY((int)item.uuid, config.value.get(), config.color, config.thickness, config.flags, nullptr, &hovered, &held)) { item.submitCallback(); } @@ -858,7 +859,7 @@ DearPyGui::draw_drag_rect(ImDrawList* drawlist, mvAppItem& item, mvDragRectConfi ymax = (*config.value.get())[3]; // item.config.specifiedLabel.c_str(), - if (ImPlot::DragRect(item.uuid, &xmin, &ymin, &xmax, &ymax, config.color, config.flags)) + if (ImPlot::DragRect((int)item.uuid, &xmin, &ymin, &xmax, &ymax, config.color, config.flags)) { (*config.value.get())[0] = xmin; (*config.value.get())[1] = ymin; @@ -883,7 +884,7 @@ DearPyGui::draw_drag_point(ImDrawList* drawlist, mvAppItem& item, mvDragPointCon bool hovered = false; bool held = false; - if (ImPlot::DragPoint(item.uuid, &dummyx, &dummyy, config.color, config.radius, config.flags, nullptr, &hovered, &held)) + if (ImPlot::DragPoint((int)item.uuid, &dummyx, &dummyy, config.color, config.radius, config.flags, nullptr, &hovered, &held)) { (*config.value.get())[0] = dummyx; (*config.value.get())[1] = dummyy; @@ -914,10 +915,7 @@ DearPyGui::draw_bar_series(ImDrawList* drawlist, mvAppItem& item, const mvBarSer // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -983,10 +981,7 @@ DearPyGui::draw_bar_group_series(ImDrawList* drawlist, mvAppItem& item, const mv // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1056,10 +1051,7 @@ DearPyGui::draw_line_series(ImDrawList* drawlist, mvAppItem& item, const mvLineS // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1124,10 +1116,7 @@ DearPyGui::draw_scatter_series(ImDrawList* drawlist, mvAppItem& item, const mvSc // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1192,10 +1181,7 @@ DearPyGui::draw_stair_series(ImDrawList* drawlist, mvAppItem& item, const mvStai // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1260,10 +1246,7 @@ DearPyGui::draw_stem_series(ImDrawList* drawlist, mvAppItem& item, const mvStemS // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1328,10 +1311,7 @@ DearPyGui::draw_shade_series(ImDrawList* drawlist, mvAppItem& item, const mvShad // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1399,10 +1379,7 @@ DearPyGui::draw_inf_lines_series(ImDrawList* drawlist, mvAppItem& item, const mv // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1465,10 +1442,7 @@ DearPyGui::draw_2dhistogram_series(ImDrawList* drawlist, mvAppItem& item, const // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1534,10 +1508,7 @@ DearPyGui::draw_error_series(ImDrawList* drawlist, mvAppItem& item, const mvErro // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1606,10 +1577,7 @@ DearPyGui::draw_heat_series(ImDrawList* drawlist, mvAppItem& item, const mvHeatS // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1674,10 +1642,7 @@ DearPyGui::draw_histogram_series(ImDrawList* drawlist, mvAppItem& item, const mv // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1748,10 +1713,7 @@ DearPyGui::draw_digital_series(ImDrawList* drawlist, mvAppItem& item, const mvDi // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1818,10 +1780,7 @@ DearPyGui::draw_pie_series(ImDrawList* drawlist, mvAppItem& item, const mvPieSer // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1895,10 +1854,7 @@ DearPyGui::draw_label_series(ImDrawList* drawlist, mvAppItem& item, const mvLabe // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1957,10 +1913,7 @@ DearPyGui::draw_image_series(ImDrawList* drawlist, mvAppItem& item, mvImageSerie // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -1970,40 +1923,35 @@ DearPyGui::draw_image_series(ImDrawList* drawlist, mvAppItem& item, mvImageSerie //----------------------------------------------------------------------------- { - if (config._texture) + if (config._texture && config._texture->state.ok) { - if (config._internalTexture) - config._texture->draw(drawlist, 0.0f, 0.0f); - - if (!config._texture->state.ok) - return; - - void* texture = nullptr; - - if (config._texture->type == mvAppItemType::mvStaticTexture) - texture = static_cast(config._texture.get())->_texture; - else if (config._texture->type == mvAppItemType::mvRawTexture) - texture = static_cast(config._texture.get())->_texture; - else - texture = static_cast(config._texture.get())->_texture; + auto type = config._texture->type; + if (type == mvAppItemType::mvStaticTexture || + type == mvAppItemType::mvDynamicTexture || + type == mvAppItemType::mvRawTexture) + { + // TODO: use this line once ImPlot gets updated to newer version that supports ImTextureRef + // ImTextureRef texture = static_cast(config._texture.get())->getTexRef(); + ImTextureID texture = static_cast(config._texture.get())->_texture; - ImPlot::PlotImage(item.info.internalLabel.c_str(), texture, config.bounds_min, config.bounds_max, config.uv_min, config.uv_max, config.tintColor, config.flags); + ImPlot::PlotImage(item.info.internalLabel.c_str(), texture, config.bounds_min, config.bounds_max, config.uv_min, config.uv_max, config.tintColor, config.flags); - // Begin a popup for a legend entry. - if (ImPlot::BeginLegendPopup(item.info.internalLabel.c_str(), 1)) - { - for (auto& childset : item.childslots) + // Begin a popup for a legend entry. + if (ImPlot::BeginLegendPopup(item.info.internalLabel.c_str(), 1)) { - for (auto& item : childset) + for (auto& childset : item.childslots) { - // skip item if it's not shown - if (!item->config.show) - continue; - item->draw(drawlist, ImPlot::GetPlotPos().x, ImPlot::GetPlotPos().y); - UpdateAppItemState(item->state); + for (auto& item : childset) + { + // skip item if it's not shown + if (!item->config.show) + continue; + item->draw(drawlist, ImPlot::GetPlotPos().x, ImPlot::GetPlotPos().y); + UpdateAppItemState(item->state); + } } + ImPlot::EndLegendPopup(); } - ImPlot::EndLegendPopup(); } } } @@ -2037,10 +1985,7 @@ DearPyGui::draw_area_series(ImDrawList* drawlist, mvAppItem& item, const mvAreaS // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2110,10 +2055,7 @@ DearPyGui::draw_candle_series(ImDrawList* drawlist, mvAppItem& item, const mvCan // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2187,10 +2129,7 @@ DearPyGui::draw_custom_series(ImDrawList* drawlist, mvAppItem& item, mvCustomSer // push font if a font object is attached if (item.font) - { - ImFont* fontptr = static_cast(item.font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(item.font.get())->pushFont(); // themes apply_local_theming(&item); @@ -2294,8 +2233,8 @@ DearPyGui::draw_custom_series(ImDrawList* drawlist, mvAppItem& item, mvCustomSer item.submitCallbackEx([=, channelCount=config.channelCount, transformedValues=config._transformedValues] () { const int extras = 4; PyObject* helperData = PyDict_New(); - PyDict_SetItemString(helperData, "MouseX_PlotSpace", ToPyFloat(mouse.x)); - PyDict_SetItemString(helperData, "MouseY_PlotSpace", ToPyFloat(mouse.y)); + PyDict_SetItemString(helperData, "MouseX_PlotSpace", ToPyDouble(mouse.x)); + PyDict_SetItemString(helperData, "MouseY_PlotSpace", ToPyDouble(mouse.y)); PyDict_SetItemString(helperData, "MouseX_PixelSpace", ToPyFloat(mouse2.x)); PyDict_SetItemString(helperData, "MouseY_PixelSpace", ToPyFloat(mouse2.y)); PyObject* appData = PyTuple_New(channelCount + extras); @@ -2403,14 +2342,13 @@ DearPyGui::set_positional_configuration(PyObject* inDict, mvBarSeriesConfig& out static bool ValidateBarGroupConfig(mvBarGroupSeriesConfig& outConfig) { - if (outConfig.group_size == 0) + if (outConfig.group_size <= 0) { - mvThrowPythonError(mvErrorCode::mvNone, "draw_bar_group_series", "`group_size` can't be 0", nullptr); + mvThrowPythonError(mvErrorCode::mvNone, "draw_bar_group_series", "`group_size` must be positive", nullptr); return false; } const std::vector* values = &(*outConfig.value.get())[0]; const size_t values_size = values->size(); - const int item_count = values_size / outConfig.group_size; if (values_size % outConfig.group_size != 0) { @@ -2584,17 +2522,16 @@ DearPyGui::set_required_configuration(PyObject* inDict, mvImageSeriesConfig& out outConfig.bounds_min.y = resultmin.y; outConfig.bounds_max.x = resultmax.x; outConfig.bounds_max.y = resultmax.y; - outConfig._texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); - if (outConfig._texture) - { - } - else if (outConfig.textureUUID == MV_ATLAS_UUID) + if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig._texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; } else - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageSeries), "Texture not found.", nullptr); + { + outConfig._texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig._texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageSeries), "Texture not found.", nullptr); + } } void @@ -3203,19 +3140,15 @@ DearPyGui::set_configuration(PyObject* inDict, mvImageSeriesConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "texture_tag")) { outConfig.textureUUID = GetIDFromPyObject(item); - outConfig._texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); if (outConfig.textureUUID == MV_ATLAS_UUID) { outConfig._texture = std::make_shared(outConfig.textureUUID); - outConfig._internalTexture = true; - } - else if (outConfig._texture) - { - outConfig._internalTexture = false; } else { - mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageSeries), "Texture not found.", nullptr); + outConfig._texture = GetRefItem(*GContext->itemRegistry, outConfig.textureUUID); + if (!outConfig._texture) + mvThrowPythonError(mvErrorCode::mvTextureNotFound, GetEntityCommand(mvAppItemType::mvImageSeries), "Texture not found.", nullptr); } } } @@ -3245,7 +3178,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvCandleSeriesConfig& outConfig) if (PyObject* item = PyDict_GetItemString(inDict, "closes")) { (*outConfig.value)[2] = ToDoubleVect(item); } if (PyObject* item = PyDict_GetItemString(inDict, "lows")) { (*outConfig.value)[3] = ToDoubleVect(item); } if (PyObject* item = PyDict_GetItemString(inDict, "highs")) { (*outConfig.value)[4] = ToDoubleVect(item); } - if (PyObject* item = PyDict_GetItemString(inDict, "time_unit")) { outConfig.timeunit = ToUUID(item); } + if (PyObject* item = PyDict_GetItemString(inDict, "time_unit")) { outConfig.timeunit = ToInt(item); } } void diff --git a/src/mvPlotting.h b/src/mvPlotting.h index 9d35d90cb..ceeb95d3b 100644 --- a/src/mvPlotting.h +++ b/src/mvPlotting.h @@ -2,6 +2,7 @@ #include "mvItemRegistry.h" #include +#include struct mvPlotConfig; struct mvPlotAxisConfig; @@ -334,7 +335,6 @@ struct mvImageSeriesConfig : _mvBasicSeriesConfig // pointer to existing item or internal std::shared_ptr _texture = nullptr; - bool _internalTexture = false; // create a local texture if necessary }; struct mvAreaSeriesConfig : _mvBasicSeriesConfig diff --git a/src/mvPyUtils.cpp b/src/mvPyUtils.cpp index 70e722ead..c9ac97e9f 100644 --- a/src/mvPyUtils.cpp +++ b/src/mvPyUtils.cpp @@ -1,12 +1,13 @@ #include "mvPyUtils.h" -#include +#pragma hdrstop -#include #include "mvAppItem.h" -#include "mvAppItemCommons.h" #include "mvContext.h" #include "mvItemRegistry.h" #include "dearpygui.h" + +#include +#include #include #include @@ -869,6 +870,23 @@ ToInt(PyObject* value, const std::string& message) return 0; } +long +ToLong(PyObject* value, const std::string& message) +{ + if (value == nullptr) + return 0; + + + if (PyLong_Check(value)) + return PyLong_AsLong(value); + + else if (PyFloat_Check(value)) + return (long)PyFloat_AsDouble(value); + + mvThrowPythonError(mvErrorCode::mvWrongType, "Python value error. Must be int."); + return 0; +} + mvUUID ToUUID(PyObject* value, const std::string& message) { diff --git a/src/mvPyUtils.h b/src/mvPyUtils.h index 573f56547..3e92214fa 100644 --- a/src/mvPyUtils.h +++ b/src/mvPyUtils.h @@ -179,6 +179,7 @@ void UpdatePyStringStringList(PyObject* pyvalue, const std::vector static float Dist2(ImVec2 const v, ImVec2 const w) { @@ -188,7 +192,8 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f ImVec2 const vCursorPos((oXYDrag.Max.x - oXYDrag.Min.x) * fScaleX + oXYDrag.Min.x, (oXYDrag.Max.y - oXYDrag.Min.y) * fScaleY + oXYDrag.Min.y); - ImGui::SetWindowFontScale(0.75f); + ImGuiStyle& style = ImGui::GetStyle(); + ImGui::PushFont(nullptr, style.FontSizeBase * 0.75f); ImVec2 const vXSize = ImGui::CalcTextSize(pBufferX); ImVec2 const vYSize = ImGui::CalcTextSize(pBufferY); @@ -252,7 +257,7 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f vZTextPos, uTextCol, pBufferZ); - ImGui::SetWindowFontScale(1.0f); + ImGui::PopFont(); // Handles pDrawList->AddNgonFilled(vHandlePosX, fHandleRadius, uBlue, 4); @@ -381,10 +386,7 @@ void mvSlider3D::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -412,7 +414,7 @@ void mvSlider3D::draw(ImDrawList* drawlist, float x, float y) // set cursor position to cached position if (info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (config.indent > 0.0f) ImGui::Unindent(config.indent); diff --git a/src/mvSlider3D.h b/src/mvSlider3D.h index 34debc5ec..a98c87d07 100644 --- a/src/mvSlider3D.h +++ b/src/mvSlider3D.h @@ -4,7 +4,6 @@ #include #include "mvItemRegistry.h" #include "mvContext.h" -#include "dearpygui.h" class mvSlider3D : public mvAppItem { diff --git a/src/mvStackWindow.cpp b/src/mvStackWindow.cpp index 0ab913176..81e9d4111 100644 --- a/src/mvStackWindow.cpp +++ b/src/mvStackWindow.cpp @@ -1,6 +1,8 @@ #include "mvStackWindow.h" -#include "mvProfiler.h" + #include "mvContext.h" +#include "mvProfiler.h" + #include "imgui_internal.h" void mvStackWindow::drawWidgets() diff --git a/src/mvStyleWindow.cpp b/src/mvStyleWindow.cpp index 58167b4d3..a75cc375b 100644 --- a/src/mvStyleWindow.cpp +++ b/src/mvStyleWindow.cpp @@ -1,5 +1,7 @@ #include "mvStyleWindow.h" + #include "mvContext.h" + #include "imnodes.h" // Play it nice with Windows users (Update: May 2018, Notepad now supports Unix-style carriage returns!) @@ -75,54 +77,104 @@ void mvStyleWindow::drawWidgets() { if (ImGui::BeginTabItem("Styles")) { - ImGui::Text("Main"); + ImGui::SeparatorText("Main"); ImGui::SliderFloat2("mvStyleVar_WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("mvStyleVar_FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("mvStyleVar_CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("mvStyleVar_ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("mvStyleVar_ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("mvStyleVar_TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); - ImGui::SliderFloat("mvStyleVar_ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); - ImGui::Text("Borders"); + + ImGui::SeparatorText("Borders"); ImGui::SliderFloat("mvStyleVar_WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("mvStyleVar_TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("mvStyleVar_TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::Text("Rounding"); + + ImGui::SeparatorText("Rounding"); ImGui::SliderFloat("mvStyleVar_WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("mvStyleVar_ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); ImGui::SliderFloat("mvStyleVar_GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("mvStyleVar_LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); + + ImGui::SeparatorText("Scrollbar"); + ImGui::SliderFloat("mvStyleVar_ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_ScrollbarPadding", &style.ScrollbarPadding, 0.0f, 10.0f, "%.0f"); + + ImGui::SeparatorText("Tabs"); + ImGui::SliderFloat("mvStyleVar_TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_TabBarBorderSize", &style.TabBarBorderSize, 0.0f, 2.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_TabBarOverlineSize", &style.TabBarOverlineSize, 0.0f, 3.0f, "%.0f"); + ImGui::SameLine(); HelpMarker("Overline is only drawn over the selected tab when draw_selected_overline=True is set on tab_bar."); + ImGui::DragFloat("mvStyleVar_TabMinWidthBase", &style.TabMinWidthBase, 0.5f, 1.0f, 500.0f, "%.0f"); + ImGui::DragFloat("mvStyleVar_TabMinWidthShrink", &style.TabMinWidthShrink, 0.5f, 1.0f, 500.0f, "%0.f"); + // ImGui::DragFloat("mvStyleVar_TabCloseButtonMinWidthSelected", &style.TabCloseButtonMinWidthSelected, 0.5f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthSelected < 0.0f) ? "%.0f (Always)" : "%.0f"); + // ImGui::DragFloat("mvStyleVar_TabCloseButtonMinWidthUnselected", &style.TabCloseButtonMinWidthUnselected, 0.5f, -1.0f, 100.0f, (style.TabCloseButtonMinWidthUnselected < 0.0f) ? "%.0f (Always)" : "%.0f"); ImGui::SliderFloat("mvStyleVar_TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::Text("AntiAliasing"); - ImGui::Checkbox("AntiAliasedLines", &style.AntiAliasedLines); - ImGui::Checkbox("AntiAliasedLinesUseTex", &style.AntiAliasedLinesUseTex); - ImGui::Checkbox("AntiAliasedFill", &style.AntiAliasedFill); - ImGui::Text("Docking"); - ImGui::SliderFloat("DockingSplitterSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f"); - ImGui::Text("Alignment"); - ImGui::SliderFloat2("mvStyleVar_WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); + + ImGui::SeparatorText("Tables"); + ImGui::SliderFloat2("mvStyleVar_CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); + ImGui::SliderAngle("mvStyleVar_TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -50.0f, +50.0f); ImGui::SliderFloat2("mvStyleVar_TableAngledHeadersTextAlign", (float*)&style.TableAngledHeadersTextAlign, 0.0f, 1.0f, "%.2f"); - //int window_menu_button_position = style.WindowMenuButtonPosition + 1; - //if (ImGui::Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0")) - // style.WindowMenuButtonPosition = window_menu_button_position - 1; - //ImGui::Combo("mvStyleVar_ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); + + ImGui::SeparatorText("Trees"); + ImGui::SliderFloat("mvStyleVar_TreeLinesSize", &style.TreeLinesSize, 0.0f, 2.0f, "%.0f"); + ImGui::SameLine(); + HelpMarker("[Experimental]\nTree lines may not work in all situations (e.g. using a clipper) and may incurs slight traversal overhead.\n\nmvTreeLines_Full is faster than mvTreeLines_ToNodes."); + ImGui::SliderFloat("mvStyleVar_TreeLinesRounding", &style.TreeLinesRounding, 0.0f, 12.0f, "%.0f"); + + ImGui::SeparatorText("Windows"); + ImGui::SliderFloat2("mvStyleVar_WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); + // ImGui::SliderFloat("mvStyleVar_WindowBorderHoverPadding", &style.WindowBorderHoverPadding, 1.0f, 20.0f, "%.0f"); + // int window_menu_button_position = style.WindowMenuButtonPosition + 1; + // if (ImGui::Combo("mvStyleVar_WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0")) + // style.WindowMenuButtonPosition = (ImGuiDir)(window_menu_button_position - 1); + + ImGui::SeparatorText("Widgets"); + // ImGui::Combo("mvStyleVar_ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); ImGui::SliderFloat2("mvStyleVar_ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); - ImGui::SameLine(); HelpMarker("mvStyleVar_Alignment applies when a button is larger than its text content."); + ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content."); ImGui::SliderFloat2("mvStyleVar_SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); - ImGui::SameLine(); HelpMarker("mvStyleVar_Alignment applies when a selectable is larger than its text content."); - ImGui::Text("Safe Area Padding"); - ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); - ImGui::SliderFloat2("mvStyleVar_DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); + ImGui::SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content."); + ImGui::SliderFloat("mvStyleVar_SeparatorTextBorderSize", &style.SeparatorTextBorderSize, 0.0f, 10.0f, "%.0f"); + ImGui::SliderFloat2("mvStyleVar_SeparatorTextAlign", (float*)&style.SeparatorTextAlign, 0.0f, 1.0f, "%.2f"); + ImGui::SliderFloat2("mvStyleVar_SeparatorTextPadding", (float*)&style.SeparatorTextPadding, 0.0f, 40.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); + ImGui::SliderFloat("mvStyleVar_ImageBorderSize", &style.ImageBorderSize, 0.0f, 1.0f, "%.0f"); + + // ImGui::SeparatorText("Docking"); + // ImGui::Checkbox("mvStyleVar_DockingNodeHasCloseButton", &style.DockingNodeHasCloseButton); + // TODO: it doesn't work anyway if configured within a mvTheme. Uncomment once we make global + // settings work (see #2312) + // ImGui::SliderFloat("mvStyleVar_DockingSeparatorSize", &style.DockingSeparatorSize, 0.0f, 12.0f, "%.0f"); + + // ImGui::SeparatorText("Tooltips"); + // for (int n = 0; n < 2; n++) + // if (ImGui::TreeNodeEx(n == 0 ? "HoverFlagsForTooltipMouse" : "HoverFlagsForTooltipNav")) + // { + // ImGuiHoveredFlags* p = (n == 0) ? &style.HoverFlagsForTooltipMouse : &style.HoverFlagsForTooltipNav; + // ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNone", p, ImGuiHoveredFlags_DelayNone); + // ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayShort", p, ImGuiHoveredFlags_DelayShort); + // ImGui::CheckboxFlags("ImGuiHoveredFlags_DelayNormal", p, ImGuiHoveredFlags_DelayNormal); + // ImGui::CheckboxFlags("ImGuiHoveredFlags_Stationary", p, ImGuiHoveredFlags_Stationary); + // ImGui::CheckboxFlags("ImGuiHoveredFlags_NoSharedDelay", p, ImGuiHoveredFlags_NoSharedDelay); + // ImGui::TreePop(); + // } + + // ImGui::SeparatorText("Misc"); + // ImGui::SliderFloat2("mvStyleVar_DisplayWindowPadding", (float*)&style.DisplayWindowPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to regular windows: amount which we enforce to keep visible when moving near edges of your screen."); + // ImGui::SliderFloat2("mvStyleVar_DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); ImGui::SameLine(); HelpMarker("Apply to every windows, menus, popups, tooltips: amount where we avoid displaying contents. Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); + + ImGui::SeparatorText("AntiAliasing"); + ImGui::Checkbox("AntiAliasedLines", &style.AntiAliasedLines); + ImGui::SameLine(); HelpMarker("These can be set via configure_app."); + ImGui::Checkbox("AntiAliasedLinesUseTex", &style.AntiAliasedLinesUseTex); + ImGui::Checkbox("AntiAliasedFill", &style.AntiAliasedFill); - ImGui::Text("Item Styling"); + ImGui::SeparatorText("Item Styling"); ImGui::SliderFloat("LineWeight", &plotstyle.LineWeight, 0.0f, 5.0f, "%.1f"); ImGui::SliderFloat("MarkerSize", &plotstyle.MarkerSize, 2.0f, 10.0f, "%.1f"); ImGui::SliderFloat("MarkerWeight", &plotstyle.MarkerWeight, 0.0f, 5.0f, "%.1f"); @@ -134,7 +186,7 @@ void mvStyleWindow::drawWidgets() float indent = ImGui::CalcItemWidth() - ImGui::GetFrameHeight(); ImGui::Indent(ImGui::CalcItemWidth() - ImGui::GetFrameHeight()); ImGui::Unindent(indent); - ImGui::Text("Plot Styling"); + ImGui::SeparatorText("Plot Styling"); ImGui::SliderFloat("PlotBorderSize", &plotstyle.PlotBorderSize, 0.0f, 2.0f, "%.0f"); ImGui::SliderFloat("MinorAlpha", &plotstyle.MinorAlpha, 0.0f, 1.0f, "%.2f"); ImGui::SliderFloat2("MajorTickLen", (float*)&plotstyle.MajorTickLen, 0.0f, 20.0f, "%.0f"); @@ -145,7 +197,7 @@ void mvStyleWindow::drawWidgets() ImGui::SliderFloat2("MinorGridSize", (float*)&plotstyle.MinorGridSize, 0.0f, 2.0f, "%.1f"); ImGui::SliderFloat2("PlotDefaultSize", (float*)&plotstyle.PlotDefaultSize, 0.0f, 1000, "%.0f"); ImGui::SliderFloat2("PlotMinSize", (float*)&plotstyle.PlotMinSize, 0.0f, 300, "%.0f"); - ImGui::Text("Plot Padding"); + ImGui::SeparatorText("Plot Padding"); ImGui::SliderFloat2("PlotPadding", (float*)&plotstyle.PlotPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("LabelPadding", (float*)&plotstyle.LabelPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("LegendPadding", (float*)&plotstyle.LegendPadding, 0.0f, 20.0f, "%.0f"); @@ -154,7 +206,7 @@ void mvStyleWindow::drawWidgets() ImGui::SliderFloat2("MousePosPadding", (float*)&plotstyle.MousePosPadding, 0.0f, 20.0f, "%.0f"); ImGui::SliderFloat2("AnnotationPadding", (float*)&plotstyle.AnnotationPadding, 0.0f, 5.0f, "%.0f"); ImGui::SliderFloat2("FitPadding", (float*)&plotstyle.FitPadding, 0, 0.2f, "%.2f"); - ImGui::Text("Nodes"); + ImGui::SeparatorText("Nodes"); ImGui::SliderFloat("mvNodeStyleVar_GridSpacing", &ImNodes::GetStyle().GridSpacing, 0.0f, 32.0f, "%.0f"); ImGui::SliderFloat("mvNodeStyleVar_NodeCornerRounding", &ImNodes::GetStyle().NodeCornerRounding, 0.0f, 10.0f, "%.0f"); ImGui::SliderFloat("mvNodeStyleVar_NodePaddingHorizontal", &ImNodes::GetStyle().NodePadding.x, 0.0f, 10.0f, "%.0f"); @@ -171,8 +223,6 @@ void mvStyleWindow::drawWidgets() ImGui::SliderFloat("mvNodeStyleVar_PinOffset", &ImNodes::GetStyle().PinOffset, 0.0f, 10.0f, "%.0f"); ImGui::SliderFloat2("mvNodesStyleVar_MiniMapPadding", (float*)&ImNodes::GetStyle().MiniMapPadding.x, 0.0f, 10.0f, "%.0f"); ImGui::SliderFloat2("mvNodesStyleVar_MiniMapOffset", (float*)&ImNodes::GetStyle().MiniMapOffset.y, 0.0f, 10.0f, "%.0f"); - ImGui::Text("Tables"); - ImGui::SliderFloat("mvStyleVar_TableAngledHeadersAngle", &style.TableAngledHeadersAngle, -1.0f, +1.0f, "%.2f"); ImGui::EndTabItem(); } @@ -183,16 +233,16 @@ void mvStyleWindow::drawWidgets() static ImGuiTextFilter filter; filter.Draw("Filter colors", ImGui::GetFontSize() * 16); - static ImGuiColorEditFlags alpha_flags = 0; - if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); - if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine(); + static ImGuiColorEditFlags alpha_flags = ImGuiColorEditFlags_AlphaOpaque; + if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_AlphaOpaque)) { alpha_flags = ImGuiColorEditFlags_AlphaOpaque; } ImGui::SameLine(); + if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::SameLine(); HelpMarker( "In the color list:\n" "Left-click on color square to open color picker,\n" "Right-click to open edit options menu."); - ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Border, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); + ImGui::BeginChild("##colors", ImVec2(0, 0), ImGuiChildFlags_Borders | ImGuiChildFlags_NavFlattened, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar); ImGui::PushItemWidth(-300); for (int i = 0; i < ImGuiCol_COUNT; i++) { diff --git a/src/mvTables.cpp b/src/mvTables.cpp index 421d5966e..dccbca868 100644 --- a/src/mvTables.cpp +++ b/src/mvTables.cpp @@ -1,12 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvTables.h" -#include "mvContext.h" + #include "mvCore.h" +#include "mvContext.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvItemHandlers.h" +#include +// For ImHasFlag +#include + mvTableCell::mvTableCell(mvUUID uuid) : mvAppItem(uuid) { @@ -159,10 +166,7 @@ void mvTable::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -181,10 +185,7 @@ void mvTable::draw(ImDrawList* drawlist, float x, float y) apply_local_theming(row); if (row->font) - { - ImFont* fontptr = static_cast(row->font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(row->font.get())->pushFont(); row->state.lastFrameUpdate = GContext->frame; row->state.visible = true; @@ -688,10 +689,7 @@ void mvSyncedTables::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); diff --git a/src/mvTextureItems.cpp b/src/mvTextureItems.cpp index 3b7c33b73..baf606a87 100644 --- a/src/mvTextureItems.cpp +++ b/src/mvTextureItems.cpp @@ -1,5 +1,8 @@ -#include "mvTextureItems.h" #include "mvPyUtils.h" +#pragma hdrstop + +#include "mvTextureItems.h" + #include "mvUtilities.h" mvTextureRegistry::mvTextureRegistry(mvUUID uuid) @@ -30,22 +33,23 @@ void mvTextureRegistry::show_debugger() ImGui::Text("Textures"); - ImGui::BeginChild("##TextureStorageChild", ImVec2(400, 0), ImGuiChildFlags_Border, ImGuiWindowFlags_AlwaysVerticalScrollbar); + ImGui::BeginChild("##TextureStorageChild", ImVec2(400, 0), ImGuiChildFlags_Borders, ImGuiWindowFlags_AlwaysVerticalScrollbar); int index = 0; for (auto& texture : childslots[1]) { - bool status = false; - void* textureRaw = nullptr; - if (texture->type == mvAppItemType::mvStaticTexture) - textureRaw = static_cast(texture.get())->_texture; - else - textureRaw = static_cast(texture.get())->_texture; - - ImGui::Image(textureRaw, ImVec2(25, 25)); - ImGui::SameLine(); - if (ImGui::Selectable(texture->info.internalLabel.c_str(), &status)) - _selection = index; + auto type = texture->type; + if (type == mvAppItemType::mvStaticTexture || + type == mvAppItemType::mvDynamicTexture || + type == mvAppItemType::mvRawTexture) + { + ImTextureRef textureRaw = static_cast(texture.get())->getTexRef(); + ImGui::Image(textureRaw, ImVec2(25, 25)); + ImGui::SameLine(); + bool status = false; + if (ImGui::Selectable(texture->info.internalLabel.c_str(), &status)) + _selection = index; + } ++index; } @@ -66,26 +70,26 @@ void mvTextureRegistry::show_debugger() ImGui::Text("Type: %s", childslots[1][_selection]->type == mvAppItemType::mvStaticTexture ? "static" : "dynamic"); ImGui::EndGroup(); - ImGui::SameLine(); - - void* textureRaw = nullptr; - if (childslots[1][_selection]->type == mvAppItemType::mvStaticTexture) - textureRaw = static_cast(childslots[1][_selection].get())->_texture; - else - textureRaw = static_cast(childslots[1][_selection].get())->_texture; - - ImGui::Image(textureRaw, ImVec2((float)childslots[1][_selection]->config.width, (float)childslots[1][_selection]->config.height)); - - ImPlot::PushStyleColor(ImPlotCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); - if (ImPlot::BeginPlot("##texture plot", ImVec2(-1, -1), - ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_Equal)) + auto type = childslots[1][_selection]->type; + if (type == mvAppItemType::mvStaticTexture || + type == mvAppItemType::mvDynamicTexture || + type == mvAppItemType::mvRawTexture) { - ImPlot::PlotImage(childslots[1][_selection]->info.internalLabel.c_str(), textureRaw, ImPlotPoint(0.0, 0.0), - ImPlotPoint(childslots[1][_selection]->config.width, childslots[1][_selection]->config.height)); - ImPlot::EndPlot(); + ImTextureRef textureRaw = static_cast(childslots[1][_selection].get())->getTexRef(); + + ImGui::SameLine(); + ImGui::Image(textureRaw, ImVec2((float)childslots[1][_selection]->config.width, (float)childslots[1][_selection]->config.height)); + + ImPlot::PushStyleColor(ImPlotCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); + if (ImPlot::BeginPlot("##texture plot", ImVec2(-1, -1), + ImPlotFlags_NoTitle | ImPlotFlags_NoLegend | ImPlotFlags_NoMenus | ImPlotFlags_Equal)) + { + ImPlot::PlotImage(childslots[1][_selection]->info.internalLabel.c_str(), textureRaw, ImPlotPoint(0.0, 0.0), + ImPlotPoint(childslots[1][_selection]->config.width, childslots[1][_selection]->config.height)); + ImPlot::EndPlot(); + } + ImPlot::PopStyleColor(); } - ImPlot::PopStyleColor(); - ImGui::EndGroup(); } @@ -101,9 +105,20 @@ void mvTextureRegistry::show_debugger() ImGui::PopID(); } -mvDynamicTexture::~mvDynamicTexture() +mvTextureItem::~mvTextureItem() { - FreeTexture(_texture); + if (_texture != ImTextureID_Invalid) + FreeTexture(_texture); +} + +ImTextureRef mvTextureItem::getTexRef() const +{ + // Check for any "special" textures that we do not store directly in mvTextureItem + if (uuid == MV_ATLAS_UUID) + return ImGui::GetIO().Fonts->TexRef; + + // Okay now this is indeed a stored texture + return _texture; } PyObject* mvDynamicTexture::getPyValue() @@ -144,7 +159,7 @@ void mvDynamicTexture::draw(ImDrawList* drawlist, float x, float y) _texture = LoadTextureFromArrayDynamic(_permWidth, _permHeight, _value->data()); - if (_texture == nullptr) + if (_texture == ImTextureID_Invalid) state.ok = false; _dirty = false; @@ -209,11 +224,6 @@ void mvRawTexture::setPyValue(PyObject* value) } } -mvRawTexture::~mvRawTexture() -{ - FreeTexture(_texture); -} - void mvRawTexture::draw(ImDrawList* drawlist, float x, float y) { if (_dirty) @@ -225,7 +235,7 @@ void mvRawTexture::draw(ImDrawList* drawlist, float x, float y) if (_componentType == ComponentType::MV_FLOAT_COMPONENT) _texture = LoadTextureFromArrayRaw(_permWidth, _permHeight, (float*)_value, _components); - if (_texture == nullptr) + if (_texture == ImTextureID_Invalid) state.ok = false; _dirty = false; @@ -279,32 +289,29 @@ void mvRawTexture::getSpecificConfiguration(PyObject* dict) return; } -mvStaticTexture::~mvStaticTexture() +void mvStaticTexture::draw(ImDrawList* drawlist, float x, float y) { if (uuid == MV_ATLAS_UUID) + { + // This is a special kind of texture. With the current version of ImGui, it's not + // actually static anymore, as font atlas can be updated or re-created at any + // moment and even the texture ID is not permanent. However, DPG traditionally + // exposed this as a static_texture and we have to retain it for compatibility. + // But, since it can change, we'll be pulling some properties from Fonts every frame. + config.width = ImGui::GetIO().Fonts->TexData->Width; + config.height = ImGui::GetIO().Fonts->TexData->Height; return; - //UnloadTexture(_name); - FreeTexture(_texture); -} + } -void mvStaticTexture::draw(ImDrawList* drawlist, float x, float y) -{ if (!_dirty) return; if (!state.ok) return; - if (uuid == MV_ATLAS_UUID) - { - _texture = ImGui::GetIO().Fonts->TexID; - config.width = ImGui::GetIO().Fonts->TexWidth; - config.height = ImGui::GetIO().Fonts->TexHeight; - } - else - _texture = LoadTextureFromArray(_permWidth, _permHeight, _value->data()); + _texture = LoadTextureFromArray(_permWidth, _permHeight, _value->data()); - if (_texture == nullptr) + if (_texture == ImTextureID_Invalid) { state.ok = false; mvThrowPythonError(mvErrorCode::mvItemNotFound, "add_static_texture", diff --git a/src/mvTextureItems.h b/src/mvTextureItems.h index f86093e1e..ce827adba 100644 --- a/src/mvTextureItems.h +++ b/src/mvTextureItems.h @@ -1,7 +1,8 @@ #pragma once #include "mvItemRegistry.h" -#include "dearpygui.h" +#include "mvPyUtils.h" +#include class mvTextureRegistry : public mvAppItem { @@ -18,13 +19,31 @@ class mvTextureRegistry : public mvAppItem int _selection = -1; }; -class mvStaticTexture : public mvAppItem +class mvTextureItem : public mvAppItem { public: - explicit mvStaticTexture(mvUUID uuid) : mvAppItem(uuid) {} - ~mvStaticTexture(); + explicit mvTextureItem(mvUUID uuid) : mvAppItem(uuid) {} + ~mvTextureItem(); + + // Must be used as a getter instead of directly accessing `_texture`. + // For built-in textures like font atlas this may return a texture other than + // `_texture`, and the texture reference may change between frames. + ImTextureRef getTexRef() const; + +public: + + ImTextureID _texture = ImTextureID_Invalid; +}; + + +class mvStaticTexture : public mvTextureItem +{ + +public: + + explicit mvStaticTexture(mvUUID uuid) : mvTextureItem(uuid) {} void draw(ImDrawList* drawlist, float x, float y) override; void handleSpecificRequiredArgs(PyObject* dict) override; @@ -40,14 +59,13 @@ class mvStaticTexture : public mvAppItem public: std::shared_ptr> _value = std::make_shared>(std::vector{0.0f}); - void* _texture = nullptr; bool _dirty = true; int _permWidth = 0; int _permHeight = 0; }; -class mvRawTexture : public mvAppItem +class mvRawTexture : public mvTextureItem { enum class ComponentType { @@ -57,8 +75,7 @@ class mvRawTexture : public mvAppItem public: - explicit mvRawTexture(mvUUID uuid) : mvAppItem(uuid) {} - ~mvRawTexture(); + explicit mvRawTexture(mvUUID uuid) : mvTextureItem(uuid) {} void draw(ImDrawList* drawlist, float x, float y) override; void handleSpecificRequiredArgs(PyObject* dict) override; @@ -73,7 +90,6 @@ class mvRawTexture : public mvAppItem mvPyObject _buffer = nullptr; void* _value = nullptr; - void* _texture = nullptr; bool _dirty = true; ComponentType _componentType = ComponentType::MV_FLOAT_COMPONENT; int _components = 4; @@ -82,13 +98,12 @@ class mvRawTexture : public mvAppItem }; -class mvDynamicTexture : public mvAppItem +class mvDynamicTexture : public mvTextureItem { public: - explicit mvDynamicTexture(mvUUID uuid) : mvAppItem(uuid) {} - ~mvDynamicTexture(); + explicit mvDynamicTexture(mvUUID uuid) : mvTextureItem(uuid) {} void draw(ImDrawList* drawlist, float x, float y) override; void handleSpecificRequiredArgs(PyObject* dict) override; @@ -104,7 +119,6 @@ class mvDynamicTexture : public mvAppItem public: std::shared_ptr> _value = std::make_shared>(std::vector{0.0f}); - void* _texture = nullptr; bool _dirty = true; int _permWidth = 0; int _permHeight = 0; diff --git a/src/mvThemes.cpp b/src/mvThemes.cpp index b67ada5fc..5a94c2864 100644 --- a/src/mvThemes.cpp +++ b/src/mvThemes.cpp @@ -1,6 +1,10 @@ -#include "mvThemes.h" #include "mvPyUtils.h" +#pragma hdrstop + +#include "mvThemes.h" + #include +#include #include void @@ -358,7 +362,7 @@ struct mvGuiStyleVarInfo static const mvGuiStyleVarInfo GStyleVarInfo[] = { { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha - { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize @@ -377,14 +381,20 @@ static const mvGuiStyleVarInfo GStyleVarInfo[] = { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ScrollbarPadding) }, // ImGuiStyleVar_ScrollbarPadding { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ImageBorderSize) }, // ImGuiStyleVar_ImageBorderSize { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding - { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize - { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize - { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarOverlineSize) }, // ImGuiStyleVar_TabBarOverlineSize - { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersAngle)}, // ImGuiStyleVar_TableAngledHeadersAngle - { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersTextAlign)},// ImGuiStyleVar_TableAngledHeadersTextAlign + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBorderSize) }, // ImGuiStyleVar_TabBorderSize + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabMinWidthBase) }, // ImGuiStyleVar_TabMinWidthBase + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabMinWidthShrink) }, // ImGuiStyleVar_TabMinWidthShrink + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarOverlineSize) }, // ImGuiStyleVar_TabBarOverlineSize + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersAngle)}, // ImGuiStyleVar_TableAngledHeadersAngle + { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, TableAngledHeadersTextAlign)},// ImGuiStyleVar_TableAngledHeadersTextAlign + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TreeLinesSize)}, // ImGuiStyleVar_TreeLinesSize + { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TreeLinesRounding)}, // ImGuiStyleVar_TreeLinesRounding { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, SeparatorTextBorderSize) }, // ImGuiStyleVar_SeparatorTextBorderSize diff --git a/src/mvThemes.h b/src/mvThemes.h index 28a922e42..aaf874420 100644 --- a/src/mvThemes.h +++ b/src/mvThemes.h @@ -1,8 +1,7 @@ #pragma once -#include -#include #include "mvItemRegistry.h" +#include void apply_local_theming(mvAppItem* item); void cleanup_local_theming(mvAppItem* item); diff --git a/src/mvTimePicker.cpp b/src/mvTimePicker.cpp index 8bfeb0c2e..00e619b49 100644 --- a/src/mvTimePicker.cpp +++ b/src/mvTimePicker.cpp @@ -1,15 +1,19 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvTimePicker.h" -#include -#include -#include + #include "mvContext.h" #include "mvItemRegistry.h" -#include "mvPyUtils.h" #include "mvFontItems.h" #include "mvThemes.h" #include "mvContainers.h" #include "mvItemHandlers.h" +#include +#include +#include + void mvTimePicker::draw(ImDrawList* drawlist, float x, float y) { @@ -48,10 +52,7 @@ void mvTimePicker::draw(ImDrawList* drawlist, float x, float y) // push font if a font object is attached if (font) - { - ImFont* fontptr = static_cast(font.get())->getFontPtr(); - ImGui::PushFont(fontptr); - } + static_cast(font.get())->pushFont(); // themes apply_local_theming(this); @@ -85,7 +86,7 @@ void mvTimePicker::draw(ImDrawList* drawlist, float x, float y) // set cursor position to cached position if (info.dirtyPos) - ImGui::SetCursorPos(previousCursorPos); + DearPyGui::RestoreImGuiCursor(previousCursorPos); if (config.indent > 0.0f) ImGui::Unindent(config.indent); diff --git a/src/mvTimePicker.h b/src/mvTimePicker.h index 9aa4fba41..eaac55324 100644 --- a/src/mvTimePicker.h +++ b/src/mvTimePicker.h @@ -1,6 +1,8 @@ #pragma once #include "mvItemRegistry.h" +// For ImPlotTime +#include class mvTimePicker : public mvAppItem { diff --git a/src/mvToolManager.cpp b/src/mvToolManager.cpp index 9494fe43f..8e7cc02c4 100644 --- a/src/mvToolManager.cpp +++ b/src/mvToolManager.cpp @@ -1,5 +1,10 @@ -#include "mvToolManager.h" #include "mvPyUtils.h" +#pragma hdrstop + +#include "mvToolManager.h" + +#include "mvItemRegistry.h" + #include "mvAboutWindow.h" #include "mvDocWindow.h" #include "mvMetricsWindow.h" @@ -9,7 +14,6 @@ #include "mvFontManager.h" #include "mvLayoutWindow.h" #include "mvProfiler.h" -#include "mvItemRegistry.h" std::vector> mvToolManager::s_tools = { std::make_shared(), diff --git a/src/mvToolWindow.cpp b/src/mvToolWindow.cpp index 2f991685d..17711d666 100644 --- a/src/mvToolWindow.cpp +++ b/src/mvToolWindow.cpp @@ -1,4 +1,5 @@ #include "mvToolWindow.h" + #include "mvItemRegistry.h" void mvToolWindow::draw() diff --git a/src/mvUtilities.h b/src/mvUtilities.h index 595ef6731..24aa4a747 100644 --- a/src/mvUtilities.h +++ b/src/mvUtilities.h @@ -10,6 +10,7 @@ #include #include +#include // Need this for ImTextureID #include "mvTypes.h" #ifndef PyObject_HEAD @@ -20,20 +21,20 @@ typedef _object PyObject; struct PymvBuffer; // general -void FreeTexture(void* texture); +void FreeTexture(ImTextureID texture); b8 UnloadTexture(const std::string& filename); // static textures -void* LoadTextureFromFile(const char* filename, i32& width, i32& height); -void* LoadTextureFromArray(u32 width, u32 height, f32* data); +ImTextureID LoadTextureFromFile(const char* filename, i32& width, i32& height); +ImTextureID LoadTextureFromArray(u32 width, u32 height, f32* data); // dynamic textures -void* LoadTextureFromArrayDynamic(u32 width, u32 height, f32* data); -void UpdateTexture(void* texture, u32 width, u32 height, std::vector& data); +ImTextureID LoadTextureFromArrayDynamic(u32 width, u32 height, f32* data); +void UpdateTexture(ImTextureID texture, u32 width, u32 height, std::vector& data); // raw textures -void* LoadTextureFromArrayRaw(u32 width, u32 height, f32* data, i32 components); -void UpdateRawTexture(void* texture, u32 width, u32 height, f32* data, i32 components); +ImTextureID LoadTextureFromArrayRaw(u32 width, u32 height, f32* data, i32 components); +void UpdateRawTexture(ImTextureID texture, u32 width, u32 height, f32* data, i32 components); // framebuffer output void OutputFrameBuffer(const char* filepath); diff --git a/src/mvUtilities_apple.mm b/src/mvUtilities_apple.mm index 79f7c4205..f6e25f1ef 100644 --- a/src/mvUtilities_apple.mm +++ b/src/mvUtilities_apple.mm @@ -1,6 +1,12 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvUtilities.h" + #include "mvViewport.h" +#include "mvAppleSpecifics.h" + #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" @@ -12,8 +18,6 @@ #include #include #include -#include "mvAppleSpecifics.h" -#include "mvPyUtils.h" // this is necessary to keep objective-c's reference counts // from reaching 0. @@ -31,7 +35,7 @@ mvSubmitCallback([](){mvThrowPythonError(mvErrorCode::mvNone, "`output_frame_buffer(...)` has not been implemented for this platform yet.");}); } - void* + ImTextureID LoadTextureFromArray(unsigned width, unsigned height, float* data) { mvGraphics& graphics = GContext->graphics; @@ -47,10 +51,10 @@ g_textures.push_back({texture, texture}); - return (__bridge void*)g_textures.back().second; + return (__bridge ImTextureID)g_textures.back().second; } - void* + ImTextureID LoadTextureFromArrayDynamic(unsigned width, unsigned height, float* data) { mvGraphics& graphics = GContext->graphics; @@ -66,10 +70,10 @@ g_textures.push_back({texture, texture}); - return (__bridge void*)g_textures.back().second; + return (__bridge ImTextureID)g_textures.back().second; } - void* + ImTextureID LoadTextureFromArrayRaw(unsigned width, unsigned height, float* data, int components) { mvGraphics& graphics = GContext->graphics; @@ -85,10 +89,10 @@ g_textures.push_back({texture, texture}); - return (__bridge void*)g_textures.back().second; + return (__bridge ImTextureID)g_textures.back().second; } - void* + ImTextureID LoadTextureFromFile(const char* filename, int& width, int& height) { mvGraphics& graphics = GContext->graphics; @@ -96,7 +100,7 @@ unsigned char* image_data = stbi_load(filename, &width, &height, nullptr, 4); if (image_data == nullptr) - return nullptr; + return ImTextureID_Invalid; MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:width @@ -110,7 +114,7 @@ g_textures.push_back({texture, texture}); - return (__bridge void*)g_textures.back().second; + return (__bridge ImTextureID)g_textures.back().second; } bool @@ -121,7 +125,7 @@ } void -FreeTexture(void* texture) +FreeTexture(ImTextureID texture) { id out_srv = (__bridge id )texture; @@ -136,13 +140,14 @@ } void -UpdateTexture(void* texture, unsigned width, unsigned height, std::vector& data) +UpdateTexture(ImTextureID texture, unsigned width, unsigned height, std::vector& data) { id out_srv = (__bridge id )texture; [out_srv replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:data.data() bytesPerRow:width * 4 * 4]; } - void UpdateRawTexture(void* texture, unsigned width, unsigned height, float* data, int components) + void +UpdateRawTexture(ImTextureID texture, unsigned width, unsigned height, float* data, int components) { id out_srv = (__bridge id )texture; [out_srv replaceRegion:MTLRegionMake2D(0, 0, width, height) mipmapLevel:0 withBytes:data bytesPerRow:width * components * 4]; diff --git a/src/mvUtilities_linux.cpp b/src/mvUtilities_linux.cpp index b26ef1ff6..f1e0a02eb 100644 --- a/src/mvUtilities_linux.cpp +++ b/src/mvUtilities_linux.cpp @@ -1,5 +1,14 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvUtilities.h" +#include "mvLinuxSpecifics.h" + +#include "mvContext.h" +#include "mvViewport.h" +#include "mvCustomTypes.h" + #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" @@ -11,11 +20,6 @@ #include #include #include -#include "mvContext.h" -#include "mvLinuxSpecifics.h" -#include "mvViewport.h" -#include "mvPyUtils.h" -#include "mvCustomTypes.h" static std::unordered_map PBO_ids; @@ -88,7 +92,7 @@ OutputFrameBuffer(const char* filepath) free(data); } - void* + ImTextureID LoadTextureFromArray(unsigned width, unsigned height, float* data) { @@ -105,10 +109,10 @@ LoadTextureFromArray(unsigned width, unsigned height, float* data) glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, data); - return reinterpret_cast(image_texture); + return image_texture; } - void* + ImTextureID LoadTextureFromArrayDynamic(unsigned width, unsigned height, float* data) { @@ -132,10 +136,10 @@ LoadTextureFromArrayDynamic(unsigned width, unsigned height, float* data) glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); PBO_ids[image_texture] = pboid; - return reinterpret_cast(image_texture); + return image_texture; } - void* + ImTextureID LoadTextureFromArrayRaw(unsigned width, unsigned height, float* data, int components) { @@ -162,10 +166,10 @@ LoadTextureFromArrayRaw(unsigned width, unsigned height, float* data, int compon glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); PBO_ids[image_texture] = pboid; - return reinterpret_cast(image_texture); + return image_texture; } - void* + ImTextureID LoadTextureFromFile(const char* filename, int& width, int& height) { @@ -174,7 +178,7 @@ LoadTextureFromFile(const char* filename, int& width, int& height) int image_height = 0; unsigned char* image_data = stbi_load(filename, &image_width, &image_height, nullptr, 4); if (image_data == nullptr) - return nullptr; + return ImTextureID_Invalid; // Create a OpenGL texture identifier GLuint image_texture; @@ -193,7 +197,7 @@ LoadTextureFromFile(const char* filename, int& width, int& height) width = image_width; height = image_height; - return reinterpret_cast(image_texture);; + return image_texture; } bool @@ -204,9 +208,9 @@ UnloadTexture(const std::string& filename) } void -FreeTexture(void* texture) +FreeTexture(ImTextureID texture) { - auto out_srv = (GLuint)(size_t)texture; + GLuint out_srv = texture; if(PBO_ids.count(out_srv) != 0) PBO_ids.erase(out_srv); @@ -215,9 +219,9 @@ FreeTexture(void* texture) } void -UpdateTexture(void* texture, unsigned width, unsigned height, std::vector& data) +UpdateTexture(ImTextureID texture, unsigned width, unsigned height, std::vector& data) { - auto textureId = (GLuint)(size_t)texture; + GLuint textureId = texture; // start to copy from PBO to texture object /////// @@ -262,9 +266,9 @@ UpdateTexture(void* texture, unsigned width, unsigned height, std::vector } void -UpdateRawTexture(void* texture, unsigned width, unsigned height, float* data, int components) +UpdateRawTexture(ImTextureID texture, unsigned width, unsigned height, float* data, int components) { - auto textureId = (GLuint)(size_t)texture; + GLuint textureId = texture; // start to copy from PBO to texture object /////// diff --git a/src/mvUtilities_win32.cpp b/src/mvUtilities_win32.cpp index 4f59b69ca..989f1ff53 100644 --- a/src/mvUtilities_win32.cpp +++ b/src/mvUtilities_win32.cpp @@ -1,6 +1,11 @@ #include "mvUtilities.h" + #include "mvViewport.h" +#include "mvWindowsSpecifics.h" + +#include "mvCustomTypes.h" + #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" @@ -16,8 +21,6 @@ #include #include #include -#include "mvWindowsSpecifics.h" -#include "mvCustomTypes.h" namespace fs = std::filesystem; @@ -44,10 +47,10 @@ OutputFrameBufferArray(PymvBuffer* out) out->arr.length = description.Width * description.Height * 4; unsigned char* data = new unsigned char[out->arr.length]; f32* tdata = new f32[out->arr.length]; - for (int row = 0; row < description.Height; row++) + for (uint32_t row = 0; row < description.Height; row++) { unsigned char* src = &(((unsigned char*)resource.pData)[row * resource.RowPitch]); - for (int j = 0; j < description.Width*4; j++) + for (uint32_t j = 0; j < description.Width*4; j++) tdata[row * description.Width*4 + j] = src[j] / 255.0f; } out->arr.data = tdata; @@ -88,7 +91,7 @@ OutputFrameBuffer(const char* filepath) } - void* + ImTextureID LoadTextureFromFile(const char* filename, int& width, int& height) { @@ -102,7 +105,7 @@ LoadTextureFromFile(const char* filename, int& width, int& height) int image_height = 0; unsigned char* image_data = stbi_load(filename, &image_width, &image_height, NULL, 4); if (image_data == NULL) - return nullptr; + return ImTextureID_Invalid; // Create texture D3D11_TEXTURE2D_DESC desc; @@ -141,7 +144,7 @@ LoadTextureFromFile(const char* filename, int& width, int& height) return out_srv; } - void* + ImTextureID LoadTextureFromArray(unsigned width, unsigned height, float* data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; @@ -180,7 +183,7 @@ LoadTextureFromArray(unsigned width, unsigned height, float* data) return out_srv; } - void* + ImTextureID LoadTextureFromArray(unsigned width, unsigned height, int* data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; @@ -219,7 +222,7 @@ LoadTextureFromArray(unsigned width, unsigned height, int* data) return out_srv; } - void* + ImTextureID LoadTextureFromArrayDynamic(unsigned width, unsigned height, float* data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; @@ -258,7 +261,7 @@ LoadTextureFromArrayDynamic(unsigned width, unsigned height, float* data) return out_srv; } - void* + ImTextureID LoadTextureFromArrayDynamic(unsigned width, unsigned height, int* data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; @@ -298,7 +301,7 @@ LoadTextureFromArrayDynamic(unsigned width, unsigned height, int* data) } void -UpdateTexture(void* texture, unsigned width, unsigned height, std::vector& data) +UpdateTexture(ImTextureID texture, unsigned width, unsigned height, std::vector& data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; ID3D11ShaderResourceView* view = (ID3D11ShaderResourceView*)texture; @@ -327,7 +330,7 @@ UpdateTexture(void* texture, unsigned width, unsigned height, std::vector } void -UpdateTexture(void* texture, unsigned width, unsigned height, std::vector& data) +UpdateTexture(ImTextureID texture, unsigned width, unsigned height, std::vector& data) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; ID3D11ShaderResourceView* view = (ID3D11ShaderResourceView*)texture; @@ -356,7 +359,7 @@ UpdateTexture(void* texture, unsigned width, unsigned height, std::vector& } void -UpdateRawTexture(void* texture, unsigned width, unsigned height, float* data, int components) +UpdateRawTexture(ImTextureID texture, unsigned width, unsigned height, float* data, int components) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; ID3D11ShaderResourceView* view = (ID3D11ShaderResourceView*)texture; @@ -384,7 +387,7 @@ UpdateRawTexture(void* texture, unsigned width, unsigned height, float* data, in resource->Release(); } - void* + ImTextureID LoadTextureFromArrayRaw(unsigned width, unsigned height, float* data, int components) { mvGraphics_D3D11* graphicsData = (mvGraphics_D3D11*)GContext->graphics.backendSpecifics; @@ -438,13 +441,11 @@ LoadTextureFromArrayRaw(unsigned width, unsigned height, float* data, int compon } void -FreeTexture(void* texture) +FreeTexture(ImTextureID texture) { ID3D11ShaderResourceView* out_srv = static_cast(texture); if (out_srv) auto count = out_srv->Release(); - - texture = nullptr; } bool diff --git a/src/mvValues.cpp b/src/mvValues.cpp index 686a76e4f..18e6cc772 100644 --- a/src/mvValues.cpp +++ b/src/mvValues.cpp @@ -1,9 +1,12 @@ +#include "mvPyUtils.h" +#pragma hdrstop + #include "mvValues.h" -#include + #include "mvContext.h" -#include "dearpygui.h" + +#include #include -#include "mvPyUtils.h" PyObject* mvBoolValue::getPyValue() { diff --git a/src/mvValues.h b/src/mvValues.h index 8dbed0ee0..7807df74b 100644 --- a/src/mvValues.h +++ b/src/mvValues.h @@ -2,7 +2,6 @@ #include "mvAppItem.h" #include "mvItemRegistry.h" -#include "dearpygui.h" #include #include diff --git a/src/mvViewport_apple.mm b/src/mvViewport_apple.mm index c2f06e745..a448ae6c8 100644 --- a/src/mvViewport_apple.mm +++ b/src/mvViewport_apple.mm @@ -1,10 +1,12 @@ #include "mvViewport.h" -#include -#include "imnodes.h" -#include "mvToolManager.h" -#include "mvFontManager.h" + #include "mvAppleSpecifics.h" +#include "mvFontManager.h" +#include "mvToolManager.h" + +#include +#include "imnodes.h" #include "imgui.h" #include "imgui_impl_glfw.h" #include "imgui_impl_metal.h" @@ -215,13 +217,7 @@ { // Font manager is thread-unsafe, so we'd better sync it std::lock_guard lk(GContext->mutex); - if (mvToolManager::GetFontManager().isInvalid()) - { - mvToolManager::GetFontManager().rebuildAtlas(); - ImGui_ImplMetal_DestroyFontsTexture(); - mvToolManager::GetFontManager().updateAtlas(); - ImGui_ImplMetal_CreateFontsTexture(graphicsData->device); - } + mvToolManager::GetFontManager().updateAtlas(); } NSWindow *nswin = glfwGetCocoaWindow(viewportData->handle); diff --git a/src/mvViewport_linux.cpp b/src/mvViewport_linux.cpp index 84e1db5d2..a79618810 100644 --- a/src/mvViewport_linux.cpp +++ b/src/mvViewport_linux.cpp @@ -1,6 +1,10 @@ #include "mvViewport.h" -#include "mvFontManager.h" + #include "mvLinuxSpecifics.h" + +#include "mvFontManager.h" +#include "mvToolManager.h" + #include "implot.h" #include "imgui.h" #include "imnodes.h" @@ -9,7 +13,6 @@ #include "imgui_impl_opengl3.h" #include #include -#include "mvToolManager.h" static void glfw_error_callback(int error, const char* description) @@ -92,12 +95,7 @@ mvPrerender() else glfwPollEvents(); - if (mvToolManager::GetFontManager().isInvalid()) - { - mvToolManager::GetFontManager().rebuildAtlas(); - ImGui_ImplOpenGL3_DestroyDeviceObjects(); - mvToolManager::GetFontManager().updateAtlas(); - } + mvToolManager::GetFontManager().updateAtlas(); // Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); diff --git a/src/mvViewport_win32.cpp b/src/mvViewport_win32.cpp index 146b6c6ff..1d6b933f6 100644 --- a/src/mvViewport_win32.cpp +++ b/src/mvViewport_win32.cpp @@ -85,13 +85,7 @@ StartNewFrame() { // Font manager is thread-unsafe, so we'd better sync it std::lock_guard lk(GContext->mutex); - - if (mvToolManager::GetFontManager().isInvalid()) - { - mvToolManager::GetFontManager().rebuildAtlas(); - ImGui_ImplDX11_InvalidateDeviceObjects(); - mvToolManager::GetFontManager().updateAtlas(); - } + mvToolManager::GetFontManager().updateAtlas(); // Start the Dear ImGui frame ImGui_ImplDX11_NewFrame(); @@ -476,13 +470,13 @@ mvToggleFullScreen(mvViewport& viewport) { mvViewportData* viewportData = (mvViewportData*)viewport.platformSpecifics; - static size_t storedWidth = 0; - static size_t storedHeight = 0; - static int storedXPos = 0; - static int storedYPos = 0; + static i32 storedWidth = 0; + static i32 storedHeight = 0; + static i32 storedXPos = 0; + static i32 storedYPos = 0; - size_t width = GetSystemMetrics(SM_CXSCREEN); - size_t height = GetSystemMetrics(SM_CYSCREEN); + int width = GetSystemMetrics(SM_CXSCREEN); + int height = GetSystemMetrics(SM_CYSCREEN); if (viewport.fullScreen) { diff --git a/thirdparty/DearPyGui_Ext/dearpygui_ext/themes.py b/thirdparty/DearPyGui_Ext/dearpygui_ext/themes.py index 3bee00701..0d8b8ee7b 100644 --- a/thirdparty/DearPyGui_Ext/dearpygui_ext/themes.py +++ b/thirdparty/DearPyGui_Ext/dearpygui_ext/themes.py @@ -38,11 +38,14 @@ def create_theme_imgui_dark() -> Union[str, int]: dpg.add_theme_color(dpg.mvThemeCol_ResizeGrip , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.20 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ResizeGripHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.67 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ResizeGripActive , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.95 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_Tab , (0.18 * 255, 0.35 * 255, 0.58 * 255, 0.86 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_InputTextCursor , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TabHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.80 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabActive , (0.20 * 255, 0.41 * 255, 0.68 * 255, 1.00 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabUnfocused , (0.07 * 255, 0.10 * 255, 0.15 * 255, 0.97 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabUnfocusedActive , (0.14 * 255, 0.26 * 255, 0.42 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Tab , (0.18 * 255, 0.35 * 255, 0.58 * 255, 0.86 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelected , (0.20 * 255, 0.41 * 255, 0.68 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelectedOverline , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmed , (0.07 * 255, 0.10 * 255, 0.15 * 255, 0.97 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelected , (0.14 * 255, 0.26 * 255, 0.42 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelectedOverline, (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DockingPreview , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.70 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DockingEmptyBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 1.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_PlotLines , (0.61 * 255, 0.61 * 255, 0.61 * 255, 1.00 * 255)) @@ -55,8 +58,11 @@ def create_theme_imgui_dark() -> Union[str, int]: dpg.add_theme_color(dpg.mvThemeCol_TableRowBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TableRowBgAlt , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.06 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TextSelectedBg , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.35 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TreeLines , (0.43 * 255, 0.43 * 255, 0.50 * 255, 0.50 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DragDropTarget , (1.00 * 255, 1.00 * 255, 0.00 * 255, 0.90 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_NavHighlight , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DragDropTargetBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_UnsavedMarker , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_NavCursor , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_NavWindowingHighlight , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.70 * 255)) dpg.add_theme_color(dpg.mvThemeCol_NavWindowingDimBg , (0.80 * 255, 0.80 * 255, 0.80 * 255, 0.20 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ModalWindowDimBg , (0.80 * 255, 0.80 * 255, 0.80 * 255, 0.35 * 255)) @@ -68,29 +74,148 @@ def create_theme_imgui_dark() -> Union[str, int]: dpg.add_theme_color(dpg.mvPlotCol_LegendText , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) dpg.add_theme_color(dpg.mvPlotCol_TitleText , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) dpg.add_theme_color(dpg.mvPlotCol_InlayText , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBgActive , (0.06 * 255, 0.53 * 255, 0.98 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBgHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisGrid , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) dpg.add_theme_color(dpg.mvPlotCol_AxisText , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisGrid , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.25 * 255), category=dpg.mvThemeCat_Plots) dpg.add_theme_color(dpg.mvPlotCol_Selection , (1.00 * 255, 0.60 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) dpg.add_theme_color(dpg.mvPlotCol_Crosshairs , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.50 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackground, (50, 50, 50, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered, (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected, (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeOutline, (100, 100, 100, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBar, (41, 74, 122, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered, (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected, (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_Link, (61, 133, 224, 200), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_LinkHovered, (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_LinkSelected, (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_Pin, (53, 150, 250, 180), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_PinHovered, (53, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_BoxSelector, (61, 133, 224, 30), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_BoxSelectorOutline, (61, 133, 224, 150), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_GridBackground, (40, 40, 50, 200), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_GridLine, (200, 200, 200, 40), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackground , (50, 50, 50, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered , (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected , (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeOutline , (100, 100, 100, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBar , (41, 74, 122, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Link , (61, 133, 224, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkHovered , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkSelected , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Pin , (53, 150, 250, 180), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_PinHovered , (53, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelector , (61, 133, 224, 30), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelectorOutline , (61, 133, 224, 150), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridBackground , (40, 40, 50, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridLine , (200, 200, 200, 40), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_GridLinePrimary , (240, 240, 240, 60), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackground , (25, 25, 25, 150), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackgroundHovered, (25, 25, 25, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutline , (150, 150, 150, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutlineHovered , (150, 150, 150, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackground , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackgroundHovered, (200, 200, 200, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackgroundSelected, (200, 200, 200, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeOutline , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLink , (61, 133, 224, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLinkSelected , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvas , (200, 200, 200, 25), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvasOutline , (200, 200, 200, 200), category=dpg.mvThemeCat_Nodes) + + return theme_id + +def create_theme_imgui_classic() -> Union[str, int]: + + with dpg.theme() as theme_id: + with dpg.theme_component(0): + dpg.add_theme_color(dpg.mvThemeCol_Text , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TextDisabled , (0.60 * 255, 0.60 * 255, 0.60 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_WindowBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.85 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ChildBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_PopupBg , (0.11 * 255, 0.11 * 255, 0.14 * 255, 0.92 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Border , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.50 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_BorderShadow , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_FrameBg , (0.43 * 255, 0.43 * 255, 0.43 * 255, 0.39 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_FrameBgHovered , (0.47 * 255, 0.47 * 255, 0.69 * 255, 0.40 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_FrameBgActive , (0.42 * 255, 0.41 * 255, 0.64 * 255, 0.69 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TitleBg , (0.27 * 255, 0.27 * 255, 0.54 * 255, 0.83 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TitleBgActive , (0.32 * 255, 0.32 * 255, 0.63 * 255, 0.87 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TitleBgCollapsed , (0.40 * 255, 0.40 * 255, 0.80 * 255, 0.20 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_MenuBarBg , (0.40 * 255, 0.40 * 255, 0.55 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ScrollbarBg , (0.20 * 255, 0.25 * 255, 0.30 * 255, 0.60 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrab , (0.40 * 255, 0.40 * 255, 0.80 * 255, 0.30 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrabHovered , (0.40 * 255, 0.40 * 255, 0.80 * 255, 0.40 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ScrollbarGrabActive , (0.41 * 255, 0.39 * 255, 0.80 * 255, 0.60 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_CheckMark , (0.90 * 255, 0.90 * 255, 0.90 * 255, 0.50 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_SliderGrab , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.30 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_SliderGrabActive , (0.41 * 255, 0.39 * 255, 0.80 * 255, 0.60 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Button , (0.35 * 255, 0.40 * 255, 0.61 * 255, 0.62 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ButtonHovered , (0.40 * 255, 0.48 * 255, 0.71 * 255, 0.79 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ButtonActive , (0.46 * 255, 0.54 * 255, 0.80 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Header , (0.40 * 255, 0.40 * 255, 0.90 * 255, 0.45 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_HeaderHovered , (0.45 * 255, 0.45 * 255, 0.90 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_HeaderActive , (0.53 * 255, 0.53 * 255, 0.87 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Separator , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.60 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_SeparatorHovered , (0.60 * 255, 0.60 * 255, 0.70 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_SeparatorActive , (0.70 * 255, 0.70 * 255, 0.90 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ResizeGrip , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.10 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ResizeGripHovered , (0.78 * 255, 0.82 * 255, 1.00 * 255, 0.60 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ResizeGripActive , (0.78 * 255, 0.82 * 255, 1.00 * 255, 0.90 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_InputTextCursor , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabHovered , (0.45 * 255, 0.45 * 255, 0.90 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Tab , (0.34 * 255, 0.34 * 255, 0.68 * 255, 0.79 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelected , (0.40 * 255, 0.40 * 255, 0.73 * 255, 0.84 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelectedOverline , (0.53 * 255, 0.53 * 255, 0.87 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmed , (0.28 * 255, 0.28 * 255, 0.57 * 255, 0.82 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelected , (0.35 * 255, 0.35 * 255, 0.65 * 255, 0.84 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelectedOverline, (0.53 * 255, 0.53 * 255, 0.87 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DockingPreview , (0.40 * 255, 0.40 * 255, 0.90 * 255, 0.32 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DockingEmptyBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_PlotLines , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_PlotLinesHovered , (0.90 * 255, 0.70 * 255, 0.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_PlotHistogram , (0.90 * 255, 0.70 * 255, 0.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_PlotHistogramHovered , (1.00 * 255, 0.60 * 255, 0.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TableHeaderBg , (0.27 * 255, 0.27 * 255, 0.38 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TableBorderStrong , (0.31 * 255, 0.31 * 255, 0.45 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TableBorderLight , (0.26 * 255, 0.26 * 255, 0.28 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TableRowBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TableRowBgAlt , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.07 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TextSelectedBg , (0.00 * 255, 0.00 * 255, 1.00 * 255, 0.35 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TreeLines , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.50 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DragDropTarget , (1.00 * 255, 1.00 * 255, 0.00 * 255, 0.90 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DragDropTargetBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_UnsavedMarker , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_NavCursor , (0.45 * 255, 0.45 * 255, 0.90 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_NavWindowingHighlight , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.70 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_NavWindowingDimBg , (0.80 * 255, 0.80 * 255, 0.80 * 255, 0.20 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_ModalWindowDimBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 0.35 * 255)) + dpg.add_theme_color(dpg.mvPlotCol_ErrorBar , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_FrameBg , (0.43 * 255, 0.43 * 255, 0.43 * 255, 0.39 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_PlotBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.35 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_PlotBorder , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.50 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendBg , (0.11 * 255, 0.11 * 255, 0.14 * 255, 0.92 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendBorder , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.50 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendText , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_TitleText , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_InlayText , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisText , (0.90 * 255, 0.90 * 255, 0.90 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisGrid , (0.90 * 255, 0.90 * 255, 0.90 * 255, 0.25 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_Selection , (0.97 * 255, 0.97 * 255, 0.39 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_Crosshairs , (0.50 * 255, 0.50 * 255, 0.50 * 255, 0.75 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackground , (50, 50, 50, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered , (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected , (75, 75, 75, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeOutline , (100, 100, 100, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBar , (69, 69, 138, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered , (82, 82, 161, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected , (82, 82, 161, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Link , (255, 255, 255, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkHovered , (105, 99, 204, 153), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkSelected , (105, 99, 204, 153), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Pin , (89, 102, 156, 170), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_PinHovered , (102, 122, 179, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelector , (82, 82, 161, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelectorOutline , (82, 82, 161, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridBackground , (40, 40, 50, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridLine , (200, 200, 200, 40), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_GridLinePrimary , (240, 240, 240, 60), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackground , (25, 25, 25, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackgroundHovered, (25, 25, 25, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutline , (150, 150, 150, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutlineHovered , (150, 150, 150, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackground , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackgroundSelected, (200, 200, 240, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeOutline , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLink , (255, 255, 255, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLinkSelected , (105, 99, 204, 153), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvas , (200, 200, 200, 25), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvasOutline , (200, 200, 200, 200), category=dpg.mvThemeCat_Nodes) return theme_id @@ -131,11 +256,14 @@ def create_theme_imgui_light() -> Union[str, int]: dpg.add_theme_color(dpg.mvThemeCol_ResizeGrip , (0.35 * 255, 0.35 * 255, 0.35 * 255, 0.17 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ResizeGripHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.67 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ResizeGripActive , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.95 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_Tab , (0.76 * 255, 0.80 * 255, 0.84 * 255, 0.93 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_InputTextCursor , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TabHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.80 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabActive , (0.60 * 255, 0.73 * 255, 0.88 * 255, 1.00 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabUnfocused , (0.92 * 255, 0.93 * 255, 0.94 * 255, 0.99 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_TabUnfocusedActive , (0.74 * 255, 0.82 * 255, 0.91 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_Tab , (0.76 * 255, 0.80 * 255, 0.84 * 255, 0.93 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelected , (0.60 * 255, 0.73 * 255, 0.88 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabSelectedOverline , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmed , (0.92 * 255, 0.93 * 255, 0.94 * 255, 0.99 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelected , (0.74 * 255, 0.82 * 255, 0.91 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TabDimmedSelectedOverline, (0.26 * 255, 0.59 * 255, 1.00 * 255, 0.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DockingPreview , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.22 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DockingEmptyBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 1.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_PlotLines , (0.39 * 255, 0.39 * 255, 0.39 * 255, 1.00 * 255)) @@ -148,42 +276,55 @@ def create_theme_imgui_light() -> Union[str, int]: dpg.add_theme_color(dpg.mvThemeCol_TableRowBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TableRowBgAlt , (0.30 * 255, 0.30 * 255, 0.30 * 255, 0.09 * 255)) dpg.add_theme_color(dpg.mvThemeCol_TextSelectedBg , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.35 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_TreeLines , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.30 * 255)) dpg.add_theme_color(dpg.mvThemeCol_DragDropTarget , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.95 * 255)) - dpg.add_theme_color(dpg.mvThemeCol_NavHighlight , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.80 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_DragDropTargetBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_UnsavedMarker , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255)) + dpg.add_theme_color(dpg.mvThemeCol_NavCursor , (0.26 * 255, 0.59 * 255, 0.98 * 255, 0.80 * 255)) dpg.add_theme_color(dpg.mvThemeCol_NavWindowingHighlight , (0.70 * 255, 0.70 * 255, 0.70 * 255, 0.70 * 255)) dpg.add_theme_color(dpg.mvThemeCol_NavWindowingDimBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 0.20 * 255)) dpg.add_theme_color(dpg.mvThemeCol_ModalWindowDimBg , (0.20 * 255, 0.20 * 255, 0.20 * 255, 0.35 * 255)) - dpg.add_theme_color(dpg.mvPlotCol_FrameBg , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_PlotBg , (0.42 * 255, 0.57 * 255, 1.00 * 255, 0.13 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_PlotBorder , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_LegendBg , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.98 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_LegendBorder , (0.82 * 255, 0.82 * 255, 0.82 * 255, 0.80 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_LegendText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_TitleText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_InlayText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBg , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBgActive , (0.06 * 255, 0.53 * 255, 0.98 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisBgHovered , (0.26 * 255, 0.59 * 255, 0.98 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisGrid , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_AxisText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_Selection , (0.82 * 255, 0.64 * 255, 0.03 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvPlotCol_Crosshairs , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.50 * 255), category=dpg.mvThemeCat_Plots) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackground, (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered, (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected, (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_NodeOutline, (100, 100, 100, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBar, (248, 248, 248, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered, (209, 209, 209, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected, (209, 209, 209, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_Link, (66, 150, 250, 100), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_LinkHovered, (66, 150, 250, 242), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_LinkSelected, (66, 150, 250, 242), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_Pin, (66, 150, 250, 160), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_PinHovered, (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_BoxSelector, (90, 170, 250, 30), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_BoxSelectorOutline, (90, 170, 250, 150), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_GridBackground, (225, 225, 225, 255), category=dpg.mvThemeCat_Nodes) - dpg.add_theme_color(dpg.mvNodeCol_GridLine, (180, 180, 180, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvPlotCol_FrameBg , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_PlotBg , (0.42 * 255, 0.57 * 255, 1.00 * 255, 0.13 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_PlotBorder , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendBg , (1.00 * 255, 1.00 * 255, 1.00 * 255, 0.98 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendBorder , (0.82 * 255, 0.82 * 255, 0.82 * 255, 0.80 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_LegendText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_TitleText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_InlayText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisText , (0.00 * 255, 0.00 * 255, 0.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisGrid , (1.00 * 255, 1.00 * 255, 1.00 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_AxisTick , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.25 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_Selection , (0.82 * 255, 0.64 * 255, 0.03 * 255, 1.00 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvPlotCol_Crosshairs , (0.00 * 255, 0.00 * 255, 0.00 * 255, 0.50 * 255), category=dpg.mvThemeCat_Plots) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackground , (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundHovered , (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeBackgroundSelected , (240, 240, 240, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_NodeOutline , (100, 100, 100, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBar , (248, 248, 248, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarHovered , (209, 209, 209, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_TitleBarSelected , (209, 209, 209, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Link , (66, 150, 250, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkHovered , (66, 150, 250, 242), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_LinkSelected , (66, 150, 250, 242), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_Pin , (66, 150, 250, 160), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_PinHovered , (66, 150, 250, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelector , (90, 170, 250, 30), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_BoxSelectorOutline , (90, 170, 250, 150), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridBackground , (225, 225, 225, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodeCol_GridLine , (180, 180, 180, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_GridLinePrimary , (120, 120, 120, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackground , (25, 25, 25, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapBackgroundHovered, (25, 25, 25, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutline , (150, 150, 150, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapOutlineHovered , (150, 150, 150, 200), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackground , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeBackgroundSelected, (200, 200, 240, 255), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapNodeOutline , (200, 200, 200, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLink , (66, 150, 250, 100), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapLinkSelected , (66, 150, 250, 242), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvas , (200, 200, 200, 25), category=dpg.mvThemeCat_Nodes) + dpg.add_theme_color(dpg.mvNodesCol_MiniMapCanvasOutline , (200, 200, 200, 200), category=dpg.mvThemeCat_Nodes) return theme_id diff --git a/thirdparty/DearPyGui_Ext/dearpygui_ext/utilities.py b/thirdparty/DearPyGui_Ext/dearpygui_ext/utilities.py index e33a7ef87..025cbb0b9 100644 --- a/thirdparty/DearPyGui_Ext/dearpygui_ext/utilities.py +++ b/thirdparty/DearPyGui_Ext/dearpygui_ext/utilities.py @@ -103,8 +103,8 @@ def get_item_tree(item: ItemT, descendants_only: bool = False) -> List[Union[Ite Table items (only `mvAppItemType::Table`) are represented as a 3-item list `[table_item, [rows], [columns]]`. - `mvFileExtension`, `mvFontRangeHint`, `mvNodeLink`, `mvAnnotation`, `mvDragLine`, - `mvDragPoint`, `mvDragPayload`, and `mvLegend` items are excluded from the tree. + `mvFileExtension`, `mvNodeLink`, `mvAnnotation`, `mvDragLine`, `mvDragPoint`, + `mvDragPayload`, and `mvLegend` items are excluded from the tree. Args: * item (int | str): The tag of an item. diff --git a/thirdparty/DearPyGui_Ext/scripts/GenThemes.py b/thirdparty/DearPyGui_Ext/scripts/GenThemes.py new file mode 100644 index 000000000..b032aea9e --- /dev/null +++ b/thirdparty/DearPyGui_Ext/scripts/GenThemes.py @@ -0,0 +1,143 @@ +# Takes themes from from imgui_draw.cpp, converts them to DPG themes, and stores in themes.py + +from pathlib import Path +import re +from string import Template +from typing import Any, Dict, Set, Tuple, Union + +imgui_draw = Path(__file__).parent.parent.parent / "imgui" / "imgui_draw.cpp" +implot = Path(__file__).parent.parent.parent / "implot" / "implot.cpp" +imnodes = Path(__file__).parent.parent.parent / "imnodes" / "imnodes.cpp" +themes_py = Path(__file__).parent.parent / "dearpygui_ext" / "themes.py" + +main_template = Template(""" +from typing import List, Any, Callable, Union, Tuple +import dearpygui.dearpygui as dpg + +$themes +""".lstrip()) + +theme_template = Template(""" +def create_theme_imgui_$name() -> Union[str, int]: + + with dpg.theme() as theme_id: + with dpg.theme_component(0): +$colors + + return theme_id +""".lstrip()) + + +def parse_color(expr: str, colors: Dict[str, Any]) -> Tuple[Union[float, int], ...]: + expr = re.sub(r"(\d+\.\d*)f", r"\1", expr) + expr = expr.replace("dest->Colors", "colors") + # Turn constants into quoted strings + expr = re.sub(r"((?:ImGuiCol|ImPlotCol|ImNodesCol)_\w+)", r'"\1"', expr) + # We could have defined a multiplication operator in Python but this would require + # a class for color object where we can override __mul__... it's easier to store + # colors as tuples. + expr = re.sub(r"(.*?)\*(.*)", r"multiply(\1, \2)", expr) + + # Helper definitions. Yep I know it would be better to use a safer method than exec() + # but I needed to craft a script quickly, and I do trust Omar's C code :). + def ImVec4(x, y, z, w): + return (x, y, z, w) + + def IM_COL32(x, y, z, w): + # Unlike ImVec4, this returns a tuple of int's... and it must never be used in ImLerp or multiplication + return (x, y, z, w) + + def ImLerp(col_a, col_b, k): + return tuple([(a + k*(b - a)) for a, b in zip(col_a, col_b)]) + + def multiply(col_a, col_b): + return tuple([(a * b) for a, b in zip(col_a, col_b)]) + + IMPLOT_AUTO_COL = None + + return eval(expr, None, locals()) + + +def convert_colors(source: str) -> Dict[str, Tuple[Union[float, int], ...]]: + colors = { name: value for name, value in re.findall(r"(?:colors|dest->Colors)\[((?:ImGuiCol|ImPlotCol|ImNodesCol)_.*?)\]\s*=\s*(.*?);", source, re.DOTALL) } + # Let's try to "compute" the values + for name, value in colors.items(): + colors[name] = parse_color(value, colors) + return colors + + +def format_color(color: Tuple[Union[float, int], ...]) -> str: + return ", ".join([ + (f"{c:.2f} * 255" if isinstance(c, float) else str(c)) + for c in color + ]) + + +OLD_NODE_COLORS: Set[str] = { + "mvNodesCol_NodeBackground", + "mvNodesCol_NodeBackgroundHovered", + "mvNodesCol_NodeBackgroundSelected", + "mvNodesCol_NodeOutline", + "mvNodesCol_TitleBar", + "mvNodesCol_TitleBarHovered", + "mvNodesCol_TitleBarSelected", + "mvNodesCol_Link", + "mvNodesCol_LinkHovered", + "mvNodesCol_LinkSelected", + "mvNodesCol_Pin", + "mvNodesCol_PinHovered", + "mvNodesCol_BoxSelector", + "mvNodesCol_BoxSelectorOutline", + "mvNodesCol_GridBackground", + "mvNodesCol_GridLine", +} + +def format_color_line(name: str, color: Tuple[Union[float, int], ...]) -> str: + # See what category it is + cat = ( + "Plots" if name.startswith("ImPlotCol") else + "Nodes" if name.startswith("ImNodesCol") else + "" + ) + cat = f", category=dpg.mvThemeCat_{cat}" if cat else "" + # Replace prefix + name = name.replace("ImGuiCol_", "mvThemeCol_").replace("ImPlotCol_", "mvPlotCol_").replace("ImNodesCol_", "mvNodesCol_") + if name in OLD_NODE_COLORS: + name = name.replace("mvNodesCol", "mvNodeCol") + + return f" dpg.add_theme_color(dpg.{name:34}, ({format_color(color)}){cat})" + + +def create_theme(theme_name: str, colors: Dict) -> str: + color_lines = [format_color_line(name, value) for name, value in colors.items() if value is not None] + return theme_template.substitute(name=theme_name.lower(), colors="\n".join(color_lines)) + + +# Okay now we're ready to read and convert the sources! + +source = imgui_draw.read_text("utf-8") +theme_funcs = re.findall(r"void\s+ImGui::StyleColors(\w+)(.*?)^\}", source, re.DOTALL|re.MULTILINE) +all_colors = {name.lower(): convert_colors(source) for name, source in theme_funcs} + +source = implot.read_text("utf-8") +theme_funcs = re.findall(r"void\s+StyleColors(\w+)(.*?)^\}", source, re.DOTALL|re.MULTILINE) + +for name, source in theme_funcs: + name = name.lower() + if name in all_colors: + all_colors[name].update(convert_colors(source)) + +source = imnodes.read_text("utf-8") +theme_funcs = re.findall(r"void\s+StyleColors(\w+)(.*?)^\}", source, re.DOTALL|re.MULTILINE) + +for name, source in theme_funcs: + name = name.lower() + if name in all_colors: + all_colors[name].update(convert_colors(source)) + +dpg_themes = [create_theme(name, colors) for name, colors in all_colors.items()] +new_themes_contents = main_template.substitute(themes="\n".join(dpg_themes)) + +themes_py.write_text(new_themes_contents, "utf-8") + +print("Done.") diff --git a/thirdparty/imgui b/thirdparty/imgui index 139e99ca3..3912b3d9a 160000 --- a/thirdparty/imgui +++ b/thirdparty/imgui @@ -1 +1 @@ -Subproject commit 139e99ca37a3e127c87690202faec005cd892d36 +Subproject commit 3912b3d9a9c1b3f17431aebafd86d2f40ee6e59c diff --git a/thirdparty/imnodes/CMakeLists.txt b/thirdparty/imnodes/CMakeLists.txt index a397b2f9d..c4c8d5039 100644 --- a/thirdparty/imnodes/CMakeLists.txt +++ b/thirdparty/imnodes/CMakeLists.txt @@ -5,12 +5,35 @@ project(imnodes) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -find_package(imgui CONFIG REQUIRED) -find_package(SDL2 CONFIG REQUIRED) + +# determine whether this is a standalone project or included by other projects +if (NOT DEFINED IMNODES_STANDALONE_PROJECT) + if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(IMNODES_STANDALONE_PROJECT ON) + else() + set(IMNODES_STANDALONE_PROJECT OFF) + endif () +endif() + +# cmake options +option(IMNODES_EXAMPLES "Build examples" ${IMNODES_STANDALONE_PROJECT}) + +# allow custom imgui target name since this can vary because imgui doesn't natively include a CMakeLists.txt +if(NOT DEFINED IMNODES_IMGUI_TARGET_NAME) + find_package(imgui CONFIG REQUIRED) + set(IMNODES_IMGUI_TARGET_NAME imgui::imgui) +endif() + if(MSVC) add_compile_definitions(SDL_MAIN_HANDLED) - add_compile_options(/W4 /WX) + add_compile_options(/WX) + # replace existing /W to avoid warning + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + add_compile_options(/W4) + endif() else() add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() @@ -22,59 +45,63 @@ target_sources(imnodes PRIVATE imnodes.h imnodes_internal.h imnodes.cpp) -target_include_directories(imnodes PUBLIC ${CMAKE_SOURCE_DIR}) -target_link_libraries(imnodes PUBLIC imgui::imgui) +target_include_directories(imnodes PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(imnodes PUBLIC ${IMNODES_IMGUI_TARGET_NAME}) # Example projects +if(IMNODES_EXAMPLES) -add_executable(colornode - ${CMAKE_SOURCE_DIR}/imnodes.cpp - ${CMAKE_SOURCE_DIR}/example/main.cpp - ${CMAKE_SOURCE_DIR}/example/color_node_editor.cpp) -target_link_libraries(colornode imnodes SDL2::SDL2) -if (APPLE) - target_link_libraries(colornode "-framework OpenGL") -elseif(MSVC) - target_link_libraries(colornode "opengl32") -else() - target_link_libraries(colornode X11 Xext GL) -endif() + find_package(SDL2 CONFIG REQUIRED) -add_executable(multieditor - ${CMAKE_SOURCE_DIR}/imnodes.cpp - ${CMAKE_SOURCE_DIR}/example/main.cpp - ${CMAKE_SOURCE_DIR}/example/multi_editor.cpp) -target_link_libraries(multieditor imnodes SDL2::SDL2) -if (APPLE) - target_link_libraries(multieditor "-framework OpenGL") -elseif(MSVC) - target_link_libraries(multieditor "opengl32") -else() - target_link_libraries(multieditor X11 Xext GL) -endif() + add_executable(colornode + ${CMAKE_CURRENT_SOURCE_DIR}/imnodes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/color_node_editor.cpp) + target_link_libraries(colornode imnodes SDL2::SDL2) + if (APPLE) + target_link_libraries(colornode "-framework OpenGL") + elseif(MSVC) + target_link_libraries(colornode "opengl32") + else() + target_link_libraries(colornode X11 Xext GL) + endif() -add_executable(saveload - ${CMAKE_SOURCE_DIR}/imnodes.cpp - ${CMAKE_SOURCE_DIR}/example/main.cpp - ${CMAKE_SOURCE_DIR}/example/save_load.cpp) -target_link_libraries(saveload imnodes SDL2::SDL2) -if (APPLE) - target_link_libraries(saveload "-framework OpenGL") -elseif(MSVC) - target_link_libraries(saveload "opengl32") -else() - target_link_libraries(saveload X11 Xext GL) -endif() + add_executable(multieditor + ${CMAKE_CURRENT_SOURCE_DIR}/imnodes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/multi_editor.cpp) + target_link_libraries(multieditor imnodes SDL2::SDL2) + if (APPLE) + target_link_libraries(multieditor "-framework OpenGL") + elseif(MSVC) + target_link_libraries(multieditor "opengl32") + else() + target_link_libraries(multieditor X11 Xext GL) + endif() -add_executable(hello - ${CMAKE_SOURCE_DIR}/imnodes.cpp - ${CMAKE_SOURCE_DIR}/example/main.cpp - ${CMAKE_SOURCE_DIR}/example/hello.cpp) -target_link_libraries(hello imnodes SDL2::SDL2) -if (APPLE) - target_link_libraries(hello "-framework OpenGL") -elseif(MSVC) - target_link_libraries(hello "opengl32") -else() - target_link_libraries(hello X11 Xext GL) + add_executable(saveload + ${CMAKE_CURRENT_SOURCE_DIR}/imnodes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/save_load.cpp) + target_link_libraries(saveload imnodes SDL2::SDL2) + if (APPLE) + target_link_libraries(saveload "-framework OpenGL") + elseif(MSVC) + target_link_libraries(saveload "opengl32") + else() + target_link_libraries(saveload X11 Xext GL) + endif() + + add_executable(hello + ${CMAKE_CURRENT_SOURCE_DIR}/imnodes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/example/hello.cpp) + target_link_libraries(hello imnodes SDL2::SDL2) + if (APPLE) + target_link_libraries(hello "-framework OpenGL") + elseif(MSVC) + target_link_libraries(hello "opengl32") + else() + target_link_libraries(hello X11 Xext GL) + endif() endif() diff --git a/thirdparty/imnodes/example/color_node_editor.cpp b/thirdparty/imnodes/example/color_node_editor.cpp index 615245a01..549bd811b 100644 --- a/thirdparty/imnodes/example/color_node_editor.cpp +++ b/thirdparty/imnodes/example/color_node_editor.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -206,8 +205,7 @@ class ColorNodeEditor // These are driven by the user, so we place this code before rendering the nodes { const bool open_popup = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && - ImNodes::IsEditorHovered() && - ImGui::IsKeyReleased(SDL_SCANCODE_A); + ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(ImGuiKey_A); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f)); if (!ImGui::IsAnyItemHovered() && open_popup) @@ -514,7 +512,7 @@ class ColorNodeEditor const float label_width = ImGui::CalcTextSize("output").x; ImGui::Indent(node_width - label_width); ImGui::TextUnformatted("output"); - ImNodes::EndInputAttribute(); + ImNodes::EndOutputAttribute(); } ImNodes::EndNode(); @@ -588,7 +586,7 @@ class ColorNodeEditor { const int num_selected = ImNodes::NumSelectedLinks(); - if (num_selected > 0 && ImGui::IsKeyReleased(SDL_SCANCODE_X)) + if (num_selected > 0 && ImGui::IsKeyReleased(ImGuiKey_X)) { static std::vector selected_links; selected_links.resize(static_cast(num_selected)); @@ -602,7 +600,7 @@ class ColorNodeEditor { const int num_selected = ImNodes::NumSelectedNodes(); - if (num_selected > 0 && ImGui::IsKeyReleased(SDL_SCANCODE_X)) + if (num_selected > 0 && ImGui::IsKeyReleased(ImGuiKey_X)) { static std::vector selected_nodes; selected_nodes.resize(static_cast(num_selected)); diff --git a/thirdparty/imnodes/example/main.cpp b/thirdparty/imnodes/example/main.cpp index b9173335b..fd08780de 100644 --- a/thirdparty/imnodes/example/main.cpp +++ b/thirdparty/imnodes/example/main.cpp @@ -1,7 +1,7 @@ #include "node_editor.h" #include -#include +#include #include #include #include diff --git a/thirdparty/imnodes/example/multi_editor.cpp b/thirdparty/imnodes/example/multi_editor.cpp index cbe0a23b6..cb9fb1d17 100644 --- a/thirdparty/imnodes/example/multi_editor.cpp +++ b/thirdparty/imnodes/example/multi_editor.cpp @@ -42,7 +42,7 @@ void show_editor(const char* editor_name, Editor& editor) ImNodes::BeginNodeEditor(); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && - ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(SDL_SCANCODE_A)) + ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(ImGuiKey_A)) { const int node_id = ++editor.current_id; ImNodes::SetNodeScreenSpacePos(node_id, ImGui::GetMousePos()); diff --git a/thirdparty/imnodes/example/save_load.cpp b/thirdparty/imnodes/example/save_load.cpp index 7a2137684..01f3293cb 100644 --- a/thirdparty/imnodes/example/save_load.cpp +++ b/thirdparty/imnodes/example/save_load.cpp @@ -47,7 +47,7 @@ class SaveLoadEditor ImNodes::BeginNodeEditor(); if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && - ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(SDL_SCANCODE_A)) + ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(ImGuiKey_A)) { const int node_id = ++current_id_; ImNodes::SetNodeScreenSpacePos(node_id, ImGui::GetMousePos()); diff --git a/thirdparty/imnodes/imnodes.cpp b/thirdparty/imnodes/imnodes.cpp index bea71c99e..99d89332d 100644 --- a/thirdparty/imnodes/imnodes.cpp +++ b/thirdparty/imnodes/imnodes.cpp @@ -6,12 +6,8 @@ // [SECTION] render helpers // [SECTION] API implementation -#include "imnodes.h" #include "imnodes_internal.h" -#define IMGUI_DEFINE_MATH_OPERATORS -#include - // Check minimum ImGui version #define MINIMUM_COMPATIBLE_IMGUI_VERSION 17400 #if IMGUI_VERSION_NUM < MINIMUM_COMPATIBLE_IMGUI_VERSION @@ -354,7 +350,11 @@ void ImDrawListGrowChannels(ImDrawList* draw_list, const int num_channels) { ImDrawCmd draw_cmd; draw_cmd.ClipRect = draw_list->_ClipRectStack.back(); +#if IMGUI_VERSION_NUM < 19200 draw_cmd.TextureId = draw_list->_TextureIdStack.back(); +#else + draw_cmd.TexRef = draw_list->_TextureStack.back(); +#endif channel._CmdBuffer.push_back(draw_cmd); } } @@ -1735,7 +1735,7 @@ static inline void CalcMiniMapLayout() const ImVec2 grid_content_size = editor.GridContentBounds.IsInverted() ? max_size : ImFloor(editor.GridContentBounds.GetSize()); - const float grid_content_aspect_ratio = grid_content_size.x / grid_content_size.y; + const float grid_content_aspect_ratio = grid_content_size.x / grid_content_size.y; mini_map_size = ImFloor( grid_content_aspect_ratio > max_size_aspect_ratio ? ImVec2(max_size.x, max_size.x / grid_content_aspect_ratio) diff --git a/thirdparty/imnodes/imnodes_internal.h b/thirdparty/imnodes/imnodes_internal.h index 593ab4997..bb1ee8f33 100644 --- a/thirdparty/imnodes/imnodes_internal.h +++ b/thirdparty/imnodes/imnodes_internal.h @@ -1,11 +1,11 @@ #pragma once -#include "imnodes.h" - -#include #define IMGUI_DEFINE_MATH_OPERATORS +#include #include +#include "imnodes.h" + #include // the structure of this file: @@ -264,7 +264,7 @@ struct ImNodesEditorContext // Relative origins of selected nodes for snapping of dragged nodes ImVector SelectedNodeOffsets; // Offset of the primary node origin relative to the mouse cursor. - ImVec2 PrimaryNodeOffset; + ImVec2 PrimaryNodeOffset; ImClickInteractionState ClickInteraction; @@ -285,9 +285,8 @@ struct ImNodesEditorContext ImNodesEditorContext() : Nodes(), Pins(), Links(), Panning(0.f, 0.f), SelectedNodeIndices(), SelectedLinkIndices(), SelectedNodeOffsets(), PrimaryNodeOffset(0.f, 0.f), ClickInteraction(), - MiniMapEnabled(false), MiniMapSizeFraction(0.0f), - MiniMapNodeHoveringCallback(NULL), MiniMapNodeHoveringCallbackUserData(NULL), - MiniMapScaling(0.0f) + MiniMapEnabled(false), MiniMapSizeFraction(0.0f), MiniMapNodeHoveringCallback(NULL), + MiniMapNodeHoveringCallbackUserData(NULL), MiniMapScaling(0.0f) { } }; diff --git a/thirdparty/implot b/thirdparty/implot index f156599fa..4707b245f 160000 --- a/thirdparty/implot +++ b/thirdparty/implot @@ -1 +1 @@ -Subproject commit f156599faefe316f7dd20fe6c783bf87c8bb6fd9 +Subproject commit 4707b245fbcd69075b1a8a74fa8d2435561b3134