fixed closing/minimize button icon bounding box + fixed opengl text width callback

This commit is contained in:
vurtun 2015-07-02 13:28:43 +02:00
parent 9180bc0b59
commit e973545e3b
2 changed files with 5 additions and 5 deletions

View File

@ -249,7 +249,7 @@ font_get_text_width(gui_handle handle, const gui_char *t, gui_size l)
if (!t || !l) return 0;
glyph_len = gui_utf_decode(t, &unicode, l);
while (text_len <= l && glyph_len) {
while (text_len < l && glyph_len) {
if (unicode == GUI_UTF_INVALID) return 0;
glyph = (unicode < font->glyph_count) ? &font->glyphes[unicode] : font->fallback;
glyph = (glyph->code == 0) ? font->fallback : glyph;
@ -258,7 +258,7 @@ font_get_text_width(gui_handle handle, const gui_char *t, gui_size l)
glyph_len = gui_utf_decode(t + text_len, &unicode, l - text_len);
text_len += glyph_len;
}
return (l > 1) ? text_width : 0;
return (l >= 1) ? text_width : 0;
}
static void

6
gui.c
View File

@ -1979,8 +1979,8 @@ gui_panel_begin(struct gui_panel_layout *l, struct gui_panel *p,
/* check if the close icon has been pressed and set the panel to hidden */
header_w -= close_w;
header_x += close_h - item_padding.x;
if (i && GUI_INBOX(mouse_x, mouse_y, close_x, close_y, close_w, close_h)) {
if (GUI_INBOX(clicked_x, clicked_y, close_x, close_y, close_w, close_h)) {
if (i && GUI_INBOX(mouse_x, mouse_y, close_x, close_y, text_width, close_h)) {
if (GUI_INBOX(clicked_x, clicked_y, close_x, close_y, text_width, close_h)) {
ret = !(i->mouse_down && i->mouse_clicked);
if (!ret) p->flags |= GUI_PANEL_HIDDEN;
}
@ -2008,7 +2008,7 @@ gui_panel_begin(struct gui_panel_layout *l, struct gui_panel *p,
/* minize the panel if the minimize icon has been pressed */
header_w -= min_w;
header_x += min_w - item_padding.x;
if (i && GUI_INBOX(mouse_x, mouse_y, min_x, min_y, min_w, min_h)) {
if (i && GUI_INBOX(mouse_x, mouse_y, min_x, min_y, text_width, min_h)) {
if (GUI_INBOX(clicked_x, clicked_y, min_x, min_y, min_w, min_h))
if (i->mouse_down && i->mouse_clicked)
p->minimized = !p->minimized;