Skip to content

Commit fb59d3c

Browse files
authored
Merge branch 'hoffstadt:master' into patch-1
2 parents 1ffd6fe + 3593506 commit fb59d3c

101 files changed

Lines changed: 2874 additions & 2392 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
cmake_minimum_required (VERSION 3.13)
1+
cmake_minimum_required (VERSION 3.16)
22

3-
project ("DearPyGui")
3+
if(APPLE)
4+
# When using precompiled headers on macOS, we need to enable Objective-C
5+
# as a distinct language. This won't work on other platforms (will fail to
6+
# find the Obj-C compiler), hence the "if APPLE".
7+
project ("DearPyGui" LANGUAGES C CXX OBJC OBJCXX)
8+
else()
9+
project ("DearPyGui")
10+
endif()
411

512
if(WIN32)
6-
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig.h")
13+
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_win32.h")
714
add_definitions(-DMV_PLATFORM="windows")
815
elseif(APPLE)
9-
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiLinuxConfig.h")
16+
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_apple.h")
1017
add_definitions(-DMV_PLATFORM="apple")
1118
else() # Linux
12-
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiLinuxConfig.h")
19+
add_definitions(-DIMGUI_USER_CONFIG="mvImGuiConfig_linux.h")
1320
add_definitions(-DMV_PLATFORM="linux")
1421
endif()
1522

@@ -20,6 +27,7 @@ endif()
2027

2128
# various settings
2229
add_definitions(
30+
-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
2331
-D_CRT_SECURE_NO_WARNINGS
2432
-D_USE_MATH_DEFINES)
2533

dearpygui/_dearpygui.pyi

Lines changed: 46 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dearpygui/_dearpygui_RTD.py

Lines changed: 128 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dearpygui/_deprecated.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,55 @@ def is_item_search_delayed(item: Union[int, str]) -> Union[bool, None]:
423423
def set_start_callback(callback):
424424
""" deprecated function """
425425
return internal_dpg.set_frame_callback(3, callback)
426+
427+
@deprecated("This call is a no-op because character ranges are now automatic")
428+
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]:
429+
""" (deprecated function) Adds specific font characters to a font.
430+
431+
Args:
432+
chars (Union[List[int], Tuple[int, ...]]):
433+
label (str, optional): Overrides 'name' as label.
434+
user_data (Any, optional): User data for callbacks
435+
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
436+
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
437+
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
438+
id (Union[int, str], optional): (deprecated)
439+
Returns:
440+
Union[int, str]
441+
"""
442+
pass
443+
444+
@deprecated("This call is a no-op because character ranges are now automatic")
445+
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]:
446+
""" (deprecated function) Adds a range of font characters to a font.
447+
448+
Args:
449+
first_char (int):
450+
last_char (int):
451+
label (str, optional): Overrides 'name' as label.
452+
user_data (Any, optional): User data for callbacks
453+
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
454+
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
455+
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
456+
id (Union[int, str], optional): (deprecated)
457+
Returns:
458+
Union[int, str]
459+
"""
460+
pass
461+
462+
@deprecated("This call is a no-op because character ranges are now automatic")
463+
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]:
464+
""" (deprecated function) Adds a range of font characters (mvFontRangeHint_ constants).
465+
466+
Args:
467+
hint (int):
468+
label (str, optional): Overrides 'name' as label.
469+
user_data (Any, optional): User data for callbacks
470+
use_internal_label (bool, optional): Use generated internal label instead of user specified (appends ### uuid).
471+
tag (Union[int, str], optional): Unique id used to programmatically refer to the item.If label is unused this will be the label.
472+
parent (Union[int, str], optional): Parent to add this item to. (runtime adding)
473+
id (Union[int, str], optional): (deprecated)
474+
Returns:
475+
Union[int, str]
476+
"""
477+
pass

dearpygui/dearpygui.py

Lines changed: 170 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dearpygui/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ def _color_picker_configs(sender, value, user_data):
476476
dpg.add_radio_button(("mvColorEdit_input_rgb", "mvColorEdit_input_hsv"), callback=_color_picker_configs,
477477
user_data=_color_picker_id, horizontal=True)
478478

479-
dpg.add_color_picker((255, 0, 255, 200), label="Color Picker", alpha_preview=True, no_alpha=False, alpha_bar=True,
479+
dpg.add_color_picker((255, 0, 255, 200), label="Color Picker", alpha_preview=dpg.mvColorEdit_AlphaPreviewNone, no_alpha=False, alpha_bar=True,
480480
width=200, tag=_color_picker_id)
481481

482482
_add_config_options(_color_picker_id, 3,

docs/source/documentation/fonts.rst

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,26 @@ folder you can find an example of a otf font.
1313
Readme First
1414
------------
1515

16-
All loaded fonts glyphs are rendered into a single texture atlas ahead of time.
17-
Adding/Removing/Modifying fonts will cause the font atlas to be rebuilt.
16+
All loaded fonts glyphs are rendered into a single texture atlas. Rendering occurs
17+
on-the-fly as characters are encountered in UI strings (item labels, input contents, etc. -
18+
anything that gets displayed in the viewport).
1819

19-
You can use the style editor
20+
You can use the Fonts Manager tool
2021
:py:func:`show_font_manager <dearpygui.dearpygui.show_font_manager>`
2122
to browse your fonts and understand what's going on if you have an issue.
2223

2324
Font Loading Instructions
2425
-------------------------
2526

2627
To add your own fonts, you must first create a font registry to
27-
add fonts to. Next, add fonts to the registry. By default only basic latin
28-
and latin supplement glyphs are added (0x0020 - 0x00FF).
28+
add fonts to. Next, add fonts to the registry.
29+
30+
For a font to take effect, it must be either bound globally with :py:func:`bind_font <dearpygui.dearpygui.bind_font>`
31+
or bound to a particular item with :py:func:`bind_item_font <dearpygui.dearpygui.bind_item_font>`.
32+
In the latter case, the font is "inherited" by all child item if it is bound to
33+
a container. To remove font binding and revert to the default font (or inherit from
34+
the parent item), call `bind_font`/`bind_item_font` again, passing 0 in the `font`
35+
argument.
2936

3037
.. code-block:: python
3138
@@ -39,13 +46,14 @@ and latin supplement glyphs are added (0x0020 - 0x00FF).
3946
default_font = dpg.add_font("NotoSerifCJKjp-Medium.otf", 20)
4047
second_font = dpg.add_font("NotoSerifCJKjp-Medium.otf", 10)
4148
49+
dpg.bind_font(default_font)
50+
4251
with dpg.window(label="Font Example", height=200, width=200):
4352
dpg.add_button(label="Default font")
4453
b2 = dpg.add_button(label="Secondary font")
4554
dpg.add_button(label="default")
4655
4756
# set font of specific widget
48-
dpg.bind_font(default_font)
4957
dpg.bind_item_font(b2, second_font)
5058
5159
dpg.show_font_manager()
@@ -59,8 +67,19 @@ and latin supplement glyphs are added (0x0020 - 0x00FF).
5967
Loading Specific Unicode Characters
6068
-----------------------------------
6169

62-
There are several ways to add specific characters from a font file.
63-
You can use range hints, ranges, and specific characters. You can also remap characters.
70+
.. note::
71+
This section previously described how to load specific characters from font file
72+
so that they are displayed in the UI correctly. Since DPG version 2.3, character
73+
glyphs are rendered automatically and there is no need to specify them in advance.
74+
This section is no longer relevant, and the functions `add_font_chars`, `add_font_range`,
75+
and `add_font_range_hint` are obsolete and do nothing if you call them.
76+
77+
Remapping Characters
78+
-----------------------------------
79+
80+
For convenience, you can remap a character to a different character code and use
81+
this replacement in your text strings. In particular, it might be useful with icon
82+
fonts. Here is an example of how to do such remapping.
6483

6584
.. code-block:: python
6685
@@ -71,26 +90,6 @@ You can use range hints, ranges, and specific characters. You can also remap cha
7190
with dpg.font_registry():
7291
with dpg.font("NotoSerifCJKjp-Medium.otf", 20) as font1:
7392
74-
# add the default font range
75-
dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
76-
77-
# helper to add range of characters
78-
# Options:
79-
# mvFontRangeHint_Japanese
80-
# mvFontRangeHint_Korean
81-
# mvFontRangeHint_Chinese_Full
82-
# mvFontRangeHint_Chinese_Simplified_Common
83-
# mvFontRangeHint_Cyrillic
84-
# mvFontRangeHint_Thai
85-
# mvFontRangeHint_Vietnamese
86-
dpg.add_font_range_hint(dpg.mvFontRangeHint_Japanese)
87-
88-
# add specific range of glyphs
89-
dpg.add_font_range(0x3100, 0x3ff0)
90-
91-
# add specific glyphs
92-
dpg.add_font_chars([0x3105, 0x3107, 0x3108])
93-
9493
# remap や to %
9594
dpg.add_char_remap(0x3084, 0x0025)
9695

sandbox/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.13)
1+
cmake_minimum_required (VERSION 3.16)
22

33
add_executable (DearSandbox)
44

sandbox/sandbox.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
log.log_critical("log critical")
1717

1818
with dpg.font_registry():
19-
with dpg.font("../../assets/NotoSerifCJKjp-Medium.otf", 20, tag="custom font"):
20-
dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
19+
dpg.add_font("../../assets/NotoSerifCJKjp-Medium.otf", 20, tag="custom font")
2120
dpg.bind_font(dpg.last_container())
2221

2322
demo.show_demo()

0 commit comments

Comments
 (0)