/** @file * @author Edouard DUPIN * @copyright 2019, Edouard DUPIN, all right reserved * @license MPL v2.0 (see license file) */ #include #include #include #include #include #include #include #include #include appl::Windows::Windows() : propertyCount(this, "count", 5, "Number of time we restart a record"), m_composer(null) { addObjectType("appl::Windows"); propertyTitle.setDirectCheck("River IO viewer"); } void appl::Windows::init() { ewol::widget::Windows::init(); APPL_ERROR("Load Application"); etk::String composition = etk::String(""); composition += "\n"; composition += " \n"; composition += " \n"; composition += " \n"; composition += " \n"; composition += " \n"; composition += " \n"; composition += "\n"; m_composer = ewol::widget::Composer::create(); if (m_composer == null) { APPL_CRITICAL(" An error occured ... in the windows creatrion ..."); return; } APPL_ERROR("Composer LOAD [BEGIN]"); m_composer->loadFromString(composition); setSubWidget(m_composer); APPL_ERROR("Composer LOAD [ END ]"); subBind(ewol::widget::Button, "bt-record", signalPressed, sharedFromThis(), &appl::Windows::onCallbackRecord); subBind(ewol::widget::Button, "bt-reset", signalPressed, sharedFromThis(), &appl::Windows::onCallbackGenerate); subBind(appl::widget::DataViewer, "displayer", signalFinished, sharedFromThis(), &appl::Windows::onCallbackFinished); next(); } void appl::Windows::onCallbackFinished() { APPL_INFO("Recording is finished"); ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); if (tmpDisp != null) { tmpDisp->store("Edouard DUPIN", m_list[m_listPos], "FR_fr"); m_count++; if (m_count >= propertyCount.get()) { m_count = 0; next(); } else { updateCurentLabel(); tmpDisp->recordToggle(); } } } void appl::Windows::onCallbackRecord() { APPL_INFO("Start/stop Record of data"); ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); if (tmpDisp != null) { tmpDisp->recordToggle(); } } void appl::Windows::onCallbackGenerate() { ememory::SharedPtr tmpDisp = ememory::dynamicPointerCast(getSubObjectNamed("displayer")); if (tmpDisp != null) { tmpDisp->stop(); tmpDisp->reset(); tmpDisp->start(); } } void appl::Windows::next() { m_total++; m_listPos++; #if 0 if (m_listPos >= m_list.size()) { m_listPos = 0; m_list.clear(); while (m_list.size() == 0) { int32_t id = appl::wordList::getRandWord_FR(); if (appl::wordList::getWord_FR(id).size() > 5 ) { m_list.pushBack(appl::wordList::getWord_FR(id)); } } } configureNewText(m_list[m_listPos]); #else configureNewText(appl::wordList::getWord_FR_ordered(m_listPos-1)); #endif } void appl::Windows::updateCurentLabel() { auto elem = ememory::dynamicPointerCast(getSubObjectNamed("text-to-say")); if (elem == null) { return; } elem->propertyValue.set("[" + etk::toString(m_count+1) + "/" + etk::toString(propertyCount.get()) + "] "+ m_textToSay + "
" + etk::toString(m_listPos) + " total="+ etk::toString(m_total)); } void appl::Windows::configureNewText(const etk::String& _text) { m_textToSay = _text; updateCurentLabel(); onCallbackGenerate(); }