Пример #1
0
bool topLeftResizeCallback( Widget* widget, const Event* e ) {
    if( Widget_mouseOver( widget, &e->v ) ) {
        if( e->type == EMousePressed ) {
            widget->mouseOffset = vec2i_sub( &widget->position, &e->v );
            widget->pressed = true;
        }
    }
    if( widget->pressed && widget->mouseOffset.x != 1 ) {
        vec2i topleft = vec2i_add( &e->v, &widget->mouseOffset );
        topleft.x += 5;
        topleft.y += 23;

        vec2i bottomright = vec2i_add( &widget->parent->parent->children[WO_Window]->position, &widget->parent->parent->children[WO_Window]->size );
        vec2i size = vec2i_sub( &bottomright, &topleft );
        Window_resizeLeft( widget->parent->parent->children[WO_Window], size.x );
        Window_resizeUp( widget->parent->parent->children[WO_Window], size.y );
        if( e->type == EMouseReleased )
            widget->pressed = false;

        return true;
    }
    else {
        widget->mouseOffset = vec2i_c( 1, 1 );
        return false;
    }
}
Пример #2
0
bool moveWindowCallback( Widget* widget, const Event* e ) {
    if( e->type == EMousePressed ) {
        if( Widget_mouseOver( widget, &e->v ) ) {
            widget->mouseOffset = vec2i_sub( &widget->position, &e->v );
            widget->pressed = true;
        }
    }
    if( widget->pressed && widget->mouseOffset.x != -1 ) {
        vec2i pos = vec2i_add( &e->v, &widget->mouseOffset );
        Widget_setPosition( widget, &pos );
        vec2i win = pos;
        win.y += 18;
        Widget_setPosition( widget->children[WO_Window], &win );

        vec2i out = pos;
        out.x -= 5;
        out.y -= 5;
        Widget_setPosition( widget->children[WO_Outline], &out );
        if( e->type == EMouseReleased )
            widget->pressed = false;

        return true;
    }
    else {
        widget->mouseOffset = vec2i_c( -1, -1 );
        return false;
    }
}
Пример #3
0
void Widget_setPosition( Widget* widget, vec2i* pos ) {
    vec2i originalPos =  widget->position;
    //  TODO FIX
    widget->position = *pos;
    widget->moved = true;
    if( widget->confined ) {
        if( pos->x < widget->parent->position.x )
            widget->position.x = widget->parent->position.x;
        if( pos->y < widget->parent->position.y )
            widget->position.y = widget->parent->position.y;
        if( pos->x + widget->size.x > widget->parent->position.x + widget->parent->size.x )
            widget->position.x = widget->parent->position.x + widget->parent->size.x - widget->size.x;
        if( pos->y + widget->size.y > widget->parent->position.y + widget->parent->size.y )
            widget->position.y = widget->parent->position.y + widget->parent->size.y - widget->size.y;
    }

    vec2i offSet = vec2i_sub( pos, &originalPos );

    for( u32 i = 0; i < widget->childrenCount; ++i ) {
        if( widget->children[i]->confined ){
            vec2i newPos = vec2i_add( &widget->children[i]->position, &offSet );
            Widget_setPosition( widget->children[i], &newPos );
        }
    }
}
Пример #4
0
bool bottomRightResizeCallback( Widget* widget, const Event* e ) {
    if( Widget_mouseOver( widget, &e->v ) ) {
        if( e->type == EMousePressed ) {
            widget->mouseOffset = vec2i_sub( &e->v, &widget->position );
            widget->pressed = true;
        }
    }
    if( widget->pressed && widget->mouseOffset.x != -1 ) {
        vec2i bottomright = vec2i_sub( &e->v, &widget->mouseOffset );

        vec2i size = vec2i_sub( &bottomright, &widget->parent->parent->children[WO_Window]->position );
        Window_resizeRight( widget->parent->parent->children[WO_Window], size.x );
        Window_resizeDown( widget->parent->parent->children[WO_Window], size.y );
        if( e->type == EMouseReleased )
            widget->pressed = false;

        return true;
    }
    else {
        widget->mouseOffset = vec2i_c( -1, -1 );
        return false;
    }
}
Пример #5
0
Vector2D Vector2D::__sub__(const Vector2D& v1)
{
    Vector2D r;
    vec2i_sub(&r.v_, &v_, &v1.v_);
    return r;
}