Selaa lähdekoodia

Fixed property value drawing bug under xlib

For some reason `xlib` still draws text even if the scissor rect has
a width or height of `0`. I don't know if this is a bug on my end or
on xlib but whatever the source it is now fixed.
vurtun 9 vuotta sitten
vanhempi
commit
792a3af51e
1 muutettua tiedostoa jossa 4 lisäystä ja 5 poistoa
  1. 4 5
      nuklear.h

+ 4 - 5
nuklear.h

@@ -5368,7 +5368,7 @@ nk_draw_image(struct nk_command_buffer *b, struct nk_rect r,
     if (!b) return;
     if (b->use_clipping) {
         const struct nk_rect *c = &b->clip;
-        if (!NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
+        if (!c->w || !c->h || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
             return;
     }
 
@@ -5395,17 +5395,16 @@ nk_draw_text(struct nk_command_buffer *b, struct nk_rect r,
     if (!b || !string || !length || (bg.a == 0 && fg.a == 0)) return;
     if (b->use_clipping) {
         const struct nk_rect *c = &b->clip;
-        if (!NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
+        if (!c->w || !c->h || !NK_INTERSECT(r.x, r.y, r.w, r.h, c->x, c->y, c->w, c->h))
             return;
     }
 
     /* make sure text fits inside bounds */
     text_width = font->width(font->userdata, font->height, string, length);
     if (text_width > r.w){
-        float txt_width = (float)text_width;
         int glyphs = 0;
-        length = nk_text_clamp(font, string, length,
-                    r.w, &glyphs, &txt_width);
+        float txt_width = (float)text_width;
+        length = nk_text_clamp(font, string, length, r.w, &glyphs, &txt_width);
     }
 
     if (!length) return;