libmatoya Documentation

repository·master·Indexed 20 days ago

https://github.com/snowcone-ltd/libmatoya

A lightweight, cross-platform application development library providing a unified interface for windowing, input, networking, graphics, and data handling. It supports Windows 10, Android 9, macOS 10.15, Linux, and Web (Chrome 86+, Firefox 79+), featuring a small binary footprint and no external dependencies beyond the OS.

Tokens
980
Snippets
6
Records
9
Agent score
23%

What's inside libmatoya

  1. Overview of libmatoya features

    master

    libmatoya is a lightweight, cross-platform application development library designed to provide essential system services with a minimal footprint and no external dependencies beyond the OS.

    Key capabilities include:

    • Low Overhead: Small binary footprint (< 1MB static lib, ~300KB linked).
    • Cross-Platform: Single interface compatible with 7 platforms.
    • System & Input: Window creation, input handling, and robust game controller support.
    • Networking: HTTP/HTTPS, WebSockets, and TLS protocol wrappers.
    • Graphics: Accelerated video frame and UI draw list rendering.
    • Data & Security: JSON parsing/construction and common cryptography tasks.
  2. Supported platforms for libmatoya

    master

    libmatoya supports multiple platforms with varying requirements:

    PlatformMinimum VersionNotes
    Windows10
    AndroidAndroid 9 (API Level 28)
    macOS10.15
    iOS / tvOSComing soon!
    Linux*Relies on certain system dependencies at runtime
    Web** Chrome 86, Firefox 79Safari is currently not supported

    * Linux dependencies depend on the specific system environment. ** Web support is limited to Chrome 86+ and Firefox 79+.

  3. Calculate window sizing and positioning

    master

    Use mty_window_adjust to calculate the appropriate MTY_Frame for a window based on screen dimensions, scaling, and constraints. This is useful for handling responsive window layouts or high-DPI scaling.

    MTY_Frame frame = mty_window_adjust(screen_w, screen_h, scale, max_h, x, y, w, h);
  4. Access application event functions

    master

    Use mty_app_get_event_func to retrieve the event handling function for a given MTY_App instance. This function populates an opaque pointer which can then be used to hook into the application's event loop.

    MTY_EventFunc event_func;
    void *opaque;
    mty_app_get_event_func(app, (void **)&event_func, &opaque);
  5. Convert keyboard events to hotkeys

    master

    Use mty_app_kb_to_hotkey to map raw keyboard events (MTY_Event) to application-level hotkeys. This function takes the application instance, the event, and the MTY_EventType to perform the translation.

    mty_app_kb_to_hotkey(app, evt, type);
  6. Access window common properties

    master

    Use mty_window_get_common to retrieve the window_common structure for a specific MTY_Window. This structure provides access to the window's webview, graphics API (MTY_GFX), device context, and various graphics layers/contexts.

    struct window_common *common = mty_window_get_common(app, window);
    // Access webview or gfx layers
    struct webview *wv = common->webview;
  7. Use APP_DEFAULT_FRAME macro

    master

    The APP_DEFAULT_FRAME() macro is a convenience helper to initialize an MTY_Frame with default values: position (0, 0), size (800, 600), and a scale of 1.0f.

    // Initializes frame to 0,0, 800x600, scale 1.0
    APP_DEFAULT_FRAME();