Recipes

    Notifications from your code

    Design a toast, tag it, and show it from C++ with one call. It stacks, times out, and takes your own text.

    Design the notification where it should appear, such as a corner of the window, and tag it with the plugin. In the app it starts hidden. Your code shows it with one call: it fades in, rises into place, and hides itself after four seconds.

    Try it: click Save config a few times, then point at a toast.

    Set it up

    1. 1
      Design the toast

      Draw it as a frame or group inside the screen, where it should appear, with a title and a message. Leave it visible and at the top of the layer list, so nothing covers it.

    2. 2
      Tag it

      Select it and choose Notify → Make notification in the plugin. It's renamed notify: Saved; typing the name yourself works too.

    3. 3
      Optional: a close icon and a timer bar

      Inside it, tag an icon Closes its notification (close) and a thin bar Timer bar (progress). The bar empties as the toast's time runs out.

    4. 4
      Optional: a button that shows it

      Tag any layer Shows a notification (show: Saved) and a click on it shows the toast with its own texts.

    Layers panel
    • Menu
    • notify: Saved
    • Config saved
    • legit.cfg is active
    • close
    • progress
    • show: Saved
    • Sidebar

    Show it from your code

    your_logic.cpp
    #include "generated/generated_ui.hpp"
    
    // With the design's own texts:
    figma_generated::notify( "Saved" );
    
    // With your title and message in place of its first two texts:
    figma_generated::notify( "Saved", "Config loaded", "legit.cfg is active" );
    
    // Until its close icon is clicked (8.f would keep it for eight seconds):
    figma_generated::notify( "Error", "Injection failed", "Run the loader as administrator.", 0.f );

    The name is the one after notify:, in any case. The first two text layers, read top to bottom, take the title and the message, drawn in the design's font, size, and color from where the design's text starts; pass nullptr to keep either one. Call it from the thread that draws the UI, like the rest of Dear ImGui.

    How it behaves

    • Toasts stack. The newest appears where you designed it, and older ones move up, or down for a notification designed in the top half of the window. Notifications designed at the same spot, like a Saved and an Error toast, share one stack.
    • Each hides itself after four seconds, or the time you pass. The pointer over a toast pauses its timer.
    • A toast takes the clicks that land on it, so nothing beneath it reacts. Only its close icon responds; everything else inside a notification stays a plain visual.
    • A stack holds five toasts; showing a sixth lets the oldest go.