bool CodeWindowHandler::handleKey(const InputEvent &e) { CodeWindow * d = NULL; DisplayWindow * dd = NULL; //wm set the event before this was called. InputState * wimp = _wm->wimp(); bool ret = false; if (wimp->ctrlDown ) { ret = true; switch ( wimp->lastKey ) { case KEY_CTRL_U: _wm->arrangeWindows(); break; case KEY_CTRL_N: d = (CodeWindow*)new_window(); d->current()->setBuffer( d->getTextContent()->getBuf() ); d->moveto(wimp->lastPos[0], wimp->lastPos[1] ); _wm->addWindow(d); _wm->setTopWindow(d); break; case KEY_CTRL_F: case KEY_CTRL_O: //create new window and pass the call down... if ( !_wm->top()) { DirScanner dr; fileData * f = dr.openFileDialog(); fileData * nf = f; int c = 0; while ( nf ) { EM_log( CK_LOG_INFO, "(audicle) opening file %d : %s", c, nf->fileName.c_str() ); d = (CodeWindow*)new_window(); //new codewindow, new textwindow, empty buffer d->getTextContent()->open( (char*)nf->fileName.c_str()); d->current()->setBuffer( d->getTextContent()->getBuf() ); Point2D np = wimp->lastPos + Point2D(0.03, -0.03 ) * (double)c; d->moveto(np[0], np[1] ); d->resize( max ( 2.25, d->base()->w() ) , max ( 2.5, d->base()->h() ) ); _wm->addWindow(d); _wm->setTopWindow(d); c++; nf = nf->next; } } else ret = false; break; default: ret = false; } } return ret; }
bool TextWindowHandler::handleKey(const InputEvent &e) { DisplayWindow * d; e.fprint( stderr ); InputState * wimp = _wm->wimp(); wimp->setEvent(e); bool ret = false; if (wimp->ctrlDown ) { bool ret = true; switch ( wimp->lastKey ) { case KEY_CTRL_N: fprintf(stderr,"Make new window\n"); d = new DisplayWindow(); d->setContent(new TextContent()); _wm->addWindow(d); d->moveto(wimp->lastPos[0], wimp->lastPos[1] ); break; case KEY_CTRL_F: case KEY_CTRL_O: //create new window and pass the call down... if ( !_wm->top()) { DirScanner dr; fileData * f = dr.openFileDialog(); fileData * nf = f; int c = 0; while ( nf ) { EM_log( CK_LOG_INFO, "(audicle) opening file %d : %s", c, nf->fileName.c_str()); d = new DisplayWindow(); TextContent * ntext = new TextContent(); ntext->open((char*)nf->fileName.c_str()); d->setContent(ntext); Point2D np = wimp->lastPos + Point2D(0.03, -0.03 ) * (double)c; d->moveto(np[0], np[1] ); _wm->addWindow(d); _wm->setTopWindow(d); c++; nf = nf->next; } } break; default: ret = false; } } return ret; }
void TextBuffer::open( char * filepath ) { if ( !filepath ) { DirScanner dScan; fileData * fD = dScan.openFileDialog(); if ( fD ) { fprintf(stderr, "textbuf - opening %s\n", fD->fileName.c_str() ); open ( (char*) fD->fileName.c_str() ); if ( fD->next ) fprintf(stderr, "textbuffer: opening first of multiple files...\n"); } else { fprintf (stderr, "no filename specified\n"); } return; } else if ( !_source->readfile(filepath) ) { _lines.clear(); std::string ln; while ( _source->getline(ln) != EOF ) { addLine(ln); } setFilePath ( filepath ); _mesg = (std::string)"read file: " + _filename ; _edits.clear(); _undoPos = -1; _inUndo = false; _editDepth =0; _modDepth = 0; setVersion(); } else { _filepath = ""; _filename = ""; _mesg = (std::string)"file: " + filepath + " not found"; } }
//----------------------------------------------------------------------------- // 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 ); }