truegraphics 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. truegraphics-1.0.0/.github/workflows/publish.yml +103 -0
  2. truegraphics-1.0.0/CMakeLists.txt +110 -0
  3. truegraphics-1.0.0/LICENSE +21 -0
  4. truegraphics-1.0.0/MANUAL.md +449 -0
  5. truegraphics-1.0.0/PKG-INFO +254 -0
  6. truegraphics-1.0.0/README.md +209 -0
  7. truegraphics-1.0.0/bindings/module.cpp +758 -0
  8. truegraphics-1.0.0/build_check/CMakeCache.txt +109 -0
  9. truegraphics-1.0.0/build_check/CMakeFiles/4.2.1/CMakeSystem.cmake +15 -0
  10. truegraphics-1.0.0/build_check/CMakeFiles/CMakeConfigureLog.yaml +11 -0
  11. truegraphics-1.0.0/build_check/CMakeFiles/cmake.check_cache +1 -0
  12. truegraphics-1.0.0/engine/include/truegraphics/animation/Animator.h +29 -0
  13. truegraphics-1.0.0/engine/include/truegraphics/animation/Easing.h +10 -0
  14. truegraphics-1.0.0/engine/include/truegraphics/async/Async.h +20 -0
  15. truegraphics-1.0.0/engine/include/truegraphics/core/App.h +161 -0
  16. truegraphics-1.0.0/engine/include/truegraphics/core/Config.h +24 -0
  17. truegraphics-1.0.0/engine/include/truegraphics/core/Engine.h +40 -0
  18. truegraphics-1.0.0/engine/include/truegraphics/core/Time.h +15 -0
  19. truegraphics-1.0.0/engine/include/truegraphics/core/Uuid.h +16 -0
  20. truegraphics-1.0.0/engine/include/truegraphics/graphics/Canvas3D.h +18 -0
  21. truegraphics-1.0.0/engine/include/truegraphics/graphics/Gpu.h +12 -0
  22. truegraphics-1.0.0/engine/include/truegraphics/graphics/Image.h +37 -0
  23. truegraphics-1.0.0/engine/include/truegraphics/graphics/Renderer.h +86 -0
  24. truegraphics-1.0.0/engine/include/truegraphics/graphics/Shader.h +17 -0
  25. truegraphics-1.0.0/engine/include/truegraphics/layout/FlexLayout.h +16 -0
  26. truegraphics-1.0.0/engine/include/truegraphics/layout/Layout.h +18 -0
  27. truegraphics-1.0.0/engine/include/truegraphics/plugin/Plugin.h +17 -0
  28. truegraphics-1.0.0/engine/include/truegraphics/resource/Resources.h +23 -0
  29. truegraphics-1.0.0/engine/include/truegraphics/state/State.h +61 -0
  30. truegraphics-1.0.0/engine/include/truegraphics/style/Style.h +38 -0
  31. truegraphics-1.0.0/engine/include/truegraphics/style/StyleEngine.h +22 -0
  32. truegraphics-1.0.0/engine/include/truegraphics/style/Theme.h +13 -0
  33. truegraphics-1.0.0/engine/include/truegraphics/system/Log.h +14 -0
  34. truegraphics-1.0.0/engine/include/truegraphics/system/Profiler.h +19 -0
  35. truegraphics-1.0.0/engine/include/truegraphics/widgets/Button.h +13 -0
  36. truegraphics-1.0.0/engine/include/truegraphics/widgets/Canvas.h +53 -0
  37. truegraphics-1.0.0/engine/include/truegraphics/widgets/Checkbox.h +27 -0
  38. truegraphics-1.0.0/engine/include/truegraphics/widgets/Container.h +56 -0
  39. truegraphics-1.0.0/engine/include/truegraphics/widgets/Dropdown.h +36 -0
  40. truegraphics-1.0.0/engine/include/truegraphics/widgets/Image.h +24 -0
  41. truegraphics-1.0.0/engine/include/truegraphics/widgets/Label.h +13 -0
  42. truegraphics-1.0.0/engine/include/truegraphics/widgets/ListView.h +32 -0
  43. truegraphics-1.0.0/engine/include/truegraphics/widgets/PasswordBox.h +19 -0
  44. truegraphics-1.0.0/engine/include/truegraphics/widgets/ProgressBar.h +20 -0
  45. truegraphics-1.0.0/engine/include/truegraphics/widgets/RadioButton.h +33 -0
  46. truegraphics-1.0.0/engine/include/truegraphics/widgets/ScrollView.h +34 -0
  47. truegraphics-1.0.0/engine/include/truegraphics/widgets/Slider.h +28 -0
  48. truegraphics-1.0.0/engine/include/truegraphics/widgets/Table.h +28 -0
  49. truegraphics-1.0.0/engine/include/truegraphics/widgets/Tabs.h +35 -0
  50. truegraphics-1.0.0/engine/include/truegraphics/widgets/TextArea.h +19 -0
  51. truegraphics-1.0.0/engine/include/truegraphics/widgets/TextBox.h +19 -0
  52. truegraphics-1.0.0/engine/include/truegraphics/widgets/TreeView.h +37 -0
  53. truegraphics-1.0.0/engine/include/truegraphics/widgets/Widget.h +96 -0
  54. truegraphics-1.0.0/engine/include/truegraphics/window/Dpi.h +10 -0
  55. truegraphics-1.0.0/engine/include/truegraphics/window/Input.h +11 -0
  56. truegraphics-1.0.0/engine/include/truegraphics/window/Window.h +87 -0
  57. truegraphics-1.0.0/engine/src/animation/Animator.cpp +52 -0
  58. truegraphics-1.0.0/engine/src/animation/Easing.cpp +7 -0
  59. truegraphics-1.0.0/engine/src/async/Async.cpp +18 -0
  60. truegraphics-1.0.0/engine/src/core/App.cpp +570 -0
  61. truegraphics-1.0.0/engine/src/core/Config.cpp +1 -0
  62. truegraphics-1.0.0/engine/src/core/Engine.cpp +135 -0
  63. truegraphics-1.0.0/engine/src/core/Time.cpp +10 -0
  64. truegraphics-1.0.0/engine/src/core/Uuid.cpp +19 -0
  65. truegraphics-1.0.0/engine/src/graphics/Canvas3D.cpp +15 -0
  66. truegraphics-1.0.0/engine/src/graphics/Gpu.cpp +7 -0
  67. truegraphics-1.0.0/engine/src/graphics/Image.cpp +61 -0
  68. truegraphics-1.0.0/engine/src/graphics/Renderer.cpp +347 -0
  69. truegraphics-1.0.0/engine/src/graphics/Shader.cpp +1 -0
  70. truegraphics-1.0.0/engine/src/layout/FlexLayout.cpp +169 -0
  71. truegraphics-1.0.0/engine/src/layout/Layout.cpp +1 -0
  72. truegraphics-1.0.0/engine/src/plugin/Plugin.cpp +12 -0
  73. truegraphics-1.0.0/engine/src/resource/Resources.cpp +79 -0
  74. truegraphics-1.0.0/engine/src/state/State.cpp +59 -0
  75. truegraphics-1.0.0/engine/src/style/Style.cpp +1 -0
  76. truegraphics-1.0.0/engine/src/style/StyleEngine.cpp +17 -0
  77. truegraphics-1.0.0/engine/src/style/Theme.cpp +33 -0
  78. truegraphics-1.0.0/engine/src/system/Log.cpp +15 -0
  79. truegraphics-1.0.0/engine/src/system/Profiler.cpp +21 -0
  80. truegraphics-1.0.0/engine/src/widgets/Button.cpp +19 -0
  81. truegraphics-1.0.0/engine/src/widgets/Canvas.cpp +55 -0
  82. truegraphics-1.0.0/engine/src/widgets/Checkbox.cpp +40 -0
  83. truegraphics-1.0.0/engine/src/widgets/Container.cpp +32 -0
  84. truegraphics-1.0.0/engine/src/widgets/Dropdown.cpp +91 -0
  85. truegraphics-1.0.0/engine/src/widgets/Image.cpp +41 -0
  86. truegraphics-1.0.0/engine/src/widgets/Label.cpp +14 -0
  87. truegraphics-1.0.0/engine/src/widgets/ListView.cpp +58 -0
  88. truegraphics-1.0.0/engine/src/widgets/PasswordBox.cpp +258 -0
  89. truegraphics-1.0.0/engine/src/widgets/ProgressBar.cpp +29 -0
  90. truegraphics-1.0.0/engine/src/widgets/RadioButton.cpp +61 -0
  91. truegraphics-1.0.0/engine/src/widgets/ScrollView.cpp +133 -0
  92. truegraphics-1.0.0/engine/src/widgets/Slider.cpp +60 -0
  93. truegraphics-1.0.0/engine/src/widgets/Table.cpp +55 -0
  94. truegraphics-1.0.0/engine/src/widgets/Tabs.cpp +84 -0
  95. truegraphics-1.0.0/engine/src/widgets/TextArea.cpp +384 -0
  96. truegraphics-1.0.0/engine/src/widgets/TextBox.cpp +265 -0
  97. truegraphics-1.0.0/engine/src/widgets/TreeView.cpp +60 -0
  98. truegraphics-1.0.0/engine/src/widgets/Widget.cpp +150 -0
  99. truegraphics-1.0.0/engine/src/window/Dpi.cpp +7 -0
  100. truegraphics-1.0.0/engine/src/window/Input.cpp +1 -0
  101. truegraphics-1.0.0/engine/src/window/Window.cpp +436 -0
  102. truegraphics-1.0.0/examples/animation_demo.py +21 -0
  103. truegraphics-1.0.0/examples/canvas_demo.py +18 -0
  104. truegraphics-1.0.0/examples/check.py +86 -0
  105. truegraphics-1.0.0/examples/counter_app.py +20 -0
  106. truegraphics-1.0.0/examples/layout_demo.py +32 -0
  107. truegraphics-1.0.0/examples/multi-window.py +14 -0
  108. truegraphics-1.0.0/examples/showcase.py +244 -0
  109. truegraphics-1.0.0/pyproject.toml +52 -0
  110. truegraphics-1.0.0/python/truegraphics/__init__.py +93 -0
  111. truegraphics-1.0.0/python/truegraphics/_version.py +1 -0
  112. truegraphics-1.0.0/python/truegraphics/app.py +5 -0
  113. truegraphics-1.0.0/python/truegraphics/decorators.py +1 -0
  114. truegraphics-1.0.0/python/truegraphics/libgcc_s_seh-1.dll +0 -0
  115. truegraphics-1.0.0/python/truegraphics/libstdc++-6.dll +0 -0
  116. truegraphics-1.0.0/python/truegraphics/libwinpthread-1.dll +0 -0
  117. truegraphics-1.0.0/python/truegraphics/state.py +5 -0
  118. truegraphics-1.0.0/python/truegraphics/widgets.py +5 -0
@@ -0,0 +1,103 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+ id-token: write
9
+
10
+ jobs:
11
+ sdist:
12
+ name: Build sdist
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.13"
21
+
22
+ - name: Build sdist
23
+ run: |
24
+ python -m pip install --upgrade pip build
25
+ python -m build --sdist --outdir dist
26
+
27
+ - uses: actions/upload-artifact@v4
28
+ with:
29
+ name: dist-sdist
30
+ path: dist/*.tar.gz
31
+
32
+ wheels:
33
+ name: Build wheels (py${{ matrix.python-version }})
34
+ runs-on: windows-latest
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
39
+
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - name: Set up MSYS2 (MinGW toolchain)
44
+ uses: msys2/setup-msys2@v2
45
+ with:
46
+ msystem: UCRT64
47
+ update: true
48
+ install: >-
49
+ mingw-w64-ucrt-x86_64-toolchain
50
+ mingw-w64-ucrt-x86_64-cmake
51
+ mingw-w64-ucrt-x86_64-make
52
+
53
+ - name: Set up Python
54
+ uses: actions/setup-python@v5
55
+ with:
56
+ python-version: ${{ matrix.python-version }}
57
+
58
+ - name: Add MinGW to PATH
59
+ shell: pwsh
60
+ run: |
61
+ Add-Content $env:GITHUB_PATH "C:\\msys64\\ucrt64\\bin"
62
+
63
+ - name: Build + install (MinGW Makefiles) [smoke]
64
+ run: |
65
+ python -m pip install --upgrade pip
66
+ python -m pip install . -v --config-settings=cmake.args="-G MinGW Makefiles"
67
+
68
+ - name: Build wheel (MinGW Makefiles)
69
+ run: |
70
+ python -m pip wheel . -w dist --no-deps -v --config-settings=cmake.args="-G MinGW Makefiles"
71
+
72
+ - name: Import check
73
+ run: |
74
+ python -c "import truegraphics as tg; print('truegraphics', tg.__version__)"
75
+
76
+ - uses: actions/upload-artifact@v4
77
+ with:
78
+ name: dist-wheels-${{ matrix.python-version }}
79
+ path: dist/*.whl
80
+
81
+ publish:
82
+ name: Publish (Trusted Publishing)
83
+ needs: [sdist, wheels]
84
+ runs-on: ubuntu-latest
85
+ environment:
86
+ name: pypi
87
+ url: https://pypi.org/project/truegraphics/
88
+ steps:
89
+ - uses: actions/download-artifact@v4
90
+ with:
91
+ name: dist-sdist
92
+ path: dist
93
+
94
+ - uses: actions/download-artifact@v4
95
+ with:
96
+ pattern: dist-wheels-*
97
+ path: dist
98
+ merge-multiple: true
99
+
100
+ - name: Publish to PyPI
101
+ uses: pypa/gh-action-pypi-publish@release/v1
102
+ with:
103
+ packages-dir: dist
@@ -0,0 +1,110 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+
3
+ project(TrueGraphics VERSION 1.0.0 LANGUAGES CXX)
4
+
5
+ set(CMAKE_CXX_STANDARD 17)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+ set(CMAKE_CXX_EXTENSIONS OFF)
8
+
9
+ if(NOT WIN32)
10
+ message(FATAL_ERROR "TrueGraphics 1.0.0 currently targets Windows.")
11
+ endif()
12
+
13
+ set(PYBIND11_FINDPYTHON ON)
14
+ find_package(pybind11 CONFIG REQUIRED)
15
+
16
+ set(TG_ENGINE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/engine/include")
17
+
18
+ set(TG_ENGINE_SOURCES
19
+ engine/src/core/Engine.cpp
20
+ engine/src/core/App.cpp
21
+ engine/src/core/Config.cpp
22
+ engine/src/core/Time.cpp
23
+ engine/src/core/Uuid.cpp
24
+
25
+ engine/src/system/Log.cpp
26
+ engine/src/system/Profiler.cpp
27
+
28
+ engine/src/window/Window.cpp
29
+ engine/src/window/Input.cpp
30
+ engine/src/window/Dpi.cpp
31
+
32
+ engine/src/graphics/Renderer.cpp
33
+ engine/src/graphics/Shader.cpp
34
+ engine/src/graphics/Gpu.cpp
35
+ engine/src/graphics/Image.cpp
36
+ engine/src/graphics/Canvas3D.cpp
37
+
38
+ engine/src/resource/Resources.cpp
39
+
40
+ engine/src/layout/Layout.cpp
41
+ engine/src/layout/FlexLayout.cpp
42
+
43
+ engine/src/widgets/Widget.cpp
44
+ engine/src/widgets/Button.cpp
45
+ engine/src/widgets/Label.cpp
46
+ engine/src/widgets/TextBox.cpp
47
+ engine/src/widgets/Checkbox.cpp
48
+ engine/src/widgets/RadioButton.cpp
49
+ engine/src/widgets/ScrollView.cpp
50
+ engine/src/widgets/Slider.cpp
51
+ engine/src/widgets/ProgressBar.cpp
52
+ engine/src/widgets/Dropdown.cpp
53
+ engine/src/widgets/Tabs.cpp
54
+ engine/src/widgets/ListView.cpp
55
+ engine/src/widgets/Table.cpp
56
+ engine/src/widgets/TreeView.cpp
57
+ engine/src/widgets/PasswordBox.cpp
58
+ engine/src/widgets/TextArea.cpp
59
+ engine/src/widgets/Container.cpp
60
+ engine/src/widgets/Canvas.cpp
61
+ engine/src/widgets/Image.cpp
62
+
63
+ engine/src/style/Style.cpp
64
+ engine/src/style/StyleEngine.cpp
65
+ engine/src/style/Theme.cpp
66
+
67
+ engine/src/animation/Animator.cpp
68
+ engine/src/animation/Easing.cpp
69
+
70
+ engine/src/state/State.cpp
71
+
72
+ engine/src/async/Async.cpp
73
+
74
+ engine/src/plugin/Plugin.cpp
75
+ )
76
+
77
+ pybind11_add_module(_truegraphics
78
+ bindings/module.cpp
79
+ ${TG_ENGINE_SOURCES}
80
+ )
81
+
82
+ target_include_directories(_truegraphics PRIVATE
83
+ "${TG_ENGINE_INCLUDE_DIR}"
84
+ )
85
+
86
+ target_compile_definitions(_truegraphics PRIVATE
87
+ TG_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
88
+ TG_VERSION_MINOR=${PROJECT_VERSION_MINOR}
89
+ TG_VERSION_PATCH=${PROJECT_VERSION_PATCH}
90
+ TG_VERSION_STRING="${PROJECT_VERSION}"
91
+ NOMINMAX
92
+ WIN32_LEAN_AND_MEAN
93
+ )
94
+
95
+ if(MSVC)
96
+ target_compile_options(_truegraphics PRIVATE /W4 /EHsc /permissive-)
97
+ else()
98
+ target_compile_options(_truegraphics PRIVATE -Wall -Wextra -Wpedantic)
99
+ endif()
100
+
101
+ target_link_libraries(_truegraphics PRIVATE
102
+ user32
103
+ gdi32
104
+ gdiplus
105
+ comdlg32
106
+ ole32
107
+ uuid
108
+ )
109
+
110
+ install(TARGETS _truegraphics LIBRARY DESTINATION truegraphics RUNTIME DESTINATION truegraphics)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LegedsDaD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,449 @@
1
+ # TrueGraphics Manual
2
+
3
+ Showcase app (recommended): run `python examples/showcase.py`.
4
+
5
+ ## 1. API Documentation
6
+
7
+ ### `truegraphics.App`
8
+ Application object responsible for window lifecycle, widget construction scope, and event loop startup.
9
+
10
+ Methods:
11
+ - `window(callable)` register the root builder (used as a decorator via `@app.window`)
12
+ - `add_window(callable, title="TrueGraphics", width=640, height=480) -> int` register an additional window builder (created when `run()` is called)
13
+ - `run()` build the widget tree and start the Win32 message loop
14
+ - `set_title(str)` set the initial window title (call before `run()`)
15
+ - `set_size(width, height)` set the initial window size (call before `run()`)
16
+ - `set_theme("dark" | "light")` set theme used for default widget styles
17
+ - `set_fullscreen(bool)` request fullscreen at startup
18
+ - `set_icon(path: str)` set window icon (best with `.ico`)
19
+ - `set_min_size(w, h)` set min track size
20
+ - `set_max_size(w, h)` set max track size
21
+ - `set_timeout(seconds, callback) -> int` run callback once after delay
22
+ - `set_interval(seconds, callback) -> int` run callback repeatedly
23
+ - `clear_timer(id)` cancel a timeout/interval
24
+ - `post(callback)` schedule a callback to run on the UI thread on the next frame
25
+ - `run_async(task, on_done=None)` run a background task and optionally schedule `on_done` back on the UI thread
26
+ - `on_shortcut("Ctrl+S", callback)` register a simple shortcut handler
27
+ - `enable_tray(icon_path, tooltip="TrueGraphics", on_click=None)` enable a system tray icon (best with `.ico`)
28
+ - `disable_tray()` remove tray icon
29
+
30
+ Notes:
31
+ - The window is resizable by default; container layouts are re-applied on resize.
32
+ - The renderer redraws continuously (timer-driven) and is double-buffered to avoid flicker.
33
+
34
+ ### `truegraphics.Widget`
35
+ Base bound widget object.
36
+
37
+ Common methods:
38
+ - `set_id(str)`
39
+ - `set_text(str)`
40
+ - `set_size(width, height)`
41
+ - `set_position(x, y)`
42
+ - `set_background(color)`
43
+ - `set_text_color(color)`
44
+ - `set_border_color(color)`
45
+ - `set_border_radius(int)`
46
+ - `set_border_width(int)`
47
+ - `set_padding(int)`
48
+ - `set_margin(int)`
49
+ - `set_font(family: str)`
50
+ - `set_font_size(size: int)`
51
+ - `set_focusable(bool)`
52
+ - `on_hover(callback(bool))`
53
+ - `on_mouse_move(callback(x, y))`
54
+ - `on_key_down(callback(key_code))`
55
+ - `on_char(callback(codepoint))`
56
+ - `on_drop_files(callback(list[str]))`
57
+ - `animate(property, to, duration=0.3, easing="smoothstep")`
58
+ - `on_mouse_down(callback(x, y))`
59
+ - `on_mouse_up(callback(x, y))`
60
+
61
+ Properties:
62
+ - `text: str` (read-only)
63
+ - `id: str` (read-only)
64
+ - `x: int` (read-only)
65
+ - `y: int` (read-only)
66
+ - `width: int` (read-only)
67
+ - `height: int` (read-only)
68
+
69
+ ### `truegraphics.Button`
70
+ Construct a button widget.
71
+
72
+ Signature:
73
+ ```python
74
+ Button(text: str, on_click: Optional[Callable] = None)
75
+ ```
76
+
77
+ ### `truegraphics.Label`
78
+ Construct a label widget.
79
+
80
+ Signature:
81
+ ```python
82
+ Label(text: str = "")
83
+ ```
84
+
85
+ ### `truegraphics.TextBox`
86
+ Basic text input widget (ASCII for now). Becomes focused when clicked.
87
+
88
+ Signature:
89
+ ```python
90
+ TextBox(text: str = "")
91
+ ```
92
+
93
+ ### `truegraphics.Checkbox`
94
+ Clickable checkbox with an `on_change` callback.
95
+
96
+ Signature:
97
+ ```python
98
+ Checkbox(text: str = "", checked: bool = False, on_change: Optional[Callable[[bool], None]] = None)
99
+ ```
100
+
101
+ ### `truegraphics.Container`
102
+ Construct a container widget.
103
+
104
+ Containers can be used as context managers to build nested UI:
105
+
106
+ ```python
107
+ with tg.Container():
108
+ tg.Button("Child")
109
+ ```
110
+
111
+ Container layout configuration:
112
+ - `set_layout(tg.LayoutMode.Column | Row | Grid | None)`
113
+ - `set_align(tg.Align.Start | Center | End | Stretch)`
114
+ - `set_justify(tg.Justify.Start | Center | End | SpaceBetween)`
115
+ - `set_gap(int)`
116
+ - `set_grid_columns(int)` (for grids)
117
+
118
+ Convenience factories:
119
+ - `tg.Row()`
120
+ - `tg.Column()`
121
+ - `tg.Grid(columns)`
122
+ - `tg.Absolute()` (layout disabled; keeps `set_position` placements)
123
+
124
+ ### `truegraphics.ScrollView`
125
+ Scrollable container widget. Use it as a context manager to add children, and scroll with the mouse wheel when the cursor is over it.
126
+
127
+ Signature:
128
+ ```python
129
+ ScrollView()
130
+ ```
131
+
132
+ Methods:
133
+ - `set_scroll_y(int)`
134
+ - `scroll_by(dy: int)`
135
+ Properties:
136
+ - `scroll_y: int` (read-only)
137
+
138
+ ### `truegraphics.Canvas`
139
+ Construct a 2D canvas widget that records draw commands and renders them each frame.
140
+
141
+ Methods:
142
+ - `clear()`
143
+ - `draw_line(x1, y1, x2, y2, color="#FFFFFF", thickness=1)`
144
+ - `draw_rect(x, y, w, h, color="#FFFFFF", radius=0, filled=True, thickness=1)`
145
+ - `draw_circle(cx, cy, radius, color="#FFFFFF", filled=True, thickness=1)`
146
+ - `draw_text(x, y, text, color="#FFFFFF")`
147
+
148
+ ### `truegraphics.StateInt`
149
+ Reactive integer state container.
150
+
151
+ Methods:
152
+ - `get() -> int`
153
+ - `set(value: int) -> None`
154
+ - `subscribe(callback: Callable[[int], None]) -> None`
155
+
156
+ Other state types:
157
+ - `StateFloat`
158
+ - `StateBool`
159
+ - `StateString`
160
+
161
+ Note: state changes do not automatically rebuild your widget tree; use `subscribe(...)` to update existing widget instances (for example, calling `label.set_text(...)`).
162
+
163
+ ## 2. Engine Architecture
164
+
165
+ Subsystems:
166
+ - Core: configuration, app orchestration, timing, UUID generation
167
+ - Window: Win32 window, input events, DPI helpers
168
+ - Graphics: internal renderer and GPU abstraction placeholders
169
+ - Widgets: widget tree and primitive controls
170
+ - Layout: basic flex-like vertical stacking
171
+ - Style: theming and visual properties
172
+ - Animation: property tween bookkeeping
173
+ - State: reactive integer state
174
+ - Async: background job runner
175
+ - Plugin: dynamic module placeholder
176
+ - System: logging and profiler
177
+
178
+ ## 3. Python API Reference
179
+
180
+ Primary import:
181
+ ```python
182
+ import truegraphics as tg
183
+ ```
184
+
185
+ Typical app:
186
+ ```python
187
+ import truegraphics as tg
188
+
189
+ app = tg.App()
190
+ counter = tg.StateInt(0)
191
+ label = None
192
+
193
+ @app.window
194
+ def main():
195
+ global label
196
+
197
+ def update_label(value: int):
198
+ if label is not None:
199
+ label.set_text(f"Count: {value}")
200
+
201
+ counter.subscribe(update_label)
202
+
203
+ tg.Button("Increment", on_click=lambda: counter.set(counter.get() + 1))
204
+ label = tg.Label(f"Count: {counter.get()}")
205
+
206
+ app.run()
207
+ ```
208
+
209
+ ## 4. Widget Guide
210
+
211
+ ### Button
212
+ Interactive clickable widget with hover-aware style fields and click callback.
213
+
214
+ ### Label
215
+ Text display widget.
216
+
217
+ ### Container
218
+ Root/group widget for child composition.
219
+
220
+ ### Canvas
221
+ Custom drawing placeholder.
222
+
223
+ ## 5. Layout Guide
224
+
225
+ Layouts are configured by container widgets:
226
+
227
+ - `tg.Column()` (default for containers): stacks children vertically
228
+ - `tg.Row()`: lays out children horizontally
229
+ - `tg.Grid(cols)`: lays out children into a fixed column grid
230
+ - `tg.Absolute()`: disables layout for that container (children keep their `set_position` values)
231
+
232
+ Layout applies recursively and re-runs on window resize.
233
+
234
+ ## 6. Animation Guide
235
+
236
+ The repository contains an animation subsystem (tween bookkeeping), but it is not currently integrated into the Python-facing runtime loop (there is no public Python API for animations yet).
237
+
238
+ ## 7. Styling Guide
239
+
240
+ Colors can be provided as `"#RRGGBB"` / `"#RRGGBBAA"` or `(r, g, b)` / `(r, g, b, a)` tuples.
241
+
242
+ Common styling calls:
243
+ ```python
244
+ btn = tg.Button("OK")
245
+ btn.set_background("#3A7AFE")
246
+ btn.set_text_color("#FFFFFF")
247
+ btn.set_border_radius(8)
248
+ btn.set_border_width(1)
249
+ btn.set_border_color("#1F2937")
250
+ btn.set_padding(10)
251
+ btn.set_margin(6)
252
+ ```
253
+
254
+ ## 9. Image Support
255
+
256
+ `truegraphics.Image` draws an image loaded from disk (PNG/JPG/etc) using Windows GDI+.
257
+
258
+ Signature:
259
+ ```python
260
+ Image(path: str = "")
261
+ ```
262
+
263
+ Methods:
264
+ - `set_source(path: str)`
265
+
266
+ ## 10. Animations, Timers, Async
267
+
268
+ Animations (numeric widget properties):
269
+ ```python
270
+ btn = tg.Button("Move me")
271
+ btn.animate("x", 300, duration=0.5)
272
+ ```
273
+ Supported properties: `"x"`, `"y"`, `"width"`, `"height"`.
274
+
275
+ Timers:
276
+ ```python
277
+ app.set_timeout(1.0, lambda: print("one second"))
278
+ timer_id = app.set_interval(0.5, lambda: print("tick"))
279
+ app.clear_timer(timer_id)
280
+ ```
281
+
282
+ Async:
283
+ ```python
284
+ def work():
285
+ # do slow work here
286
+ pass
287
+
288
+ app.run_async(work, on_done=lambda: print("done"))
289
+ ```
290
+
291
+ ## 10.1 Clipboard and Shortcuts
292
+
293
+ Clipboard helpers:
294
+ ```python
295
+ tg.clipboard_set_text("hello")
296
+ print(tg.clipboard_get_text())
297
+ ```
298
+
299
+ `TextBox` supports Ctrl+C/Ctrl+X/Ctrl+V (whole-text copy/cut/paste for now).
300
+
301
+ App shortcuts:
302
+ ```python
303
+ app.on_shortcut("Ctrl+S", lambda: print("save"))
304
+ ```
305
+
306
+ ## 10.2 Common Widgets (Group 2A)
307
+
308
+ `Slider(min=0.0, max=1.0, value=0.0, on_change=None)`:
309
+ ```python
310
+ tg.Slider(0, 100, 25, on_change=lambda v: print(v))
311
+ ```
312
+
313
+ `ProgressBar(value=0.0)`:
314
+ ```python
315
+ bar = tg.ProgressBar(0.3)
316
+ bar.value = 0.7
317
+ ```
318
+
319
+ `Dropdown(items=[], selected=0, on_change=None)`:
320
+ ```python
321
+ tg.Dropdown(["Low", "Medium", "High"], selected=1, on_change=lambda i: print(i))
322
+ ```
323
+
324
+ `Tabs()` with pages created by `tabs.tab(title)`:
325
+ ```python
326
+ tabs = tg.Tabs()
327
+ with tabs.tab("One"):
328
+ tg.Label("Tab one")
329
+ with tabs.tab("Two"):
330
+ tg.Label("Tab two")
331
+ ```
332
+
333
+ `RadioButton(text="", group="default", checked=False, on_change=None)`:
334
+ ```python
335
+ tg.RadioButton("Option A", group="mode", checked=True)
336
+ tg.RadioButton("Option B", group="mode")
337
+ ```
338
+
339
+ `TextArea(text="")`:
340
+ ```python
341
+ ta = tg.TextArea("Line 1\nLine 2")
342
+ ta.set_size(520, 220)
343
+ ```
344
+
345
+ `PasswordBox(text="")`:
346
+ ```python
347
+ tg.PasswordBox("secret")
348
+ ```
349
+
350
+ `ListView(items=[], on_select=None)`:
351
+ ```python
352
+ tg.ListView(["One", "Two", "Three"], on_select=lambda i: print("selected", i))
353
+ ```
354
+
355
+ `Table(headers=[], rows=[])`:
356
+ ```python
357
+ tg.Table(["Name", "Value"], [["A", "1"], ["B", "2"]])
358
+ ```
359
+
360
+ `TreeView(items=[], on_select=None)` where items are `(text, level)` pairs:
361
+ ```python
362
+ items = [("Root", 0), ("Child 1", 1), ("Child 2", 1)]
363
+ tg.TreeView(items, on_select=lambda i: print("selected", i))
364
+ ```
365
+
366
+ `ScrollView()`:
367
+ ```python
368
+ scroll = tg.ScrollView()
369
+ scroll.set_size(520, 240)
370
+ with scroll:
371
+ for i in range(30):
372
+ tg.Label(f"Row {i}")
373
+ ```
374
+
375
+ Horizontal scroll: hold Shift while scrolling the mouse wheel.
376
+
377
+ ## 10.3 Dialog Helpers
378
+
379
+ ```python
380
+ tg.message_box("Hello", "Title")
381
+ path = tg.open_file_dialog()
382
+ save = tg.save_file_dialog()
383
+ ```
384
+
385
+ ## 11. Platform Features
386
+
387
+ ## 11.1 Resources and Fonts
388
+
389
+ Resource paths:
390
+ ```python
391
+ tg.add_resource_path("assets")
392
+ print(tg.resolve_resource("logo.png"))
393
+ ```
394
+
395
+ Load a font file (process-private) and use it by family name:
396
+ ```python
397
+ tg.load_font("assets/MyFont.ttf")
398
+
399
+ lbl = tg.Label("Hello")
400
+ lbl.set_font("My Font Family Name")
401
+ lbl.set_font_size(18)
402
+ ```
403
+
404
+ ## 11.2 Drag and Drop (files)
405
+
406
+ Register a file-drop callback on any widget:
407
+ ```python
408
+ label = tg.Label("Drop files here")
409
+ label.on_drop_files(lambda files: label.set_text(str(files)))
410
+ ```
411
+
412
+ ## 11.3 Multi-window and System Tray
413
+
414
+ Additional windows (registered before `run()`):
415
+ ```python
416
+ app = tg.App()
417
+
418
+ @app.window
419
+ def main():
420
+ tg.Label("Main")
421
+
422
+ def second():
423
+ tg.Label("Second window")
424
+
425
+ app.add_window(second, title="Second", width=420, height=220)
426
+ app.run()
427
+ ```
428
+
429
+ System tray icon:
430
+ ```python
431
+ app = tg.App()
432
+ app.enable_tray("assets/app.ico", "TrueGraphics", on_click=lambda: tg.message_box("clicked", "tray"))
433
+
434
+ @app.window
435
+ def main():
436
+ tg.Label("Running")
437
+
438
+ app.run()
439
+ ```
440
+
441
+ ## 11.4 Known Gaps
442
+
443
+ - No IME / complex text shaping.
444
+ - Text measurement/wrapping is not layout-aware yet.
445
+ - Accessibility is not implemented.
446
+
447
+ ## 8. Extensibility
448
+
449
+ Plugins and async tasks have dedicated engine modules so the architecture can scale without breaking the public Python API.