void setProperty(Tree t, Tree key, Tree val) { CTree* pl = t->attribut(); if(pl) t->attribut(updateKey(pl, key, val)); else t->attribut(updateKey(nil, key, val)); }
static void gridChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { GRID_DISPLAY (&display); if (strcasecmp (optionName, "put_center_key") == 0) updateKey (optionValue->s, &gd->put_center_key); else if (strcasecmp (optionName, "put_left_key") == 0) updateKey (optionValue->s, &gd->put_left_key); else if (strcasecmp (optionName, "put_right_key") == 0) updateKey (optionValue->s, &gd->put_right_key); else if (strcasecmp (optionName, "put_top_key") == 0) updateKey (optionValue->s, &gd->put_top_key); else if (strcasecmp (optionName, "put_bottom_key") == 0) updateKey (optionValue->s, &gd->put_bottom_key); else if (strcasecmp (optionName, "put_topleft_key") == 0) updateKey (optionValue->s, &gd->put_topleft_key); else if (strcasecmp (optionName, "put_topright_key") == 0) updateKey (optionValue->s, &gd->put_topright_key); else if (strcasecmp (optionName, "put_bottomleft_key") == 0) updateKey (optionValue->s, &gd->put_bottomleft_key); else if (strcasecmp (optionName, "put_bottomright_key") == 0) updateKey (optionValue->s, &gd->put_bottomright_key); }
void keyTimer(int tid){ static int lastKey=0; short key; int i; int down,up; watch("lastkey",lastKey); down=up=0; //for(i=0;i<8;i++) //{ // if (MYKEYDOWN(keyList[i])) { // updateKey(keyList[i],KEY_DOWN); // lastKey=keyList[i]; // break; // } // if (MYKEYUP(keyList[i])&&keyList[i]==lastKey) { // updateKey(keyList[i],KEY_UP); // break; // } //} for(i=0;i<8;i++) { if (lastKey==0) { if(MYKEYDOWN(keyList[i])) { lastKey=keyList[i]; updateKey(lastKey,KEY_DOWN); break; } } else { if (lastKey==keyList[i]) { if (MYKEYDOWN(lastKey)) { lastKey=keyList[i]; updateKey(lastKey,KEY_DOWN); break; } if (MYKEYUP(lastKey)) { lastKey=0; updateKey(keyList[i],KEY_UP); break; } } else { if (MYKEYDOWN(keyList[i])) { lastKey=keyList[i]; updateKey(lastKey,KEY_DOWN); break; } } } } }
static Tree updateKey (Tree pl, Tree key, Tree val) { if (isNil(pl)) return cons ( cons(key,val), nil ); if (left(hd(pl)) == key) return cons ( cons(key,val), tl(pl) ); if (isBefore(left(hd(pl)),key)) return cons ( hd(pl), updateKey( tl(pl), key, val )); return cons(cons(key,val), pl); }
// place un item dans un folder. Remplace eventuellement l'élément de même nom. Tree putFolder(Tree folder, Tree item) { Tree label, content; if ( ! isUiFolder(folder, label, content)) { fprintf(stderr, "ERROR in addFolder : not a folder\n"); } return uiFolder(label, updateKey(content, uiLabel(item), item)); }
static void opacifyChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { OPACIFY_DISPLAY (&display); if (strcasecmp (optionName, "toggle_key") == 0) updateKey (optionValue->s, &od->toggle_key); else if (strcasecmp (optionName, "init_toggle") == 0) od->toggle = optionValue->b; else if (strcasecmp (optionName, "window_match") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); OPACIFY_SCREEN (s); matchFini (&os->window_match); matchInit (&os->window_match); matchAddFromString (&os->window_match, optionValue->s); matchUpdate (&os->window_match); } }
void ParseContext::patternUpdate( const std::string& pattern , InputError::Action action) { const char * c_pattern = pattern.c_str(); for (const auto& pair : m_errorContexts) { const std::string& key = pair.first; if (util_fnmatch( c_pattern , key.c_str()) == 0) updateKey( key , action ); } }
void LinearKeyPad_scan_from_to( Key *keys , UINT8 fromIndex , UINT8 toIndex ) { UINT8 i; for( i = fromIndex ; i <= toIndex ; i++) { readKeyPadPort(); updateKey( &keys[i] , i ); } }
EncryptioNgSimliteDecryptor::EncryptioNgSimliteDecryptor(const Account &account, EncryptionProvider *provider, QObject *parent) : Decryptor(provider, parent), MyAccount(account) { connect(KeysManager::instance(), SIGNAL(keyAdded(Key)), this, SLOT(keyUpdated(Key))); connect(KeysManager::instance(), SIGNAL(keyUpdated(Key)), this, SLOT(keyUpdated(Key))); connect(KeysManager::instance(), SIGNAL(keyRemoved(Key)), this, SLOT(keyUpdated(Key))); updateKey(); }
void CLexiconKeyChooser::setKey(CSwordKey* key) { if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) { return; } updateKey(key); // qWarning("setKey end"); emit keyChanged( m_key); }
ParabolaPointer::RenderState::ParabolaRenderItem::ParabolaRenderItem(const glm::vec3& color, float alpha, float width, bool isVisibleInSecondaryCamera, bool drawInFront, bool enabled) : _isVisibleInSecondaryCamera(isVisibleInSecondaryCamera), _drawInFront(drawInFront), _enabled(enabled) { _uniformBuffer->resize(sizeof(ParabolaData)); setColor(color); setAlpha(alpha); setWidth(width); updateKey(); }
// // insert - 将一个索引的item装入Node里面 // bool BPlusNode::insert(const KeyPtr key, const RID& rid) { int i = -1; KeyPtr prev = nullptr, curr = nullptr; // 从后往前扫描 for (i = size_ - 1; i >= 0; i--) { prev = curr; curr = keyAt(i); if (keyComp(key, curr) > 0) break; rids_[i + 1] = rids_[i]; updateKey(i + 1, curr); } rids_[i + 1] = rid; updateKey(i + 1, key); size_++; setSize(size_); page_.setDirty(); return true; }
static void mateChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { if (strcasecmp (optionName, "main_menu_key") == 0) updateKey (optionValue->s, &main_menu_key); else if (strcasecmp (optionName, "run_key") == 0) updateKey (optionValue->s, &run_key); else if (strcasecmp (optionName, "run_command_screenshot_key") == 0) updateKey (optionValue->s, &run_command_screenshot_key); else if (strcasecmp (optionName, "run_command_window_screenshot_key") == 0) updateKey (optionValue->s, &run_command_screenshot_key); else if (strcasecmp (optionName, "run_command_terminal_key") == 0) updateKey (optionValue->s, &run_command_terminal_key); }
void JoystickController::update() { if(!m_joystickController) return; //SDL_PumpEvents(); SDL_JoystickUpdate(); updateKey(keys.jump, kmap.jump); updateKey(keys.alt_jump, kmap.jump_alt); updateKey(keys.run, kmap.run); updateKey(keys.alt_run, kmap.run_alt); updateKey(keys.right, kmap.right); updateKey(keys.left, kmap.left); updateKey(keys.up, kmap.up); updateKey(keys.down, kmap.down); updateKey(keys.drop, kmap.drop); updateKey(keys.start, kmap.start); }
void ParseContext::update(const std::string& keyString , InputError::Action action) { std::vector<std::string> keys; boost::split( keys , keyString , boost::is_any_of(":|")); for (const auto& input_key : keys) { std::vector<std::string> matching_keys; size_t wildcard_pos = input_key.find("*"); if (wildcard_pos == std::string::npos) { if (hasKey( input_key )) updateKey( input_key , action ); } else patternUpdate( input_key , action ); } }
// press all supported keys // text is a string which contains the key identifiers eg. "KEY_CTRL KEY_C" for Ctrl-C void setKeyValues(char* text) { char tmptxt[MAX_KEYSTRING_LEN]; // for parsing keystrings char * acttoken; int modifiers=0; strcpy(tmptxt, text); acttoken = strtok(tmptxt," "); while (acttoken) { int kc=getKeycode(acttoken); if (kc) updateKey(kc); acttoken = strtok(NULL," "); } }
KeyInput::KeyInput(QWidget *parent) : QDialog(parent), ui(new Ui::KeyInput), currentKey(0), currentFlags(0) { ui->setupUi(this); connect(this, &KeyInput::accepted, this, &KeyInput::emitKeyAdded); filter = new KeyFilter; connect(filter, &KeyFilter::keyPress, [this](quint32 key, quint32 mod) { currentKey = key; currentFlags = mod; updateKey(); }); qApp->installEventFilter(filter); }
void LinearKeyPad_scan( ) { UINT8 i = 0; #ifdef __INPUT_SIMULATION__ getSimulatedInput(); #else readKeyPadPort(); #endif for( i = 0; i < MAX_KEYS ; i++) { updateKey( &keys[i] , i ); } }
void EncryptioNgSimliteDecryptor::keyUpdated(const Key &key) { if (key.keyContact() == MyAccount.accountContact() && key.keyType() == "simlite_private") updateKey(); }
void ParseContext::update(InputError::Action action) { for (const auto& pair : m_errorContexts) { const std::string& key = pair.first; updateKey( key , action ); } }
/** Refreshes the content. */ void CBookKeyChooser::refreshContent() { if (m_key) { updateKey( m_key ); //refresh with current key } }
/** Sets another module to this keychooser */ void CBookKeyChooser::setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh) { m_modules.clear(); // for (modules.first(); modules.current(); modules.next()) { QList<CSwordModuleInfo*>::const_iterator end_it = modules.end(); for (QList<CSwordModuleInfo*>::const_iterator it(modules.begin()); it != end_it; ++it) { if ( (*it)->type() == CSwordModuleInfo::GenericBook ) { if (CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(*it)) { m_modules.append(book); } } } //refresh the number of combos if (refresh && m_modules.count() && m_key) { if (!m_layout) { m_layout = new QHBoxLayout(this); m_layout->setSpacing(0); m_layout->setContentsMargins(0, 0, 0, 0); } qDeleteAll(m_chooserWidgets); m_chooserWidgets.clear(); for (int i = 0; i < m_modules.first()->depth(); ++i) { // Create an empty keychooser, don't handle next/prev signals CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this); m_chooserWidgets.append( w ); //don't allow a too high width, try to keep as narrow as possible //to aid users with smaller screen resolutions int totalWidth = 200; //only 1 level if (m_modules.first()->depth() > 1) { if (m_modules.first()->depth() > 3) totalWidth = 400; //4+ levels else totalWidth = 300; //2-3 levels } int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth()); w->comboBox()->setMaximumWidth(maxWidth); w->comboBox()->setCurrentIndex(0); connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int))); connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int))); m_layout->addWidget(w); boxes[w] = i; w->show(); } //set the tab order of the key chooser widgets CKeyChooserWidget* chooser = 0; CKeyChooserWidget* chooser_prev = 0; const int count = m_chooserWidgets.count(); for (int i = 0; i < count; ++i) { chooser = m_chooserWidgets.at(i); Q_ASSERT(chooser); if (chooser && chooser_prev) { QWidget::setTabOrder(chooser_prev, chooser); } chooser_prev = chooser; } QWidget::setTabOrder(chooser, 0); updateKey(m_key); adjustFont(); // only when refresh is set. } }
static void colorFilterChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { FILTER_DISPLAY (&display); if (strcasecmp (optionName, "toggle_window_key") == 0) updateKey (optionValue->s, &cfd->toggle_window_key); else if (strcasecmp (optionName, "toggle_screen_key") == 0) updateKey (optionValue->s, &cfd->toggle_screen_key); else if (strcasecmp (optionName, "switch_filter_key") == 0) updateKey (optionValue->s, &cfd->switch_filter_key); else if (strcasecmp (optionName, "filter_match") == 0) { CompWindow *w; CompScreen *s = getScreenFromScreenNum (screenNum); FILTER_SCREEN (s); //Re-check every window against new match settings for (w = s->windows; w; w = w->next) { FILTER_WINDOW (w); if (matchEval (&cfs->filter_match, w) && cfs->isFiltered && !cfw->isFiltered) { colorFilterToggleWindow (w); } } } else if (strcasecmp (optionName, "exclude_match") == 0) { CompWindow *w; CompScreen *s = getScreenFromScreenNum (screenNum); FILTER_SCREEN (s); // Re-check every window against new match settings for (w = s->windows; w; w = w->next) { Bool isExcluded; FILTER_WINDOW (w); isExcluded = matchEval (&cfs->exclude_match, w); if (isExcluded && cfw->isFiltered) colorFilterToggleWindow (w); else if (!isExcluded && cfs->isFiltered && !cfw->isFiltered) colorFilterToggleWindow (w); } } else if (strcasecmp (optionName, "filters") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); FILTER_SCREEN (s); /* Just set the filtersLoaded boolean to FALSE, unloadFilters will be * called in loadFilters */ cfs->filtersLoaded = FALSE; } else if (strcasecmp (optionName, "filter_decorations") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); damageScreen (s); } }
void LinearKeyPad_updateKey( Key *key , UINT8 keyIndex ) { readKeyPadPort(); updateKey( key , keyIndex); }
static void groupChangeNotify (const char *optionName, BananaType optionType, const BananaValue *optionValue, int screenNum) { GROUP_DISPLAY (&display); if (strcasecmp (optionName, "window_match") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); matchFini (&gs->window_match); matchInit (&gs->window_match); matchAddFromString (&gs->window_match, optionValue->s); matchUpdate (&gs->window_match); } else if (strcasecmp (optionName, "tab_base_color") == 0 || strcasecmp (optionName, "tab_highlight_color") == 0 || strcasecmp (optionName, "tab_border_color") == 0 || strcasecmp (optionName, "tab_style") == 0 || strcasecmp (optionName, "border_radius") == 0 || strcasecmp (optionName, "border_width") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) if (group->tabBar) groupRenderTabBarBackground (group); } else if (strcasecmp (optionName, "tabbar_font_size") == 0 || strcasecmp (optionName, "tabbar_font_color") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) groupRenderWindowTitle (group); } else if (strcasecmp (optionName, "thumb_size") == 0 || strcasecmp (optionName, "thumb_space") == 0) { GroupSelection *group; CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); for (group = gs->groups; group; group = group->next) if (group->tabBar) { BoxPtr box = &group->tabBar->region->extents; groupRecalcTabBarPos (group, (box->x1 + box->x2 ) / 2, box->x1, box->x2); } } else if (strcasecmp (optionName, "glow") == 0 || strcasecmp (optionName, "glow_size") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); CompWindow *w; for (w = s->windows; w; w = w->next) { GROUP_WINDOW (w); groupComputeGlowQuads (w, &gs->glowTexture.matrix); if (gw->glowQuads) { damageWindowOutputExtents (w); updateWindowOutputExtents (w); damageWindowOutputExtents (w); } } } else if (strcasecmp (optionName, "glow_type") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); int glowType; GlowTextureProperties *glowProperty; GROUP_DISPLAY (&display); const BananaValue * option_glow_type = bananaGetOption (bananaIndex, "glow_type", s->screenNum); glowType = option_glow_type->i; glowProperty = &gd->glowTextureProperties[glowType]; finiTexture (s, &gs->glowTexture); initTexture (s, &gs->glowTexture); imageDataToTexture (s, &gs->glowTexture, glowProperty->textureData, glowProperty->textureSize, glowProperty->textureSize, GL_RGBA, GL_UNSIGNED_BYTE); const BananaValue * option_glow = bananaGetOption (bananaIndex, "glow", s->screenNum); if (option_glow->b && gs->groups) { CompWindow *w; for (w = s->windows; w; w = w->next) groupComputeGlowQuads (w, &gs->glowTexture.matrix); damageScreen (s); } } else if (strcasecmp (optionName, "select_button") == 0) updateButton (optionValue->s, &gd->select_button); else if (strcasecmp (optionName, "select_single_key") == 0) updateKey (optionValue->s, &gd->select_single_key); else if (strcasecmp (optionName, "group_key") == 0) updateKey (optionValue->s, &gd->group_key); else if (strcasecmp (optionName, "ungroup_key") == 0) updateKey (optionValue->s, &gd->ungroup_key); else if (strcasecmp (optionName, "remove_key") == 0) updateKey (optionValue->s, &gd->remove_key); else if (strcasecmp (optionName, "close_key") == 0) updateKey (optionValue->s, &gd->close_key); else if (strcasecmp (optionName, "ignore_key") == 0) updateKey (optionValue->s, &gd->ignore_key); else if (strcasecmp (optionName, "tabmode_key") == 0) updateKey (optionValue->s, &gd->tabmode_key); else if (strcasecmp (optionName, "change_tab_left_key") == 0) updateKey (optionValue->s, &gd->change_tab_left_key); else if (strcasecmp (optionName, "change_tab_right_key") == 0) updateKey (optionValue->s, &gd->change_tab_right_key); else if (strcasecmp (optionName, "change_color_key") == 0) updateKey (optionValue->s, &gd->change_color_key); else if (strcasecmp (optionName, "autotab_windows") == 0) { CompScreen *s = getScreenFromScreenNum (screenNum); GROUP_SCREEN (s); int i; if (gs->autotab && gs->autotabCount != 0) { for (i = 0; i <= gs->autotabCount - 1; i++) matchFini (&gs->autotab[i]); free (gs->autotab); } gs->autotabCount = optionValue->list.nItem; gs->autotab = malloc (gs->autotabCount * sizeof (CompMatch)); for (i = 0; i <= gs->autotabCount - 1; i++) { matchInit (&gs->autotab[i]); matchAddFromString (&gs->autotab[i], optionValue->list.item[i].s); matchUpdate (&gs->autotab[i]); } } }
static int mct( CONTEXT_INFO *contextInfo, const CAPABILITY_INFO *capabilityInfo, const BYTE *initialKey, const int keySize, const BYTE *initialIV, const BYTE *initialPT ) { BYTE key[ AES_KEYSIZE + 8 ], iv[ AES_KEYSIZE + 8 ]; BYTE temp[ AES_BLOCKSIZE + 8 ]; int i; memcpy( key, initialKey, keySize ); if( iv != NULL ) memcpy( iv, initialIV, AES_BLOCKSIZE ); memcpy( temp, initialPT, AES_BLOCKSIZE ); for( i = 0; i < 100; i++ ) { BYTE prevTemp[ AES_BLOCKSIZE + 8 ]; int j, status; status = capabilityInfo->initKeyFunction( contextInfo, key, keySize ); if( cryptStatusError( status ) ) return( status ); printVector( "Key", key, keySize ); if( iv != NULL ) printVector( "IV", iv, AES_BLOCKSIZE ); printVector( "Plaintext", temp, AES_BLOCKSIZE ); if( iv != NULL ) memcpy( contextInfo->ctxConv->currentIV, iv, AES_BLOCKSIZE ); for( j = 0; j < 1000; j++ ) { /* memcpy( prevTemp, temp, AES_BLOCKSIZE ); */ if( iv != NULL && j == 0 ) { status = capabilityInfo->encryptCBCFunction( contextInfo, temp, AES_BLOCKSIZE ); memcpy( prevTemp, temp, AES_BLOCKSIZE ); memcpy( temp, iv, AES_BLOCKSIZE ); } else { status = capabilityInfo->encryptFunction( contextInfo, temp, AES_BLOCKSIZE ); if( iv != NULL ) { BYTE tmpTemp[ AES_BLOCKSIZE + 8 ]; memcpy( tmpTemp, temp, AES_BLOCKSIZE ); memcpy( temp, prevTemp, AES_BLOCKSIZE ); memcpy( prevTemp, tmpTemp, AES_BLOCKSIZE ); } } if( cryptStatusError( status ) ) return( status ); } printVector( "Ciphertext", temp, AES_BLOCKSIZE ); putchar( '\n' ); status = updateKey( key, keySize, contextInfo, capabilityInfo, prevTemp, temp ); if( cryptStatusError( status ) ) return( status ); } return( CRYPT_OK ); }
//***************************************************************************** //***************************************************************************** int main(void) { //char posArray[40]; PLL_Init(); initPollingUART0(); //initPollingUART1(); UART0_TxPoll("\n\r\n\r\n\r*****Chiposizer V.9****"); UART0_TxPoll("\n\rInitializing GPIO Ports..."); initGPIOPorts(); UART0_TxPoll("\n\rInitializing PWM Modules..."); initPWM(); UART0_TxPoll("\n\rInitializing Timers..."); initTimers(); UART0_TxPoll("\n\rInitializing Effects..."); initPremadeEffects(); UART0_TxPoll("\n\rInitializing Channels..."); initChannels(); setCurrentChannel(ch5); UART0_TxPoll("\n\rEntering Main Loop"); recordLoopNum = 0; configureUART(); while(1){ if (checkMsgs(myMsgBuffer)){ handleLCDinput(myMsgBuffer[2], myMsgBuffer[4], currentCh->note->effects); } if (alertEffect) { alertEffect = false; updateAllEffects(); } if (alertScan) { alertScan = false; /*if (recordLoopNum < 1000) { recordLoopNum++; } else if (!recordLoop) { recordLoop = true; cur = testList.head; UART0_TxPoll("\n\rBegin Record Loop"); } if (!recordLoop) { keyNumber = scanMatrix(scanningMatrix); keyNumberPtr = malloc(sizeof(int8_t)); *keyNumberPtr = keyNumber; add(&testList, keyNumberPtr); } else { keyNumber = *((int8_t*) cur->data); if (cur == testList.tail) { cur = testList.head; } else { cur = cur->next; } }*/ keyNumber = scanMatrix(scanningMatrix); updateKey(currentCh->note, keyNumber); //printMatrix(scanningMatrix); } updateAllTuningWords(); } };
void Widget::handleInput(){ if(!initializedJoysticks){ SDL_Init(SDL_INIT_JOYSTICK); if(SDL_NumJoysticks() > 0){ guiLogger.log("found joysticks: " + std::to_string(SDL_NumJoysticks())); SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickOpen(0); } else{ guiLogger.log("found no joystick. SDL Init stat: " + std::to_string(SDL_WasInit(SDL_INIT_JOYSTICK))); } initializedJoysticks = true; } while(SDL_PollEvent(&event)){ float *s; std::vector<Widget*> *widgets; switch(event.type){ case SDL_JOYAXISMOTION: if(focused != NULL){ if(event.jaxis.value < -3200 || event.jaxis.value > 3200){ focused->handleAxisEvent(event.jaxis.axis, event.jaxis.value / 32767.0); } else{ focused->handleAxisEvent(event.jaxis.axis, 0); } } break; case SDL_JOYBUTTONDOWN: if(focused != NULL){ focused->handleButtonEvent(event.jbutton.button, true); } break; case SDL_JOYBUTTONUP: if(focused != NULL){ focused->handleButtonEvent(event.jbutton.button, false); } break; case SDL_MOUSEMOTION: s = pixelToScreenSpace(event.motion.x, event.motion.y); updateMousePosition(s[0], s[1]); widgets = new std::vector<Widget*>(); getWidgetsAt(s[0], s[1], widgets); Widget *w; //if(getFocused() != NULL && getFocused()->isListeningToMouse()){ while(!widgets->empty()){ w = widgets->back(); widgets->pop_back(); if(w->isListeningToMouse()){ w->handleMouseMotionEvent(s[0] - w->getAbsoluteLeft(), s[1] - w->getAbsoluteTop()); for(Widget *w1 : w->children){ if(!w1->isFocusable()){ w1->handleMouseMotionEvent(s[0] - w1->getAbsoluteLeft(), s[1] - w1->getAbsoluteTop()); } } } } //} delete widgets; delete[] s; break; case SDL_MOUSEBUTTONDOWN: updateMouseButton(event.button.button, true); s = pixelToScreenSpace(event.button.x, event.button.y); widgets = new std::vector<Widget*>(); getWidgetsAt(s[0], s[1], widgets); if(consoleActive && game::physics::pointInRect(s[0], s[1], console.getAbsoluteLeft(), console.getAbsoluteTop(), console.getWidth(), console.getHeight())){ widgets->push_back(&console); } while(widgets->size() > 0){ //Widget *w = widgets->at(i); Widget *w = widgets->back(); widgets->pop_back(); /** * if the widget is listening to mouse events and focusable, let it handle the event, transforming the global event coordinates in local coordinates * if the widget is also listening to keys, make it the currently focused widget */ if(w->isListeningToMouse() && w->isFocusable()){ if(w->isListeningToKeys()){ setFocus(w); // if(focused != NULL) // focused->hasFocus = false; // focused = w; // focused->hasFocus = true; } w->handleMouseButtonEvent(event.button.button, s[0] - w->getAbsoluteLeft(), s[1] - w->getAbsoluteTop(), true); for(Widget *h : w->children){ if(!h->isFocusable()){ h->handleMouseButtonEvent(event.button.button, s[0] - h->getAbsoluteLeft(), s[1] - h->getAbsoluteTop(), true); } } break; } } delete widgets; delete[] s; break; case SDL_MOUSEBUTTONUP: updateMouseButton(event.button.button, false); s = pixelToScreenSpace(event.button.x, event.button.y); widgets = new std::vector<Widget*>(); getWidgetsAt(s[0], s[1], widgets); if(consoleActive && game::physics::pointInRect(s[0], s[1], console.getAbsoluteLeft(), console.getAbsoluteTop(), console.getWidth(), console.getHeight())){ widgets->push_back(&console); } while(widgets->size() > 0){ //Widget *w = widgets->at(i); Widget *w = widgets->back(); widgets->pop_back(); /** * if the widget is listening to mouse events and focusable, let it handle the event, transforming the global event coordinates in local coordinates * if the widget is also listening to keys, make it the currently focused widget */ if(w->isListeningToMouse() && w->isFocusable()){ if(w->isListeningToKeys()){ setFocus(w); // if(focused != NULL) // focused->hasFocus = false; // focused = w; // focused->hasFocus = true; } w->handleMouseButtonEvent(event.button.button, s[0] - w->getAbsoluteLeft(), s[1] - w->getAbsoluteTop(), false); for(Widget *h : w->children){ if(!h->isFocusable()){ h->handleMouseButtonEvent(event.button.button, s[0] - h->getAbsoluteLeft(), s[1] - h->getAbsoluteTop(), false); } } break; } } delete widgets; delete[] s; break; case SDL_MOUSEWHEEL: if(getFocused() != NULL && getFocused()->isListeningToMouse()){ getFocused()->handleMouseWheelEvent(event.wheel.y); } break; case SDL_KEYDOWN: updateKey(event.key.keysym.scancode, true); //mapKey(event.key.keysym.scancode, true); if(event.key.keysym.sym == SDLK_ESCAPE){ if(game::isInHomescreen()){ render::stop(); game::stop(); } else{ game::toHomescreenWidget(); audio::clearMusicQueue(); audio::queueMusic("sfx/temp/pippin_the_hunchback.wav"); audio::nextSong(); } } #ifdef unix if(event.key.keysym.sym == SDLK_BACKQUOTE && (event.key.keysym.mod & (KMOD_SHIFT | KMOD_CAPS)) > 0){ #else #ifdef windows if(event.key.keysym.sym == SDLK_BACKQUOTE){ // TODO find way to get shift mod with wine SDL #else if(false){ #endif #endif consoleActive = !consoleActive; if(consoleActive){ setFocus(&console); } else if(getFocused() == &console){ if(children.size() > 0){ setFocus(children[0]); } else{ setFocus(NULL); } } } if(focused != NULL){ focused->handleKeyEvent(event.key.keysym.sym, event.key.keysym.mod, true); } break; case SDL_TEXTINPUT: if(focused != NULL){ focused->handleTextEvent(std::string(event.text.text)); } break; case SDL_KEYUP: updateKey(event.key.keysym.scancode, false); //mapKey(event.key.keysym.scancode, false); if(focused != NULL){ focused->handleKeyEvent(event.key.keysym.sym, event.key.keysym.mod, false); } break; } } } void Widget::render(float updateFactor){ render::setRenderTarget(render::HUD); //TODO unnecessary repeated setting of render Target for(Widget *w : children){ render::setScissorArea(w->getAbsoluteLeft(), w->getAbsoluteTop() + w->getHeight(), w->getWidth(), w->getHeight()); w->render(updateFactor); } } void Widget::renderConsole(float updateFactor){ render::setRenderTarget(render::HUD); if(consoleActive){ render::setScissorArea(console.getAbsoluteLeft(), console.getAbsoluteTop() + console.getHeight(), console.getWidth(), console.getHeight()); console.render(updateFactor); } }
void append(const KoColor& data) { int pos = findPos(data); if (pos > -1) updateKey(pos); else appendNew(data); }
static Tree updateKey (Tree pl, Tree key, Tree val) { if (isNil(pl)) return cons ( cons(key,val), gGlobal->nil ); if (left(hd(pl)) == key) return cons ( cons(key,val), tl(pl) ); /* left(hd(pl)) != key */ return cons ( hd(pl), updateKey( tl(pl), key, val )); }