From 864ee5f167d1e2dda9bfce24ef617d71ce49bfd8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 7 Dec 2021 20:20:27 +0100 Subject: scrollview --- src/mgui/image.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mgui/image.c') 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 }; + } } -- cgit v1.2.3