diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-12-07 20:20:27 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-12-07 20:20:27 +0100 |
commit | 864ee5f167d1e2dda9bfce24ef617d71ce49bfd8 (patch) | |
tree | 14c3bfe2d9b28dce43be9efae8e18156de7787fc /src/mgui/image.c | |
parent | d3a5b3d579e30ce02afd5e270dfdd511af195c31 (diff) |
scrollview
Diffstat (limited to 'src/mgui/image.c')
-rw-r--r-- | src/mgui/image.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mgui/image.c b/src/mgui/image.c index ad8a7d2..a3b163e 100644 --- a/src/mgui/image.c +++ b/src/mgui/image.c @@ -45,10 +45,12 @@ void mgui_image_on_event(mgui_image *self, mgl_window *window, mgl_event *event) } mgl_vec2i mgui_image_draw(mgui_image *self, mgl_window *window) { - (void)window; - mgl_sprite_draw(mgl_get_context(), &self->sprite); - if(self->sprite.texture) - return (mgl_vec2i){ self->sprite.texture->width, self->sprite.texture->height }; - else + if(self->sprite.texture) { + const mgl_vec2i texture_size = (mgl_vec2i){ self->sprite.texture->width, self->sprite.texture->height }; + if(mgui_rectangle_intersects_with_scissor((mgl_vec2i){ self->sprite.position.x, self->sprite.position.y }, texture_size, window)) + mgl_sprite_draw(mgl_get_context(), &self->sprite); + return texture_size; + } else { return (mgl_vec2i){ 0, 0 }; + } } |