widget_t* widget_hit_test(widget_t* root, point_t p) { widget_t* w; for (w = root->first_child; w != NULL; w = w->next_sibling) { point_t translated_p = { .x = p.x - root->rect.x, .y = p.y - root->rect.y, }; widget_t* w_hit = widget_hit_test(w, translated_p); if (w_hit != NULL) return w_hit; } if (widget_is_visible(root) && rect_inside(root->rect, p)) return root; return NULL; } point_t widget_rel_pos(widget_t* w, point_t abs_pos) { widget_t* parent; point_t rel_pos = abs_pos; for (parent = w->parent; parent != NULL; parent = parent->parent) { rel_pos.x -= parent->rect.x; rel_pos.y -= parent->rect.y; } return rel_pos; }
static void widget_layout_predicate(widget_t* w, widget_traversal_event_t event, void* data) { (void)data; if (event == WIDGET_TRAVERSAL_BEFORE_CHILDREN) { if (w->needs_layout && widget_is_visible(w)) { CALL_WC(w, on_layout)(w); w->needs_layout = false; } } }
void horizontal_layout_on_size_change(Container* _c) { Rect r = ((Widget*)_c)->rect; int visible_widgets=0; for(int i =0;i<_c->child_widget_array_size;i++) { if(widget_is_visible((Widget*)_c)) visible_widgets++; } if(!visible_widgets) return; int width_of_child = r.width/visible_widgets; int height_of_child = r.height; int x_child=0,y_child=0; for(int i=0;i<_c->child_widget_array_size;i++) { if(widget_is_visible((Widget*)_c)) { x_child = i*width_of_child; MoveWindow(((Widget*)_c)->hwnd,x_child,y_child,width_of_child,height_of_child,TRUE); } } }
static void widget_paint_predicate(widget_t* w, widget_traversal_event_t event, void* data) { (void)data; if (event == WIDGET_TRAVERSAL_BEFORE_CHILDREN) { gfx_ctx_push(); if (w->bg_color != TRANSPARENT) gfx_set_bg_color(w->bg_color); if (w->needs_paint && widget_is_visible(w)) { paint_event_t event = { .id = EVT_PAINT, .widget = w, }; gfx_clear_rect(w->rect); CALL_WC(w, on_paint)(&event); w->needs_paint = false; }
bool GroupDialog_isShown() { return widget_is_visible(GTK_WIDGET(g_GroupDlg.m_window)); }