agentleFS
gerphgerph/riscos-agent-skills/skills/using-toolbox-imagefilegadget/SKILL.md

using-toolbox-imagefilegadget

Skill4 starsChanged 7 months agoMITView on GitHub

Use when writing, reviewing, or debugging RISC OS Toolbox applications that use the ImageFileGadget object or its methods, including ImageFileGadget_SetValue, SetTransform, SetQuality, SetColourMap, SetScroll, GetBounds, and ImageFileGadget_MouseClick events.

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when application code uses the Toolbox ImageFileGadget object to display image files in a Toolbox Window.

    line 10
  2. Very specific:

    Call ImageFileGadget_SetValue with the filetype, data pointer, and data length.

    line 27
  3. Very specific:

    If code needs the actual ImageFileRender register contract or transform block formats, read the riscos-output ImageFileRender reference.

    line 92
  4. Very specific:

    Use *ImageFileRenderers to confirm that a renderer is registered for the filetype being supplied to ImageFileGadget_SetValue.

    line 131
  5. Distinctive:

    If the image is blank, check:

    line 134

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Toolbox ImageFileGadget

Use this skill when application code uses the Toolbox ImageFileGadget object to display image files in a Toolbox Window. ImageFileGadget is a client of ImageFileRender: the application supplies image file bytes and metadata, and the gadget performs redraws by calling ImageFileRender_Render.

For direct image rendering or for implementing new filetype renderers, use the riscos-output skill and read its references/imagefilerender.md reference. New image file format support is registered with ImageFileRender, not with ImageFileGadget. Once a renderer is registered for a filetype, ImageFileGadget can render that filetype through its normal SetValue method.

Application Workflow

  1. Include the ImageFileGadget Toolbox headers and use a Toolbox resource which contains an ImageFileGadget component.
  2. Load the image file into memory and determine its RISC OS filetype, normally from (load_address >> 8) & &FFF.
  3. Call ImageFileGadget_SetValue with the filetype, data pointer, and data length.
  4. Optionally call ImageFileGadget_SetIndex, SetQuality, SetColourMap, SetTransform, or SetScroll to configure how the image is displayed.
  5. Register a Toolbox handler for ImageFileGadget_MouseClick if the application needs image-coordinate mouse interaction.

Applications do not need to register the gadget type with the Toolbox Window object. That is internal module setup done by ImageFileGadget itself.

Template and Flags

The ImageFileGadget template extends a normal Toolbox GadgetHeader:

typedef struct {
    GadgetHeader hdr;
    int event;
    unsigned int unused;
    unsigned int background;
} ImageFileGadget;

Useful gadget flags:

FlagMeaning
ImageFileGadget_NoBorderDisable the gadget border
ImageFileGadget_ColourMapWholeApply colour mapping to the whole gadget area

Public Methods

MethodPurpose
ImageFileGadget_SetValue(flags, window, component, filetype, data, length)Set the image bytes and filetype
ImageFileGadget_GetValue(flags, window, component, &filetype, &data, &length)Read the current filetype, data pointer, and length
ImageFileGadget_SetColour / GetColourSet or read the background colour
ImageFileGadget_SetState / GetStateSet or read gadget state bits
ImageFileGadget_SetIndex / GetIndexSelect or read the image sequence number
ImageFileGadget_SetQuality / GetQualitySelect or read the ImageFileRender quality level
ImageFileGadget_SetColourMapSupply a colour map descriptor
ImageFileGadget_SetTransformSet the ImageFileRender transform type and transform data
ImageFileGadget_SetScroll / GetScrollSet or read the scroll position
ImageFileGadget_GetBoundsRead bounds for the current image and transform

ImageFileGadget_DesktopColours is used with colour methods when the colour is a desktop colour. ImageFileGadget_ImageCoords is used with scroll methods when scroll positions are in image coordinates.

Transform and Display

ImageFileGadget_SetTransform uses the same transform types and data blocks as ImageFileRender:

Transform typeData
TRANSFORMTYPE_SIZE16-byte to-fit block: width, height, border, angle
TRANSFORMTYPE_SCALEStandard 16-byte scale block: xmult, ymult, xdiv, ydiv
TRANSFORMTYPE_TRANSFORMSix-word standard transform matrix

The gadget computes display size with ImageFileRender_BBox, then redraws inside Wimp redraw rectangles using ImageFileRender_Render. It normally uses FLAG_IGNORE_DOCUMENT_OFFSET, optional FLAG_COLOURMAP, and quality << FLAG_QUALITY_SHIFT.

If code needs the actual ImageFileRender register contract or transform block formats, read the riscos-output ImageFileRender reference.

Mouse Events

Mouse events are raised as ImageFileGadget_MouseClick. The event block is:

typedef struct {
    ToolboxEventHeader hdr;
    unsigned int flags;
    int smousex;
    int smousey;
    int imousex;
    int imousey;
} ImageFileGadgetMouseClickEvent;

smousex and smousey are screen coordinates within the gadget. imousex and imousey are image coordinates computed by inverting the ImageFileRender transform.

Mouse event flags:

FlagMeaning
ImageFileGadget_MouseClick_Flags_DoubleClickDouble-click
ImageFileGadget_MouseClick_Flags_AdjustClickAdjust button was used
ImageFileGadget_MouseClick_Flags_StartDragDrag start
ImageFileGadget_MouseClick_Flags_MenuClickMenu button was used
ImageFileGadget_MouseClick_Flags_XInImageX coordinate is inside image bounds
ImageFileGadget_MouseClick_Flags_XLowX coordinate is below image bounds
ImageFileGadget_MouseClick_Flags_XHighX coordinate is above image bounds
ImageFileGadget_MouseClick_Flags_YInImageY coordinate is inside image bounds
ImageFileGadget_MouseClick_Flags_YLowY coordinate is below image bounds
ImageFileGadget_MouseClick_Flags_YHighY coordinate is above image bounds

Debugging

Use *ImageFileRenderers to confirm that a renderer is registered for the filetype being supplied to ImageFileGadget_SetValue.

If the image is blank, check:

  • The file data pointer remains valid for as long as the gadget needs it.
  • The filetype matches the image data.
  • A renderer exists for that filetype.
  • The transform data matches the selected transform type.
  • The quality value is in the ImageFileRender range 0-15.
  • Scroll values are using the expected coordinate system.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.