32#pragma mark - ObjectInterface
46 glDeleteTextures(1, &this->texture);
59 String *classNames = $((Object *) this->classNames,
description);
60 String *
description = str(
"%s@%p \"%s\" %s [%d, %d, %d, %d]",
61 this->identifier ?: classnameof(self),
63 ((
Text *) self)->text,
65 this->frame.x, this->frame.y, this->frame.w, this->frame.h);
88 char *fontFamily = NULL;
89 int fontSize = -1, fontStyle = -1;
126 $(self,
bind, inlets, dictionary);
151 if (this->texture == 0) {
155 this->lineWrap ? frame.w : 0);
160 SDL_FreeSurface(surface);
163 assert(this->texture);
189 glDeleteTextures(1, &this->texture);
243 if (font != self->
font) {
246 self->
font = retain(font);
249 glDeleteTextures(1, &self->
texture);
263 if (strcmp(self->
text ?:
"", text ?:
"")) {
267 if (text && strlen(text)) {
268 self->
text = strdup(text);
274 glDeleteTextures(1, &self->
texture);
295 const int len = vasprintf(&text, fmt, args);
304#pragma mark - Class lifecycle
311 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
312 ((ObjectInterface *) clazz->interface)->description =
description;
314 ((ViewInterface *) clazz->interface)->applyStyle =
applyStyle;
316 ((ViewInterface *) clazz->interface)->init =
init;
320 ((ViewInterface *) clazz->interface)->sizeThatFits =
sizeThatFits;
322 ((TextInterface *) clazz->interface)->initWithText =
initWithText;
323 ((TextInterface *) clazz->interface)->naturalSize =
naturalSize;
324 ((TextInterface *) clazz->interface)->setFont =
setFont;
325 ((TextInterface *) clazz->interface)->setText =
setText;
338 clazz = _initialize(&(
const ClassDef) {
340 .superclass =
_View(),
341 .instanceSize =
sizeof(
Text),
342 .interfaceOffset = offsetof(
Text, interface),
343 .interfaceSize =
sizeof(TextInterface),
const EnumName FontStyleNames[]
static String * description(const Object *self)
static void dealloc(Object *self)
static void initialize(Class *clazz)
Text rendered with TrueType fonts.
#define MakeSize(w, h)
Creates an SDL_Size with the given dimensions.
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
Box * initWithFrame(Box *self, const SDL_Rect *frame)
Initializes this Box with the given frame.
SDL_Size naturalSize(const CollectionView *self)
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.
Font * cachedFont(const char *family, int size, int style)
Resolves the cached Font with the given attributes.
void renderCharacters(const Font *self, const char *chars, SDL_Color color, int wrapWidth)
Renders the given characters in this Font.
void renderDeviceDidReset(Font *self)
This method should be invoked when the render context is invalidated.
void sizeCharacters(const Font *self, const char *chars, int *w, int *h)
SDL_Size size(const Image *self)
Inlets enable inbound data binding of View attributes through JSON.
Label * initWithText(Label *self, const char *text, Font *font)
Initializes this Label with the given text and Font.
The Renderer is responsible for rasterizing the View hierarchy of a WindowController.
GLuint createTexture(const Renderer *self, const SDL_Surface *surface)
Generates and binds to an OpenGL texture object, uploading the given surface.
void renderDeviceWillReset(Renderer *self)
This method is invoked when the render device will become reset.
void drawTexture(const Renderer *self, GLuint texture, const SDL_Rect *dest)
Draws a textured GL_QUAD in the given rectangle.
Text rendered with TrueType fonts.
void setFont(Text *self, Font *font)
Sets this Text's font.
void setTextWithFormat(Text *self, const char *fmt,...)
Sets this Text's text with the given format string.
GLuint texture
The rendered texture.
void setText(Text *self, const char *text)
Sets this Text's text.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
_Bool bind(View *self, const Inlet *inlets, const Dictionary *dictionary)
Performs data binding for the Inlets described in dictionary.
Class * _View(void)
The View archetype.
void applyStyle(View *self, const Style *style)
Applies the given Style to this View.
void sizeThatFits(const View *self)
void awakeWithDictionary(View *self, const Dictionary *dictionary)
Wakes this View with the specified Dictionary.
SDL_Rect renderFrame(const View *self)
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.
void sizeToFit(View *self)
Resizes this View to fit its subviews.