Commit graph

389 commits

Author SHA1 Message Date
Seintian
de3d63cf61 feat(ncurses): optimize rendering, fix memory leaks, and add rounded corners
Significantly improves the stability, performance, and visual quality of the ncurses renderer.
**Renderer Improvements (`clay_renderer_ncurses.c`):**
*   **Flicker Reduction**:
    *   Removed `erase()` call at the start of the frame to enable differential rendering.
    *   Implemented "Dirty Check" optimizations for Rectangles, Borders, and Text. The renderer now reads the existing screen content (using `mvinch`, `mvin_wch`, `mvin_wchnstr`) and only issues draw commands if the content or color differs.
    *   Hardened Rectangle dirty check to mask out volatile attributes (comparing only `A_CHARTEXT | A_COLOR`), preventing false-positive redraws caused by internal terminal flags.
*   **Memory Safety**:
    *   Fixed internal ncurses memory leaks by calling `delscreen(set_term(NULL))` in `Clay_Ncurses_Terminate` to properly free the default screen wrapper.
*   **Visual Features**:
    *   Added support for **Rounded Corners**: Borders with `cornerRadius > 0` now render using Unicode arc characters (`╭`, `╮`, `╯`, `╰`).
    *   Upgraded standard borders to use full Unicode box-drawing characters.
**Example Application Updates (`ncurses-example/main.c`):**
*   **Layout Stability**:
    *   Refactored all layout dimensions and gaps to use `CLAY_NCURSES_CELL_WIDTH` (8) and `CLAY_NCURSES_CELL_HEIGHT` (16) macros, ensuring strict grid alignment.
    *   Fixed vertical jitter in "Profile Icon" and text headers by enforcing exact height multiples and top-alignment, eliminating sub-pixel rounding errors during scroll.
*   **New UI Elements**:
    *   Added a **Floating Help Modal** (toggled via 'H') to demonstrate Z-ordering and localized input handling.
    *   Added "Server Status" progress bars to the Sidebar to demonstrate percent-based sizing and colored rectangles.
    *   Added "Mixed Border" examples to the Sidebar to showcase the new rounded corner capabilities.
    *   Added "Black" background constant usage for cleaner code.
2025-12-28 18:05:06 +01:00
Seintian
d4a48a07fc feat(ncurses): overhaul renderer with UTF-8, 256-colors, and visual improvements
Significantly enhances the Ncurses renderer capabilities and updates the example application.

Renderer Changes:
- Unicode Support:
  - Implemented automatic UTF-8 locale detection and initialization.
  - Switched to wide-character handling (`wchar_t`, `mvaddnwstr`) for correct rendering of multi-byte characters (e.g., Emojis).
  - Used `wcwidth` for accurate string width measurement.
- Color Support:
  - Upgraded from 3-bit (8 colors) to 256-color support (xterm-256color).
  - Added `Clay_Ncurses_MatchColor` to map arbitrary RGB values to the nearest color in the standard 6x6x6 color cube.
  - Added capability detection to fallback gracefully on simpler terminals.
- Visual Fidelity:
  - Implemented background color inheritance (`Clay_Ncurses_GetBackgroundAt`) to simulate transparency.
  - Text and borders now render on top of existing background colors instead of resetting to the terminal default.
- Build & POSIX:
  - Added `_XOPEN_SOURCE_EXTENDED` and `_XOPEN_SOURCE=700` definitions for standard compliance.

Example Application (clay-ncurses-example):
- Theme:
  - Updated to a modern dark theme (Uniform `{20, 20, 20}` background).
  - Switched to saturated/bright foreground colors for better contrast.
- Fixes:
  - Replaced obsolete `usleep` with POSIX-compliant `nanosleep`.
- Build:
  - Updated CMakeLists.txt to enforce linking against `ncursesw` (wide version).

Verified with `clay-ncurses-example` on Linux (xterm-256color).
2025-12-28 15:19:37 +01:00
Seintian
840606d0c1 feat: Add ncurses renderer and example
- **Renderer**: Implemented `clay_renderer_ncurses.c` supporting rectangles, text, borders, and clipping using standard ncurses plotting.
- **Example**: Added `examples/ncurses-example` demonstrating a scrollable "Social Feed" UI with keyboard navigation.
- **Build**: Added `CLAY_INCLUDE_NCURSES_EXAMPLES` option to root `CMakeLists.txt` and integrated the new example.
- **CompConfig**: Updated `.gitignore` to strictly exclude `build/`, `_deps/`, and other standard CMake artifacts.
2025-12-28 14:01:41 +01:00
github-actions[bot]
7d099ad870 [bindings/odin] Update Odin bindings
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-12-23 06:29:55 +00:00
Rats
681e085cd4
[Core] Include floating element count in text id hash (#567) 2025-12-23 17:29:09 +11:00
Isaiah Paget
389a044cd2
[Bindings/Odin] Fixed incorrect assignment in README example (#533)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-12-05 14:23:56 +11:00
github-actions[bot]
2749e56e7e [bindings/odin] Update Odin bindings
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-11-26 04:12:20 +00:00
TotallyGamerJet
0c8e300524
[Core] Update Clay_OnHover to take void* instead of uintptr_t (#334) 2025-11-26 15:11:34 +11:00
Yang Zhang
7a9a976d42
Remove unneeded semicolon so that Odin compiler won't fail with -strict-style -vet (#514) 2025-11-26 13:38:34 +11:00
Rats
c13feb2428
[Bindings/Odin] Improve example text measurement function (#541)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-11-12 09:46:20 +11:00
Daniel Mayovskiy
fd97d8179e
[Renderers/termbox] fixed horizontal text culling bug (#525)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-10-23 12:58:39 +11:00
Daniel Mayovskiy
7216815536
Fixed termbox2 demo build, added scroll functionality (#523) 2025-10-23 12:57:11 +11:00
Thomas Anderson
83129995f7
[Examples/official-website] updated paths in build.sh 2025-10-23 12:56:20 +11:00
Daniel Mayovskiy
588b93196c
[Renderers/termbox] Fixing termbox2-image-demo build error (#524)
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-10-02 11:21:11 +10:00
github-actions[bot]
382dcde89d [bindings/odin] Update Odin bindings 2025-10-02 01:17:05 +00:00
elmfrain
c6442bd192
[Bug Fix] Multiple Floating Elements Cannot Use Clay_Hovered() (#461)
Co-authored-by: Nic Barker <contact+github@nicbarker.com>
2025-10-02 11:14:17 +10:00
Nic Barker
7874cdb085 Fix README update
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / check_changes (push) Has been cancelled
Odin Bindings Update / build (macos-latest) (push) Has been cancelled
Odin Bindings Update / build (ubuntu-latest) (push) Has been cancelled
Odin Bindings Update / commit (push) Has been cancelled
2025-09-29 13:27:40 +10:00
github-actions[bot]
37675089e3 [bindings/odin] Update Odin bindings 2025-09-16 01:40:04 +00:00
Nic Barker
1cbc56cbf2
[Core] Remove ID from element declaration struct and split clay macro into CLAY and CLAY_WITHID (#492) 2025-09-16 11:39:07 +10:00
github-actions[bot]
0d6969c8c3 [bindings/odin] Update Odin bindings 2025-09-08 02:15:33 +00:00
Víctor López
958d684b3c
[Compilers] Fix struct with default initializer not using CLAY__DEFAULT_STRUCT (#498) 2025-09-08 12:14:05 +10:00
Rats
f55513493b
[Bindings/Odin] Fix ID procedure ignoring index (#496) 2025-09-08 12:13:00 +10:00
github-actions[bot]
dabf8214a8 [bindings/odin] Update Odin bindings 2025-09-08 02:12:08 +00:00
fgungor
747643e84e
[Core] fix unused extra macro param in CLAY_SID_LOCAL (#505) 2025-09-08 12:10:10 +10:00
rivten
5a0d301c60
[Renderers/Sokol] allow usage of images with sokol renderer (#489)
Co-authored-by: Hugo Viala <h.viala@ganacos.com>
Co-authored-by: Andrew Sampson <1297077+andrewmd5@users.noreply.github.com>
2025-09-08 11:35:18 +10:00
Andrew Sampson
1bc5105272
[Renderers/Sokol] Text measurement/rendering width mismatch in sokol_clay (#480) 2025-08-19 12:14:13 +10:00
github-actions[bot]
61bab7bba6 [bindings/odin] Update Odin bindings 2025-08-14 23:38:20 +00:00
Nic Barker
7f767d2301 [Core] Increase the default scroll container limit to 100 2025-08-15 09:37:23 +10:00
Daniel S Jeremiah
2b192409b9
[Documentation] -- updated README (#475) 2025-08-14 10:02:23 +10:00
github-actions[bot]
91c6d05774 [bindings/odin] Update Odin bindings 2025-07-15 23:32:23 +00:00
Nic Barker
4aa3d75bef [Core] Split base ID hash from index ID hash 2025-07-16 09:30:54 +10:00
Hayden Gray
9d38edb989
[Bindings/Odin] SizingFit and SizingGrow default parameters (#462) 2025-07-09 09:07:10 +10:00
github-actions[bot]
516e85bdfe [bindings/odin] Update Odin bindings 2025-07-01 23:47:56 +00:00
Tomás Ralph
0022d12c0c
[DebugTools] Fix aspect ratio display, closes #449 (#451) 2025-07-02 09:46:12 +10:00
Nic Barker
d9d0b6c37b [Core] Fix incorrect percentage sizing of floating elements 2025-07-02 09:37:38 +10:00
Hayden Gray
8dfcc944fa
[Bindings/Odin] - add CI to update binding libs (#452) 2025-06-27 15:05:13 +10:00
Mivirl
a9c1f9a8a7
[Renderers/termbox2] Termbox2 renderer & examples (#419) 2025-06-27 08:26:38 +10:00
Nic Barker
281f961e3d [Bindings/Odin] Update Odin bindings 2025-06-24 13:57:15 +10:00
Nic Barker
3433a53a8e [Core] Fix an alignment bug for scrolling container contents 2025-06-24 13:55:20 +10:00
wolfee
4a91cac1b2
[Renderers/SDL3] Fix border position calculated incorrectly (#446) 2025-06-23 10:43:08 +10:00
Nic Barker
ff7917798c [Core] Avoid calling measure text function with length zero 2025-06-23 10:10:13 +10:00
wolfee
f97cb9ea10
[Renderers/SDL] Font sizing is ignored (#444) 2025-06-23 09:30:14 +10:00
Nic Barker
74f0ffbe26 [Renderers/Cairo] Fix outdated image API usage in cairo example 2025-06-23 09:16:41 +10:00
Nic Barker
a5e212b8de [Renderers/HTML] Fix a mouse overlap bug with external scroll handling 2025-06-20 10:59:44 +10:00
Nic Barker
0835781602 [Bindings/Odin] Update Odin Bindings 2025-06-18 09:55:32 +10:00
Nic Barker
13ecd80ee5 [Renderers/SDL3] Fix up outdated API usage in SDL3 example 2025-06-18 09:54:27 +10:00
Nic Barker
c524485c46 [Core] Fix case where there could be 64 extra bytes of padding between arrays in clays internal arena 2025-06-17 13:07:56 +10:00
Nic Barker
b9e27178c0 [Core] Align base arena memory to 64 byte cache line 2025-06-17 10:32:30 +10:00
Nic Barker
6f10bf4b3d [Core] Remove erroneous break statement when using external scroll handling 2025-06-13 10:35:31 +10:00
Nic Barker
adb1bd620a [Examples/clay-official-website] Fix links on official website example 2025-06-13 09:59:07 +10:00