void Container::_insertBefore(const Ref & child,const Ref & before){ if (child.isNull() || child==before) return; if(child->getParent()!=this){ ++contentsCount; if(child->hasParent()){ child->getParent()->_removeChild(child); } child->_setParent(this); childRectChanged(child.get()); child->invalidateAbsPosition(); } if(before==getFirstChild()) firstChild=child; // child->insertBefore(before); child->_updateNeighbors(before.isNull() ? nullptr : before->getPrev(),before); if(firstChild==nullptr) firstChild=child; if(lastChild==nullptr) lastChild=child; if(getFirstChild()->getPrev()!=nullptr){ firstChild=getFirstChild()->getPrev(); } if(getLastChild()->getNext()!=nullptr){ lastChild=getLastChild()->getNext(); } childRectChanged(child.get()); invalidateLayout(); }
void PD_UI_Tasklist::addTask(std::string _scenario, int _id, std::string _text){ if(numTasks == 0 && icon->isVisible()){ journalLayout->setVisible(true); } if(tasks.find(_scenario) == tasks.end()){ std::map<int, PD_UI_Task *> m; tasks.insert(std::make_pair(_scenario, m)); } if(tasks.at(_scenario).find(_id) == tasks.at(_scenario).end()){ PD_UI_Task * task = new PD_UI_Task(world, font, textShader); task->setRationalWidth(1.f, taskLayout); task->setHeight(font->getLineHeight() * 3.f); taskLayout->addChild(task); task->text->setText(_text); task->addTimeout->eventManager->addEventListener("start", [this](sweet::Event * _event){ std::stringstream s; s << "journalLayout: " << journalLayout << " taskLayout: " << taskLayout->height.getSize(); Log::info(s.str()); }); tasks.at(_scenario).insert(std::make_pair(_id, task)); task->addTimeout->restart(); incrementCount(1); invalidateLayout(); }else{ Log::warn("Task id for this scenario has already been added!"); } }
void Container::_insertAfter(const Ref & child,const Ref & after){ if (child.isNull() || child==after) return; if(child->getParent()!=this){ ++contentsCount; if(child->hasParent()) child->getParent()->_removeChild(child); child->_setParent(this); child->invalidateAbsPosition(); } if(after==getLastChild()) lastChild=child; if(firstChild==child) firstChild=child->getNext(); // child->insertAfter(after); child->_updateNeighbors(after,after.isNull() ? nullptr : after->getNext()); if(firstChild==nullptr) firstChild=child; if(lastChild==nullptr) lastChild=child; if(getFirstChild()->getPrev()!=nullptr){ firstChild=getFirstChild()->getPrev(); } if(getLastChild()->getNext()!=nullptr){ lastChild=getLastChild()->getNext(); } childRectChanged(child.get()); invalidateLayout(); }
void ContactListModel::setAccountsEnabled(bool enabled) { if (d->accountsEnabled != enabled) { d->accountsEnabled = enabled; invalidateLayout(); } }
void PD_UI_Tasklist::updateTask(std::string _scenario, int _id, std::string _text, bool _complete){ auto it = tasks.find(_scenario); // if the scenario has no tasks, this one must not exist yet, so make it and return early if(it == tasks.end()){ if(!_complete){ // if the task would have been removed, we don't need to add it addTask(_scenario, _id, _text); } return; } auto it2 = it->second.find(_id); // if the scenario has no task with the given id, make it and return early if(it2 == it->second.end()){ if(!_complete){ // if the task would have been removed, we don't need to add it addTask(_scenario, _id, _text); } return; } // update the task text it2->second->text->setText(_text); invalidateLayout(); it2->second->addTimeout->restart(); // if we're supposed to remove the task, do that last so that the text is up-to-date if(_complete){ removeTask(_scenario, _id); } }
void ContactListModel::setGroupsEnabled(bool enabled) { if (d->groupsEnabled != enabled) { d->groupsEnabled = enabled; invalidateLayout(); } }
void ContactListModel::destroyingContactList() { d->commit(); // Save groups state d->collapsed.clear(); QList<ContactListItem*> list = static_cast<ContactListItem*>(root())->allChildren(); for (const auto *item: list) { if (!item->expanded()) d->collapsed << item->internalName(); if (item->isHidden()) d->hidden << item->internalName(); } PsiOptions::instance()->setOption(COLLAPSED_OPTIONS, d->collapsed); PsiOptions::instance()->setOption(HIDDEN_OPTIONS, d->hidden); d->clear(); d->contactList = nullptr; invalidateLayout(); }
bool PD_UI_Dialogue::sayNext(){ invalidateLayout(); if(currentSpeaker != nullptr) { currentSpeaker->pr->talking = false; } if (ConversationIterator::sayNext()){ uiBubble->clear(); if(speechTimeout->active) { speechTimeout->stop(); } currentSpeaker = PD_Listing::listings[currentConversation->scenario]->characters[currentConversation->getCurrentDialogue()->speaker]; if(Dialogue * dialogue = currentConversation->getCurrentDialogue()){ text->setText(dialogue->getCurrentText()); }else{ text->setText(""); } clearSpeechBuffer(); for(std::wstring s : sweet::StringUtils::split(text->getText(), L' ')) { speechBuffer.push(s); } if (waitingForInput){ currentSpeaker->pr->talking = false; clearSpeechBuffer(); for(unsigned long int i = 0; i < currentConversation->options.size(); ++i){ uiBubble->addOption(currentConversation->options.at(i)->text, [this, i](sweet::Event * _event){ select(i); }); } }else{ currentSpeaker->pr->talking = true; uiBubble->addOption("...", [this](sweet::Event * _event){ sayNext(); }); } if(!speechTimeout->active) { speechTimeout->start(); } hadNextDialogue = true; return hadNextDialogue; } uiBubble->clear(); currentSpeaker = nullptr; setVisible(false); speechTimeout->stop(); hadNextDialogue = false; return hadNextDialogue; }
void PD_UI_Tasklist::removeTask(std::string _scenario, int _id){ if(tasks.find(_scenario) != tasks.end()){ auto sTasks = tasks.at(_scenario); if(sTasks.find(_id) != sTasks.end()){ PD_UI_Task * task = tasks.at(_scenario).at(_id); task->setTextShader(crossedTextShader); task->text->setFont(crossedFont, true); incrementCount(-1); invalidateLayout(); task->checkTimeout->restart(); } } }
void TwLayoutManager::setHostWidget( TwWidget* w) { if (m_hostWidget == w) { return; } if (m_hostWidget) { m_hostWidget->setLayout(nullptr); } m_hostWidget = w; m_dirty = false; invalidateLayout(); }
void Container::_removeChild(const Ref & child) { if (child.isNull() || (child->getParent()!=this) ) { if(!child.isNull()){ std::cout << "Container::_removeChild: Component is not a child. this:" <<this->getTypeName()<<" component:"<<child->getTypeName()<<"\n"; } return; } if(child==getFirstChild()){ firstChild = child->getNext(); } if(child==getLastChild()){ lastChild = child->getPrev(); } child->_updateNeighbors(nullptr,nullptr); child->_setParent(nullptr); --contentsCount; childRectChanged(child.get()); invalidateLayout(); }
void Container::childRectChanged(Component * /*c*/){ // if(getFlag(LAYOUT_DEPENDS_ON_CHILDREN)) !!!!!!!!!!!!!!!!!! invalidateLayout(); // if is sensible to child changes && internal layout is valid // invalidate internal layout, inform parent }
PD_UI_Task::PD_UI_Task(BulletWorld * _world, Font * _font, ComponentShaderText * _textShader): NodeUI(_world) { setRenderMode(kTEXTURE); background->setVisible(false); setAlpha(0.f); NodeUI * container = new NodeUI(_world); addChild(container); container->setRationalWidth(1.f, this); container->setRationalHeight(1.f, this); container->background->setVisible(false); VerticalLinearLayout * checkContainer = checkBox = new VerticalLinearLayout(world); container->addChild(checkContainer); checkContainer->horizontalAlignment = kCENTER; checkContainer->verticalAlignment = kMIDDLE; checkContainer->setWidth(PD_ResourceManager::scenario->getFont("FONT")->font->getLineHeight()); checkContainer->setRationalHeight(1.f, container); checkContainer->background->setVisible(false); checkBox = new VerticalLinearLayout(world); checkBox->horizontalAlignment = kCENTER; checkBox->verticalAlignment = kMIDDLE; checkContainer->addChild(checkBox); checkBox->setRationalWidth(0.75f, checkContainer); checkBox->setSquareHeight(1.f); checkBox->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("JOURNAL-CHECK-BOX")->texture); checkBox->background->mesh->setScaleMode(GL_NEAREST); checkBox->setBackgroundColour(1.f, 1.f, 1.f, 1.f); checkBox->background->setVisible(true); checkMark = new NodeUI(world); checkBox->addChild(checkMark); checkMark->setRationalWidth(0.f, checkBox); checkMark->setSquareHeight(1.f); checkMark->background->mesh->pushTexture2D(PD_ResourceManager::scenario->getTexture("JOURNAL-CHECK-MARK")->texture); checkMark->background->mesh->setScaleMode(GL_NEAREST); checkMark->setVisible(false); text = new TextArea(world, _font, _textShader); text->setWrapMode(kWORD); text->verticalAlignment = kMIDDLE; container->addChild(text); text->setRationalWidth(1.f, container); text->setRationalHeight(1.f, container); text->marginLeft.setRationalSize(1.f, &checkContainer->width); text->background->setVisible(false); addTimeout = new Timeout(1.f, [this](sweet::Event * _event){ setAlpha(1.f); }); addTimeout->eventManager->addEventListener("start", [this](sweet::Event * _event){ setAlpha(0.f); }); addTimeout->eventManager->addEventListener("progress", [this](sweet::Event * _event){ float p = _event->getFloatData("progress"); setAlpha(p); }); childTransform->addChild(addTimeout, false); checkTimeout = new Timeout(0.5f, [this](sweet::Event * _event){ checkMark->setRationalWidth(1.f, checkMark->nodeUIParent); invalidateLayout(); invalidateRenderFrame(); }); checkTimeout->eventManager->addEventListener("start", [this](sweet::Event * _event){ checkMark->setVisible(true); invalidateLayout(); invalidateRenderFrame(); }); checkTimeout->eventManager->addEventListener("progress", [this](sweet::Event * _event){ float p = _event->getFloatData("progress"); p = Easing::easeOutElastic(p, 0.f, 1.f, checkTimeout->targetSeconds, -1, 4.f); checkMark->setRationalWidth(p, checkMark->nodeUIParent); invalidateLayout(); invalidateRenderFrame(); }); childTransform->addChild(checkTimeout, false); }
QSizeF KWidget::calcIdealSize() { setFixSize(-1,-1); invalidateLayout(); return minimumSize(); }
void PD_UI_DissBattle::enable(){ setVisible(true); enabled = true; invalidateLayout(); }
void PD_UI_DissBattle::disable(){ setVisible(false); enabled = false; invalidateLayout(); }