_Bool panel_mmove(PANEL *p, int x, int y, int width, int height, int mx, int my, int dy) { mx -= (p->x < 0) ? width + p->x : p->x; my -= (p->y < 0) ? height + p->y : p->y; FUNC(); if(p->content_scroll) { int dy = scroll_gety(p->content_scroll, height); y -= dy; my += dy; } _Bool draw = p->type ? mmovefunc[p->type - 1](p, mx, my, dy, width, height) : 0; PANEL **pp = p->child, *subp; if(pp) { while((subp = *pp++)) { if(!subp->disabled) { draw |= panel_mmove(subp, x, y, width, height, mx, my, dy); } } } if(draw && p == &panel_main) { redraw(); } return draw; }
static void panel_draw_sub(PANEL *p, int x, int y, int width, int height) { FUNC(); if(p->content_scroll) { pushclip(x, y, width, height); y -= scroll_gety(p->content_scroll, height); } if(p->type) { drawfunc[p->type - 1](p, x, y, width, height); } else { if(p->drawfunc) { p->drawfunc(x, y, width, height); } } PANEL **pp = p->child, *subp; if(pp) { while((subp = *pp++)) { if(!subp->disabled) { panel_draw_sub(subp, x, y, width, height); } } } if(p->content_scroll) { popclip(); } }
static void panel_draw_core(PANEL *p, int x, int y, int width, int height) { FIX_XY_CORDS_FOR_SUBPANELS(); if (p->content_scroll) { pushclip(x, y, width, height); y -= scroll_gety(p->content_scroll, height); } if (p->type) { drawfunc[p->type - 1](p, x, y, width, height); } else { if (p->drawfunc) { p->drawfunc(x, y, width, height); } } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { panel_draw_core(subp, x, y, width, height); } } } if (p->content_scroll) { popclip(); } }
_Bool edit_mmove(EDIT *edit, int px, int py, int width, int height, int x, int y, int dx, int dy) { if(utox_window_baseline && py > utox_window_baseline - font_small_lineheight - 4 * SCALE) { y += py - (utox_window_baseline - font_small_lineheight - 4 * SCALE); py = utox_window_baseline - font_small_lineheight - 4 * SCALE; } _Bool need_redraw = 0; _Bool mouseover = inrect(x, y, 0, 0, width - (edit->multiline ? SCROLL_WIDTH : 0), height); if(mouseover) { cursor = CURSOR_TEXT; } if(mouseover != edit->mouseover) { edit->mouseover = mouseover; if(edit != active_edit) { need_redraw = 1; } } if(edit->multiline) { need_redraw |= scroll_mmove(edit->scroll, px, py, width, height, x, y, dx, dy); y += scroll_gety(edit->scroll, height); } if(edit == active_edit && edit_select) { if (edit->select_completely) { edit_setfocus(edit); need_redraw = 1; return need_redraw; } setfont(FONT_TEXT); edit_sel.p2 = hittextmultiline(x - 2 * SCALE, width - 4 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0), y - 2 * SCALE, INT_MAX, font_small_lineheight, edit->data, edit->length, edit->multiline); STRING_IDX start, length; if(edit_sel.p2 > edit_sel.p1) { start = edit_sel.p1; length = edit_sel.p2 - edit_sel.p1; } else { start = edit_sel.p2; length = edit_sel.p1 - edit_sel.p2; } if(start != edit_sel.start || length != edit_sel.length) { edit_sel.start = start; edit_sel.length = length; need_redraw = 1; } } else if(mouseover) { setfont(FONT_TEXT); edit->mouseover_char = hittextmultiline(x - 2 * SCALE, width - 4 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0), y - 2 * SCALE, INT_MAX, font_small_lineheight, edit->data, edit->length, edit->multiline); } return need_redraw; }
bool panel_mmove(PANEL *p, int x, int y, int width, int height, int mx, int my, int dx, int dy) { if (p == &panel_root) { mouse.x = mx; mouse.y = my; } mx -= (p->x < 0) ? width + SCALE(p->x) : SCALE(p->x); my -= (p->y < 0) ? height + SCALE(p->y) : SCALE(p->y); FIX_XY_CORDS_FOR_SUBPANELS(); int mmy = my; if (p->content_scroll) { const int scroll_y = scroll_gety(p->content_scroll, height); if (my < 0) { mmy = -1; } else if (my >= height) { mmy = 1024 * 1024 * 1024; // large value } else { mmy = my + scroll_y; } y -= scroll_y; my += scroll_y; } bool draw = p->type ? mmovefunc[p->type - 1](p, x, y, width, height, mx, mmy, dx, dy) : false; // Has to be called before children mmove if (p == &panel_root) { draw |= tooltip_mmove(); } PANEL **pp = p->child; if (pp) { PANEL *subp; while ((subp = *pp++)) { if (!subp->disabled) { draw |= panel_mmove(subp, x, y, width, height, mx, my, dx, dy); } } } if (p == &panel_root) { draw |= contextmenu_mmove(mx, my, dx, dy); if (draw) { redraw(); } } return draw; }
void edit_draw(EDIT *edit, int x, int y, int width, int height) { if((width - 4 * SCALE - SCROLL_WIDTH) < 0) { return; } if(utox_window_baseline && y > utox_window_baseline - font_small_lineheight - 4 * SCALE) { y = utox_window_baseline - font_small_lineheight - 4 * SCALE; } edit->width = width -4 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0); edit->height = height - 4 * SCALE; if(!edit->noborder) { framerect(x, y, x + width, y + height, (edit == active_edit) ? BLUE : (edit->mouseover ? C_GRAY2 : C_GRAY)); } drawrect(x + 1, y + 1, x + width - 1, y + height - 1, WHITE); setfont(FONT_TEXT); setcolor(COLOR_TEXT); int yy = y; if(edit->multiline) { pushclip(x + 1, y + 1, width - 2, height - 2); SCROLLABLE *scroll = edit->scroll; scroll->content_height = text_height(width - 4 * SCALE - SCROLL_WIDTH, font_small_lineheight, edit->data, edit->length) + 4 * SCALE; scroll_draw(scroll, x, y, width, height); yy -= scroll_gety(scroll, height); } if(!edit->length && maybe_i18nal_string_is_valid(&edit->empty_str)) { STRING* empty_str_text = maybe_i18nal_string_get(&edit->empty_str); setcolor(C_GRAY2); drawtext(x + 2 * SCALE, yy + 2 * SCALE, empty_str_text->str, empty_str_text->length); } _Bool a = (edit == active_edit); drawtextmultiline(x + 2 * SCALE, x + width - 2 * SCALE - (edit->multiline ? SCROLL_WIDTH : 0), yy + 2 * SCALE, y, y + height, font_small_lineheight, edit->data, edit->length, a ? edit_sel.start : STRING_IDX_MAX, a ? edit_sel.length : STRING_IDX_MAX, edit->multiline); if(edit->multiline) { popclip(); } }