31 MakeEnumName(SDL_GPU_BLENDFACTOR_ZERO),
32 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE),
33 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_COLOR),
34 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR),
35 MakeEnumName(SDL_GPU_BLENDFACTOR_DST_COLOR),
36 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR),
37 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_ALPHA),
38 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA),
39 MakeEnumName(SDL_GPU_BLENDFACTOR_DST_ALPHA),
40 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA),
41 MakeEnumName(SDL_GPU_BLENDFACTOR_CONSTANT_COLOR),
42 MakeEnumName(SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR),
43 MakeEnumName(SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE)
46#define _Class _ImageView
59 free(this->imageName);
84 $(self, bind, inlets, dictionary);
102 if (this->imageName == NULL) {
106 char *
name = this->imageName;
107 this->imageName = NULL;
119 this->imageName =
name;
139 SDL_Rect region, *src = NULL;
146 if (atlasImage->
atlas) {
148 region = atlasImage->
rect;
153 if (this->texture == NULL) {
154 this->texture = $(renderer->
device, createTextureFromSurface,
155 this->image->surface, SDL_GPU_TEXTUREUSAGE_SAMPLER,
false);
156 assert(this->texture);
171 SDL_RectToFRect(&frame, &frect);
200#pragma mark - ImageView
210 self->
blend.
src = SDL_GPU_BLENDFACTOR_SRC_ALPHA;
211 self->
blend.
dst = SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
239 free(self->imageName);
240 self->imageName = NULL;
242 release(self->
image);
248 const SDL_Size imageSize = $(
image,
size);
283 self->imageName = strdup(
name);
310#pragma mark - Class lifecycle
317 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
320 ((ViewInterface *) clazz->interface)->didMoveToWindow =
didMoveToWindow;
321 ((ViewInterface *) clazz->interface)->init =
init;
325 ((ImageViewInterface *) clazz->interface)->initWithFrame =
initWithFrame;
342 clazz = _initialize(&(
const ClassDef) {
344 .superclass =
_View(),
346 .interfaceSize =
sizeof(ImageViewInterface),
Class * _AtlasImage(void)
static String * name(const Font *self)
static Image * initWithSurface(Image *self, SDL_Surface *surface)
static Image * imageWithResource(const Resource *resource, float pixelDensity)
static Image * imageWithResourceName(const char *name, float pixelDensity)
static SDL_Size size(const Image *self)
static Texture * texture(ImageAtlas *self, RenderDevice *device)
Packs many Images into one sheet, backed by one Texture.
static void setImageWithResource(ImageView *self, const Resource *resource)
static void didMoveToWindow(View *self, SDL_Window *window)
static void setImageWithSurface(ImageView *self, SDL_Surface *surface)
static View * init(View *self)
static void awakeWithDictionary(View *self, const Dictionary *dictionary)
static ImageView * initWithFrame(ImageView *self, const SDL_Rect *frame)
static void setImageWithResourceName(ImageView *self, const char *name)
static void setImage(ImageView *self, Image *image)
static void render(View *self, Renderer *renderer)
static ImageView * initWithImage(ImageView *self, Image *image)
static void dealloc(Object *self)
const EnumName SDLGPUBlendFactorNames[]
static void initialize(Class *clazz)
static void renderDeviceWillReset(View *self)
ImageViews render an Image in the context of a View hierarchy.
static void drawTextureRegion(const Renderer *self, Texture *texture, const SDL_Rect *src, const SDL_FRect *dest, const SDL_Color *color)
static void drawRoundedTextureRegion(const Renderer *self, Texture *texture, const SDL_Rect *src, const SDL_FRect *dest, int radius, const SDL_Color *color)
static Theme * theme(SDL_Window *window)
static Image * image(Theme *self, const char *name, float pixelDensity)
#define MakeInlets(...)
Creates a null-termianted array of Inlets.
#define MakeInlet(name, type, dest, data)
Creates an Inlet with the specified parameters.
static void resize(View *self, const SDL_Size *size)
static SDL_Rect renderFrame(const View *self)
An Image packed into an ImageAtlas.
SDL_Rect rect
This AtlasImage's rectangle within the atlas sheet, in texels.
ImageAtlas * atlas
The ImageAtlas this AtlasImage belongs to, or NULL once that atlas has been released,...
Packs many Images into one sheet, backed by one Texture.
ImageViews render an Image in the context of a View hierarchy.
void setImage(ImageView *self, Image *image)
Sets the Image for this ImageView.
Texture * texture
The GPU texture.
ImageView * initWithImage(ImageView *self, const SDL_Rect *frame)
SDL_Color color
The drawing color.
struct ImageView::@0 blend
The blend factors (currently unused; reserved for future per-pipeline support).
Inlets enable inbound data binding of View attributes through JSON.
Renderer extends Object with ObjectivelyMVC's UI rendering layer.
RenderDevice * device
The backing RenderDevice.
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
int borderRadius
The corner radius applied to the background, border and bevel.
void render(View *self, Renderer *renderer)
Renders this View using the given renderer.