Пример #1
0
void CApp::onLoop() {
  CFPS::FPSControl.onLoop();

  CEntityCol::entColList.clear();

  map< int, GnmsCursor*>::iterator it;
  tuioClient->lockCursorList(); // lock the cursor list
  for (it=gnmsCursors.begin(); it!=gnmsCursors.end(); it++) {
    GnmsCursor* cur = it->second;
    if (it->second != NULL) {
      if (cur->isLive() == false && cur->isDead() == false) {
	float x, y;
	if (cur->singleTouch(x, y) == true) {
	  bool refreshed = onSingleTouch(x, y);
	  if (refreshed == true) {
	    break;
	  }
	} else if (cur->swipeDown(WHEIGHT/5, WWIDTH/8) == true) {
	  onPrevPage();
	} else if (cur->swipeUp(WHEIGHT/5, WWIDTH/8) == true) {
	  onNextPage();
	} else if (cur->drewCircle(WWIDTH/3, WHEIGHT/4, WWIDTH/8, WHEIGHT/12)
		   == true) {
	  rotate180();
	}
	cur->killCursor();     // cursor has been serviced
      }
    }
  }
  tuioClient->unlockCursorList(); // unlock cursor list

  return;
}
Пример #2
0
ResLibrary::ResLibrary(QWidget *parent) :
    QWidget(parent), ui(new Ui::ResLibrary)
{
    std::cout << "Initialize ResLibrary..." << std::endl;
    initResPlugins();
    if (n_resplugins == 0)
    {
        new QLabel("This function is under development. Please wait!", this);
        return;
    }
    ui->setupUi(this);
    listWidget = new MyListWidget;
    ui->gridLayout->addWidget(listWidget, 0, 1, 1, 4);

    for (int i = 0; i < n_resplugins; i++)
    {
        ResPlugin *plugin = resplugins[i];
        ui->pluginComboBox->addItem(plugin->getName());

        QWidget *page = new QWidget;
        ui->stackedWidget->addWidget(page);
        QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
        layout->setContentsMargins(0, 11, 0, 11);
        page->setLayout(layout);

        layout->addWidget(new QLabel(tr("Tags:")));
        MyButtonGroup *buttonGroup = new MyButtonGroup(plugin->tagsList);
        connect(buttonGroup, SIGNAL(selectedChanged()), this, SLOT(reSearch()));
        layout->addWidget(buttonGroup);

        layout->addWidget(new QLabel(tr("Countries:")));
        buttonGroup = new MyButtonGroup(plugin->countriesList);
        connect(buttonGroup, SIGNAL(selectedChanged()), this, SLOT(reSearch()));
        layout->addWidget(buttonGroup);
    }
    current_plugin = 0;
    current_tag = resplugins[0]->tagsList[0];
    current_country = resplugins[0]->countriesList[0];
    current_page = 1;
    res_library = this;

    connect(ui->pageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onPageChanged(int)));
    connect(ui->prevPushButton, SIGNAL(clicked()), this, SLOT(onPrevPage()));
    connect(ui->nextPushButton, SIGNAL(clicked()), this, SLOT(onNextPage()));
    connect(ui->keyLineEdit, SIGNAL(returnPressed()), this, SLOT(keySearch()));
    connect(listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*)));
}
Пример #3
0
bool CApp::onSingleTouch(float x, float y) {
  bool retVal = false;

  vector< GnmsApp*> appList = gnmsApps[curPage];
  vector< GnmsApp*>::iterator it;
  for (it=appList.begin(); it!=appList.end(); it++) {
    if (*it == NULL) {
      // this should be cause for alarm
      // but we're going to ignore it for now
      continue;
    } else {
      float appX = (*it)->getX();
      if (x > appX && x < appX+TILE_WIDTH) {
	float appY = (*it)->getY();
	if (y > appY && y < appY+TILE_HEIGHT) {
	  onAppSelect(*it);
	  retVal = true;
	}
      }
    }
  }

  if (x > USBsymbol->getX() && x < USBsymbol->getX()+USB_WIDTH) {
    if (y > USBsymbol->getY() && y < USBsymbol->getY()+USB_HEIGHT) {
      string temp = GNMS_LOAD_USB;
      system(temp.c_str());
      onRefresh();
      retVal = true;
    }
  }

  if (gnmsApps.size() > (curPage+1)*4 &&
	     (x > 475 && x < 810 && y > 900)) {
    onNextPage();
  }
  if (curPage > 0 &&
      (x > 475 && x < 810 && y > 630 && y < 650)) {
    onPrevPage();
  }

  return retVal;
}
Пример #4
0
void CApp::onKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode) {
  switch(sym) {
  case SDLK_ESCAPE: {
    onExit();
    break;
  }
  case SDLK_n: {
    onNextPage();
    break;
  }
  case SDLK_p: {
    onPrevPage();
    break;
  }
  case SDLK_f: {
    // toggle fullscreen
    SDL_WM_ToggleFullScreen(dispSurf);
    break;
  }
  case SDLK_r: {
    // rotate
    rotate180();
    break;
  }
  case SDLK_c: {
    // toggle cursor
    if (SDL_ShowCursor(SDL_QUERY) == SDL_DISABLE) {
      SDL_ShowCursor(SDL_ENABLE);
    } else {
      SDL_ShowCursor(SDL_DISABLE);
    }
    break;
  }
  default: { // do nothing
  }
  }
  return;
}