bool MessageManager::removeChat(const UserPtr& aUser) { PrivateChatPtr chat; { WLock l(cs); auto i = chats.find(aUser); if (i == chats.end()) { return false; } chat = i->second; chat->close(); auto uc = chat->getUc(); if (uc) { //Closed the window, keep listening to the connection until QUIT is received with CPMI; ccpms[aUser] = uc; uc->addListener(this); } chats.erase(i); } fire(MessageManagerListener::ChatRemoved(), chat); return true; }
int configure(Configuration const& cfg) { JSON_Config::Value lConfig(cfg.member(listeners)); if (lConfig.isArray()) { int n = lConfig.count(); for (int i = 0; i < n; ++i) { int r = addListener(lConfig.element(i)); if (r) return r; } } else if (lConfig.isObject()) { int r = addListener(lConfig); if (r) return r; } else if (!lConfig.isNull()) { Error("Invalid \"listeners\" configuration: Exists but not an Object or Array"); return 1; } return 0; }
ossimQtImageControllerOssimEventCapture::ossimQtImageControllerOssimEventCapture( ossimQtImageWindowController* imageWindow) :ossimConnectableObject(NULL, 1, 0, false, false), theController(imageWindow) { ossimReferenced::ref(); addListener((ossimConnectableObjectListener*)this); addListener((ossimDisplayEventListener*)this); }
bool BreakBlocksScene::init() { if (!CCLayer::init()) { return false; } CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true); auto size = CCDirector::sharedDirector()->getWinSize(); auto center = ccp(size.width * 0.5f, size.height * 0.5f); this->presenter = new BreakBlocksPresenter(); this->presenter->initialize(0.0f, 0.0f, size.width, size.height); auto ball = this->presenter->getBall(); ball->addListener(this->ballChangedHandler); this->ball = CCSprite::create("ball.png"); this->ball->setPosition(ball->getCenterX(), ball->getCenterY()); this->addChild(this->ball); auto bar = this->presenter->getBar(); bar->addListener(this->barChangedHandler); this->bar = CCSprite::create("bar.png"); this->bar->setPosition(bar->getCenterX(), bar->getCenterY()); this->addChild(this->bar); auto blockTexture = CCTextureCache::sharedTextureCache()->addImage("block.png"); for (int i = 0; i < this->presenter->getBlockCount(); i++) { auto b = this->presenter->getBlock(i); b->addListener(this->blockChangedHandler); auto block = CCSprite::createWithTexture(blockTexture); block->setPositionX(b->getCenterX()); block->setPositionY(b->getCenterY()); block->setTag(b->getId()); this->blocks.push_back(block); this->addChild(block); } this->label = CCLabelTTF::create("", "Thonburi", 50.0f); this->label->setPosition(center); this->addChild(this->label, 100); this->schedule(schedule_selector(BreakBlocksScene::update)); return true; }
void EventManager<T>::doSubscribeId( const ListenerRequest &req) { PrimaryListenerInfo *newPrimary = insertPriId(req.eventId.mPriId); ListenerList *insertList; SecondaryListenerMap *secondListeners = NULL; if (req.onlyPrimary) { insertList = &(newPrimary->first.get(req.whichOrder)); } else { secondListeners = &(newPrimary->second); typename SecondaryListenerMap::iterator secondIter = insertSecId(*secondListeners, req.eventId.mSecId); insertList = &((*secondIter).second->get(req.whichOrder)); } typename ListenerList::iterator iter = addListener(insertList, req.listenerFunc, req.listenerId); if (req.listenerId != SubscriptionIdClass::null()) { mRemoveById.insert( typename RemoveMap::value_type(req.listenerId, EventSubscriptionInfo( insertList, iter, secondListeners, req.eventId.mSecId))); } }
bool ofxOMXPlayerEngine::setup(ofxOMXPlayerSettings settings) { moviePath = settings.videoPath; useHDMIForAudio = settings.useHDMIForAudio; doLooping = settings.enableLooping; addListener(settings.listener); ofLogVerbose() << "moviePath is " << moviePath; isTextureEnabled = settings.enableTexture; bool doDumpFormat = false; if(omxReader.Open(moviePath.c_str(), doDumpFormat)) { ofLogVerbose() << "omxReader open moviePath PASS: "******"HAS AUDIO"; }else { ofLogVerbose() << "NO AUDIO"; } if (!settings.enableAudio) { hasAudio = false; } if (hasVideo) { ofLogVerbose() << "Video streams detection PASS"; if(clock.OMXInitialize(hasVideo, hasAudio)) { ofLogVerbose() << "clock Init PASS"; return openPlayer(); }else { ofLogError() << "clock Init FAIL"; return false; } }else { ofLogError() << "Video streams detection FAIL"; return false; } }else { ofLogError() << "omxReader open moviePath FAIL: " << moviePath; return false; } }
void QLocalServerPrivate::_q_onNewConnection() { Q_Q(QLocalServer); DWORD dummy; // Reset first, otherwise we could reset an event which was asserted // immediately after we checked the conn status. ResetEvent(eventHandle); // Testing shows that there is indeed absolutely no guarantee which listener gets // a client connection first, so there is no way around polling all of them. for (int i = 0; i < listeners.size(); ) { HANDLE handle = listeners[i].handle; if (GetOverlappedResult(handle, &listeners[i].overlapped, &dummy, FALSE)) { listeners.removeAt(i); addListener(); if (pendingConnections.size() > maxPendingConnections) connectionEventNotifier->setEnabled(false); // Make this the last thing so connected slots can wreak the least havoc q->incomingConnection((quintptr)handle); } else { if (GetLastError() != ERROR_IO_INCOMPLETE) { setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); closeServer(); return; } ++i; } } }
LLSD LLControlBase::registerListener(LLSimpleListenerObservable *listener, LLSD userdata) { // Symmetric listener relationship addListener(listener, "", userdata); listener->addListener(this, "", userdata); return getValue(); }
CabbageInfoButton::CabbageInfoButton (ValueTree wData, String style) : widgetData (wData), TextButton() { widgetData.addListener (this); //add listener to valueTree so it gets notified when a widget's property changes initialiseCommonAttributes (this, wData); //initialise common attributes such as bounds, name, rotation, etc.. setLookAndFeelColours (wData); setButtonText (getText()); filename = CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::file); setImgProperties (*this, wData, "buttonon"); setImgProperties (*this, wData, "buttonoff"); addListener (this); const String imgOff = CabbageWidgetData::getStringProp(wData, CabbageIdentifierIds::imgbuttonoff); const String imgOver = CabbageWidgetData::getStringProp(wData, CabbageIdentifierIds::imgbuttonover); const String imgOn = CabbageWidgetData::getStringProp(wData, CabbageIdentifierIds::imgbuttonon); if(style == "legacy") { return; } //if users are passing custom images, use old style look and feel if (CabbageWidgetData::getStringProp(wData, CabbageIdentifierIds::style) == "flat" && imgOff.isEmpty() && imgOn.isEmpty() && imgOver.isEmpty()) { setLookAndFeel(&flatLookAndFeel); } }
/// Makes the LocalConnection object listen. /// /// The name is a symbolic name like "lc1", that is used by the /// send() command to signify which local connection to send the /// object to. // /// When connect is called, this object adds its domain + name plus some /// other bits of information to the listeners portion of the shared memory. /// It also sets the initial bytes of the shared memory to a set /// pattern. // /// The connection will fail if a listener with the same id (domain + name) /// already exists. ActionScript isn't informed of this failure. void LocalConnection_as::connect(const std::string& name) { assert(!name.empty()); _name = name; if (!_shm.attach()) { log_error("Failed to open shared memory segment"); return; } SharedMem::iterator ptr = _shm.begin(); // We can't connect if there is already a listener with the same name. if (!addListener(_domain + ":" + _name, _shm)) { return; } const char i[] = { 1, 0, 0, 0, 1, 0, 0, 0 }; std::copy(i, i + 8, ptr); movie_root& mr = getRoot(owner()); mr.addAdvanceCallback(this); _connected = true; return; }
void ProgressWidget::setObject(ossimObject* obj) { removeListener(); reset(); m_object = obj; addListener(); }
xmlgui::Editor::Editor(): Container() { enabled = false; resizing = false; focusedControl = NULL; rolledOverControl = NULL; addListener(this); }
GuiCommandButton::GuiCommandButton(Vec dim, std::string text_label, int loadTime) : m_dim(dim), m_loadTime(loadTime), m_loadProgress(0) { sf::Texture *texture = ImageManager::instance.getTexture(text_label); m_textDim = Vec(texture->getSize().x, texture->getSize().y); m_sprite.setTexture(*texture); addListener(this); }
//=============MidiInputDeviceSelector============================================ MidiInputDeviceSelector::MidiInputDeviceSelector(String name) : ComboBox(name) { // get list of devices StringArray devices = MidiInput::getDevices(); addItemList(devices, 1); addListener(this); setSelectedItemIndex(MidiInput::getDefaultDeviceIndex()); }
//============MidiOutputDeviceSelector=========================================== MidiOutputDeviceSelector::MidiOutputDeviceSelector(String name) : ComboBox(name) { // populate self with available devices StringArray options = MidiOutput::getDevices(); addItemList(options, 1); addListener(this); setSelectedItemIndex(MidiOutput::getDefaultDeviceIndex()); }
void GuideManager::beginGuide(int step) { Assistant::sharedAssistant()->loadResourceFromFile(P_Guide); m_guideLayer = GuideLayer::create(Rect()); m_guideLayer->retain(); addListener(); setNextStepId(step); }
void AnimationClip::addListener(const char* function, unsigned long eventTime) { if (!_scriptListeners) _scriptListeners = new std::vector<ScriptListener*>; ScriptListener* listener = new ScriptListener(function); _scriptListeners->push_back(listener); addListener(listener, eventTime); }
void VSReceiver::addListenerAndStoreFunctor(const char* path, const char* types, lowrappers::ServerThread::Listener *listener) { // add listener to auto-deletion list: functorList_.push_back(std::unique_ptr<lowrappers::ServerThread::Listener>(listener)); // add listener to server: addListener(path, types, listener); }
void DeviceOrientationController::resumeEventsForAllListeners(DOMWindow* window) { if (!m_suspendedListeners.contains(window)) return; int count = m_suspendedListeners.count(window); m_suspendedListeners.removeAll(window); while (count--) addListener(window); }
keyBase::keyBase(long handle) { /* attributes */ mHandle = handle; mPrevX = 0; mPrevY = 0; mButton = 0; mKeyDown = NULL; mKeyUp = NULL; mMouseDown = NULL; mMouseMove = NULL; mMouseUp = NULL; /* misc */ addListener(VK_LBUTTON, true); addListener(VK_RBUTTON, true); addListener(VK_MBUTTON, true); addListener(27, false); }
OOTrack::OOTrack() :monoLoopSample(1,44100*MAX_LOOP_LENGTH_S), // 16000 ~ 300ms and 256*64 streamBipBuffer(16384) { quantizedRecordEnd = -1; quantizedRecordStart = -1; quantizedPlayStart = -1; quantizedPlayEnd = -1; shouldRecord= new AudioParameterBool("shouldRec","shouldRec",false); isRecording= new AudioParameterBool("Rec","Rec",false); shouldPlay= new AudioParameterBool("shouldPlay","shouldPlay",false); isPlaying= new AudioParameterBool("Play","Play",false); shouldClear = new AudioParameterBool("shouldClear","shouldClear",false); volume= new AudioParameterFloat("Volume","Volume",NormalisableRange<float>(0,1),1); groupID = new AudioParameterInt("GroupID","GroupID",-1,10,-1); trackNum = new AudioParameterInt("trackNum","trackNum",0,10,0); streamBipBufferDelay = new AudioParameterInt("RecordDelay","RecordDelay",0,streamBipBuffer.buf.getNumSamples(),0); addParameter(shouldRecord); addParameter(isRecording); addParameter(shouldPlay); addParameter(isPlaying); addParameter(shouldClear); addParameter(volume); addParameter(groupID); addParameter(trackNum); addParameter(streamBipBufferDelay); OOServer::getInstance()->registerTrack(this); init(44100, 512); // update from outside trackState = new TrackState(this); addListener(this); lastVolume = 1; }
MainMenuScene::MainMenuScene(AppContext& appContext): appContext(appContext) { staticImages = appContext.getDevice()->getVideoDriver()->getTexture("graphics/mainmenu.png"); // load positions of static images from XML file irr::io::IFileSystem* filesys = appContext.getDevice()->getFileSystem(); irr::io::IReadFile* rectanglesFile = filesys->createAndOpenFile(L"graphics/mainmenu.xml"); irr::io::IXMLReader* reader = filesys->createXMLReader(rectanglesFile); loadRectangleList(reader, staticImagesRects); reader->drop(); rectanglesFile->drop(); // create menu arcadeMenu = std::make_shared<ArcadeMenu>(appContext.getDevice()->getTimer(), appContext.getDevice()->getVideoDriver()); addListener(arcadeMenu); ArcadeMenuNode* rootNode = new ArcadeMenuNode(); ArcadeMenuNode* pressStartNode = new ArcadeMenuNode(staticImages, staticImagesRects[HashedString("pressstart")]); ArcadeMenuNode* newGameNode = new ArcadeMenuNode(staticImages, staticImagesRects[HashedString("newgame")]); newGameNode->onClickAction = [this]{ onNewGame(); }; ArcadeMenuNode* optionsNode = new ArcadeMenuNode(staticImages, staticImagesRects[HashedString("options")]); ArcadeMenuNode* quitNode = new ArcadeMenuNode(staticImages, staticImagesRects[HashedString("quit")]); quitNode->onClickAction = [this]{ onQuitGame(); }; rootNode->addChild(pressStartNode); pressStartNode->addChild(newGameNode); pressStartNode->addChild(optionsNode); pressStartNode->addChild(quitNode); arcadeMenu->setRootNode(rootNode); if (!loadControlSchemes(L"save/controls.xml", appContext.getDevice()->getFileSystem(), controlSchemes)) { std::cout << "Failed to load controls." << std::endl; } else { for (size_t i = 0; i < controlSchemes.size(); i++) { arcadeMenu->addControlScheme(&controlSchemes[i]); } } objectEngine.addObject(arcadeMenu); auto fpsDisplay = std::make_shared<FPSDisplay>(appContext); objectEngine.addObject(fpsDisplay); }
/** * \copydoc Controller::run() */ bool UpdateController::run() { addListener(lpStep); addListener(&lAutoCorrelator); addListener(&lParameterSum); // Run lPhase2N2subphases sub phases lpStep->setGain(lGainInitial); for (int subphase = 0; subphase < lNSubphases; ++subphase) { const pair<int, int> n = calculateNIterations(subphase); LOGS(Priority::INFO)<<"\n\n=== start subphase ===========" <<"\nSubphase: "<<subphase <<"\nIterations: ["<<n.first<<".."<<n.second<<"]" <<"\n==============================\n"; retryPhase(n); // Reduce gain lpStep->setGain(lpStep->getGain() * lGainDecay); LOGS(Priority::VERBOSE)<<"reduced gain to: "<<lpStep->getGain(); } removeListener(&lParameterSum); removeListener(&lAutoCorrelator); removeListener(lpStep); return true; }
int main() { { auto s = std::make_shared<vik::EventSource>(); auto l = std::make_shared<EventListenerTester>(); // intentionally not using the vik::Event constructor // because it requires GameApp to be defined, which means // including a bazillion other files. BogusEvent bogusEvent; // test no events l->resetEventCount(); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 0); l->resetEventCount(); // test adding listener s->addListener(l); // test sending events s->onEvent(bogusEvent); s->onEvent(bogusEvent); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 3); // test removing listener l->resetEventCount(); s->removeListener(l); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 0); // test listener being removed by being destroyed { auto l2 = std::make_shared<EventListenerTester>(); s->addListener(l2); } s->onEvent(bogusEvent); } generateReport(); }
void MessageManager::removeChat(const UserPtr& aUser) { WLock l(cs); auto i = chats.find(aUser); i->second->onExit(); auto uc = i->second->getUc(); if (uc) { //Closed the window, keep listening to the connection until QUIT is received with CPMI; ccpms[aUser] = uc; uc->addListener(this); } delete i->second; //TODO: use smart pointers chats.erase(i); }
void ZaScreenHis::init() { if (m_init) return; m_bg = new ZAImage(); m_bg->LoadImg("app/native/res/bg0.jpg",m_width,m_height); m_bg->setXY((int)m_width/2,(int)m_height/2); AddChild(m_bg); m_list = new ZaListHis(); m_list->m_rowheight = 310; m_list->setSize(0,20,m_width,m_height-40); AddChild(m_list); addListener(m_list,ZaEvent::EVENT_LIST_SELECT,&ZaScreenHis::onclick); addListener(m_list->m_delete,ZaEvent::EVENT_CLICK,&ZaScreenHis::onclick); ZAImage *l_img = new ZAImage(); l_img->LoadImg("app/native/res/GenericFolder.png", 48, 48); m_dir = new ZaButton(); m_dir->setImage(l_img); m_dir->setSize(m_width-90, m_height-70, 48, 48); AddChild(m_dir); addListener(m_dir, ZaEvent::EVENT_CLICK, &ZaScreenHis::onclick); l_img = new ZAImage(); l_img->LoadImg("app/native/res/dict.png", 48, 48); m_dict = new ZaButton(); m_dict->setImage(l_img); m_dict->setSize(m_width-90, m_height-200, 48, 48); AddChild(m_dict); addListener(m_dict, ZaEvent::EVENT_CLICK, &ZaScreenHis::onclick); l_img = new ZAImage(); l_img->LoadImg("app/native/res/about.png", 48, 48); m_help = new ZaButton(); m_help->setImage(l_img); m_help->setSize(m_width-90, 200, 48, 48); AddChild(m_help); addListener(m_help, ZaEvent::EVENT_CLICK, &ZaScreenHis::onclick); l_img = new ZAImage(); l_img->LoadImg("app/native/res/Mailgreen.png", 48, 48); m_mail = new ZaButton(); m_mail->setImage(l_img); m_mail->setSize(m_width-90, 70, 48, 48); AddChild(m_mail); addListener(m_mail, ZaEvent::EVENT_CLICK, &ZaScreenHis::onclick); m_textarea = new ZaTextArea(); m_textarea->init(); m_textarea->setSize(0,400,600,200); m_textarea->setcontent("<p>aaaaa</p><p>bbbbbbbb</p><p>cccccccccc</p><p>ddddd</p><p>eeeeeeeee</p><p>ffffffff</p>","utf-8"); //AddChild(m_textarea); m_init = true; }
AccountsRowComponent(CoeusList &owner_, bool addComp_) : CoeusListRowComponent(owner_, addComp_) { detailedView = false; showControls = false; // add fields // summary addAndMakeVisible(InvoiceTE = new CoeusListTextEditor("Invoice")); addAndMakeVisible(RecordDateTE = new CoeusListTextEditor("RecordDate")); addAndMakeVisible(RecordTypeTE = new CoeusListTextEditor("RecordType")); addAndMakeVisible(ReasoningTE = new CoeusListTextEditor("Reasoning")); if (!addComp) { InvoiceTE->addListener(&owner); RecordDateTE->addListener(&owner); RecordTypeTE->addListener(&owner); ReasoningTE->addListener(&owner); } const int maxRows = 6; const int numFields = 3; const int numComponents = maxRows*numFields; for (int i = 0; i < numComponents; i++) { auto comp = new CoeusListTextEditor("#" + String(i)); if (!addComp) { comp->addListener(&owner); } transactions.add(comp); addAndMakeVisible(comp); } // summary labels addAndMakeVisible(Invoice = new CoeusListLabel("Invoice", "Invoice")); addAndMakeVisible(RecordDate = new CoeusListLabel("RecordDate", "Record Date")); addAndMakeVisible(RecordType = new CoeusListLabel("RecordType", "Record Type")); addAndMakeVisible(Reasoning = new CoeusListLabel("Reasoning", "Reasoning")); // detailed view addAndMakeVisible(CommentsTE = new CoeusListTextEditor("Comments")); if (!addComp) { CommentsTE->addListener(&owner); } // detailed view labels addAndMakeVisible(Comments = new CoeusListLabel("Comments", "Comments")); addAndMakeVisible(AccountCode = new CoeusListLabel("AccountCode", "Account Code")); addAndMakeVisible(Debit = new CoeusListLabel("Debit", "Debit")); addAndMakeVisible(Credit = new CoeusListLabel("Credit", "Credit")); resized(); }
SimpleGui::SimpleGui(): xmlgui::Container() { gui = this; addListener(this); setLayoutType(xmlgui::LayoutType_vertical); x = 10; y = 20; isSetup = false; SIMPLE_GUI_WIDTH = 150; autosave = true; autoLayout = true; type = "simplegui"; }
Combo::Combo(const parameters::ParameterInfo& inParamInfo, juce::AudioProcessor* inProcessor) : Control(inParamInfo, inProcessor) { const int numValues = static_cast<int>(getPlainValue(1.f)) + 1; for (int i = 0; i < numValues; ++i) { addItem(getControlValueText(getNormalizedValue(float(i))), i + 1); } setJustificationType(juce::Justification::centred); setSelectedItemIndex(static_cast<int>(getPlainValue(getControlValue())), juce::dontSendNotification); addListener(this); }
void EditorButton::setState(bool state) { isEnabled = state; if (!state) { removeListener((Button::Listener*) getParentComponent()); } else { addListener((Button::Listener*) getParentComponent()); } repaint(); }