Skip to content

MiscShoesAPI.md

Noah Gibbs edited this page Nov 10, 2023 · 1 revision

The Shoes API

The Shoes API has changed a bit from early versions of Shoes to the most recent "official" version, Shoes4. That's ignoring the many different Shoes implementations, not all of which 100% agree on what constants, etc, are available. We do Shoes API research on Shoes3, Shoes4, etc in our quest to understand it.

This document is strongly based on the Shoes Manual(s) found in Red Shoes, and also mentions some features from Shoes4 Shoes-Core.

The Top Level

Shoes Raisins (2.0) and before used an odd-for-Ruby binding rule for methods, and so each Shoes app got its own semi-isolated method environment. In Policeman and later, a new Shoes file starts at the Ruby top level (TOPLEVEL_BINDING), which is sometimes called the Ruby main app. This is an incompatibility between Shoes 2.0 and 3.1+.

Scarpe uses a binding like Shoes 3.1+, but also doesn't load multiple Shoes apps into the same process.

Drawables

The methods for making buttons and other drawables are slot methods. That means drawables can only be created in slots (more or less). It also means that masks, shapes and images all act as slots. That's interesting because I can't tell if Slot is even a class or module or anything in Red Shoes. Mostly it seems to be a concept in the docs.

Drawable Styles

A drawable has a list of styles. For instance, the "para" drawable has "stroke" and "underline" as styles. Styles can be passed as keyword params to their constructors, and in a few specific cases (e.g. passing top and left to rect) can instead be passed as positional parameters.

Once the drawable is created the styles can be changed with the "style" method and (usually) by calling the same style's name as a setter method:

    @text = para "Whorple"
    @text.stroke = black
    @text.style(underline: "single")

Drawable Properties

It's hard to be certain, but I think all data on Shoes drawables are "styles" in the sense above. For instance, the text on a button or in an edit_line is a "text" style, which can be passed positionally but also set later using a style setter (NOTE: test style= later?)

The manual is written such that "path" on an image for video might not be a style, but perhaps a different sort of attribute, but still settable in a similar way? Hard to be sure.

Clone this wiki locally