/** * create the action events create the gui. */ void KJezzball::initXMLUI() { m_newAction = KStdGameAction::gameNew( this, SLOT(newGame()), actionCollection() ); // AB: originally KBounce/KJezzball used Space for new game - but Ctrl+N is // default. We solve this by providing space as an alternative key KShortcut s = m_newAction->shortcut(); s.append(KKeySequence(QKeySequence(Key_Space))); m_newAction->setShortcut(s); KStdGameAction::quit(this, SLOT(close()), actionCollection() ); KStdGameAction::highscores(this, SLOT(showHighscore()), actionCollection() ); m_pauseButton = KStdGameAction::pause(this, SLOT(pauseGame()), actionCollection()); KStdGameAction::end(this, SLOT(closeGame()), actionCollection()); KStdGameAction::configureHighscores(this, SLOT(configureHighscores()),actionCollection()); new KAction( i18n("&Select Background Folder..."), 0, this, SLOT(selectBackground()), actionCollection(), "background_select" ); m_backgroundShowAction = new KToggleAction( i18n("Show &Backgrounds"), 0, this, SLOT(showBackground()), actionCollection(), "background_show" ); m_backgroundShowAction->setCheckedState(i18n("Hide &Backgrounds")); m_backgroundShowAction->setEnabled( !m_backgroundDir.isEmpty() ); m_backgroundShowAction->setChecked( m_showBackground ); m_soundAction = new KToggleAction( i18n("&Play Sounds"), 0, 0, 0, actionCollection(), "toggle_sound"); }
static void determineBackgroundColor(struct pam * const pamP, bool const verbose, tuple * const bgColorP) { /*---------------------------------------------------------------------------- Determine what color is the background color of the image in the file represented by *pamP. Expect the file to be positioned to the start of the raster, and leave it positioned arbitrarily. -----------------------------------------------------------------------------*/ unsigned int row; tuple * tuplerow; tuple ul, ur, ll, lr; /* Color of upper left, upper right, lower left, lower right */ tuplerow = pnm_allocpamrow(pamP); ul = pnm_allocpamtuple(pamP); ur = pnm_allocpamtuple(pamP); ll = pnm_allocpamtuple(pamP); lr = pnm_allocpamtuple(pamP); pnm_readpamrow(pamP, tuplerow); pnm_assigntuple(pamP, ul, tuplerow[0]); pnm_assigntuple(pamP, ur, tuplerow[pamP->width-1]); for (row = 1; row < pamP->height; ++row) pnm_readpamrow(pamP, tuplerow); pnm_assigntuple(pamP, ll, tuplerow[0]); pnm_assigntuple(pamP, lr, tuplerow[pamP->width-1]); selectBackground(pamP, ul, ur, ll, lr, bgColorP); if (verbose) { int const hexokTrue = 1; const char * const colorname = pnm_colorname(pamP, *bgColorP, hexokTrue); pm_message("Background color is %s", colorname); strfree(colorname); } pnm_freepamtuple(lr); pnm_freepamtuple(ll); pnm_freepamtuple(ur); pnm_freepamtuple(ul); pnm_freepamrow(tuplerow); }
void Gource::mousetrace(Frustum& frustum, float dt) { GLuint buffer[512]; GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glSelectBuffer(512, buffer); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); (void) glRenderMode(GL_SELECT); glInitNames(); glPushName(0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix((GLdouble) mousepos.x, (GLdouble) (viewport[3]-mousepos.y), 1.0f, 1.0f, viewport); gluPerspective(90.0f, (GLfloat)display.width/(GLfloat)display.height, 0.1f, camera.getZFar()); camera.look(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); for(std::map<std::string,RUser*>::iterator it = users.begin(); it!=users.end(); it++) { it->second->drawSimple(dt); } glDisable(GL_TEXTURE_2D); glColor4f(1.0, 1.0, 1.0, 1.0); root->drawSimple(frustum, dt); glMatrixMode(GL_MODELVIEW); mouse_hits = glRenderMode(GL_RENDER); RFile* fileSelection = 0; RUser* userSelection = 0; if (mouse_hits > 0) { int choice = buffer[3]; GLuint depth = buffer[1]; for (int loop = 1; loop < mouse_hits; loop++) { if (buffer[loop*4+1] < depth) { choice = buffer[loop*4+3]; depth = buffer[loop*4+1]; } } if(choice != 0) { selectionDepth = depth; std::map<int, RFile*>::iterator filetest; std::map<int, RUser*>::iterator usertest; if((filetest = tagfilemap.find(choice)) != tagfilemap.end()) { fileSelection = filetest->second; } else if((usertest = tagusermap.find(choice)) != tagusermap.end()) { userSelection = usertest->second; } } } glDisable(GL_DEPTH_TEST); // is over a file if(fileSelection != 0) { // un hover a user if(hoverUser != 0) { hoverUser->setMouseOver(false); hoverUser = 0; } if(fileSelection != hoverFile) { //deselect previous selection if(hoverFile !=0) hoverFile->setMouseOver(false); //select new fileSelection->setMouseOver(true); hoverFile = fileSelection; } // is over a user } else if(userSelection != 0) { // un hover a file if(hoverFile != 0) { hoverFile->setMouseOver(false); hoverFile = 0; } if(userSelection != hoverUser) { //deselect previous selection if(hoverUser !=0) hoverUser->setMouseOver(false); //select new userSelection->setMouseOver(true); hoverUser = userSelection; } } else { if(hoverFile!=0) hoverFile->setMouseOver(false); if(hoverUser!=0) hoverUser->setMouseOver(false); hoverFile=0; hoverUser=0; } if(mouseclicked) { if(hoverUser!=0) selectUser(hoverUser); else if(hoverFile!=0) selectFile(hoverFile); else { selectBackground(); } } }