示例#1
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);

}
示例#2
0
bool
EventManager::selectPrevious(Widget* target, Widget* startFrom, int iter)
{
    if (iter)
        return true;

    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::WidgetListReverseIterator it = target->_children.rbegin(), end = target->_children.rend();
                it != end; ++it)
        {
            targetChild = (Widget*) *it;

            if (startFrom)
            {
                if (startFrom == targetChild)
                    startFrom = NULL;
            } else
            {
                if (targetChild->_children.size())
                {
                    if (selectPrevious(targetChild, NULL, iter))
                        return true;
                } else if (setFocusedWidget(targetChild))
                    return true;
            }
        }
        return selectPrevious(target->_parent, target, iter);
    } else if (target != _creator)
        return selectPrevious(target->_parent, target, iter);
    return false;
}
示例#3
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);
		}
	}
}
示例#4
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;
	}
}
示例#5
0
文件: menu.cpp 项目: hjqqq/tetrimino
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;
    }
}
示例#6
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 );
	}
}
示例#7
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);
}
示例#8
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();
			}
		}
	}
示例#9
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();
         }
     }
 }
示例#10
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;
}
示例#11
0
文件: BBEditor.cpp 项目: rcorre/lmms
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);
}
示例#12
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;

	}
}
示例#13
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;
	    default:
	      break;
	    }
	default:
		break;

	}
}