コード例 #1
0
ファイル: MidiLoop.cpp プロジェクト: Amcut/pizmidi
void Loop::cleanZeroLengthNotes()
{
	Array<int> matchedNoteOffs;
	for (int i=0;i<getNumEvents();i++)
	{
		if (getEventPointer(i)->message.isNoteOn())
		{
			if (getEventTime(i) == getTimeOfMatchingKeyUp(i) || getTimeOfMatchingKeyUp(i)==0.0)
			{
				//zero length note
				deleteEvent(i,(getTimeOfMatchingKeyUp(i)!=0.0));
				updateMatchedPairs();
			}
		}
	}
	for (int i=0;i<getNumEvents();i++)
	{
		if (getEventPointer(i)->message.isNoteOn() && getIndexOfMatchingKeyUp(i)!=-1)
			matchedNoteOffs.add(getIndexOfMatchingKeyUp(i));
	}
	for (int i=0;i<getNumEvents();i++)
	{
		if (getEventPointer(i)->message.isNoteOff() && !matchedNoteOffs.contains(i)) {
			//unmatched note-off
			deleteEvent(i,false);
			updateMatchedPairs();
			break;
		}	
	}
	//updateMatchedPairs();
}
コード例 #2
0
ファイル: IoEvent.cpp プロジェクト: gkalab/ChessCore
IoEvent::~IoEvent() {

#ifdef WINDOWS
	if (m_handle != INVALID_HANDLE_VALUE) {
		CloseHandle(m_handle);
		m_handle = NULL;
	}
#else // !WINDOWS

#if IO_EVENT_USE_POLL
    if (m_pipe[0] >= 0) {
        if (m_ownsFDs)
            close(m_pipe[0]);

        m_pipe[0] = -1;
    }

    if (m_pipe[1] >= 0) {
        if (m_ownsFDs)
            close(m_pipe[1]);

        m_pipe[1] = -1;
    }

#elif IO_EVENT_USE_KQUEUE
    logdbg("%p", this);

    deleteEvent();
    m_type = IoEventTypeNone;
    m_ident = -1;
#endif // IO_EVENT_USE_xxx
#endif // WINDOWS
}
コード例 #3
0
ファイル: Date.cpp プロジェクト: ishaansingal/Tempus
void Date::editEventTime(int editIndex, Time startTime, Time endTime)
{
	eventList[editIndex].setStartTime(startTime);
	eventList[editIndex].setEndTime(endTime);
	Event tempObj=eventList[editIndex];
	deleteEvent(editIndex);
	addEvent(tempObj.getId(),tempObj.getName(),tempObj.getLocation(),tempObj.getStartTime(),tempObj.getEndTime(), tempObj.getEventType(), tempObj.getEventStatus());
}
コード例 #4
0
ファイル: event_set.cpp プロジェクト: CDargis/Roto-Cal
/* deletes Event object pointer from year, month, day sets and inserts
 * new object 
 * returns false if object already exists 
 * */
bool Event_set::editEvent(Event * current_e, Event * new_e)
{                                                                               
    /* if same start time / title already exists */                             
    if (findDuplicate(new_e))                                                   
        return true;
    deleteEvent(current_e);                                                     
    insertEvent(new_e);                                                         
    return false;
}                                                                               
コード例 #5
0
void MidiMessageSequence::deleteEvent (const int index,
                                       const bool deleteMatchingNoteUp)
{
    if (isPositiveAndBelow (index, list.size()))
    {
        if (deleteMatchingNoteUp)
            deleteEvent (getIndexOfMatchingKeyUp (index), false);

        list.remove (index);
    }
}
コード例 #6
0
ファイル: server.c プロジェクト: Gaoyuan0710/LinuxNetWorkCode
void dealRead(int epollFd, int fd, char *buf){
	int readLen;

	readLen = read(fd, buf, MAXSIZE);

	if (readLen == -1){
		perror("read error");
		close(fd);
		deleteEvent(epollFd, fd, EPOLLIN);
		exit(1);
	}
	else if (readLen == 0){
		fprintf(stderr, "client close\n");
		close(fd);
		deleteEvent(epollFd, fd, EPOLLIN);		
	}
	else{
		printf("The message is : %s\n", buf);
		modifyEvent(epollFd, fd, EPOLLOUT);
	}
}
コード例 #7
0
ファイル: server.c プロジェクト: Gaoyuan0710/LinuxNetWorkCode
void dealWrite(int epollFd, int fd, char *buf){
	int writeLen;

	writeLen = write(fd, buf, strlen(buf));

	if (writeLen == -1){
		perror("write error");
		close(fd);
		deleteEvent(epollFd, fd, EPOLLOUT);
	}
	else{
		modifyEvent(epollFd, fd, EPOLLIN);
	}
	memset(buf, 0, sizeof(buf));
}
コード例 #8
0
KstEventMonitorI::KstEventMonitorI(QWidget* parent,
                                           const char* name,
                                           bool modal,
                                           WFlags fl) :
  EventMonitor(parent, name, modal, fl) {
  QStringList	labels;

  _bSetWidths = FALSE;
  
  labels.append(i18n("Log as:"));
  labels.append(i18n("Expression:"));
  labels.append(i18n("Description:"));
  
  tableEvents = new KstEventTable( this, "tableEvents" );
  tableEvents->setNumRows( 0 );
  tableEvents->setNumCols( 3 );
  tableEvents->setReadOnly( TRUE );
  tableEvents->setSorting( FALSE );     
  tableEvents->setRowMovingEnabled( FALSE );
  tableEvents->setColumnLabels( labels );
  tableEvents->setSelectionMode( QTable::SingleRow );
  tableEvents->setEventMonitors( &_eventMonitors );
  layoutGrid->addWidget( tableEvents, 1, 0 );

  connect(vectorSelector, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
  connect(vectorSelectorEq, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
  connect( scalarSelectorEq, SIGNAL( newScalarCreated() ), this, SIGNAL(modified()));
  connect( buttonGroupLog, SIGNAL( clicked(int) ), this, SLOT( logChanged(int) ) );
  connect( checkBoxDebug, SIGNAL(clicked()), this, SLOT(logCheckChanged()));
  connect( Close, SIGNAL( clicked() ), this, SLOT( close() ) );
  connect( pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addEvent() ) );
  connect( pushButtonDelete, SIGNAL( clicked() ), this, SLOT( deleteEvent() ) );
  connect( pushButtonAccept, SIGNAL( clicked() ), this, SLOT( acceptChanges() ) );
  connect( pushButtonDiscard, SIGNAL( clicked() ), this, SLOT( discardChanges() ) );
  connect( lineEditEquation, SIGNAL( textChanged(const QString&) ), this, SLOT( expressionChanged(const QString&) ) );
  connect( lineEditDescription, SIGNAL( textChanged(const QString&) ), this, SLOT( descriptionChanged(const QString&) ) );
  connect( tableEvents, SIGNAL( currentChanged(int, int) ), this, SLOT( changedEvent(int, int) ) );
  connect( tableEvents, SIGNAL( selectionChanged() ), this, SLOT( changedSelection() ) );
  connect( vectorSelector, SIGNAL( selectionChanged(const QString&) ), this, SLOT( vectorChanged(const QString&) ) );
  connect( vectorSelector, SIGNAL( newVectorCreated(const QString&) ), this, SLOT( vectorChanged(const QString&) ) );
  connect( vectorSelectorEq, SIGNAL( selectionChangedLabel(const QString&)), lineEditEquation, SLOT( insert(const QString&) ) );
  connect( scalarSelectorEq, SIGNAL( selectionChangedLabel(const QString&)), lineEditEquation, SLOT( insert(const QString&) ) );
  connect( pushButtonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
    
  languageChange( );
  
  setChanged( FALSE );
}
コード例 #9
0
ファイル: worker.c プロジェクト: alemic/wheatserver
// workerProcessCron is the cron of worker process, it must be called before
// worker process initialized.
//
// `fake_func` is used by spawnFakeWorker and call it every cron.
void workerProcessCron(void (*fake_func)(void *data), void *data)
{
    static long long max_cron_interval = 0;

    struct timeval nowval;
    long long interval;
    int refresh_seconds;
    void (*worker_cron)();

    refresh_seconds = Server.stat_refresh_seconds;
    worker_cron = WorkerProcess->worker->cron;
    while (WorkerProcess->alive) {
        arrayEach(WorkerProcess->apps, appCronRun);

        if (worker_cron)
            worker_cron();
        if (fake_func)
            fake_func(data);
        processEvents(WorkerProcess->center, WHEATSERVER_CRON_MILLLISECONDS);
        if (WorkerProcess->ppid != getppid()) {
            wheatLog(WHEAT_NOTICE, "parent change, worker shutdown");
            WorkerProcess->alive = 0;
        }
        clientsCron();

        if (Server.cron_time.tv_sec - WorkerProcess->refresh_time > refresh_seconds) {
            sendStatPacket(WorkerProcess);
            WorkerProcess->refresh_time = Server.cron_time.tv_sec;
        }

        // Get the max worker cron interval for statistic info
        gettimeofday(&nowval, NULL);
        interval = getMicroseconds(nowval) - getMicroseconds(Server.cron_time);
        if (interval > max_cron_interval) {
            max_cron_interval = interval;
            getStatValByName("Max worker cron interval") = interval;
        }
        Server.cron_time = nowval;
    }

    // Stop accept new client
    deleteEvent(WorkerProcess->center, Server.ipfd, EVENT_READABLE|EVENT_WRITABLE);
    WorkerProcess->refresh_time = Server.cron_time.tv_sec;
    while (Server.cron_time.tv_sec - WorkerProcess->refresh_time < Server.graceful_timeout) {
        processEvents(WorkerProcess->center, WHEATSERVER_CRON_MILLLISECONDS);
        gettimeofday(&Server.cron_time, NULL);
    }
}
コード例 #10
0
ファイル: CharmConstants.cpp プロジェクト: KDAB/Charm
void connectControllerAndModel( Controller* controller, CharmDataModel* model )
{
    QObject::connect( controller, SIGNAL(eventAdded(Event)),
                      model, SLOT(addEvent(Event)) );
    QObject::connect( controller, SIGNAL(eventModified(Event)),
                      model, SLOT(modifyEvent(Event)) );
    QObject::connect( controller, SIGNAL(eventDeleted(Event)),
                      model, SLOT(deleteEvent(Event)) );
    QObject::connect( controller, SIGNAL(allEvents(EventList)),
                      model, SLOT(setAllEvents(EventList)) );
    QObject::connect( controller, SIGNAL(definedTasks(TaskList)),
                      model, SLOT(setAllTasks(TaskList)) );
    QObject::connect( controller, SIGNAL(taskAdded(Task)),
                      model, SLOT(addTask(Task)) );
    QObject::connect( controller, SIGNAL(taskUpdated(Task)),
                      model, SLOT(modifyTask(Task)) );
    QObject::connect( controller, SIGNAL(taskDeleted(Task)),
                      model, SLOT(deleteTask(Task)) );
}
コード例 #11
0
	void EventManager::updateEvents() {
		readQueueIndex = (readQueueIndex + 1) % 2;
		writeQueueIndex = (writeQueueIndex + 1) % 2;

		EventQueue& readQueue = queue[readQueueIndex];

		double time = clock.getTimeInMicroSec();

		while(!readQueue.isEmpty()) {
			const EventQueue::TimedEvent& timedEvent = readQueue.peekEvent();

			if(timedEvent.timer > time)
				break;

			sendEvent(timedEvent.event);
			deleteEvent(timedEvent.event);

			readQueue.popEvent();
		}
	}
コード例 #12
0
void HistoryHandler::editEvent (CommandParser& test)
{
	int displayIndex=atoi(test.getInputIndex().c_str());
	if(displayIndex>displayList.size())
		throw TempusException(TempusException::INVALID_INDEX_EXCEPTION);
	if(!test.hasWords())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "No Details Entered");
	if(!test.hasDate())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "Only Date Can Be Edited In Archive");
	string id = displayList[displayIndex-1].getId();
	string date=id.substr(0,8);
	Date dateObj=masterList[0].dateStringToObject(date);
	int dateIndex=masterList[0].dateDifference(dateObj);
	int indexToEdit=masterList[dateIndex].getIndex(id);

	assert(indexToEdit!=-1);

	Event eventObj2 = masterList[dateIndex].getEvent(indexToEdit);
	if (test.hasTime() && !test.hasDate())
		throw TempusException(TempusException::INVALID_EDIT_EXCEPTION, "Cannot Edit Time In Archive");
	deleteEvent(test);
		
	stringstream input;
	input << eventObj2.getName();
	if (eventObj2.getLocation()!="")
		input << " Location " << eventObj2.getLocation();
	input << " Date " << test.getInputDate();
	if (eventObj2.getEventType()!="d")
		input << " Time ";
	else
		input << " By ";
	
	if (test.hasTime())
		input << test.getStartTimeObj().formatCompleteTime(test.getEndTimeObj());
	else
		input  << eventObj2.getStartTime().formatCompleteTime(eventObj2.getEndTime());

	test.setStatus(eventObj2.getEventStatus());
	test.setInputDetails(input.str());
}
コード例 #13
0
ファイル: worker.c プロジェクト: alemic/wheatserver
void freeClient(struct client *c)
{
    struct listNode *node;

    if (c->notify)
        c->notify(c);
    wstrFree(c->ip);
    wstrFree(c->name);
    msgFree(c->req_buf);
    freeList(c->conns);
    close(c->clifd);
    node = searchListKey(Clients, c);
    deleteEvent(WorkerProcess->center, c->clifd, EVENT_READABLE|EVENT_WRITABLE);
    if (!node)
        ASSERT(0);
    removeListNode(Clients, node);
    if (listLength(FreeClients) <= 120) {
        appendToListTail(FreeClients, c);
    } else {
        wfree(c);
    }
}
コード例 #14
0
/**
 * trata evento de teclados (ASCII)
 */
void RobotWindow::keyboard(unsigned char key, int x, int y) {
	switch(key) {
	// evento de reset da câmera e das posições iniciais
	case 'R':
	case 'r':
		newEvent(EVENT_RESET, interval);
		break;
    // event to go to home posisiton, 6/6/13
    case 'H':
    case 'h':
//        newEvent(EVENT_RESET, interval);
// INSERT CODE HERE
        break;
// event to move as line/circular motion, 6/6/13
    case 'M':
    case 'm':
//        newEvent(EVENT_RESET, interval);
// INSERT CODE HERE
       break;
    // evento de afastamento da câmera
	case 'v':
	case 'V':
		cameraRadius += 0.5;
		setCameraPosition(cameraLongitude, cameraLatitude);
		break;
	// evento de aproximação da câmera
	case 'f':
	case 'F':
		if (cameraRadius >= MIN_CAM_RADIUS) {
			cameraRadius -= 0.5;
			setCameraPosition(cameraLongitude, cameraLatitude);
		}
		break;
	// rotação da base do braço do robô
	case 'z':
	case 'Z':
		if (!robot.isFlying())
			robot.armBase.rotate(1);
		break;
	case 'c':
	case 'C':
		if (!robot.isFlying())
			robot.armBase.rotate(-1);
		break;
    // rotate the base of the claw of robot
    // Added 6/6/13
    case ',':
    case '<':
        if (!robot.isFlying())
            robot.clawBase.rotate(1);
        break;
    case '.':
    case '>':
        if (!robot.isFlying())
            robot.clawBase.rotate(-1);
        break;
    // rotação do braço do robô
	case 'q':
	case 'Q':
		if (!robot.isFlying())
			robot.arm.rotate(1);
		break;
	case 'a':
	case 'A':
		if (!robot.isFlying())
			robot.arm.rotate(-1);
		break;
	// rotação da garra do robô (inclui toda a hélice e os dedos da garra)
	case 'e':
	case 'E':
		if (!robot.isFlying())
			robot.claw.rotate(1);
		break;
	case 'd':
	case 'D':
		if (!robot.isFlying())
			robot.claw.rotate(-1);
		break;
	// rotação dos dedos da garra
	case 'x':
	case 'X':
		robot.claw.finger.rotate(1);
		break;
	case 's':
	case 'S':
		robot.claw.finger.rotate(-1);
		break;
	// alterna estado do robô entre de voando, pousando sobre a base ou resgate
	case 't':
	case 'T':
		// se  o robô está voando
		if (robot.isFlying()) {
			// e já está tentando pousar
			if (getEventId(eventFlying) == EVENT_LANDING) {
				deleteEvent(eventFlying);
				// ativa o modo de resgate
				eventFlying = newEvent(EVENT_RESCUE, interval);
			} else {
				deleteEvent(eventFlying);
				// se está voando, ativa o modo de pouso
				eventFlying = newEvent(EVENT_LANDING, interval);
			}
		} else {
			// se não está voando, inicia o modo de "voando"
			robot.startFlying();
			deleteEvent(eventFlying);
			eventFlying = newEvent(EVENT_START_FLY, interval);
		}
		break;
	// faz uma animação de pouso do robô até sua posição inicial
	case 'y':
	case 'Y':
		if (robot.isFlying()) {
			if (getEventId(eventFlying) == EVENT_FLYING) {
				deleteEvent(eventFlying);
				eventFlying = newEvent(EVENT_SAFE_LANDING, interval);
			}
		}
		break;
	// sobe o robô, caso esteja flutuando (após as animações de início do voo)
	case 'g':
	case 'G':
		robot.moveUp();
		break;
	// desce o robô, caso esteja flutuando (após as animações de início do voo)
	case 'b':
	case 'B':
		robot.moveDown();
		break;
	// modifica o ângulo entre as garras (que formam a hélice)
	case 'i':
	case 'I':
		if (!robot.isFlying())
			robot.claw.rotateAngle(1);
		break;
	case 'k':
	case 'K':
		if (!robot.isFlying())
			robot.claw.rotateAngle(-1);
		break;
	// modifica o ângulo de cada garras (simulando o ângulo de ataque da hélice)
	case 'o':
	case 'O':
		if (!robot.isFlying())
			robot.claw.rotateAttack(0.25);
		break;
	case 'l':
	case 'L':
		if (!robot.isFlying())
			robot.claw.rotateAttack(-0.25);
		break;
	// liga/desliga o desenho da grade de limíte espacial do jogo
	case 'p':
	case 'P':
		drawCage = !drawCage;
		break;
	// modifica o ângulo de deslocamento (usado na rotação das hélices)
	case '+':
	case '=':
		robot.aceleratePropeller(1);
		break;
	case '-':
	case '_':
		robot.aceleratePropeller(-1);
		break;
	default:
		// se não for nenhuma das teclas de comando, retorna sem fazer nada
		return;

	}
	// agenda a renderização do próxim frame
	glutPostRedisplay();
}
コード例 #15
0
ファイル: jeu.c プロジェクト: pouet/rubik
int jeu(Cube * cube, struct SItem * it, int nbItem) {
  Bouton ** b;
  SDL_Rect rimg[6] = {
    { POS_X_CUBISO + 3, POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO +
      cube->nbCubLig * 53 + 12, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * OFFSET_X_H_CUBISO + 22 - 6,
      POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO +
      (cube->nbCubLig - 1) * OFFSET_Y_H_CUBISO + cube->nbCubLig * 53 + 12, 0, 0 },
    { POS_X_CUBISO, POS_Y_CUBISO + (cube->nbCubLig - 1) * OFFSET_Y_H_CUBISO - 15 + 10, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * OFFSET_X_H_CUBISO + 18, POS_Y_CUBISO - 15 + 10, 0, 0 },
    { POS_X_CUBISO + cube->nbCubLig * (OFFSET_X_H_CUBISO * 2 ) + 10,
      POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO + 15, 0, 0 },
    { POS_X_CUBISO - 27, POS_Y_CUBISO + cube->nbCubLig * OFFSET_Y_H_CUBISO + 15, 0, 0 }
  };
  SDL_Rect roff[6] = {
    { OFFSET_X_H_CUBISO, OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, -OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, -OFFSET_Y_H_CUBISO, 0, 0 },
    { OFFSET_X_H_CUBISO, OFFSET_Y_H_CUBISO, 0, 0 },
    { 0, 53, 0, 0 },
    { 0, 53, 0, 0 }
  };
  Input * in;
  int ret = M_MENU;
  int nbBtn;
  int done;
  int clic;
  int timer;
  int i, j, k;
  
  if (cube == NULL)
    return ret;
  
  in = newEvent();
  
  nbBtn = nbItem + cube->nbCubLig * 6;
  b = emalloc((nbBtn + 1) * sizeof **b, "Erreur d'allocation de boutons.\n");
  b[nbBtn] = NULL;
  
  for (i = 0, j = 0; i < nbItem; i++, j++)
    b[i] = creerBoutonTexte(it[i].pItemName, SCR_W - g_boutons[0]->w - 12,
                            SCR_H - 6 - (nbItem - i) * (g_boutons[0]->h + 6), 1);
  
  for (k = 0; k < 6; k++)
    for (i = 0; i < cube->nbCubLig; i++, j++)
      b[j] = creerBoutonImage(k * 3, rimg[k].x + roff[k].x * i,
                              rimg[k].y + roff[k].y * i, 1);
  
  refreshScreen();
  
  timer = 0;
  clic = 0;
  done = 0;
  while (!done) {
    updateEvents(in);
    
    if (in->quit) {
      done = 1;
      ret = M_QUIT;
    }
    
    for (i = 0; i < nbBtn; i++) {
      if (b[i]->actif) {
        if (collisionPoint(&b[i]->r, &in->mouse)) {
          /* Si on clique */
          if (!clic && (in->mousebuttons[1] || in->mousebuttons[2])) {
            clic = 1;
            b[i]->etat = BTN_ETAT_CLIC;
            b[i]->majAff = 1;
          }
          /* Si on relâche le clic */
          else if (clic && b[i]->etat == BTN_ETAT_CLIC &&
                   !in->mousebuttons[1] && !in->mousebuttons[2]) {
            clic = 0;
            b[i]->etat = BTN_ETAT_NORMAL;
            b[i]->majAff = 1;
            
            if (i < nbItem) {
              if (it[i].nItemVal == M_MENU || it[i].nItemVal == M_QUIT) {
                ret = it[i].nItemVal;
                if (it[i].pVal)
                  *it[i].pVal = it[i].nVal;
                done = 1;
              }
              else if (it[i].nItemVal == M_MELANGE) {
                melangerCube(cube);
                timer = 0;
                cube->tpsTotal = 0;
                cube->nbCoups = 0;
              }
              else if (it[i].nItemVal == M_REINIT) {
                refreshScreen();
                initCube(cube, cube->nbCubLig);
                timer = 0;
              }
              else if (it[i].nItemVal == M_SAUVE) {
                sauverCube(cube);
              }
            }
            else if (i >= nbItem) {
              int tmp = i - nbItem;
              
              cube->nbCoups++;
              if (timer == 0)
                timer = 1;
              
              /* Ca va crescendo on teste la borne la plus basse et ainsi de suite
               * sans retester plus bas, c'est déjà test avant */
              /* Flèche haut gauche */
              if (tmp < cube->nbCubLig) {
                rotationCubeEntier(cube, R_GAUCHE);
                mouvement(cube, tmp, R_BAS);
                rotationCubeEntier(cube, R_DROITE);
              }
              /* Flèches haut droite */
              else if (tmp < cube->nbCubLig * 2) {
                tmp -= cube->nbCubLig;
                mouvement(cube, tmp, R_BAS);
              }
              /* Flèches bas gauche */
              else if (tmp < cube->nbCubLig * 3) {
                tmp -= (cube->nbCubLig * 2);
                mouvement(cube, tmp, R_HAUT);
              }
              /* Flèches bas droite */
              else if (tmp < cube->nbCubLig * 4) {
                tmp -= (cube->nbCubLig * 3);
                rotationCubeEntier(cube, R_GAUCHE);
                mouvement(cube, tmp, R_HAUT);
                rotationCubeEntier(cube, R_DROITE);
              }
              /* Flèches droite */
              else if (tmp < cube->nbCubLig * 5) {
                tmp -= (cube->nbCubLig * 4);
                mouvement(cube, tmp, R_DROITE);
              }
              /* Flèches gauche */
              else if (tmp < cube->nbCubLig * 6) {
                tmp -= (cube->nbCubLig * 5);
                mouvement(cube, tmp, R_GAUCHE);
              }
              else {
                cube->nbCoups--;
                aprintf("Bouton inconnu.\n");
              }
            }
            else {
              aprintf("Bouton inconnu.\n");
            }
          }
          else if (b[i]->etat != BTN_ETAT_CLIC) {
            if (b[i]->etat != BTN_ETAT_SURVOLE)
              b[i]->majAff = 1;
            b[i]->etat = BTN_ETAT_SURVOLE;
          }
        }
        else if (b[i]->etat != BTN_ETAT_CLIC) {
          if (b[i]->etat != BTN_ETAT_NORMAL)
            b[i]->majAff = 1;
          b[i]->etat = BTN_ETAT_NORMAL;
        }
      }
    }
    
    if (clic && !in->mousebuttons[1] && !in->mousebuttons[2]) {
      clic = 0;
      for (i = 0; i < nbBtn; i++)
        if (b[i]->etat == BTN_ETAT_CLIC) {
          b[i]->etat = BTN_ETAT_NORMAL;
          b[i]->majAff = 1;
        }
    }
    
    if (timer)
      cube->tpsTotal += TICK;
    
    affiche(BCK_JEU, cube, b);
  }
  
  for (i = 0; i < nbBtn; i++)
    detruireBouton(&b[i]);
  free(b);
  deleteEvent(&in);
  
  return ret;
}
コード例 #16
0
ファイル: undo.cpp プロジェクト: faesong/oom
void Song::doRedo2()
{
    Undo& u = redoList->back();
    for (iUndoOp i = u.begin(); i != u.end(); ++i)
    {
        switch (i->type)
        {
        case UndoOp::AddTrack:
            insertTrack2(i->oTrack, i->trackno);
            // Added by T356.
            chainTrackParts(i->oTrack, true);

            updateFlags |= SC_TRACK_INSERTED;
            break;
        case UndoOp::DeleteTrack:
            removeTrack2(i->oTrack);
            updateFlags |= SC_TRACK_REMOVED;
            break;
        case UndoOp::ModifyTrack:
        {
            // Unchain the track parts, but don't touch the ref counts.
            unchainTrackParts(i->nTrack, false);

            //Track* track = i->nTrack->clone();
            Track* track = i->nTrack->clone(false);

            *(i->nTrack) = *(i->oTrack);

            // Prevent delete i->oTrack from crashing.
            switch (i->oTrack->type())
            {
            case Track::AUDIO_OUTPUT:
            {
                AudioOutput* ao = (AudioOutput*) i->oTrack;
                for (int ch = 0; ch < ao->channels(); ++ch)
                    ao->setJackPort(ch, 0);
            }
            break;
            case Track::AUDIO_INPUT:
            {
                AudioInput* ai = (AudioInput*) i->oTrack;
                for (int ch = 0; ch < ai->channels(); ++ch)
                    ai->setJackPort(ch, 0);
            }
            break;
            default:
                break;
            }
            if (!i->oTrack->isMidiTrack())
                ((AudioTrack*) i->oTrack)->clearEfxList();

            delete i->oTrack;
            i->oTrack = track;

            // Chain the track parts, but don't touch the ref counts.
            chainTrackParts(i->nTrack, false);

            // Connect and register ports.
            switch (i->nTrack->type())
            {
            case Track::AUDIO_OUTPUT:
            {
                AudioOutput* ao = (AudioOutput*) i->nTrack;
                ao->setName(ao->name());
            }
            break;
            case Track::AUDIO_INPUT:
            {
                AudioInput* ai = (AudioInput*) i->nTrack;
                ai->setName(ai->name());
            }
            break;
            default:
                break;
            }

            // Update solo states, since the user may have changed soloing on other tracks.
            updateSoloStates();

            updateFlags |= SC_TRACK_MODIFIED;
        }
        break;

        /*
        // Prevent delete i->oTrack from crashing.
        switch(i->oTrack->type())
        {
        	  case Track::AUDIO_OUTPUT:
        			  {
        			  AudioOutput* ao = (AudioOutput*)i->oTrack;
        			  for(int ch = 0; ch < ao->channels(); ++ch)
        				ao->setJackPort(ch, 0);
        			  }
        			break;
        	  case Track::AUDIO_INPUT:
        			  {
        			  AudioInput* ai = (AudioInput*)i->oTrack;
        			  for(int ch = 0; ch < ai->channels(); ++ch)
        				ai->setJackPort(ch, 0);
        			  }
        			break;
        	  default:
        			break;
        }
        if(!i->oTrack->isMidiTrack())
          ((AudioTrack*)i->oTrack)->clearEfxList();

        //delete i->oTrack;
        //i->oTrack = track;

        // Remove the track. removeTrack2 takes care of unchaining the old track.
        removeTrack2(i->oTrack);

        // Connect and register ports.
        switch(i->nTrack->type())
        {
          case Track::AUDIO_OUTPUT:
        	  {
        	  AudioOutput* ao = (AudioOutput*)i->nTrack;
        	  ao->setName(ao->name());
        	  }
        	break;
          case Track::AUDIO_INPUT:
        	  {
        	  AudioInput* ai = (AudioInput*)i->nTrack;
        	  ai->setName(ai->name());
        	  }
        	break;
          default:
        	break;
        }

        // Insert the new track.
        insertTrack2(i->nTrack, i->trackno);
        // Chain the new track parts. (removeTrack2, above, takes care of unchaining the old track).
        chainTrackParts(i->nTrack, true);

        // Update solo states, since the user may have changed soloing on other tracks.
        updateSoloStates();

        updateFlags |= SC_TRACK_MODIFIED;
        }
        break;
         */

        case UndoOp::SwapTrack:
        {
            Track* track = _tracks[i->a];
            _tracks[i->a] = _tracks[i->b];
            _tracks[i->b] = track;
            updateFlags |= SC_TRACK_MODIFIED;
        }
        break;
        case UndoOp::AddPart:
            addPart(i->oPart);
            updateFlags |= SC_PART_INSERTED;
            i->oPart->events()->incARef(1);
            //i->oPart->chainClone();
            chainClone(i->oPart);
            break;
        case UndoOp::DeletePart:
            removePart(i->oPart);
            updateFlags |= SC_PART_REMOVED;
            i->oPart->events()->incARef(-1);
            //i->oPart->unchainClone();
            unchainClone(i->oPart);
            break;
        case UndoOp::ModifyPart:
            if (i->doCtrls)
                removePortCtrlEvents(i->nPart, i->doClones);
            changePart(i->nPart, i->oPart);
            i->oPart->events()->incARef(1);
            i->nPart->events()->incARef(-1);
            //i->nPart->replaceClone(i->oPart);
            replaceClone(i->nPart, i->oPart);
            if (i->doCtrls)
                addPortCtrlEvents(i->oPart, i->doClones);
            updateFlags |= SC_PART_MODIFIED;
            break;
        case UndoOp::AddEvent:
            addEvent(i->nEvent, i->part);
            if (i->doCtrls)
                addPortCtrlEvents(i->nEvent, i->part, i->doClones);
            updateFlags |= SC_EVENT_INSERTED;
            break;
        case UndoOp::DeleteEvent:
            if (i->doCtrls)
                removePortCtrlEvents(i->nEvent, i->part, i->doClones);
            deleteEvent(i->nEvent, i->part);
            updateFlags |= SC_EVENT_REMOVED;
            break;
        case UndoOp::ModifyEvent:
            if (i->doCtrls)
                removePortCtrlEvents(i->nEvent, i->part, i->doClones);
            changeEvent(i->nEvent, i->oEvent, i->part);
            if (i->doCtrls)
                addPortCtrlEvents(i->oEvent, i->part, i->doClones);
            updateFlags |= SC_EVENT_MODIFIED;
            break;
        case UndoOp::AddTempo:
            //printf("doRedo2: UndoOp::AddTempo. adding tempo at: %d with tempo=%d\n", i->a, i->b);
            tempomap.addTempo(i->a, i->b);
            updateFlags |= SC_TEMPO;
            break;
        case UndoOp::DeleteTempo:
            //printf("doRedo2: UndoOp::DeleteTempo. deleting tempo at: %d with tempo=%d\n", i->a, i->b);
            tempomap.delTempo(i->a);
            updateFlags |= SC_TEMPO;
            break;
        case UndoOp::AddSig:
            ///sigmap.add(i->a, i->b, i->c);
            AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c));
            updateFlags |= SC_SIG;
            break;
        case UndoOp::DeleteSig:
            ///sigmap.del(i->a);
            AL::sigmap.del(i->a);
            updateFlags |= SC_SIG;
            break;
        case UndoOp::ModifyClip:
        case UndoOp::ModifyMarker:
            break;
        }
    }
}
コード例 #17
0
ファイル: MainWindow.cpp プロジェクト: MikeMcQuaid/Fabula
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    database(0),
    eventsFilterModel(new QSortFilterProxyModel(this)),
    conversationsTreeModel(new TableToTreeProxyModel(this)),
    hideEventsTableColumnsModel(new HideColumnsProxyModel(this))
{
    ui->setupUi(this);

    eventsFilterModel->setObjectName("eventsFilterModel");

    hideEventsTableColumnsModel->setObjectName("hideEventsTableColumnsModel");
    QList<int> hideColumns;
    hideColumns << 0 << 1 << 4 << 5;
    hideEventsTableColumnsModel->setHideColumns(hideColumns);

    conversationsTreeModel = new TableToTreeProxyModel(this);
    conversationsTreeModel->setObjectName("conversationsTreeModel");

    QString fileName = settings.value("database").toString();

    if (fileName.isEmpty() || !QFile(fileName).exists()) {
        newFile();
    }
    else {
        openFile(fileName);
    }

    ui->statusBar->hide();

    ui->splitter->setStretchFactor(1, 1);
    QVariant treeSize = settings.value("treeSize");
    QVariant tableSize = settings.value("tableSize");
    if (treeSize.isValid() && tableSize.isValid()) {
        QList<int> splitterSizes;
        splitterSizes << treeSize.toInt() << tableSize.toInt();
        ui->splitter->setSizes(splitterSizes);
    }

    // TODO: Disable actions that need new e.g. characters until ready
    connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
    connect(ui->actionAdd_Event, SIGNAL(triggered()), this, SLOT(addEvent()));
    connect(ui->actionDelete_Event, SIGNAL(triggered()), this, SLOT(deleteEvent()));
    connect(ui->actionAdd_Conversation, SIGNAL(triggered()), this, SLOT(addConversation()));
    connect(ui->actionDelete_Conversation, SIGNAL(triggered()), this, SLOT(deleteConversation()));
    connect(ui->actionAdd_Character, SIGNAL(triggered()), this, SLOT(addCharacter()));
    connect(ui->actionDelete_Character, SIGNAL(triggered()), this, SLOT(deleteCharacter()));
    connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openPreferences()));

    ui->conversationsView->installEventFilter(this);
    ui->eventsView->installEventFilter(this);

    connect(ui->conversationsView, SIGNAL(clicked(QModelIndex)),
            this, SLOT(filterOnConversation(QModelIndex)));

    ui->eventsView->setModel(eventsFilterModel);
    ui->eventsView->hideColumn(0);
    ui->eventsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);

    ui->eventsView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->eventsView, SIGNAL(activated(QModelIndex)), this, SLOT(editEvent(QModelIndex)));

    conversationsTreeModel->index(0,0).parent().isValid();
    ui->conversationsView->setModel(conversationsTreeModel);
    ui->conversationsView->sortByColumn(0, Qt::AscendingOrder);

    ui->conversationsView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->conversationsView, SIGNAL(activated(QModelIndex)), this, SLOT(editTreeItem(QModelIndex)));
}