Esempio n. 1
0
void Player::playNextMusic(PlaylistPtr playlist, const MusicMeta &info)
{
    Q_ASSERT(playlist == m_playinglist);

    if (m_mode == RepeatSingle) {
        selectNext(info, RepeatAll);
    } else {
        selectNext(info, m_mode);
    }
}
Esempio n. 2
0
bool
EventManager::selectNext(Widget* target, Widget* startFrom, int iter)
{
    ILOG_TRACE_F(ILX_EVENTMANAGER);
    ILOG_DEBUG(ILX_EVENTMANAGER, " -> target: %p\n", target);
    ILOG_DEBUG(ILX_EVENTMANAGER, " -> startFrom: %p\n", startFrom);
    ILOG_DEBUG(ILX_EVENTMANAGER, " -> iter: %d\n", iter);

    if (iter)
        return true;

    if (target == NULL && startFrom == _creator)
        ++iter;

    if (startFrom && target == _creator)
    {
        startFrom = NULL;
        iter++;
    } else if (!target)
    {
        if (_focusedWidget)
            target = _focusedWidget;
        else
            target = _creator;
    }

    if (setFocusedWidget(target))
        return true;

    if (target->_children.size())
    {
        Widget* targetChild;
        for (Widget::WidgetListIterator it = target->_children.begin(), end = target->_children.end(); it != end; ++it)
        {
            targetChild = (Widget*) *it;

            if (startFrom)
            {
                if (startFrom == targetChild)
                    startFrom = NULL;
            } else
            {
                if (targetChild->_children.size())
                {
                    if (selectNext(targetChild, NULL, iter))
                        return true;
                } else if (setFocusedWidget(targetChild))
                    return true;
            }
        }
        return selectNext(target->_parent, target, iter);
    } else if (target != _creator)
        return selectNext(target->_parent, target, iter);
    return false;
}
Esempio n. 3
0
void WindowlistMenu::keyPressEvent (const XKeyEvent * const e) {

  unsigned int state = e->state;

  if (_debug)
    std::cout << BBTOOL << ": " << "WindowlistMenu: got keyPressEvent!" << std::endl;

  if (!_honor_modifiers) {
    state = e->state & ~(LockMask|scrollLockMask|numLockMask);
  }

  const Action *it = _keybindings->getAction(e, state, _screen);

  if (it) {
    switch (it->type()) {

    case Action::nextWindow:
    case Action::nextWindowOnAllWorkspaces:
    case Action::nextWindowOnAllScreens:
    case Action::nextWindowOfClass:
    case Action::nextWindowOfClassOnAllWorkspaces:
      selectNext();
      break;

    case Action::prevWindow:
    case Action::prevWindowOnAllWorkspaces:
    case Action::prevWindowOnAllScreens:
    case Action::prevWindowOfClass:
    case Action::prevWindowOfClassOnAllWorkspaces:
      selectPrevious();
      break;

    default:
      break;
    }
  }

  // if the user is cancelling the menu/cycle, then set focus back on the
  // window they started with.
  if (e->keycode == XKeysymToKeycode(_display, XK_Escape)) {
    XWindow * win = dynamic_cast<XWindow *>(*_windowList.begin());
    win->focus();
  } else if (e->keycode == XKeysymToKeycode(_display, XK_Up)) {
    selectPrevious(false);
  } else if (e->keycode == XKeysymToKeycode(_display, XK_Down)) {
    selectNext(false);
  }

  bt::Menu::keyPressEvent(e);

}
TMouseDialog::TMouseDialog() :
    TDialog( TRect(0, 0, 34, 12), "Mouse options" ),
    TWindowInit( &TMouseDialog::initFrame )
{
    TRect r(3, 4, 30, 5);

    options |= ofCentered;

    mouseScrollBar = new TScrollBar(r);
    mouseScrollBar->setParams(1, 1, 20, 20, 1);
    mouseScrollBar->options |= ofSelectable;
    mouseScrollBar->setValue(TEventQueue::doubleDelay);
    insert(mouseScrollBar);

    r = TRect(2, 2, 21, 3);
    insert(new TLabel(r, "~M~ouse double click", mouseScrollBar));

    r = TRect(3, 3, 30, 4);
    insert(new TClickTester(r, "Fast       Medium      Slow"));

    r = TRect(3, 6, 30, 7);
    insert(new TCheckBoxes(r, new TSItem("~R~everse mouse buttons", NULL)));
    oldDelay = TEventQueue::doubleDelay;

    r = TRect(9, 9, 19, 11);
    insert(new TButton(r, "O~K~", cmOK, bfDefault));

    r = TRect(21, 9, 31, 11);
    insert(new TButton(r, "Cancel", cmCancel, bfNormal));

    selectNext( (Boolean) 0);
}
TChDirDialog::TChDirDialog( ushort opts, ushort histId ) :
    TDialog( TRect( 16, 2, 64, 20 ), changeDirTitle ),
    TWindowInit( &TChDirDialog::initFrame )
{
    options |= ofCentered;

    dirInput = new TInputLine( TRect( 3, 3, 30, 4 ), 68 );
    insert( dirInput );
    insert( new TLabel( TRect( 2, 2, 17, 3 ), dirNameText, dirInput ));
    insert( new THistory( TRect( 30, 3, 33, 4 ), dirInput, histId ) );

    TScrollBar *sb = new TScrollBar( TRect( 32, 6, 33, 16 ) );
    insert( sb );
    dirList = new TDirListBox( TRect( 3, 6, 32, 16 ), sb );
    insert( dirList );
    insert( new TLabel( TRect( 2, 5, 17, 6 ), dirTreeText, dirList ) );

    okButton = new TButton( TRect( 35, 6, 45, 8 ), okText, cmOK, bfDefault );
    insert( okButton );
    chDirButton = new TButton( TRect( 35, 9, 45, 11 ), chdirText, cmChangeDir, bfNormal );
    insert( chDirButton );
    insert( new TButton( TRect( 35, 12, 45, 14 ), revertText, cmRevert, bfNormal ) );
    if( (opts & cdHelpButton) != 0 )
        insert( new TButton( TRect( 35, 15, 45, 17 ), helpText, cmHelp, bfNormal ) );
    if( (opts & cdNoLoadDir) == 0 )
        setUpDialog();
    selectNext( False );
}
Esempio n. 6
0
TLdrBootDialog::TLdrBootDialog() :
       TDialog(TRect(15, 8, 64, 15), "OS2LDR file launch"),
       TWindowInit(TLdrBootDialog::initFrame)
{
   TView *control;
   options |= ofCenterX | ofCenterY;

   bf_name = new TInputLine(TRect(13, 2, 43, 3), 29);
   bf_name->helpCtx = hcLdrName;
   insert(bf_name);

   insert(new THistory(TRect(43, 2, 46, 3), bf_name, hhLdrName));

   insert(new TLabel(TRect(2, 2, 12, 3), "File name", bf_name));

   control = new TButton(TRect(9, 4, 19, 6), "~L~oad", cmLaunchLdr, bfDefault);
   control->helpCtx = hcLdrLoad;
   insert(control);

   control = new TButton(TRect(20, 4, 30, 6), "~C~ancel", cmCancel, bfNormal);
   insert(control);

   control = new TButton(TRect(31, 4, 41, 6), "~K~ernel", cmSelectKernelDialog, bfNormal);
   control->helpCtx = hcLdrKernel;
   insert(control);

   selectNext(False);
}
Esempio n. 7
0
TRunCommandDialog::TRunCommandDialog() :
       TDialog(TRect(8, 7, 71, 15), "Run command"),
       TWindowInit(TRunCommandDialog::initFrame)
{
   TView *control;
   options |= ofCenterX | ofCenterY;
   helpCtx  = hcRunExecute;

   r_cmdline = new TInputLine(TRect(12, 2, 57, 3), 256);
   r_cmdline->helpCtx = hcRunCmdline;
   insert(r_cmdline);

   insert(new THistory(TRect(57, 2, 60, 3), r_cmdline, hhCmdLine));

   insert(new TLabel(TRect(2, 2, 11, 3), "Command:", r_cmdline));

   r_opts = new TCheckBoxes(TRect(12, 4, 31, 6),
      new TSItem("Echo ON",
      new TSItem("Pause on exit", 0)));
   r_opts->helpCtx = hcRunEchoON;
   insert(r_opts);

   control = new TButton(TRect(38, 4, 48, 6), "~B~rowse", cmRunBrowse, bfNormal);
   control->helpCtx = hcRunBrowseDisk;
   insert(control);

   control = new TButton(TRect(49, 4, 58, 6), "~G~o!", cmRunExecute, bfDefault);
   control->helpCtx = hcRunExecute;
   insert(control);

   selectNext(False);
}
Esempio n. 8
0
TeamSelector::TeamSelector()
  : teams(),
    teamsMap(),
    teamPages(),
    teamViews()
{
  static const size_t NUM_PLAYERS = 8;
  selectActions.reserve(NUM_PLAYERS);
  for(size_t i = 0; i < NUM_PLAYERS; ++i)
  {
    QAction* a = new QAction(this);
    a->setShortcut(QKeySequence(Qt::Key_F1 + i));
    addAction(a);
    connect(a, SIGNAL(triggered()), this, SLOT(selectPlayer()));
    selectActions.push_back(a);
  }

  QAction *aNext = new QAction(this);
  aNext->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown));
  addAction(aNext);
  connect(aNext, SIGNAL(triggered()), this, SLOT(selectNext()));

  QAction *aPrev = new QAction(this);
  aPrev->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp));
  addAction(aPrev);
  connect(aPrev, SIGNAL(triggered()), this, SLOT(selectPrev()));
}
Esempio n. 9
0
void GCMenu::pointerReleaseEvent(MAPoint2d point) {
	if (moved < 8) {
		locateItem(point);
	}
	else if (subLayout->contains(point.x, point.y)) {
		int xEnd = point.x;
		int distance = abs(xEnd - xStart);

		if (distance >= (scrWidth * 0.3)) {
			moved=0;
			if (xEnd>xStart) {
				mainImage->setTransition(TT_PUSH, 1, 0);
				selectPrevious();
			} else {
				mainImage->setTransition(TT_PUSH, -1, 0);
				selectNext();
			}
		}
	}
	else if (iconList->contains(point.x, point.y)) {
		int xEnd = point.x;
		int distance = abs(xEnd - xStart);

		if (distance >= (scrWidth * 0.3)) {
			moved=0;
			xEnd>xStart?swipeList(-1):swipeList(1);
		}
	}
}
Esempio n. 10
0
void Menu::disableEntry(unsigned i) {
	lairAssert(i < _entries.size());
	if(_entries[i].status == ENABLED) {
		--_nSelectable;
		if(_selected == i) {
			selectNext();
		}
	}
	_entries[i].status = DISABLED;
}
Esempio n. 11
0
void Menu::update() {
	if(_inputs->down->justPressed()) {
		selectNext();
	} else if(_inputs->up->justPressed()) {
		selectPrev();
	} else if(_inputs->ok->justPressed()) {
		validate();
	} else if(_inputs->cancel->justPressed()) {
		cancel();
	}
}
Esempio n. 12
0
/*
 =======================================================================================================================
    start hill climbing
 =======================================================================================================================
 */
void startClimb(State **returnState, FileData *fileData, float *p, long timeInSeconds)
{
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    State			*currentState = NULL;
    struct timespec startTW, currentTW;
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

    clock_gettime(CLOCK_MONOTONIC, &startTW);

    /*
     * long timeInSeconds = 5;
     */
    genRandomConsistentState
    (
        &currentState,
        fileData->noOfBids,
        fileData->numberCompanies,
        fileData->numberBlocks,
        p,
        0.5 * timeInSeconds
    );

    /*
     * printf("Generated\n");
     */
    *returnState = NULL;

    /*~~~~~~~~~~~~~~~~~~~~~~~*/
    long	numNeighbors = 0;
    State	**neighbors = NULL;
    /*~~~~~~~~~~~~~~~~~~~~~~~*/

    while(currentState)
    {
        freeStateObject(returnState);
        *returnState = currentState;

        clock_gettime(CLOCK_MONOTONIC, &currentTW);
        if(currentTW.tv_sec - startTW.tv_sec >= timeInSeconds)
        {
            return;
        }

        numNeighbors = getStateNeighbors(&neighbors, currentState);

        /* currentState changes in the below call */
        selectNext(&currentState, neighbors, numNeighbors);
        free(neighbors);
    }

    /*
     * printf("%s\n", testAnswer(*returnState, fileData->numberCompanies, fileData->numberBlocks));
     */
}
Esempio n. 13
0
void GCMenu::keyPressEvent(int keyCode) {
	switch(keyCode) {
		case MAK_RIGHT:
			mainImage->setTransition(TT_PUSH, -1, 0);
			selectNext();
			break;
		case MAK_LEFT:
			mainImage->setTransition(TT_PUSH, 1, 0);
			selectPrevious();
			break;
	}
}
Esempio n. 14
0
void Menu::handleKey(const SDLKey &sym)
{
    switch (sym){
    case SDLK_UP:
	ResourceData::sound->playChunk(Sound::CURSOR);
	selectPrevious();
	break;
    case SDLK_DOWN:
	ResourceData::sound->playChunk(Sound::CURSOR);	
	selectNext();
	break;
    }
}
Esempio n. 15
0
void ComboBox::mousePressEvent( QMouseEvent* event )
{
	if( model() == NULL )
	{
		return;
	}

	if( event->button() == Qt::LeftButton && ! ( event->modifiers() & Qt::ControlModifier ) )
	{
		if( event->x() > width() - CB_ARROW_BTN_WIDTH )
		{
			m_pressed = true;
			update();

			m_menu.clear();
			for( int i = 0; i < model()->size(); ++i )
			{
				QAction * a = m_menu.addAction( model()->itemPixmap( i ) ? model()->itemPixmap( i )->pixmap() : QPixmap(),
													model()->itemText( i ) );
				a->setData( i );
			}

			QPoint gpos = mapToGlobal( QPoint( 0, height() ) );
			if( gpos.y() + m_menu.sizeHint().height() < qApp->desktop()->height() )
			{
				m_menu.exec( gpos );
			}
			else
			{
				m_menu.exec( mapToGlobal( QPoint( width(), 0 ) ) );
			}
			m_pressed = false;
			update();
		}
		else if( event->button() == Qt::LeftButton )
		{
			selectNext();
			update();
		}
	}
	else if( event->button() == Qt::RightButton )
	{
		selectPrevious();
		update();
	}
	else
	{
		IntModelView::mousePressEvent( event );
	}
}
Esempio n. 16
0
DS18B20::DS18B20(uint8_t pin) : oneWire(OneWire(pin)) {
    resetSearch();
    sendCommand(SKIP_ROM, READ_POWER_SUPPLY);
    globalPowerMode = oneWire.read_bit();

    while (selectNext()) {
        uint8_t resolution = getResolution();

        if (resolution > globalResolution) {
            globalResolution = resolution;
        }

        numberOfDevices++;
    }
}
Esempio n. 17
0
static int nextSong(const char* next) {
  fprintf(stderr,"PATH: %s",next);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  struct stat buf;
  if(stat(next,&buf)!=0) {
    write(STDOUT_FILENO,"!",1);
    selectNext();
    playerPlay();
    return 1;
  } else {
    g_object_set (src, "location", next, NULL);
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    return 0;
  }
}
Esempio n. 18
0
bool PlaylistWindow::eventFilter(QObject *obj, QEvent *event)
{
    Q_UNUSED(obj);
    if (obj == ui->searchField && event->type() == QEvent::KeyPress) {
        auto keyEvent = reinterpret_cast<QKeyEvent*>(event);
        if (!keyEvent->modifiers() &&
                (keyEvent->key() == Qt::Key_Up ||
                 keyEvent->key() == Qt::Key_Down)) {
            if (keyEvent->key() == Qt::Key_Up)
                selectPrevious();
            else
                selectNext();
            return true;
        }
    }
    return QDockWidget::eventFilter(obj, event);
}
Esempio n. 19
0
g_cpu_state* g_scheduler::switchTask(g_cpu_state* cpuState) {

	lock();

	if (current) {
		current->value->cpuState = cpuState;
	}

	do {
		selectNext();
	} while (!applySwitch());
	++current->value->rounds;

	unlock();

	return current->value->cpuState;
}
Esempio n. 20
0
void TDeskTop::handleEvent(TEvent& event)
{
    TGroup::handleEvent( event );
    if( event.what == evCommand )
        {
        switch( event.message.command )
            {
            case cmNext:
                selectNext( False );
                break;
            case cmPrev:
                current->putInFrontOf( background );
                break;
            default:
                return;
            }
        clearEvent( event );
        }
}
Esempio n. 21
0
	void Container::handleEvent(const sf::Event& event)
	{
		if (hasSelection() && children[selected_child]->isActive())
		{
			children[selected_child]->handleEvent(event);
		}
		else if (event.type == sf::Event::KeyReleased)
		{
			if (event.key.code == sf::Keyboard::W || event.key.code == sf::Keyboard::Up)
			{
				selectPrevious();
			}
			else if (event.key.code == sf::Keyboard::S || event.key.code == sf::Keyboard::Down)
			{
				selectNext();
			}
			else if (event.key.code == sf::Keyboard::Return || event.key.code == sf::Keyboard::Space)
			{
				if (hasSelection())
					children[selected_child]->activate();
			}
		}
	}
Esempio n. 22
0
 void Container::handleEvent(const sf::Event& event)
 {
     // If we have selected a child then give it events
     if (hasSelection() && mChildren[mSelectedChild]->isActive())
     {
         mChildren[mSelectedChild]->handleEvent(event);
     }
     else if (event.type == sf::Event::KeyReleased)
     {
         if (event.key.code == sf::Keyboard::W || event.key.code == sf::Keyboard::Up)
         {
             selectPrevious();
         }
         else if (event.key.code == sf::Keyboard::S || event.key.code == sf::Keyboard::Down)
         {
             selectNext();
         }
         else if (event.key.code == sf::Keyboard::Return || event.key.code == sf::Keyboard::Space)
         {
             if (hasSelection())
                 mChildren[mSelectedChild]->activate();
         }
     }
 }
Esempio n. 23
0
static gboolean on_input (GIOChannel *source,
                   GIOCondition condition,
                   gpointer data) {
  gchar buf[0x100];
  GError* error = NULL;
  gsize amt;
  uint8_t ready = 0;
  for(;;) {
    GIOStatus status =  g_io_channel_read_chars (source,
                                                 buf,
                                                 0x100,
                                                 &amt,
                                                 &error);
    if(amt < 0x100) break;
    switch(status) {
    case G_IO_STATUS_NORMAL:
      continue;
    case G_IO_STATUS_AGAIN:
      ready = 1;
      break;
    case G_IO_STATUS_EOF:
      {
        GMainLoop* loop = (GMainLoop*) data;
        g_main_loop_quit (loop);
        return FALSE;
      }
    case G_IO_STATUS_ERROR:
      g_printerr("%s",error->message);
      exit(error->code);
    };
    if(ready) break;
  }
  selectNext();
  playerPlay();
  return TRUE;
}
Esempio n. 24
0
void projectM::default_key_handler( projectMEvent event, projectMKeycode keycode) {

	switch( event ) {

	case PROJECTM_KEYDOWN:

	  switch( keycode )
	    {
	    case PROJECTM_K_UP:
            beatDetect->beat_sensitivity += 0.25;
			if (beatDetect->beat_sensitivity > 5.0) beatDetect->beat_sensitivity = 5.0;
	      break;
	    case PROJECTM_K_DOWN:
            beatDetect->beat_sensitivity -= 0.25;
			if (beatDetect->beat_sensitivity < 0) beatDetect->beat_sensitivity = 0;
	      break;
		case PROJECTM_K_h:
 		  renderer->showhelp = !renderer->showhelp;
	      renderer->showstats= false;
	      renderer->showfps=false;
	    case PROJECTM_K_F1:
	      renderer->showhelp = !renderer->showhelp;
	      renderer->showstats=false;
	      renderer->showfps=false;
	      break;
	    case PROJECTM_K_y:
		this->setShuffleEnabled(!this->isShuffleEnabled());
		 break;

	    case PROJECTM_K_F5:
	      if (!renderer->showhelp)
		      renderer->showfps = !renderer->showfps;
	      break;
	    case PROJECTM_K_F4:
		if (!renderer->showhelp)
	       		renderer->showstats = !renderer->showstats;
	      break;
	    case PROJECTM_K_F3: {
	      renderer->showpreset = !renderer->showpreset;
	      break;
	     }
	    case PROJECTM_K_F2:
	      renderer->showtitle = !renderer->showtitle;
	      break;
#ifndef MACOS
	    case PROJECTM_K_F9:
#else
        case PROJECTM_K_F8:
#endif

	      renderer->studio = !renderer->studio;
	      break;

	    case PROJECTM_K_ESCAPE: {
//	        exit( 1 );
	        break;
	      }
	    case PROJECTM_K_f:

	      break;
	    case PROJECTM_K_a:
		    renderer->correction = !renderer->correction;
	        break;
	    case PROJECTM_K_b:
	      break;
            case PROJECTM_K_n:
		selectNext(true);
	      break;
            case PROJECTM_K_N:
		selectNext(false);
	      break;
	    case PROJECTM_K_r:
		selectRandom(true);
		break;
	    case PROJECTM_K_R:
		selectRandom(false);
		break;
	    case PROJECTM_K_p:
	      selectPrevious(true);
	      break;
	    case PROJECTM_K_P:
	      selectPrevious(false);
	      break;
	    case PROJECTM_K_l:
		renderer->noSwitch=!renderer->noSwitch;
	      break;
	    case PROJECTM_K_s:
            	renderer->studio = !renderer->studio;
	    case PROJECTM_K_i:
	        break;
	    case PROJECTM_K_z:
	      break;
	    case PROJECTM_K_0:
//	      nWaveMode=0;
	      break;
	    case PROJECTM_K_6:
//	      nWaveMode=6;
	      break;
	    case PROJECTM_K_7:
//	      nWaveMode=7;
	      break;
	    case PROJECTM_K_m:
	      break;
	    case PROJECTM_K_t:
	      break;
	    case PROJECTM_K_EQUALS:
	    case PROJECTM_K_PLUS:

	    	unsigned int index;

	    	if (selectedPresetIndex(index)) {

	    		const int oldRating = getPresetRating(index, HARD_CUT_RATING_TYPE);

	    		if (oldRating >= 6)
	    			  break;

	    		const int rating = oldRating + 1;

	    		changePresetRating(index, rating, HARD_CUT_RATING_TYPE);
	    	}

	    	break;

	    case PROJECTM_K_MINUS:
	    	if (selectedPresetIndex(index)) {

	    		const int oldRating = getPresetRating(index, HARD_CUT_RATING_TYPE);

	    		if (oldRating <= 1)
	    			  break;

	    		const int rating = oldRating - 1;

	    		changePresetRating(index, rating, HARD_CUT_RATING_TYPE);
	    	}
	    	break;

	    default:
	      break;
	    }
	default:
		break;

	}
}
Esempio n. 25
0
    void projectM::renderFrame()
    {
        #ifdef SYNC_PRESET_SWITCHES
        pthread_mutex_lock(&preset_mutex);
        #endif

        #ifdef DEBUG
        char fname[1024];
        FILE *f = NULL;
        int index = 0;
        int x, y;
        #endif

        timeKeeper->UpdateTimers();
/*
        if (timeKeeper->IsSmoothing())
        {
            printf("Smoothing A:%f, B:%f, S:%f\n", timeKeeper->PresetProgressA(), timeKeeper->PresetProgressB(), timeKeeper->SmoothRatio());
        }
        else
        {
            printf("          A:%f\n", timeKeeper->PresetProgressA());
        }*/

        mspf= ( int ) ( 1000.0/ ( float ) settings().fps ); //milliseconds per frame

        /// @bug who is responsible for updating this now?"
        pipelineContext().time = timeKeeper->GetRunningTime();
        pipelineContext().frame = timeKeeper->PresetFrameA();
        pipelineContext().progress = timeKeeper->PresetProgressA();

        //m_activePreset->Render(*beatDetect, pipelineContext());

        beatDetect->detectFromSamples();

        //m_activePreset->evaluateFrame();

        //if the preset isn't locked and there are more presets
        if ( renderer->noSwitch==false && !m_presetChooser->empty() )
        {
            //if preset is done and we're not already switching
            if ( timeKeeper->PresetProgressA()>=1.0 && !timeKeeper->IsSmoothing())
            {

		if (settings().shuffleEnabled)
			selectRandom(false);
		else
			selectNext(false);

           }

            else if ((beatDetect->vol-beatDetect->vol_old>beatDetect->beat_sensitivity ) &&
                timeKeeper->CanHardCut())
            {
                // printf("Hard Cut\n");
		if (settings().shuffleEnabled)
			selectRandom(true);
		else
			selectNext(true);
            }
        }


        if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() <= 1.0 && !m_presetChooser->empty() )
        {


            //	 printf("start thread\n");
            assert ( m_activePreset2.get() );

            #ifdef USE_THREADS

            pthread_cond_signal(&condition);
            pthread_mutex_unlock( &mutex );
            #endif
            m_activePreset->Render(*beatDetect, pipelineContext());

            #ifdef USE_THREADS
            pthread_mutex_lock( &mutex );
            #else
            evaluateSecondPreset();
            #endif

            Pipeline pipeline;

            pipeline.setStaticPerPixel(settings().meshX, settings().meshY);

            assert(_matcher);
            PipelineMerger::mergePipelines( m_activePreset->pipeline(),
                                            m_activePreset2->pipeline(), pipeline,
					    _matcher->matchResults(),
                                            *_merger, timeKeeper->SmoothRatio());

            renderer->RenderFrame(pipeline, pipelineContext());

	    pipeline.drawables.clear();

	    /*
	    while (!pipeline.drawables.empty()) {
		delete(pipeline.drawables.back());
		pipeline.drawables.pop_back();
	    } */

        }
        else
        {


            if ( timeKeeper->IsSmoothing() && timeKeeper->SmoothRatio() > 1.0 )
            {
                //printf("End Smooth\n");
                m_activePreset = m_activePreset2;
                timeKeeper->EndSmoothing();
            }
            //printf("Normal\n");

            m_activePreset->Render(*beatDetect, pipelineContext());
            renderer->RenderFrame (m_activePreset->pipeline(), pipelineContext());


        }

        //	std::cout<< m_activePreset->absoluteFilePath()<<std::endl;
        //	renderer->presetName = m_activePreset->absoluteFilePath();



        count++;
        #ifndef WIN32
        /** Frame-rate limiter */
        /** Compute once per preset */
        if ( this->count%100==0 )
        {
            this->renderer->realfps=100.0/ ( ( getTicks ( &timeKeeper->startTime )-this->fpsstart ) /1000 );
            this->fpsstart=getTicks ( &timeKeeper->startTime );
        }

        int timediff = getTicks ( &timeKeeper->startTime )-this->timestart;

        if ( timediff < this->mspf )
        {
            // printf("%s:",this->mspf-timediff);
            int sleepTime = ( unsigned int ) ( this->mspf-timediff ) * 1000;
            //		DWRITE ( "usleep: %d\n", sleepTime );
            if ( sleepTime > 0 && sleepTime < 100000 )
            {
                if ( usleep ( sleepTime ) != 0 ) {}}
        }
        this->timestart=getTicks ( &timeKeeper->startTime );
        #endif /** !WIN32 */

	#ifdef SYNC_PRESET_SWITCHES
        pthread_mutex_unlock(&preset_mutex);
        #endif

    }
Esempio n. 26
0
void MVListBase::handleEvent(MVEvent& event,phaseType phase)
/****************************************************************************
*
* Function:     MVListBase::handleEvent
* Parameters:   event   - Event to handle
*               phase   - Current phase for the event (pre,focus,post)
*
* Description:  Event handling mechanism for the MVListBase class.
*
****************************************************************************/
{
    MVView::handleEvent(event,phase);

    switch (event.what) {
        case evMouseDown:
            if (range.isEmpty())
                return;

            if (event.mouse.buttons & mbLeftButton) {
                while (event.what != evMouseUp) {
                    switch (event.what) {
                        case evMouseDown:
                            if (!(event.mouse.modifiers & mdShift)
                                    && !(flags & lsDisjointSelect)) {
                                clearSelection();
                                selectCell(cursor);
                                refresh();
                                }
                            if (event.mouse.doubleClick) {
                                MV_message(owner,evBroadcast,cmListItemSelected,this);
                                goto doneMouse;
                                }
                        case evMouseAuto:
                        case evMouseMove:
                            MVPoint loc;
                            uint    modifiers = mdShift;

                            if (event.what == evMouseDown)
                                modifiers = event.mouse.modifiers;
                            if (flags & lsDisjointSelect)
                                modifiers = 0;

                            uint pos = findCellHit(event.where,loc);
                            if (pos == lsInside && event.what != evMouseAuto) {
                                // Selection within the list
                                if (loc == cursor && event.what == evMouseDown) {
                                    // Post a message to ensure updates
                                    // occur for the first mouse down event
                                    // in the list box.
                                    MV_message(owner,evBroadcast,
                                        cmListCursorChanged,this);
                                    }

                                if (loc.x < cursor.x)
                                    selectLeft(cursor.x - loc.x,modifiers);
                                else if (loc.x > cursor.x)
                                    selectRight(loc.x - cursor.x,modifiers);

                                if (loc.y < cursor.y)
                                    selectUp(cursor.y - loc.y,modifiers);
                                else if (loc.y > cursor.y)
                                    selectDown(loc.y - cursor.y,modifiers);
                                }
                            else if (event.what == evMouseAuto) {
                                // Auto selection outside window to scroll
                                if (pos & lsAbove)
                                    selectUp(1,modifiers);
                                if (pos & lsBelow)
                                    selectDown(1,modifiers);
                                if (pos & lsLeft)
                                    selectLeft(1,modifiers);
                                if (pos & lsRight)
                                    selectRight(1,modifiers);
                                }
                            if (event.what == evMouseDown
                                    && flags & lsDisjointSelect) {
                                toggleCell(cursor);
                                refresh();
                                }
                            break;
                        }
                    getEvent(event);
                    }

doneMouse:
                clearEvent(event);
                }
            break;
        case evKeyDown:
        case evKeyAuto:
            if (range.isEmpty())
                return;

            switch (event.key.charScan.scanCode) {
                case kbSpace:
                    if (event.what == evKeyAuto)
                        break;
                    if (flags & lsDisjointSelect) {
                        toggleCell(cursor);
                        refresh();
                        }
                    break;
                case kbLeft:
                    selectLeft(1,event.key.modifiers);
                    break;
                case kbRight:
                    selectRight(1,event.key.modifiers);
                    break;
                case kbUp:
                    selectUp(1,event.key.modifiers);
                    break;
                case kbDown:
                    selectDown(1,event.key.modifiers);
                    break;
                case kbHome:
                    selectNext(lsLeft | lsAbove,range.bottom(),
                        event.key.modifiers);
                    break;
                case kbEnd:
                    selectNext(lsRight | lsBelow,range.bottom(),
                        event.key.modifiers);
                    break;
                case kbPgUp:
                    selectUp(visible.bottom()-visible.top(),
                        event.key.modifiers,true);
                    break;
                case kbPgDn:
                    selectDown(visible.bottom()-visible.top(),
                        event.key.modifiers,true);
                default:
                    // Key press is not handled by us, so simply return.
                    return;
                }
            clearEvent(event);
            break;
        case evBroadcast:
            if (options & ofSelectable) {
                if (event.message.command == cmScrollBarClicked &&
                        (event.message.infoPtr == hScroll ||
                         event.message.infoPtr == vScroll))
                    select();
                else if (event.message.command == cmScrollBarChanged) {
                    if (range.isEmpty())
                        return;
                    if (event.message.infoPtr == hScroll)
                        hScrollTo(hScroll->getValue());
                    else if (event.message.infoPtr == vScroll)
                        vScrollTo(vScroll->getValue());
                    }
                }
            break;
        }
}
Esempio n. 27
0
void CFlexListCtrl::OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
{
    int nTotalRow = GetItemCount();
    int nTotalColumn = GetHeaderCtrl()->GetItemCount();
    int nIncrement = 0;
    switch (nChar)
    {
        case VK_TAB:
        {
            nIncrement = -1;
            if (GetKeyState (VK_SHIFT) >= 0)
            {
                nIncrement = 1;
            }
            selectNext(nIncrement);
            break;
        }
        case VK_LEFT:
        {
            nIncrement = -1;
            selectNext(nIncrement);
            break;
        }
        case VK_RIGHT:
        {
            nIncrement = 1;
            selectNext(nIncrement);
            break;
        }

        case VK_UP :
        {
            nIncrement = -1*GetHeaderCtrl()->GetItemCount();
            selectNext(nIncrement);
            break;
        }
        case VK_DOWN :
        {
            nIncrement = GetHeaderCtrl()->GetItemCount();
            selectNext(nIncrement);
            break;
        }
        case VK_PRIOR:
        {
            nIncrement = -1*GetHeaderCtrl()->GetItemCount();
            selectNext(nIncrement);
            break;
        }
        case VK_NEXT:
        {
            nIncrement = GetHeaderCtrl()->GetItemCount();
            selectNext(nIncrement);
            break;
        }
        case VK_HOME:
        {
            m_nCurrentCell = 0;
            nIncrement = 1;
            selectNext(nIncrement);
            break;
        }
        case VK_END:
        {
            m_nCurrentCell = GetItemCount() * GetHeaderCtrl()->GetItemCount();
            nIncrement = -1;
            selectNext(nIncrement);
            break;
        }

        default :
        {
            CFFListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
            break;
        }
    }
}
Esempio n. 28
0
static void signalNext(int signal) {
  // this should execute in the main GTK thread (see signals.c)
  queueInterrupted = 1;
  selectNext();
  playerPlay();
}
Esempio n. 29
0
void Container::handleEvent(const sf::Event& event)
{
    float dirY = sf::Joystick::getAxisPosition(0, sf::Joystick::Y) / 100; // for the stick ( see bottom of function )
	
	// If we have selected a child then give it events
	if (hasSelection() && mChildren[mSelectedChild]->isActive())
	{
		mChildren[mSelectedChild]->handleEvent(event);
	}
	else if (event.type == sf::Event::KeyReleased)
	{
		if (event.key.code == sf::Keyboard::W || event.key.code == sf::Keyboard::Up)
		{
			selectPrevious();
		}
		else if (event.key.code == sf::Keyboard::S || event.key.code == sf::Keyboard::Down)
		{
			selectNext();
		}
		else if (event.key.code == sf::Keyboard::Return || event.key.code == sf::Keyboard::Space)
		{
			if (hasSelection())
				mChildren[mSelectedChild]->activate();
		}
	}
	// if mouse button is clicked, and an item was selected,
	// then activate the item (button, etc.)
	else if (event.type == sf::Event::MouseButtonPressed)
	{
		if (event.mouseButton.button == sf::Mouse::Left)
		{
			if (selectMouse())
			{
				if (hasSelection())
					mChildren[mSelectedChild]->activate();
			}
		}
	}
	// if mouse button is clicked, and an item was selected,
	// then activate the item (button, etc.)
	else if (event.type == sf::Event::JoystickMoved && !mIsStickMove)
	{
		if (abs(dirY) > mStickSensitivity)
		{
			if (dirY > 0)
				selectNext();
			else if (dirY < 0)
				selectPrevious();

			mIsStickMove = true;
		}
	}
	else if (event.type == sf::Event::JoystickButtonPressed)
	{
		// 'a' button pressed
		if (sf::Joystick::isButtonPressed(0, 0))
			mChildren[mSelectedChild]->activate();
	}

	if (abs(dirY) <= mStickSensitivity)
		mIsStickMove = false;
}
Esempio n. 30
0
BBEditor::BBEditor( BBTrackContainer* tc ) :
	Editor(false),
	m_trackContainerView( new BBTrackContainerView(tc) )
{
	setWindowIcon( embed::getIconPixmap( "bb_track_btn" ) );
	setWindowTitle( tr( "Beat+Bassline Editor" ) );
	setCentralWidget(m_trackContainerView);

	setAcceptDrops(true);
	m_toolBar->setAcceptDrops(true);
	connect(m_toolBar, SIGNAL(dragEntered(QDragEnterEvent*)), m_trackContainerView, SLOT(dragEnterEvent(QDragEnterEvent*)));
	connect(m_toolBar, SIGNAL(dropped(QDropEvent*)), m_trackContainerView, SLOT(dropEvent(QDropEvent*)));

	// TODO: Use style sheet
	if( ConfigManager::inst()->value( "ui",
					  "compacttrackbuttons" ).toInt() )
	{
		setMinimumWidth( TRACK_OP_WIDTH_COMPACT + DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT
			     + 2 * TCO_BORDER_WIDTH + 264 );
	}
	else
	{
		setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH
			     + 2 * TCO_BORDER_WIDTH + 264 );
	}


	m_playAction->setToolTip(tr( "Play/pause current beat/bassline (Space)" ));
	m_stopAction->setToolTip(tr( "Stop playback of current beat/bassline (Space)" ));

	m_playAction->setWhatsThis(
		tr( "Click here to play the current "
			"beat/bassline.  The beat/bassline is automatically "
			"looped when its end is reached." ) );
	m_stopAction->setWhatsThis(
		tr( "Click here to stop playing of current "
							"beat/bassline." ) );


	// Beat selector
	DropToolBar *beatSelectionToolBar = addDropToolBarToTop(tr("Beat selector"));

	m_bbComboBox = new ComboBox( m_toolBar );
	m_bbComboBox->setFixedSize( 200, 22 );
	m_bbComboBox->setModel( &tc->m_bbComboBoxModel );

	beatSelectionToolBar->addWidget( m_bbComboBox );


	// Track actions
	DropToolBar *trackAndStepActionsToolBar = addDropToolBarToTop(tr("Track and step actions"));


	trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"),
						 Engine::getSong(), SLOT(addBBTrack()));
	trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"),
						 m_trackContainerView, SLOT(addAutomationTrack()));

	QWidget* stretch = new QWidget(m_toolBar);
	stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	trackAndStepActionsToolBar->addWidget(stretch);


	// Step actions
	trackAndStepActionsToolBar->addAction(embed::getIconPixmap("step_btn_remove"), tr("Remove steps"),
						 m_trackContainerView, SLOT(removeSteps()));
	trackAndStepActionsToolBar->addAction(embed::getIconPixmap("step_btn_add"), tr("Add steps"),
						 m_trackContainerView, SLOT( addSteps()));
	trackAndStepActionsToolBar->addAction( embed::getIconPixmap( "step_btn_duplicate" ), tr( "Clone Steps" ),
						  m_trackContainerView, SLOT( cloneSteps() ) );

	connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ),
			m_trackContainerView, SLOT( updatePosition() ) );


	QAction* viewNext = new QAction(this);
	connect(viewNext, SIGNAL(triggered()), m_bbComboBox, SLOT(selectNext()));
	viewNext->setShortcut(Qt::Key_Plus);
	addAction(viewNext);

	QAction* viewPrevious = new QAction(this);
	connect(viewPrevious, SIGNAL(triggered()), m_bbComboBox, SLOT(selectPrevious()));
	viewPrevious->setShortcut(Qt::Key_Minus);
	addAction(viewPrevious);
}