Example #1
0
//-----------------------------------------------------------------------------
// name: on_event_1()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceShredder::on_event_1( const AudicleEvent & event )
{
    static t_CKUINT m_mouse_down = FALSE;
    static Point2D last;
    map<t_CKUINT, Shred_Data *>::iterator iter;
    t_CKBOOL hit = FALSE;
    Point2D diff;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();
            
            for( iter = m_map.begin(); iter != m_map.end(); iter++ )
            {
                if( ie->checkID( (*iter).second->name ) )
                {
                    hit = TRUE;
                    if( ie->state == ae_input_DOWN )
                        (*iter).second->mouse_down = 1;
                    else
                    {
                        if( (*iter).second->mouse_down == 1 )
                            (*iter).second->mouse_clicked = 1;
                        (*iter).second->mouse_down = 0;
                        if( m_mouse_down )
                            m_mouse_down = FALSE;
                        fprintf( stderr, "click: %s\n", (*iter).second->stat->name.c_str() );
                    }
                }
            }

            if( hit == FALSE )
            {
                if( ie->state == ae_input_DOWN )
                {
                    m_mouse_down = TRUE;
                    last = ie->pos;
                }
                else
                    m_mouse_down = FALSE;
            }
        }
        else if( ie->type == ae_input_MOTION )
        {
            if( m_mouse_down )
            {
                m_eye_y += ( ie->pos - last ).length() * ( ie->pos[1] < last[1] ? 2.0 : -2.0 );
                last = ie->pos;
                //render_view();
            }
        }
    }

    return AudicleFace::on_event( event );
}
Example #2
0
void
UIButton::handleMouse ( const InputEvent &e  ) { 
    _selected = e.checkID(_id);
    if ( _selected && _menu ) { 
        InputEvent sub = e;
        sub.popStack();
        _menu->handleMouse( sub );            
    }
}
Example #3
0
void
UIMenu::handleMouse( const InputEvent &e ) { 
    _selected = e.checkID ( _id );
    if ( _selected ) { 
        InputEvent sub = e;
        sub.popStack();
        for ( int i = 0; i < _options.size(); i++ ) 
            _options[i].button.handleMouse(sub);
    }
}
Example #4
0
void
UIScrollBar::handleMouse(const InputEvent &e) {  
    _selected = false;
    if ( e.checkID(_id) ) { 
        if ( e.state == ae_input_DOWN ) _selected = true;
        InputEvent sub = e;
        sub.popStack();
	    _box.handleMouse ( sub );
    }
}
Example #5
0
void 
AlertBox::handleMouse( const InputEvent & e ) { 
    UIRectangle::handleMouse( e );
    if ( _selected ) { 
        InputEvent sub = e;
        sub.popStack();
        _dismissButton.handleMouse ( sub ) ;
        if ( _dismissButton.selected() ) { 
            _time_ends = AudicleWindow::main()->get_current_time() + 0.5;
        }
    }
}
Example #6
0
void
ShredInstance::handleMouse( const InputEvent & e ) { 
    DragManager * dm = DragManager::instance();
    selected = false;
    if ( e.checkID(pickID) ) { 
        InputEvent sub = e;
        sub.popStack();
        _killButton->handleMouse(sub);
        if ( e.state == ae_input_DOWN ) selected = true;
        dragAction( dm );
    }
    
    
}
Example #7
0
//-----------------------------------------------------------------------------
// name: main_mouse()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleWindow::main_mouse( int button, int state, int x, int y)
{

    assert( this == AudicleWindow::main() );
    set_mouse_coords( x, y );


    //fetch pick stack
    main_pick();
    t_CKUINT * temp_stack = (t_CKUINT*) malloc ( m_pick_size * sizeof(t_CKUINT) );
    memcpy ( (void*)temp_stack, (void*)m_pick_top, m_pick_size * sizeof(t_CKUINT) );

    // create mouse input event
    InputEvent* ev = new InputEvent ( ae_input_MOUSE, m_cur_pt, button, state );
    ev->setMods( glutGetModifiers() );
    ev->setStack( temp_stack , m_pick_size );
    ev->time = get_current_time();

    InputEvent sub = *ev;

    //START AN AUDICLE EVENT 
    //make_mouse_event( m_cur_pt,  button, state );

    AudicleEvent event;
    event.type = ae_event_INPUT;
    event.message = 2;
    event.param1 = button;
    event.param2 = state;
    event.data = (void *) ev;

    Audicle::instance()->face()->on_event( event );

    sub.popStack();

//    if( m_console )
//    {
//        m_console->handleMouse( sub );
//        m_console->handleMouseAlerts( sub ); 
//    }

    free (temp_stack);
    delete ev; //XXX assumes unqueued...

    //    if ( wm ) wm->handleMouse(button, state, cur_pt);

    //    if ( DragManager::instance()->object() ) { } 

}
Example #8
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceShredder::on_event( const AudicleEvent & event )
{
    int handled = 0;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();
            
            if( ie->checkID( m_b1_id ) )
            {
                if( ie->state == ae_input_DOWN )
                {
                    sphere_down = TRUE;
                    handled = TRUE;
                }
                else
                {
                    if( which == 1 ) which = 2;
                    else if( which ==2 ) which = 1;
                }
            }
            
            if( ie->state == ae_input_UP && sphere_down )
                sphere_down = FALSE;
        }
    }

    if( !handled )
    {
        if( which == 1 ) return on_event_1( event );
        if( which == 2 ) return on_event_2( event );
    }
    
    return AudicleFace::on_event( event );
}
Example #9
0
void
CodeRevision::handleMouse(const InputEvent & e) { 

    _selected = e.checkID(_id);
    if ( _selected ) { 
        //match lower on stack, but it's not our match...
        //are we selected or not?
        _selected = true;

        InputEvent sub = e;
        sub.popStack();
        for ( int j =0 ; j < _shreds.size(); j++ ) { 
            _shreds[j]->handleMouse( sub );
            if ( _shreds[j]->selected ) {
                _selected = false;
            }
        }
        //not a shred...
        _killButton->handleMouse(sub);
        _sporkButton->handleMouse(sub);
        dragAction( DragManager::instance() );
    }

}
Example #10
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_TAPUINT UITreesynth::on_event( const AudicleEvent & event )
{
    static t_TAPUINT m_mouse_down = FALSE;
    static t_TAPUINT which = 0;
    static Point2D last;
    t_TAPBOOL hit = FALSE;
    Point2D diff;
    t_TAPUINT i;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();

            for( i = 0; i < NUM_UI_ELEMENTS; i++ )
            {
                if( ie->checkID( ui_elements[i]->id ) )
                {
                    if( ie->state == ae_input_DOWN )
                    {
                        hit = TRUE;
                        ui_elements[i]->down = TRUE;
                        
                        if( i >= SL_PERCENTAGE && i <= SL_STOPLEVEL )
                            ui_elements[i]->slide_last = (ie->pos[1]/AudicleWindow::main()->m_vsize ) / g_slider_height;
                    
                        
                        if( i == FL_ANCFIRST )
                        {
                            ui_elements[i]->slide = 1.0f - ui_elements[i]->slide;
                            if( g_ts )
                            {
                                g_mutex.acquire();
                                g_ts->ancfirst = ui_elements[FL_ANCFIRST]->fvalue() > 0.5;
                                g_mutex.release();
                            }
                        }

                        if( i == FL_RANDFLIP )
                        {
                            ui_elements[i]->slide = 1.0f - ui_elements[i]->slide;
                            if( g_ts )
                            {
                                g_mutex.acquire();
                                g_ts->randflip = ui_elements[FL_RANDFLIP]->fvalue() > 0.5;
                                g_mutex.release();
                            }
                        }

                        if( i == FL_WRITE_FILE )
                        {
                            if( g_shutup )
                            {
                                ui_elements[i]->slide = 1.0f - ui_elements[i]->slide;
                            }
                            else
                            {
                                msg_box( "bad!", "wavelet-tree already synthesizing!" );
                            } 
                        }
                    }

                    if( ie->state == ae_input_UP && ui_elements[i]->down == TRUE )
                    {

                        // ~~~~~~~~~~~~~~~~~~~~~~~~ LOAD FROM FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        if( i == BT_LOAD_FILE )
                        {
                            m_audio->bus(1)->stop();
                            usleep( 100000 );
                            g_shutup = TRUE;
                            g_lib = FALSE;
                            DirScanner dScan;
                            fileData * fD = dScan.openFileDialog();
                            if ( fD )
                            {
                                fprintf(stderr, "residue file %s\n", fD->fileName.c_str() );
                                if ( fD->next ) 
                                    fprintf( stderr, "may not be opening first of multiple files...\n");
                                
                                strcpy( g_ifile, fD->fileName.c_str() );
                            }
                        }

                        
                        // ~~~~~~~~~~~~~~~~~~~~~~~~ LOAD FROM ANALYSIS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        if( i == BT_LOAD_ANALYSIS )
                        {
                            m_audio->bus(1)->stop();
                            usleep( 100000 );
                            g_shutup = TRUE;
                            g_lib = TRUE;
                        }


                        // ~~~~~~~~~~~~~~~~~~~~~~~~ SYNTHESIZE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        if( i == BT_SYNTHESIZE )
                        {
                            if( g_shutup )
                            {
                                ts_init( ui_elements );
                                ts_run();
                                AudioSrcEliot * ts = new AudioSrcEliot( g_tsio );
                                ts->on = &ui_elements[BT_SYNTHESIZE]->on;
                                m_audio->bus(1)->play( ts, FALSE );
                                ui_elements[BT_SYNTHESIZE]->on = TRUE;
                                ui_elements[BT_SYNTHESIZE]->on_where = 0.0;
                            }
                            else
                            {
                                msg_box( "bad!", "wavelet-tree already synthesizing!" );
                            }
                        }


                        // ~~~~~~~~~~~~~~~~~~~~~~~~ STOP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        if( i == BT_STOP )
                        {
                            m_audio->bus(1)->stop();
                            usleep( 100000 );
                            g_shutup = TRUE;
                        }

                    }
                }

                // button up
                if( ie->state == ae_input_UP && ui_elements[i]->down )
                    ui_elements[i]->down = FALSE;
            }   

            // background
            if( hit == FALSE )
            {
                if( ie->state == ae_input_DOWN )
                {
                    which = !!(ie->mods & ae_input_CTRL);
                    m_mouse_down = TRUE;
                    last = ie->pos;
                }
                else 
                {
                    m_mouse_down = FALSE;
                }
            }
        }
        else if( ie->type == ae_input_MOTION )
        {
            for( i = SL_PERCENTAGE; i <= SL_STOPLEVEL; i++ )
            {
                if( ui_elements[i]->down )
                {
                    ui_elements[i]->slide += (ie->pos[1]/AudicleWindow::main()->m_vsize ) 
                                            / g_slider_height - ui_elements[i]->slide_last;
                    ui_elements[i]->slide_last = (ie->pos[1]/AudicleWindow::main()->m_vsize ) / g_slider_height;
                    if( ui_elements[i]->slide > 1.0 ) ui_elements[i]->slide = ui_elements[i]->slide_last = 1.0;
                    if( ui_elements[i]->slide < 0.0 ) ui_elements[i]->slide = ui_elements[i]->slide_last = 0;
                }
            }

            if( ui_elements[SL_STARTLEVEL]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->startlevel = ui_elements[SL_STARTLEVEL]->ivalue();
                    g_mutex.release();
                }
            }

            if( ui_elements[SL_STOPLEVEL]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->stoplevel = ui_elements[SL_STOPLEVEL]->ivalue();
                    g_mutex.release();
                }
            }

            if( ui_elements[SL_PERCENTAGE]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->percentage = ui_elements[SL_PERCENTAGE]->fvalue();
                    g_mutex.release();
                }
            }

            if( ui_elements[SL_K]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->kfactor = ui_elements[SL_K]->fvalue();
                    g_mutex.release();
                }
            }

            if( ui_elements[FL_ANCFIRST]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->ancfirst = ui_elements[FL_ANCFIRST]->fvalue() > 0.5;
                    g_mutex.release();
                }
            }

            if( ui_elements[FL_RANDFLIP]->down )
            {
                if( g_ts )
                {
                    g_mutex.acquire();
                    g_ts->randflip = ui_elements[FL_RANDFLIP]->fvalue() > 0.5;
                    g_mutex.release();
                }
            }
        }
    }

    return AudicleFace::on_event( event );
}
Example #11
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceTnT::on_event( const AudicleEvent & event )
{
    EM_log( CK_LOG_FINER, "AudicleFaceTNT: on event..." );

    if ( event.type == ae_event_INPUT ) { 

        InputEvent * e = (InputEvent * ) event.data;
        inp.setEvent(*e);
        if ( e->type == ae_input_MOUSE ) { 
            InputEvent sub = *e;
            sub.popStack();
            int i;
            map<Shred_Stat *, Shred_Stat *>::iterator iter;
            Shred_Stat * stat;

            m_current_shred = NULL;

            for( i = 0; i < m_shreds.size(); i++ )
                if ( sub.checkID ( m_shreds[i]->data->name ) )
                    m_current_shred = m_shreds[i];
            for( iter = m_done.begin(); iter != m_done.end(); iter++ )
            {
                stat = (*iter).second;
                if ( sub.checkID ( stat->data->name ) )
                    m_current_shred = stat;
            }    


        }
        if ( e->type == ae_input_MOTION ) { 
            // wtf? we don't need random rotations in here...or do we ? //PLD 
            /*
            if ( inp.isDepressed ) { 
                if ( fabs( inp.dPos[0] ) > fabs( inp.dPos[1] ) )  {
                    m_rotx += inp.dPos[0];
                }   
                else { 
                    m_roty += inp.dPos[1];
                }
            }
            */
        }
        if ( e->type == ae_input_KEY ) { 
            switch ( e->key ) { 
            case 'a':
                m_window_target = 0.5 * m_window_target;
                break;
            case 'd':
                m_window_target = 2.0 * m_window_target;
                break;
            case 's':
                m_log_scale = !m_log_scale;
                break;
            case 'w':
                m_wrapmode = !m_wrapmode;
                break;
            case 'f':
                m_fit_mode = ( m_fit_mode + 1 ) % FIT_NTYPES;
                break;
            case 'h':
                m_show_mode = ( m_show_mode + 1 ) % SHOW_NTYPES;
                break;
            }

        } 

    }

    return AudicleFace::on_event( event );
}
Example #12
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceVMSpace::on_event( const AudicleEvent & event )
{
    static t_CKUINT m_mouse_down = FALSE;
    static t_CKUINT which = 0;
    static Point2D last;
    t_CKBOOL hit = FALSE;
    Point2D diff;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();

            if( ie->checkID( g_id ) )
            {
                if( ie->state == ae_input_DOWN )
                {
                    hit = TRUE;
                    sphere_down = TRUE;
                }
                else
                {
                    if( !g_window ) g_window = g_hamm;
                    else if( g_window == g_hamm ) g_window = g_hann;
                    else if( g_window == g_hann ) g_window = g_rect;
                    else if( g_window == g_rect ) g_window = NULL;
                    g_changed = TRUE;
                    g_changedf = 1.0;
                    g_rate = .0250;
                }
            }
            
            if( ie->checkID( g_id2 ) )
            {
                if( ie->state == ae_input_DOWN )
                {
                    hit = TRUE;
                    sphere_down2 = TRUE;
                    g_rate = .0125;
                }
                else
                {
                    g_changed = TRUE;
                    g_changedf = 1.0;
                }
            }
            
            if( ie->state == ae_input_UP && sphere_down )
                sphere_down = FALSE;
                
            if( ie->state == ae_input_UP && sphere_down2 )
                sphere_down2 = FALSE;

            if( hit == FALSE )
            {
                if( ie->state == ae_input_DOWN )
                {
                    which = !!(ie->mods & ae_input_CTRL);
                    m_mouse_down = TRUE;
                    last = ie->pos;
                }
                else
                    m_mouse_down = FALSE;
            }
        }
        else if( ie->type == ae_input_MOTION )
        {
            if( m_mouse_down )
            {
                if( which )
                {
                    fp[0] += ( ie->pos - last ).length() * ( ie->pos[0] < last[0] ? -1.0 : 1.0 );
                    last = ie->pos;
                }
                else
                {
                    m_eye_y += ( ie->pos - last ).length() * ( ie->pos[1] < last[1] ? 2.0 : -2.0 );
                    last = ie->pos;
                    render_view();
                }
            }
        }
    }

    return AudicleFace::on_event( event );
}
Example #13
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceGroove::on_event( const AudicleEvent & event )
{
    static t_CKBOOL m_mouse_down = FALSE;
    t_CKUINT x, y;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();

            // loop over panel
            for( x = 0; x < m_panel->width; x++ )
            {
                if( ie->checkID( m_panel->matrix[x]->xid ) )
                {
                    if( ie->state == ae_input_DOWN )
                    {
                        m_panel->clear();
                        m_panel->matrix[x]->mode = 1;
                        m_panel->which = x;
                    }
                }
            }

            // loop over pane
            for( y = 0; y < m_pane->height; y++ )
            {
                for( x = 0; x < m_pane->width; x++ )
                {
                    if( ie->checkID( m_pane->matrix[x+m_pane->width*y]->xid ) )
                    {
                        if( ie->state == ae_input_DOWN )
                        {
                            m_pane->clear();
                            m_pane->matrix[x+m_pane->width*y]->value = m_panel->which;
                        }
                    }
                }
            }

            // mouse down
            if( ie->state == ae_input_DOWN )
                m_mouse_down = TRUE;
            if( ie->state == ae_input_UP )
                m_mouse_down = FALSE;
        }
		else if( ie->type == ae_input_KEY )
		{
			switch( ie->key )
			{
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
				case '0':
                    x = ie->key - '0';
                    if( x < m_panel->width )
                    {
                        m_panel->clear();
                        m_panel->matrix[x]->mode = 1;
                        m_panel->which = x;
                    }
                break;
				case 27:
                    x = 0;
                    m_panel->clear();
                    m_panel->matrix[x]->mode = 1;
                    m_panel->which = x;
                break;
                case 'A':
                    m_pane->reset( m_panel->which );
                break;
                case 'C':
                    m_pane->reset( 0 );
                break;
            }
        }
        else if( ie->type == ae_input_MOTION )
        {
/*            ie->popStack();

            // loop over panel
            for( x = 0; x < m_panel->width; x++ )
            {
                if( ie->checkID( m_panel->matrix[x]->xid ) )
                {
                    m_panel->clear();
                    m_panel->matrix[x]->mode = 1;
                    m_panel->which = x;
                }
            }
*/
        }
    }

    return AudicleFace::on_event( event );
}
Example #14
0
//-----------------------------------------------------------------------------
// name: on_event()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceFloor::on_event( const AudicleEvent & event )
{
    static t_CKBOOL m_mouse_down = FALSE;
    t_CKUINT x;

    if( event.type == ae_event_INPUT )
    {
        InputEvent * ie = (InputEvent *)event.data;
        if( ie->type == ae_input_MOUSE )
        {
            ie->popStack();

            // loop over panel
            for( x = 0; x < m_num_triggers; x++ )
            {
                if( ie->checkID( m_triggers[x]->xid ) )
                {
                    if( ie->state == ae_input_DOWN )
                    {
                        m_last_hit = x+1;
                        m_event->broadcast();
                        m_triggers[x]->size = 1.5f;
                        m_triggers[x]->size2 = 1.5f;
                    }
                }
            }

            // mouse down
            if( ie->state == ae_input_DOWN )
                m_mouse_down = TRUE;
            if( ie->state == ae_input_UP )
                m_mouse_down = FALSE;
        }
		else if( ie->type == ae_input_KEY )
		{
            m_last_hit = -1;

			switch( ie->key )
			{
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
				case '0':
                    x = ie->key - '0';
                    if( (x-1) < m_num_triggers )
                    {
                        m_last_hit = x;
                        m_triggers[x-1]->size = 1.5f;
                        m_triggers[x-1]->size2 = 1.5f;
                    }
                break;

            }

            m_event->queue_broadcast();
        }
    }

    return AudicleFace::on_event( event );
}