Ejemplo n.º 1
0
bool Selector::event(SPEventContext *event_context, GdkEvent *event)
{
    // The hidden control point will capture all events after it obtains the grab,
    // but it relies on this function to initiate it. If we pass only first button
    // press events here, it won't interfere with any other event handling.
    switch (event->type) {
    case GDK_BUTTON_PRESS:
        // Do not pass button presses other than left button to the control point.
        // This way middle click and right click can be handled in SPEventContext.
        if (event->button.button == 1 && !event_context->space_panning) {
            _dragger->setPosition(_desktop->w2d(event_point(event->motion)));
            return _dragger->event(event_context, event);
        }
        break;
    default: break;
    }
    return false;
}
Ejemplo n.º 2
0
int
Panner::handle ( int m )
{
    int r = Fl_Widget::handle( m );

    switch ( m )
    {
        case FL_ENTER:
        case FL_LEAVE:
            redraw();
            return 1;
        case FL_PUSH:

            if ( Fl::event_button2() )
            {
                _bypassed = ! _bypassed;
                redraw();
                return 1;
            }
            else if ( Fl::event_button1() && ( drag = event_point() ) )
                return 1;
            else
                return 0;
        case FL_RELEASE:
            if ( Fl::event_button1() && drag )
            {
                drag = NULL;
                do_callback();
                redraw();
                return 1;
            }
            else
                return 0;
        case FL_MOUSEWHEEL:
        {
            /* TODO: place point on opposite face of sphere */
        }
        case FL_DRAG:
        {
            if ( ! drag )
                return 0;

            float X = Fl::event_x() - x();
            float Y = Fl::event_y() - y();

            int tx, ty, tw, th;
            bbox( tx, ty, tw, th );

/*             if ( _outs < 3 ) */
/*                 drag->angle( (float)(X / (tw / 2)) - 1.0f, 0.0f ); */
/*             else */
            drag->angle( (float)(X / (tw / 2)) - 1.0f, (float)(Y / (th / 2)) - 1.0f );

            if ( when() & FL_WHEN_CHANGED )
                do_callback();

            redraw();

            return 1;
        }

    }

    return r;

//    return 0;
}
Ejemplo n.º 3
0
Archivo: Panner.C Proyecto: 0mk/non
int
Panner::handle ( int m )
{
    int r = Fl_Group::handle( m );

    switch ( m )
    {
        case FL_ENTER:
        case FL_LEAVE:
            _projection_choice->value(_projection_mode);
            _range_choice->value(_range_mode);
            redraw();
            return 1;
        case FL_PUSH:
        {
            if ( Fl::event_button1() || Fl::event_button3() )
                drag = event_point();

            if ( Fl::event_button2() )
            {
                /* if ( _projection == POLAR ) */
                /*     _projection = ORTHO; */
                /* else */
                /*     _projection = POLAR; */
            }
            return 1;
        }
        case FL_RELEASE:
            if ( drag )
            {
                do_callback();
                drag = NULL;
                redraw();
                return 1;
            }
            else
                return 0;
        case FL_MOUSEWHEEL:
        {
/*             Point *p = event_point(); */

/*             if ( p ) */
/*                 drag = p; */

/*             if ( drag ) */
/*             { */
/* //                drag->elevation( drag->elevation() + Fl::event_dy()); */
/*                 drag->elevation( 0 - drag->elevation() ); */
/*                 do_callback(); */
/*                 redraw(); */
/*                 return 1; */
/*             } */

            return 1;
        }
        case FL_DRAG:
        {
            if ( ! drag )
                return 0;

            int tx, ty, tw, th;
            bbox( tx, ty, tw, th );

            float X = (float(Fl::event_x() - tx) / tw ) - 0.5f;
            float Y = (float(Fl::event_y() - ty) / th) - 0.5f;
            
            if ( Fl::event_button1() )
            {
                if ( POLAR == projection() )
                    set_polar( drag,X,Y );
                else
                {
                    if ( fabsf( X ) < 0.5f &&
                         fabsf( Y ) < 0.5f ) 
                        set_ortho( drag, X,Y );
                }
            }
            else
                set_polar_radius( drag,X,Y );

            if ( when() & FL_WHEN_CHANGED )
                do_callback();

            damage(FL_DAMAGE_EXPOSE);

            return 1;
        }

    }

    return r;

//    return 0;
}