void ClickableWidget::leftMouseReleased(float x, float y) { // Add the callback (if the user requested it) if (m_CallbackFunctions[LeftMouseReleased].empty() == false) { m_Callback.trigger = LeftMouseReleased; m_Callback.mouse.x = static_cast<int>(x - getPosition().x); m_Callback.mouse.y = static_cast<int>(y - getPosition().y); addCallback(); } // Check if we clicked on the label (not just mouse release) if (m_MouseDown == true) { // Add the callback (if the user requested it) if (m_CallbackFunctions[LeftMouseClicked].empty() == false) { m_Callback.trigger = LeftMouseClicked; m_Callback.mouse.x = static_cast<int>(x - getPosition().x); m_Callback.mouse.y = static_cast<int>(y - getPosition().y); addCallback(); } m_MouseDown = false; } }
//private void MenuHighScoreState::buildMenu(const sf::Font& font) { const float centreX = xy::DefaultSceneSize.x / 2.f; const auto& scores = getContext().appInstance.getScores(); auto list = xy::UI::create<xy::UI::ScoreList>(font); list->setAlignment(xy::UI::Alignment::Centre); list->setPosition(centreX, 590.f); list->setList(scores); list->setIndex(getContext().appInstance.getLastScoreIndex()); m_uiContainer.addControl(list); auto upScroll = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/scroll_arrow_vertical.png")); upScroll->setAlignment(xy::UI::Alignment::Centre); upScroll->setPosition(1310, 470.f); upScroll->addCallback([list]() { list->scroll(list->getVerticalSpacing()); }); m_uiContainer.addControl(upScroll); auto downScroll = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/scroll_arrow_vertical.png")); downScroll->setAlignment(xy::UI::Alignment::Centre); downScroll->setRotation(180.f); downScroll->setPosition(1310.f, 720.f); downScroll->addCallback([list]() { list->scroll(-list->getVerticalSpacing()); }); m_uiContainer.addControl(downScroll); auto button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png")); button->setString("OK"); button->setAlignment(xy::UI::Alignment::Centre); button->setPosition(centreX, 875.f); button->addCallback([this]() { auto msg = m_messageBus.post<xy::Message::UIEvent>(xy::Message::UIMessage); msg->type = xy::Message::UIEvent::MenuClosed; msg->value = 0.f; msg->stateID = (m_endGame) ? States::ID::HighScoresEnd : States::ID::HighScoresMenu; if (m_endGame) { requestStackClear(); requestStackPush(States::ID::MenuBackground); } else { requestStackPop(); requestStackPush(States::ID::MenuMain); } }); m_uiContainer.addControl(button); }
//private void MenuPauseState::buildMenu(const sf::Font& font) { const float centreX = xy::DefaultSceneSize.x / 2.f; auto label = xy::UI::create<xy::UI::Label>(font); label->setAlignment(xy::UI::Alignment::Centre); label->setPosition(centreX, 300.f); label->setString("PAUSED"); m_uiContainer.addControl(label); auto button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png")); button->setString("Continue"); button->setAlignment(xy::UI::Alignment::Centre); button->setPosition(centreX, 425.f); button->addCallback([this]() { close(); }); m_uiContainer.addControl(button); button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png")); button->setString("Options"); button->setAlignment(xy::UI::Alignment::Centre); button->setPosition(centreX, 525.f); button->addCallback([this]() { close(); requestStackPush(States::ID::PausedOptions); }); m_uiContainer.addControl(button); button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png")); button->setString("Quit to Main"); button->setAlignment(xy::UI::Alignment::Centre); button->setPosition(centreX, 625.f); button->addCallback([this]() { close(); requestStackClear(); requestStackPush(States::ID::MenuBackground); }); m_uiContainer.addControl(button); button = xy::UI::create<xy::UI::Button>(font, m_textureResource.get("assets/images/ui/start_button.png")); button->setString("Exit to Desktop"); button->setAlignment(xy::UI::Alignment::Centre); button->setPosition(centreX, 725.f); button->addCallback([this]() { xy::App::quit(); }); m_uiContainer.addControl(button); }
//// Global settings //// void setupGlobal() { auto settings_node = *m_dev->emplace(m_dev->children().cend(), "settings"); auto vol_node = *settings_node->emplace(settings_node->children().cend(), "volume"); auto files_node = *settings_node->emplace(settings_node->children().cend(), "files"); auto vol_addr = vol_node->createAddress(OSSIA::Value::Type::FLOAT); auto files_addr = files_node->createAddress(OSSIA::Value::Type::TUPLE); vol_addr->addCallback([] (const OSSIA::Value* val) { }); files_addr->addCallback([] (const OSSIA::Value* val) { }); }
void BaseStage::begin() { changeBase(); textFunds = form->findControlTyped<Label>("TEXT_FUNDS"); textFunds->setText(state->getPlayerBalance()); int b = 0; for (auto &pair : state->player_bases) { auto &viewBase = pair.second; auto viewName = format("BUTTON_BASE_%d", ++b); auto view = form->findControlTyped<GraphicButton>(viewName); if (!view) { // This screen doesn't have miniviews return; } if (state->current_base == viewBase) { currentView = view; } view->setData(viewBase); auto viewImage = drawMiniBase(viewBase, viewHighlight, viewFacility); view->setImage(viewImage); view->setDepressedImage(viewImage); wp<GraphicButton> weakView(view); view->addCallback(FormEventType::ButtonClick, [this, weakView](FormsEvent *e) { auto base = e->forms().RaisedBy->getData<Base>(); if (this->state->current_base != base) { this->changeBase(base); this->currentView = weakView.lock(); } }); view->addCallback(FormEventType::MouseEnter, [this](FormsEvent *e) { auto base = e->forms().RaisedBy->getData<Base>(); this->textViewBase->setVisible(true); this->textViewBase->setText(base->name); }); view->addCallback(FormEventType::MouseLeave, [this](FormsEvent *) { this->textViewBase->setText(""); this->textViewBase->setVisible(false); }); miniViews.push_back(view); } textViewBase = form->findControlTyped<Label>("TEXT_BUTTON_BASE"); this->textViewBase->setVisible(false); }
void BoundaryListener::Violation(b2Body *body) { BoundaryCallback* c = new BoundaryCallback; c->bodyID = body->GetUserData()->ID; addCallback(c,rdPtr); }
void ContactListener::ContactPointAdd(b2Contact* contact, const b2ContactPoint* point) { shapeUserData* u1 = point->shape1->GetUserData(); shapeUserData* u2 = point->shape2->GetUserData(); char cr = rdPtr->collReg[u1->collType][u2->collType] | rdPtr->collReg[u2->collType][u1->collType]; if(cr == 1) { CollideCallback* c = new CollideCallback(21); c->data.body1 = u1->body; c->data.body2 = u2->body; c->data.collPoint = point->position; c->data.collPoint *= rdPtr->scale; c->data.shape1 = u1->ID; c->data.shape2 = u2->ID; c->data.type1 = u1->collType; c->data.type2 = u2->collType; c->data.friction = point->friction; c->data.restitution = point->restitution; c->data.separation = point->separation; c->data.velocity = point->velocity; addCallback(c,rdPtr); } }
void ContactListener::ContactPointResponse(b2Contact* contact, const b2ContactResult* point) { shapeUserData* u1 = point->shape1->GetUserData(); shapeUserData* u2 = point->shape2->GetUserData(); char cr = rdPtr->collReg[u1->collType][u2->collType] | rdPtr->collReg[u2->collType][u1->collType]; if(cr == 1) { CollideCallback* c = new CollideCallback(0); c->data.body1 = u1->body; c->data.body2 = u2->body; c->data.collPoint = point->position; c->data.collPoint *= rdPtr->scale; c->data.shape1 = u1->ID; c->data.shape2 = u2->ID; c->data.type1 = u1->collType; c->data.type2 = u2->collType; c->data.impulse.Set(point->tangentImpulse,point->normalImpulse); c->data.angle = atan2(point->normal.y,point->normal.x) * RAD_TO_DEG; addCallback(c,rdPtr); } }
void Widget::widgetUnfocused() { if (m_CallbackFunctions[Unfocused].empty() == false) { m_Callback.trigger = Unfocused; addCallback(); } }
void Widget::mouseEnteredWidget() { if (m_CallbackFunctions[MouseEntered].empty() == false) { m_Callback.trigger = MouseEntered; addCallback(); } }
bool addCallback(wxString const &Identifier, std::function<ResultT (ArgTs...)> Callback) { typedef seec::callbackfs::CallbackImpl<ResultT, ArgTs...> ImplTy; return addCallback(Identifier, seec::makeUnique<ImplTy>(std::move(Callback))); }
void Widget::mouseLeftWidget() { if (m_CallbackFunctions[MouseLeft].empty() == false) { m_Callback.trigger = MouseLeft; addCallback(); } }
void ArmyEngine::addCollisionCallback(collisionTagTuple tagTuple, functionCollisionTemplate func) { auto collisionManager = CollisionManager::getInstance(); if (!collisionManager->hasCallback(tagTuple)) { collisionManager->addCallback(tagTuple, func); } else { std::cout << "Warning: Collision callback for given tuple already exists" << std::endl; } }
/** * Add a callback to obtain and pass processor session to a generated processor * */ std::shared_ptr<core::Processor> ExecutionPlan::addSimpleCallback(void *obj, std::function<void(core::ProcessSession*)> fp) { if (finalized) { return nullptr; } auto simple_func_wrapper = [fp](core::ProcessSession *session, core::ProcessContext *context)->void { fp(session); }; return addCallback(obj, simple_func_wrapper); }
void ArmyEngine::addInputCallback(std::string name, functionEventTemplate func) { auto callbackManager = CallbackManager::getInstance(); if (!callbackManager->hasCallback(name)) { callbackManager->addCallback(name, (functionEventTemplate) func); } else { std::cout << "Warning: Attempting to add callback '" << name << "' which already exists, ignoring."; std::cout << std::endl; } }
void JNIHelper :: registerTerminationCallback( CallbackFunc callback, void * closure) { if (callback) { addCallback(&mTerminationCallbacks, callback, closure); } }
//// Listener settings //// void setupListener() { auto listener_node = *m_dev->emplace(m_dev->children().cend(), "listener"); auto listener_pos_node = *listener_node->emplace(listener_node->children().cend(), "pos"); add_position(listener_pos_node, make_parameter( [&] () { return m_scene.listener().Position(); }, [&] (const auto& elt) { m_scene.listener().Position(elt); })); auto listener_orient_node = *listener_node->emplace(listener_node->children().cend(), "orientation"); auto listener_orient_addr = listener_orient_node->createAddress(OSSIA::Value::Type::TUPLE); // [ at_x at_y at_z up_x at_y at_z ] auto tupl = new OSSIA::Tuple; const auto& orient = m_scene.listener().Orientation(); tupl->value.push_back(new OSSIA::Float(orient.At()[0])); tupl->value.push_back(new OSSIA::Float(orient.At()[1])); tupl->value.push_back(new OSSIA::Float(orient.At()[2])); tupl->value.push_back(new OSSIA::Float(orient.Up()[0])); tupl->value.push_back(new OSSIA::Float(orient.Up()[1])); tupl->value.push_back(new OSSIA::Float(orient.Up()[2])); listener_orient_addr->pushValue(tupl); listener_orient_addr->addCallback([&] (const OSSIA::Value* val) { auto tpl = dynamic_cast<const OSSIA::Tuple*>(val); if(tpl->value.size() != 6) return; auto at_x = dynamic_cast<const OSSIA::Float*>(tpl->value[0]); auto at_y = dynamic_cast<const OSSIA::Float*>(tpl->value[1]); auto at_z = dynamic_cast<const OSSIA::Float*>(tpl->value[2]); auto up_x = dynamic_cast<const OSSIA::Float*>(tpl->value[3]); auto up_y = dynamic_cast<const OSSIA::Float*>(tpl->value[4]); auto up_z = dynamic_cast<const OSSIA::Float*>(tpl->value[5]); if(!at_x || !at_y || !at_z || !up_x || !up_y || !up_z) return; m_scene.listener().Orientation(at_x->value, at_y->value, at_z->value, up_x->value, up_y->value, up_z->value); }); auto listener_orient_at_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "at"); add_position(listener_orient_at_node, make_parameter( [&] () { return m_scene.listener().OrientationAt(); }, [&] (const auto& elt) { m_scene.listener().Orientation(elt, m_scene.listener().OrientationUp()); } )); auto listener_orient_up_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "up"); add_position(listener_orient_up_node, make_parameter( [&] () { return m_scene.listener().OrientationUp(); }, [&] (const auto& elt) { m_scene.listener().Orientation(m_scene.listener().OrientationAt(), elt); } )); }
auto add_float_child(std::shared_ptr<OSSIA::Node>& node, const std::string& name, Fun&& callback) { auto new_node = *node->emplace(node->children().cend(), name); auto addr = new_node->createAddress(OSSIA::Value::Type::FLOAT); addr->addCallback(callback); addr->setDomain(OSSIA::Domain::create(new OSSIA::Float(-100.), new OSSIA::Float(100.))); return new_node; }
ActivityWebView::ActivityWebView(Evas *_e, Evas_Object *_parent): ActivityView(_e, _parent, "calaos/page/web") { setPartText("header.label", _("Web browser")); keyboard = new KeyboardView(evas, parent); Swallow(keyboard, "keyboard"); if (elm_need_web()) { web = elm_web_add(parent); Swallow(web, "webkit"); evas_object_show(web); elm_object_focus_set(web, true); elm_web_useragent_set(web, USER_AGENT); elm_web_inwin_mode_set(web, true); evas_object_smart_callback_add(web, "load,started", _web_load_started, this); evas_object_smart_callback_add(web, "load,progress", _web_load_progress, this); evas_object_smart_callback_add(web, "load,finished", _web_load_finished, this); evas_object_smart_callback_add(web, "load,error", _web_load_finished, this); evas_object_smart_callback_add(web, "title,changed", _web_title_changed, this); evas_object_smart_callback_add(web, "inputmethod,changed", _web_inputmethod_changed, this); #ifdef HAVE_EWEBKIT Evas_Object *eview = elm_web_webkit_view_get(web); ewk_view_setting_enable_auto_resize_window_set(eview, false); #endif goToCallback(DEFAULT_BROWSER_URL); } Evas_Object *btn = edje_object_part_external_object_get(edje, "button.back"); elm_object_text_set(btn, _("Back to menu")); btn = edje_object_part_external_object_get(edje, "button.reload"); elm_object_text_set(btn, _("Reload")); btn = edje_object_part_external_object_get(edje, "button.stop"); elm_object_text_set(btn, _("Stop")); btn = edje_object_part_external_object_get(edje, "button.home"); elm_object_text_set(btn, _("Home page")); btn = edje_object_part_external_object_get(edje, "button.go"); elm_object_text_set(btn, _("Go to...")); btn = edje_object_part_external_object_get(edje, "button.bookmark"); elm_object_text_set(btn, _("Add to favorites")); addCallback("button.*", "pressed", sigc::mem_fun(*this, &ActivityWebView::buttonCallback)); }
void Widget::widgetFocused() { if (m_CallbackFunctions[Focused].empty() == false) { m_Callback.trigger = Focused; addCallback(); } // Make sure the parent is also focused if (m_Parent) m_Parent->focus(); }
NewFileTransferNotification::NewFileTransferNotification(QString &type, FileTransfer *ft, DccSocket *socket, const UserListElements &userListElements, FileTransfer::StartType startType) : Notification(type, "SendFile", userListElements), ft(ft), socket(socket), fileName("") { if (startType == FileTransfer::StartRestore) { addCallback(tr("Continue"), SLOT(callbackAccept())); addCallback(tr("Save file under new name"), SLOT(callbackAcceptAsNew())); addCallback(tr("Ignore transfer"), SLOT(callbackDiscard())); Continue = true; } else { addCallback(tr("Accept"), SLOT(callbackAccept())); addCallback(tr("Reject"), SLOT(callbackReject())); Continue = false; } setDefaultCallback(30 * 60 * 1000, SLOT(callbackDiscard())); }
void ClickableWidget::leftMousePressed(float x, float y) { // Set the mouse down flag m_MouseDown = true; // Add the callback (if the user requested it) if (m_CallbackFunctions[LeftMousePressed].empty() == false) { m_Callback.trigger = LeftMousePressed; m_Callback.mouse.x = static_cast<int>(x - getPosition().x); m_Callback.mouse.y = static_cast<int>(y - getPosition().y); addCallback(); } }
std::shared_ptr<AbstractEntity> createCursorEntity(std::string name) { static int ID = 0; auto entity = std::shared_ptr<AbstractEntity> (new MainEntity(name, ID++)); //assign components //sprite auto spriteComponent = std::shared_ptr<AbstractComponent> (new SpriteComponent("CursorSprite")); spriteComponent->setAttribute_float("Offset_X", -100.); spriteComponent->setAttribute_float("Offset_Y", -100.); entity->addComponent(spriteComponent); //position auto positionComponent = std::shared_ptr<AbstractComponent> (new PositionComponent("CursorPosition")); entity->addComponent(positionComponent); //input, mouse move auto inputComponent = std::shared_ptr<AbstractComponent> (new InputComponent("CursorInput")); //assign input to entity entity->addComponent(inputComponent); //define attributes of the input inputComponent->setAttribute_string(ATTRIBUTE_INPUT_TYPE, INPUT_MOUSE_MOVE); inputComponent->setAttribute_string(ATTRIBUTE_CALLBACK, "CursorMoveCallBack"); //Create our callback function and store it in the manager auto callbackManager = CallbackManager::getInstance(); if (!callbackManager->hasCallback("CursorMoveCallback")) { callbackManager->addCallback("CursorMoveCallBack", (functionEventTemplate) [] (int ID, int eventIndex) { auto entity = EntityManager::getInstance()->getEntityById(ID); //grab the given event from the current eventList using the event index sf::Event theEvent = *EventManager::getInstance()->getEvents()[eventIndex]; //we know that the event is a INPUT_MOUSE_MOVE event, //so we treat it as that type of an sfml::Event object with //its given set of attributes //http://www.sfml-dev.org/documentation/2.0/Event_8hpp_source.php //http://www.sfml-dev.org/documentation/2.0/structsf_1_1Event_1_1MouseMoveEvent.php //Grab the mouse x and y positions float xPosition = static_cast<float> (theEvent.mouseMove.x); float yPosition = static_cast<float> (theEvent.mouseMove.y); std::cout << "(" << xPosition << ", " << yPosition << ")" << std::endl; //apply the position of the mouse to the position of the entity auto positionComponent = entity->getComponentByName("CursorPosition"); positionComponent->setAttribute_float("Position_X", xPosition); positionComponent->setAttribute_float("Position_Y", yPosition); return 0; }); } //(!callbackManager->hasCallback("CursorMoveCallback")) { return entity; }
void Checkbox::uncheck() { if (m_Checked) { m_Checked = false; // Add the callback (if the user requested it) if (m_CallbackFunctions[Unchecked].empty() == false) { m_Callback.trigger = Unchecked; m_Callback.checked = false; addCallback(); } } }
void Checkbox::keyPressed(sf::Keyboard::Key key) { // Check if the space key or the return key was pressed if (key == sf::Keyboard::Space) { // Check or uncheck the checkbox if (m_Checked) uncheck(); else check(); // Add the callback (if the user requested it) if (m_CallbackFunctions[SpaceKeyPressed].empty() == false) { m_Callback.trigger = SpaceKeyPressed; m_Callback.checked = m_Checked; addCallback(); } } else if (key == sf::Keyboard::Return) { // Check or uncheck the checkbox if (m_Checked) uncheck(); else check(); // Add the callback (if the user requested it) if (m_CallbackFunctions[ReturnKeyPressed].empty() == false) { m_Callback.trigger = ReturnKeyPressed; m_Callback.checked = m_Checked; addCallback(); } } }
ActivityAudioListView::ActivityAudioListView(Evas *_e, Evas_Object *_parent): ActivityView(_e, _parent, "calaos/page/media/audio_list"), player_current(NULL), in_edit_mode(false) { players.reserve(3); for (int i = 0;i < 3;i++) { ActivityPlayerObject ac(evas, parent); players.push_back(ac); players[players.size() - 1].createEdjeObject(theme, evas); Swallow(players[players.size() - 1].object, "player.swallow." + Utils::to_string(i + 1)); players[players.size() - 1].player_selected.connect(sigc::mem_fun(*this, &ActivityAudioListView::playerSelected)); } Evas_Object *btn = edje_object_part_external_object_get(edje, "button.browser.back"); elm_object_text_set(btn, _("My Music")); btn = edje_object_part_external_object_get(edje, "button.browser.root"); elm_object_text_set(btn, _("Back")); addCallback("button.browser.back", "pressed", sigc::mem_fun(*this, &ActivityAudioListView::browserButtonBack)); addCallback("button.browser.root", "pressed", sigc::mem_fun(*this, &ActivityAudioListView::browserButtonRoot)); gplaylist = elm_genlist_add(parent); Swallow(gplaylist, "playlist.swallow"); elm_object_style_set(gplaylist, "calaos"); elm_genlist_homogeneous_set(gplaylist, true); evas_object_show(gplaylist); pager_browser = elm_naviframe_add(parent); evas_object_show(pager_browser); Swallow(pager_browser, "browser.swallow"); addCallback("audio", "*", sigc::mem_fun(*this, &ActivityAudioListView::EdjeCallback)); }
void DestructionListener::SayGoodbye(b2Joint *joint) { JointDieCallback* c = new JointDieCallback; c->jointID = joint->GetUserData()->ID; addCallback(c,rdPtr); b2Body* b = getBody(joint->GetUserData()->body1,rdPtr); b2Body* b2 = getBody(joint->GetUserData()->body2,rdPtr); if(b) b->GetUserData()->numJoints--; if(b2) b2->GetUserData()->numJoints--; rdPtr->joints[joint->GetUserData()->ID] = NULL; }
ConnectionErrorNotification::ConnectionErrorNotification(Account account, const QString &errorServer, const QString &errorMessage) : Notification(account, Chat::null, "ConnectionError", KaduIcon("dialog-error")), ErrorServer(errorServer), ErrorMessage(errorMessage) { setTitle(tr("Connection error")); setText(Qt::escape(tr("Connection error on account: %1 (%2)").arg(account.id()).arg(account.accountIdentity().name()))); if (!ErrorMessage.isEmpty()) { if (ErrorServer.isEmpty()) setDetails(Qt::escape(ErrorMessage)); else setDetails(Qt::escape(QString("%1 (%2)").arg(ErrorMessage).arg(ErrorServer))); } addCallback("connection-ignore-errors"); }
ActivityScenariosView::ActivityScenariosView(Evas *_e, Evas_Object *_parent): ActivityView(_e, _parent, "calaos/page/scenarios"), view_mode(VIEW_MODE_ALL) { setPartText("header.label", _("Scenario management")); addCallback("button.*", "pressed", sigc::mem_fun(*this, &ActivityScenariosView::buttonPressed)); schedule_list = elm_genlist_add(parent); Swallow(schedule_list, "scenario_schedule.list"); elm_object_style_set(schedule_list, "calaos"); elm_genlist_homogeneous_set(schedule_list, true); evas_object_show(schedule_list); scenario_list = elm_genlist_add(parent); Swallow(scenario_list, "scenario.list"); elm_object_style_set(scenario_list, "calaos"); elm_genlist_homogeneous_set(scenario_list, true); evas_object_show(scenario_list); Evas_Object *btn = edje_object_part_external_object_get(edje, "button.calendar.today"); elm_object_text_set(btn, _("Today")); btn = edje_object_part_external_object_get(edje, "button.create"); elm_object_text_set(btn, _("Create a new scenario")); btn = edje_object_part_external_object_get(edje, "button.list.all"); elm_object_text_set(btn, _("All")); btn = edje_object_part_external_object_get(edje, "button.list.light"); elm_object_text_set(btn, _("Lights")); btn = edje_object_part_external_object_get(edje, "button.list.shutters"); elm_object_text_set(btn, _("Shutters")); btn = edje_object_part_external_object_get(edje, "button.list.schedule"); elm_object_text_set(btn, _("Scheduled")); //default to today time_t t = time(0); currDate = *localtime(&t); if (CalaosModel::Instance().getScenario()) scenarioChangeCon = CalaosModel::Instance().getScenario()->scenario_change.connect([=](Scenario *) { reloadCalendar(); }); }
void AnimatedPicture::update() { // Only continue when you are playing if (m_Playing == false) return; // Check if the next frame should be displayed while (m_AnimationTimeElapsed > m_FrameDuration[m_CurrentFrame]) { // Make sure the frame duration isn't 0 if (m_FrameDuration[m_CurrentFrame].asMicroseconds() > 0) { // Decrease the elapsed time m_AnimationTimeElapsed -= m_FrameDuration[m_CurrentFrame]; // Make the next frame visible if (static_cast<unsigned int>(m_CurrentFrame + 1) < m_Textures.size()) ++m_CurrentFrame; else { // If looping is enabled then stat over if (m_Looping == true) m_CurrentFrame = 0; else { // Looping is disabled so stop the animation m_Playing = false; m_AnimationTimeElapsed = sf::Time(); } // The animation has finished, send a callback if needed if (m_CallbackFunctions[AnimationFinished].empty() == false) { m_Callback.trigger = AnimationFinished; addCallback(); } } } else // The frame has to remain visible m_AnimationTimeElapsed = sf::Time(); } }