aboutsummaryrefslogtreecommitdiff
path: root/src/mgui/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mgui/button.c')
-rw-r--r--src/mgui/button.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/mgui/button.c b/src/mgui/button.c
index 08cf91c..4abe8a0 100644
--- a/src/mgui/button.c
+++ b/src/mgui/button.c
@@ -61,8 +61,11 @@ void mgui_button_on_event(mgui_button *self, mgl_window *window, mgl_event *even
}
mgl_vec2i mgui_button_draw(mgui_button *self, mgl_window *window) {
- (void)window;
- mgl_rectangle_draw(mgl_get_context(), &self->background);
- mgl_text_draw(mgl_get_context(), &self->text);
- return (mgl_vec2i){ self->background.size.x, self->background.size.y };
+ const mgl_vec2i position = (mgl_vec2i){ self->background.position.x, self->background.position.y };
+ const mgl_vec2i size = (mgl_vec2i){ self->background.size.x, self->background.size.y };
+ if(mgui_rectangle_intersects_with_scissor(position, size, window)) {
+ mgl_rectangle_draw(mgl_get_context(), &self->background);
+ mgl_text_draw(mgl_get_context(), &self->text);
+ }
+ return size;
}