Styles provide a means by which to inherit attribute values from a patcher that are consistently used across many objects.
More...
|
#define | FILL_ATTR_SAVE |
| Flag indicating we want this fill attribute saved (creates attrs). More...
|
|
#define | CLASS_ATTR_STYLE_RGBA_NOSAVE(c, attrname, flags, structname, structmember, label) |
| Define an RGBA style attribute with standard settings. More...
|
|
#define | CLASS_ATTR_STYLE_RGBA(c, attrname, flags, structname, structmember, label) |
| Define an RGBA style attribute with standard settings. More...
|
|
#define | CLASS_ATTR_STYLE_RGBA_PREVIEW(c, attrname, flags, structname, structmember, label, previewtype) |
| Define an RGBA style attribute with standard settings. More...
|
|
#define | CLASS_ATTR_STYLE_ALIAS_NOSAVE(c, attrname, aliasname) |
| Define an unsaved alias. More...
|
|
#define | CLASS_ATTR_STYLE_ALIAS_COMPATIBILITY(c, attrname, aliasname) |
| Define a Max 5/6 saved compatibility alias. More...
|
|
#define | CLASS_ATTR_STYLE_ALIAS_RGBA_LEGACY(c, attrname, aliasname) |
| Define a Max 4 legacy RGB attribute alias. More...
|
|
|
BEGIN_USING_C_LINKAGE void | class_attr_setstyle (t_class *c, const char *s) |
| Add an attribute to the current style. More...
|
|
void | class_attr_style_alias (t_class *c, const char *name, const char *aliasname, long legacy) |
| Add an alias to the current style. More...
|
|
void | class_attr_setfill (t_class *c, const char *name, long flags) |
| Specify that an attr requires a fill. More...
|
|
void | jgraphics_attr_fillrect (t_object *b, t_jgraphics *g, t_symbol *attrname, t_rect *area) |
| Fill using the current value of a named style color that exists either in the object or the defined style. More...
|
|
t_jpattern * | jgraphics_attr_setfill (t_object *b, t_jgraphics *g, t_symbol *attrname, t_rect *area) |
| Fill using the current value of a named style color that exists either in the object or the defined style. More...
|
|
void | object_attr_getfillcolor_atposition (t_object *b, const char *attrname, double pos, t_jrgba *c) |
| Determine the color at a given position in a fill. More...
|
|
long | object_attr_getfill (t_object *obj, t_symbol *attrname) |
| Determine if an attribute is a fill. More...
|
|
void | class_attr_stylemap (t_class *c, char *attrname, char *mapname) |
| Associate the name of an attribute of your class with the name of an attribute of a style. More...
|
|
Styles provide a means by which to inherit attribute values from a patcher that are consistently used across many objects.
#define CLASS_ATTR_STYLE_ALIAS_COMPATIBILITY |
( |
|
c, |
|
|
|
attrname, |
|
|
|
aliasname |
|
) |
| |
Define a Max 5/6 saved compatibility alias.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
aliasname | The name of the alias. |
#define CLASS_ATTR_STYLE_ALIAS_NOSAVE |
( |
|
c, |
|
|
|
attrname, |
|
|
|
aliasname |
|
) |
| |
Define an unsaved alias.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
aliasname | The name of the alias. |
- See also
- 'jslider' example project in the SDK.
#define CLASS_ATTR_STYLE_ALIAS_RGBA_LEGACY |
( |
|
c, |
|
|
|
attrname, |
|
|
|
aliasname |
|
) |
| |
Define a Max 4 legacy RGB attribute alias.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
aliasname | The name of the alias. |
- See also
- 'jslider' example project in the SDK.
#define CLASS_ATTR_STYLE_RGBA |
( |
|
c, |
|
|
|
attrname, |
|
|
|
flags, |
|
|
|
structname, |
|
|
|
structmember, |
|
|
|
label |
|
) |
| |
Define an RGBA style attribute with standard settings.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
flags | Any flags you wish to declare for this attribute, as defined in e_max_attrflags. |
structname | The C identifier for the struct (containing a valid t_object header) representing an instance of this class. |
structmember | The C identifier of the member in the struct that holds the value of this attribute. |
label | A human-friendly label for the Max inspector. |
- See also
- CLASS_ATTR_STYLE_RGBA_NOSAVE is a variant that does not save the state with the Patcher.
-
CLASS_ATTR_STYLE_RGBA_PREVIEW is a variant that provides a style preview.
-
class_attr_setstyle() is the lower level function used to provide the style part of the attribute definition.
#define CLASS_ATTR_STYLE_RGBA_NOSAVE |
( |
|
c, |
|
|
|
attrname, |
|
|
|
flags, |
|
|
|
structname, |
|
|
|
structmember, |
|
|
|
label |
|
) |
| |
Define an RGBA style attribute with standard settings.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
flags | Any flags you wish to declare for this attribute, as defined in e_max_attrflags. |
structname | The C identifier for the struct (containing a valid t_object header) representing an instance of this class. |
structmember | The C identifier of the member in the struct that holds the value of this attribute. |
label | A human-friendly label for the Max inspector. |
- See also
- CLASS_ATTR_STYLE_RGBA is a variant that saves the state with the Patcher.
-
CLASS_ATTR_STYLE_RGBA_PREVIEW is a variant that provides a style preview.
-
class_attr_setstyle() is the lower level function used to provide the style part of the attribute definition.
#define CLASS_ATTR_STYLE_RGBA_PREVIEW |
( |
|
c, |
|
|
|
attrname, |
|
|
|
flags, |
|
|
|
structname, |
|
|
|
structmember, |
|
|
|
label, |
|
|
|
previewtype |
|
) |
| |
Define an RGBA style attribute with standard settings.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
flags | Any flags you wish to declare for this attribute, as defined in e_max_attrflags. |
structname | The C identifier for the struct (containing a valid t_object header) representing an instance of this class. |
structmember | The C identifier of the member in the struct that holds the value of this attribute. |
label | A human-friendly label for the Max inspector. |
previewtype | Type of preview to use in the style bar, e.g. "triangle_fill" |
- See also
- CLASS_ATTR_STYLE_RGBA_NOSAVE is a variant that does not save the state with the Patcher.
-
CLASS_ATTR_STYLE_RGBA is a variant that saves the state with the Patcher but does not provide the preview.
-
class_attr_setstyle() is the lower level function used to provide the style part of the attribute definition.
Flag indicating we want this fill attribute saved (creates attrs).
- See also
- class_attr_setfill()
-
The 'uitextfield' example project in the SDK.
void class_attr_setfill |
( |
t_class * |
c, |
|
|
const char * |
name, |
|
|
long |
flags |
|
) |
| |
Specify that an attr requires a fill.
- Parameters
-
c | The class whose attribute is a fill. |
name | The name of the attribute. |
flags | 0 for none, or FILL_ATTR_SAVE. |
- See also
- The 'uitextfield' example project in the SDK.
Add an attribute to the current style.
- Parameters
-
c | The class whose attribute will be added to the style. |
s | The name of the attribute to be added to the style. |
- See also
- The 'uitextfield' example project in the SDK.
void class_attr_style_alias |
( |
t_class * |
c, |
|
|
const char * |
name, |
|
|
const char * |
aliasname, |
|
|
long |
legacy |
|
) |
| |
Add an alias to the current style.
This is used for backward compatibility where an attribute using an old name will want a style applied to it from a different name. Typically you will use one of the macros such as CLASS_ATTR_STYLE_ALIAS_NOSAVE rather than using this function directly.
- Parameters
-
c | The class for whom the alias will be created. |
name | The name of the attribute of the style. |
aliasname | The name of the alias. |
legacy | Always pass 0 for this argument. |
- See also
- CLASS_ATTR_STYLE_ALIAS_NOSAVE
-
The 'jslider' project in the SDK.
void class_attr_stylemap |
( |
t_class * |
c, |
|
|
char * |
attrname, |
|
|
char * |
mapname |
|
) |
| |
Associate the name of an attribute of your class with the name of an attribute of a style.
- Parameters
-
c | The class whose attribute will be added to the style. |
attrname | The name of the attribute of your class. |
mapname | The name of the attribute from the style. |
- See also
- 'jslider' example project in the SDK.
Fill using the current value of a named style color that exists either in the object or the defined style.
Abdridged example from the 'attrui' object:
1 long is_fill = object_attr_getfill(destination, x->j_attr);
4 jgraphics_attr_fillrect((t_object *)destination, g, x->j_attr, rect);
5 jgraphics_rectangle(g, rect->x, rect->y, rect->width, rect->height); // ready to be stroked
8 object_attr_getjrgba(destination, x->j_attr, &color);
9 jgraphics_set_source_jrgba(g, &color);
10 jgraphics_rectangle(g, rect->x, rect->y, rect->width, rect->height);
11 jgraphics_fill_preserve(g);
14 jgraphics_set_source_jrgba(g, &bordercolor);
- Parameters
-
b | The instance of your object. |
g | The jgraphics context. |
attrname | The name of the attribute whose fill style you want. |
area | The rect area to be filled. |
Fill using the current value of a named style color that exists either in the object or the defined style.
Example from the 'panel' object:
3 r.x = r.y = thick * 0.5;
4 r.width = rect->width - thick;
5 r.height = rect->height - thick;
7 pat = jgraphics_attr_setfill((t_object *)x, g, ps_bgfillcolor, &r);
8 jgraphics_rectangle_rounded(g, r.x, r.y, r.width, r.height, round, round);
9 jgraphics_fill_preserve(g);
10 jgraphics_pattern_destroy(pat);
12 object_attr_getjrgba(x, ps_bordercolor, &color);
13 jgraphics_set_source_jrgba(g, &color);
14 jgraphics_set_line_width(g, thick);
- Parameters
-
b | The instance of your object. |
g | The jgraphics context. |
attrname | The name of the attribute whose fill style you want. |
area | The rect area to be filled. |
- Returns
- The pattern.
Determine if an attribute is a fill.
- Parameters
-
obj | The instance of your object. |
attrname | The name of the attribute to query. |
- Returns
- true if the object is a fill, otherwise false.
void object_attr_getfillcolor_atposition |
( |
t_object * |
b, |
|
|
const char * |
attrname, |
|
|
double |
pos, |
|
|
t_jrgba * |
c |
|
) |
| |
Determine the color at a given position in a fill.
- Parameters
-
b | The instance of your object. |
attrname | The name of the attribute to query. |
pos | The position in a range of [0.0, 1.0]. |
c | A valid t_jrgba whose members will be filled-in upon return. |
- Returns
- true if the object is a fill, otherwise false.