Пример #1
0
SkinOverlap
skin_rect_contains_rect( SkinRect  *r1, SkinRect  *r2 )
{
    SkinBox  a, b;

    skin_box_from_rect( &a, r1 );
    skin_box_from_rect( &b, r2 );

    if (a.x2 <= b.x1 || b.x2 <= a.x1 || a.y2 <= b.y1 || b.y2 <= a.y1) {
        return SKIN_OUTSIDE;
    }

    if (b.x1 >= a.x1 && b.x2 <= a.x2 && b.y1 >= a.y1 && b.y2 <= a.y2) {
        return SKIN_INSIDE;
    }

    return SKIN_OVERLAP;
}
Пример #2
0
int
skin_region_iterator_next_box( SkinRegionIterator*  iter, SkinBox  *box )
{
    SkinRect  rect;
    int       result = skin_region_iterator_next( iter, &rect );

    if (result)
        skin_box_from_rect( box, &rect );

    return result;
}
Пример #3
0
void
skin_box_minmax_update( SkinBox*  a, SkinRect*  r )
{
    SkinBox  b[1];

    skin_box_from_rect(b, r);

    if (b->x1 < a->x1) a->x1 = b->x1;
    if (b->y1 < a->y1) a->y1 = b->y1;
    if (b->x2 > a->x2) a->x2 = b->x2;
    if (b->y2 > a->y2) a->y2 = b->y2;
}
Пример #4
0
int
skin_rect_intersect( SkinRect*  result, SkinRect*  r1, SkinRect*  r2 )
{
    SkinBox  a, b, r;

    skin_box_from_rect( &a, r1 );
    skin_box_from_rect( &b, r2 );

    if (a.x2 <= b.x1 || b.x2 <= a.x1 || a.y2 <= b.y1 || b.y2 <= a.y1) {
        result->pos.x = result->pos.y = result->size.w = result->size.h = 0;
        return 0;
    }

    r.x1 = (a.x1 > b.x1) ? a.x1 : b.x1;
    r.x2 = (a.x2 < b.x2) ? a.x2 : b.x2;
    r.y1 = (a.y1 > b.y1) ? a.y1 : b.y1;
    r.y2 = (a.y2 < b.y2) ? a.y2 : b.y2;

    skin_box_to_rect( &r, result );
    return 1;
}
Пример #5
0
static void
expectRectRegion( Region*  r, int  x1, int  y1, int  x2, int  y2 )
{
    SkinRect  rect;
    SkinBox   b;

    printf( "expectRectRegion(%d,%d,%d,%d): ",x1,y1,x2,y2 );
    if (!skin_region_is_rect(r)) {
        printf( "region not rect !!\n" );
        panic();
    }

    skin_region_get_bounds( r, &rect );
    skin_box_from_rect( &b, &rect );

    if (b.x1 != x1 || b.x2 != x2 || b.y1 != y1 || b.y2 != y2) {
        printf( "rect region bounds are (%d,%d,%d,%d), expecting (%d,%d,%d,%d)\n",
                b.x1, b.y1, b.x2, b.y2, x1, y1, x2, y2 );
        panic();
    }
    printf( "ok\n" );
}