diff --git a/lutinParseSubFolders.txt b/lutinParseSubFolders.txt index bddd11da..edf76979 100644 --- a/lutinParseSubFolders.txt +++ b/lutinParseSubFolders.txt @@ -1,4 +1,5 @@ sample/HelloWord sample/CustomWidgets sample/wallpaper -tools/visual_test \ No newline at end of file +tools/visual_test +tools/platform_test \ No newline at end of file diff --git a/tools/platform_test/appl/MainWindows.cpp b/tools/platform_test/appl/MainWindows.cpp new file mode 100644 index 00000000..8ae38808 --- /dev/null +++ b/tools/platform_test/appl/MainWindows.cpp @@ -0,0 +1,588 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license BSD v3 (see license file) + */ + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +appl::MainWindows::MainWindows() : + m_gravity(ewol::gravity_buttomLeft), + m_idWidget(-1) { + APPL_DEBUG("CREATE WINDOWS ... "); + addObjectType("appl::MainWindows"); +} + +void appl::MainWindows::init() { + ewol::widget::Windows::init(); + + m_composer = ewol::widget::Composer::create(); + m_composer->loadFromFile("DATA:gui.xml"); + setSubWidget(m_composer); + externSubBind(m_composer, ewol::widget::Button, "appl-theme-toggle", signalValue, sharedFromThis(), &appl::MainWindows::onCallbackThemeChange); + externSubBind(m_composer, ewol::widget::Button, "appl-previous-widget", signalPressed, sharedFromThis(), &appl::MainWindows::onCallbackWidgetChange, -1); + externSubBind(m_composer, ewol::widget::Button, "appl-next-widget", signalPressed, sharedFromThis(), &appl::MainWindows::onCallbackWidgetChange, 1); + externSubBind(m_composer, ewol::widget::Button, "appl-next-gravity", signalPressed, sharedFromThis(), &appl::MainWindows::onCallbackGravityChange); + + m_sizerVert = ememory::dynamicPointerCast(m_composer->getSubObjectNamed("appl-upper-test-widget")); + if (m_sizerVert == nullptr) { + APPL_CRITICAL("Can not get vertical pointer"); + } + m_sizerDynamic = ememory::dynamicPointerCast(m_composer->getSubObjectNamed("appl-dynamic-config")); + if (m_sizerDynamic == nullptr) { + APPL_CRITICAL("Can not get dynamic pointer"); + } + m_subWidget = ememory::dynamicPointerCast(m_composer->getSubObjectNamed("[TEST]TO-TEST")); + if (m_subWidget == nullptr) { + APPL_CRITICAL("Can not get subWidget pointer"); + } + shortCutAdd("F12", "menu:reloade-shader"); + signalShortcut.connect(sharedFromThis(), &appl::MainWindows::onCallbackShortCut); +} + +void appl::MainWindows::onCallbackShortCut(const std::string& _value) { + APPL_WARNING("Event from ShortCut : " << _value); + if (_value == "menu:reloade-shader") { + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else { + APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'"); + } +} + +void appl::MainWindows::onCallbackThemeChange(const bool& _value) { + if (_value == true) { + etk::theme::setName("GUI", "shape/round/"); + } else { + etk::theme::setName("GUI", "shape/square/"); + } + // Reload shaders and graphic system ... + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); +} + +void appl::MainWindows::onCallbackGravityChange() { + switch(m_gravity) { + case ewol::gravity_center: + m_gravity = ewol::gravity_topLeft; + break; + case ewol::gravity_topLeft: + m_gravity = ewol::gravity_top; + break; + case ewol::gravity_top: + m_gravity = ewol::gravity_topRight; + break; + case ewol::gravity_topRight: + m_gravity = ewol::gravity_right; + break; + case ewol::gravity_right: + m_gravity = ewol::gravity_buttomRight; + break; + case ewol::gravity_buttomRight: + m_gravity = ewol::gravity_buttom; + break; + case ewol::gravity_buttom: + m_gravity = ewol::gravity_buttomLeft; + break; + case ewol::gravity_buttomLeft: + m_gravity = ewol::gravity_left; + break; + case ewol::gravity_left: + m_gravity = ewol::gravity_center; + break; + } + propertySetOnWidgetNamed("appl-upper-test-widget", "gravity", ewol::gravityToString(m_gravity)); + propertySetOnWidgetNamed("appl-next-gravity-label", "value", "Next gravity
(" + ewol::gravityToString(m_gravity) + ")"); +} + +void appl::MainWindows::onCallbackWidgetChange(int32_t _increment) { + m_idWidget += _increment; + ememory::SharedPtr oldWidget = m_subWidget; + std::string tmpDescription; + std::string tmpConstruct; + switch(m_idWidget) { + case 0: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Spin"; + break; + case 1: + tmpConstruct = std::string() + + "\n"; + tmpDescription = "Test ewol::widget::Select"; + break; + case 2: + tmpConstruct = ""; + tmpDescription = "Test ewol::widget::ButtonColor"; + break; + case 3: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Label"; + break; + case 4: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Image"; + break; + case 5: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Checkbox"; + break; + case 6: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Entry"; + break; + case 7: + tmpConstruct = "\n"; + tmpDescription = "Test ewol::widget::Entry"; + break; + case 8: + tmpConstruct = std::string() + + "\n"; + tmpDescription = "Test ewol::widget::Button"; + break; + default: + tmpConstruct = "\n"; + tmpDescription = "Test Label"; + m_idWidget = -1; + break; + /* + break; + case 1: + m_subWidget = TestDistanceField::create(); + if (m_subWidget != nullptr) { + m_sizerVert->subWidgetAdd(m_subWidget); + } + tmpDescription = "Test Distance Field"; + */ + break; + } + // create the widget with a xml generator (readable for test ...): + m_subWidget = ewol::widget::composerGenerateString(tmpConstruct); + if (m_subWidget != nullptr) { + m_sizerVert->subWidgetReplace(oldWidget, m_subWidget); + } + propertySetOnWidgetNamed("appl-label-test", "value", tmpDescription); + updateProperty(); +} + +static void addSpacer(ememory::SharedPtr _sizer, etk::Color<> _color=etk::color::none) { + ememory::SharedPtr mySpacer = ewol::widget::Spacer::create(); + if (mySpacer != nullptr) { + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyFill.set(bvec2(true,false)); + if (_color == etk::color::none) { + mySpacer->propertyMinSize.set(vec2(3,3)); + mySpacer->propertyColor.set(_color); + } + _sizer->subWidgetAdd(mySpacer); + } +} + +void appl::MainWindows::updateProperty() { + // remove all elements: + m_sizerDynamic->subWidgetRemoveAll(); + if (m_subWidget == nullptr) { + return; + } + m_listConnection.clear(); + ememory::SharedPtr widget = ewol::widget::Label::create(); + widget->propertyValue.set(m_subWidget->getObjectType()); + m_sizerDynamic->subWidgetAdd(widget); + addSpacer(m_sizerDynamic, etk::color::red); + for (size_t iii=0; iiiproperties.size(); ++iii) { + eproperty::Property* param = m_subWidget->properties.getRaw(iii); + if (param == nullptr) { + APPL_WARNING("Parameter EMPTY . " << iii << " : nullptr"); + continue; + } + ememory::SharedPtr widgetSizer = ewol::widget::Sizer::create(); + if (widgetSizer != nullptr) { + widgetSizer->propertyMode.set(ewol::widget::Sizer::modeHori); + widgetSizer->propertyExpand.set(bvec2(true,false)); + widgetSizer->propertyFill.set(bvec2(true,true)); + m_sizerDynamic->subWidgetAddStart(widgetSizer); + ememory::SharedPtr widget = ewol::widget::Label::create(); + widget->propertyValue.set(param->getName() + ":"); + widgetSizer->subWidgetAdd(widget); + std::string type = param->getType(); + if (param->getPropertyType() != "eproperty::List") { + //addSpacer(widgetSizer, etk::color::purple); + // Main part TODO: ... + if (type == typeid(std::string).name()) { + ewol::widget::EntryShared widgetTmp = ewol::widget::Entry::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr..."); + return; + } + std::string value = paramValue->get(); + widgetTmp->propertyValue.set(value); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); + esignal::Connection conn = widgetTmp->signalModify.connect( + [=](const std::string& _value) { + APPL_INFO("set parameter : NAME name=" << param->getName() << " value=" << _value); + paramValue->set(_value); + return; + }); + m_listConnection.push_back(std::move(conn)); + } else if (type == typeid(gale::Dimension).name()) { + addSpacer(widgetSizer); + ewol::widget::SpinShared widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr... 2 "); + return; + } + gale::Dimension value = paramValue->get(); + widgetTmp->propertyMantis.set(3); + widgetTmp->propertyValue.set(value.get(value.getType()).x()*1000); + esignal::Connection conn = widgetTmp->signalValueDouble.connect( + [=](const double& _value) { + APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); + gale::Dimension lastValueInterpreted = paramValue->get(); + vec2 val = lastValueInterpreted.get(lastValueInterpreted.getType()); + val.setX(_value); + lastValueInterpreted.set(val, lastValueInterpreted.getType()); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + ewol::widget::LabelShared widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("x"); + widgetSizer->subWidgetAdd(widgetLabel); + + widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyValue.set(value.get(value.getType()).y()*1000); + widgetTmp->propertyMantis.set(3); + conn = widgetTmp->signalValueDouble.connect( + [=](const double& _value) { + APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); + gale::Dimension lastValueInterpreted = paramValue->get(); + vec2 val = lastValueInterpreted.get(lastValueInterpreted.getType()); + val.setY(_value); + lastValueInterpreted.set(val, lastValueInterpreted.getType()); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("y"); + widgetSizer->subWidgetAdd(widgetLabel); + + ewol::widget::SelectShared widgetSelectTmp = ewol::widget::Select::create(); + widgetSizer->subWidgetAdd(widgetSelectTmp); + widgetSelectTmp->propertyExpand.set(bvec2(true,false)); + widgetSelectTmp->propertyFill.set(bvec2(true,false)); + widgetSelectTmp->optionAdd(int32_t(gale::distance::pourcent), "Pourcent"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::pixel), "Pixel"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::meter), "Meter"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::centimeter), "Centimeter"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::millimeter), "Millimeter"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::kilometer), "Kilometer"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::inch), "Inch"); + widgetSelectTmp->optionAdd(int32_t(gale::distance::foot), "foot"); + widgetSelectTmp->propertyValue.set(int32_t(value.getType())); + conn = widgetSelectTmp->signalValue.connect( + [=](const int32_t& _value) { + APPL_INFO("set parameter: gravity name=" << param->getName() << " value=" << (enum gale::distance)_value); + gale::Dimension lastValueInterpreted = paramValue->get(); + lastValueInterpreted.set(lastValueInterpreted.get(lastValueInterpreted.getType()), (enum gale::distance)_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + + } else if (type == typeid(bvec2).name()) { + addSpacer(widgetSizer); + ewol::widget::CheckBoxShared widgetTmp = ewol::widget::CheckBox::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr... 2 "); + return; + } + bvec2 value = paramValue->get(); + widgetTmp->propertyValue.set(value.x()); + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const bool& _value) { + APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); + bvec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setX(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + ewol::widget::LabelShared widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("x"); + widgetTmp->setSubWidget(widgetLabel); + + widgetTmp = ewol::widget::CheckBox::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyValue.set(value.y()); + conn = widgetTmp->signalValue.connect( + [=](const bool& _value) { + APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); + bvec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setY(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("y"); + widgetTmp->setSubWidget(widgetLabel); + } else if (type == typeid(ivec2).name()) { + addSpacer(widgetSizer); + ewol::widget::SpinShared widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr... 2 "); + return; + } + ivec2 value = paramValue->get(); + widgetTmp->propertyValue.set(value.x()); + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const int32_t& _value) { + APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); + ivec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setX(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + ewol::widget::LabelShared widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("x"); + widgetSizer->subWidgetAdd(widgetLabel); + + widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyValue.set(value.y()); + conn = widgetTmp->signalValue.connect( + [=](const int32_t& _value) { + APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); + ivec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setY(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("y"); + widgetSizer->subWidgetAdd(widgetLabel); + } else if (type == typeid(uivec2).name()) { + addSpacer(widgetSizer); + ewol::widget::SpinShared widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr... 2 "); + return; + } + uivec2 value = paramValue->get(); + widgetTmp->propertyValue.set(value.x()); + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const uint32_t& _value) { + APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); + uivec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setX(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + ewol::widget::LabelShared widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("x"); + widgetSizer->subWidgetAdd(widgetLabel); + + widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyValue.set(value.y()); + conn = widgetTmp->signalValue.connect( + [=](const uint32_t& _value) { + APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); + uivec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setY(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("y"); + widgetSizer->subWidgetAdd(widgetLabel); + } else if (type == typeid(vec2).name()) { + addSpacer(widgetSizer); + ewol::widget::SpinShared widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + eproperty::Value* paramValue = dynamic_cast*>(param); + if (paramValue == nullptr) { + APPL_ERROR("nullptr... 2 "); + return; + } + vec2 value = paramValue->get(); + widgetTmp->propertyMantis.set(3); + widgetTmp->propertyValue.set(value.x()*1000); + esignal::Connection conn = widgetTmp->signalValueDouble.connect( + [=](const double& _value) { + APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); + vec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setX(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + ewol::widget::LabelShared widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("x"); + widgetSizer->subWidgetAdd(widgetLabel); + + widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyValue.set(value.y()*1000); + widgetTmp->propertyMantis.set(3); + conn = widgetTmp->signalValueDouble.connect( + [=](const double& _value) { + APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); + vec2 lastValueInterpreted = paramValue->get(); + lastValueInterpreted.setY(_value); + paramValue->set(lastValueInterpreted); + return; + }); + m_listConnection.push_back(std::move(conn)); + widgetLabel = ewol::widget::Label::create(); + widgetLabel->propertyValue.set("y"); + widgetSizer->subWidgetAdd(widgetLabel); + } else if (type == typeid(bool).name()) { + addSpacer(widgetSizer); + ewol::widget::CheckBoxShared widgetTmp = ewol::widget::CheckBox::create(); + widgetSizer->subWidgetAdd(widgetTmp); + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const bool& _value) { + if (m_subWidget == nullptr) { + APPL_ERROR("nullptr..."); + return; + } + APPL_INFO("set parameter : name=" << param->getName() << " value=" << _value); + m_subWidget->properties.set(param->getName(), etk::to_string(_value)); + return; + }); + m_listConnection.push_back(std::move(conn)); + } else if ( type == typeid(int64_t).name() + || type == typeid(int32_t).name() + || type == typeid(int16_t).name() + || type == typeid(int8_t).name() + || type == typeid(uint64_t).name() + || type == typeid(uint32_t).name() + || type == typeid(uint16_t).name() + || type == typeid(uint8_t).name()) { + ewol::widget::SpinShared widgetTmp = ewol::widget::Spin::create(); + widgetSizer->subWidgetAdd(widgetTmp); + std::string value = param->getString(); + widgetTmp->propertyValue.set(etk::string_to_int8_t(value)); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); + + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const int64_t& _value) { + APPL_INFO("set parameter : NAME name=" << param->getName() << " value=" << _value); + param->setString(etk::to_string(_value)); + return; + }); + m_listConnection.push_back(std::move(conn)); + if (type == typeid(int64_t).name()) { + widgetTmp->propertyMin.set(0x8000000000000000LL); + widgetTmp->propertyMax.set(0x7FFFFFFFFFFFFFFFLL); + } else if (type == typeid(int32_t).name()) { + widgetTmp->propertyMin.set(0x80000000LL); + widgetTmp->propertyMax.set(0x7FFFFFFFLL); + } else if (type == typeid(int16_t).name()) { + widgetTmp->propertyMin.set(-65338); + widgetTmp->propertyMax.set(65337); + } else if (type == typeid(int8_t).name()) { + widgetTmp->propertyMin.set(-128); + widgetTmp->propertyMax.set(127); + } else if (type == typeid(uint64_t).name()) { + widgetTmp->propertyMin.set(0); + widgetTmp->propertyMax.set(0x7FFFFFFFFFFFFFFFLL); + } else if (type == typeid(uint32_t).name()) { + widgetTmp->propertyMin.set(0); + widgetTmp->propertyMax.set(0x7FFFFFFFLL); + } else if (type == typeid(uint16_t).name()) { + widgetTmp->propertyMin.set(0); + widgetTmp->propertyMax.set(65337*2); + } else if (type == typeid(uint8_t).name()) { + widgetTmp->propertyMin.set(0); + widgetTmp->propertyMax.set(256); + } + } else if (type == typeid(float).name()) { + type = "float"; + } else if (type == typeid(double).name()) { + type = "double"; + } + } else { + // property list ... + std::vector listElement = param->getListValue(); + ewol::widget::SelectShared widgetTmp = ewol::widget::Select::create(); + widgetSizer->subWidgetAdd(widgetTmp); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); + std::string value = param->getString(); + int32_t selectId = 0; + for (int32_t iii=0; iiioptionAdd(iii, listElement[iii]); + if (listElement[iii] == value) { + selectId = iii; + } + } + widgetTmp->propertyValue.set(selectId); + esignal::Connection conn = widgetTmp->signalValue.connect( + [=](const int32_t& _value) { + APPL_INFO("set parameter: gravity name=" << param->getName() << " value=" << listElement[_value]); + param->setString(listElement[_value]); + return; + }); + m_listConnection.push_back(std::move(conn)); + } + } + ewol::widget::SpacerShared mySpacer = ewol::widget::Spacer::create(); + if (mySpacer != nullptr) { + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyFill.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(vec2(3,3)); + mySpacer->propertyColor.set(etk::color::blue); + m_sizerDynamic->subWidgetAddStart(mySpacer); + } + } +} + diff --git a/tools/platform_test/appl/MainWindows.hpp b/tools/platform_test/appl/MainWindows.hpp new file mode 100644 index 00000000..85124351 --- /dev/null +++ b/tools/platform_test/appl/MainWindows.hpp @@ -0,0 +1,42 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license BSD v3 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +namespace appl { + class MainWindows : public ewol::widget::Windows { + private: + std::vector m_listConnection; + ewol::widget::ComposerShared m_composer; + ewol::widget::SizerShared m_sizerVert; + ewol::widget::SizerShared m_sizerDynamic; + ewol::WidgetShared m_subWidget; + ewol::gravity m_gravity; + int32_t m_idWidget; + public: + // Constructeur + MainWindows(); + void init(); + public: + DECLARE_FACTORY(MainWindows); + ~MainWindows() {}; + protected: + void onCallbackGravityChange(); + void onCallbackThemeChange(const bool& _value); + void onCallbackWidgetChange(int32_t _increment); + void updateProperty(); + void onCallbackShortCut(const std::string& _value); + }; +}; + + diff --git a/tools/platform_test/appl/TestDistanceField.cpp b/tools/platform_test/appl/TestDistanceField.cpp new file mode 100644 index 00000000..6c6117b4 --- /dev/null +++ b/tools/platform_test/appl/TestDistanceField.cpp @@ -0,0 +1,82 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license BSD v3 (see license file) + */ + + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +appl::TestDistanceField::TestDistanceField(){ + addObjectType("appl::TestDistanceField"); +} + +void appl::TestDistanceField::init() { + ewol::Widget::init(); + APPL_INFO("Create appl::TestDistanceField (start)"); + propertyExpand.set(bvec2(true, true)); + propertyFill.set(bvec2(true, true)); + APPL_INFO("Create appl::TestDistanceField (end)"); +} + + +void appl::TestDistanceField::calculateSize(const vec2& _availlable) { + // set minimal size + m_size = _availlable; +} + + +void appl::TestDistanceField::calculateMinMaxSize() { + m_minSize = vec2(256,256); + markToRedraw(); +} + + +void appl::TestDistanceField::onDraw() { + m_text2.draw(); + + m_text1.draw(); +} + + + +void appl::TestDistanceField::onRegenerateDisplay() { + if (false == needRedraw()) { + return; + } + APPL_WARNING("Regenerate..."); + m_text1.clear(); + m_text1.setPos(vec3(m_size.x()*0.5-20,m_size.y()*0.5+10,0)); + m_text1.printDecorated("Text To compare ... Avenue AAVVAA ... Normal generic test"); + + m_text2.clear(); + m_text2.setPos(vec3(m_size.x()*0.5-20,m_size.y()*0.5-10,0)); + m_text2.printDecorated("Text To compare ... Avenue AAVVAA ... Test en distance field Mode"); + +} + +bool appl::TestDistanceField::onEventInput(const ewol::event::Input& _event) { + if (_event.getId() == 4) { + setZoom(getZoom() + 0.01f); + } else if (_event.getId() == 5) { + setZoom(getZoom() - 0.01f); + } + return true; +} + diff --git a/tools/platform_test/appl/TestDistanceField.hpp b/tools/platform_test/appl/TestDistanceField.hpp new file mode 100644 index 00000000..75d95cfa --- /dev/null +++ b/tools/platform_test/appl/TestDistanceField.hpp @@ -0,0 +1,34 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license BSD v3 (see license file) + */ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace appl { + class TestDistanceField : public ewol::Widget { + ewol::compositing::Text m_text1; + ewol::compositing::TextDF m_text2; + public: + // Constructeur + TestDistanceField(); + void init(); + public: + DECLARE_FACTORY(TestDistanceField); + virtual ~TestDistanceField() {}; + public: // Derived function + virtual void onDraw(); + virtual void calculateMinMaxSize(); + virtual void calculateSize(const vec2& _availlable); + virtual void onRegenerateDisplay(); + virtual bool onEventInput(const ewol::event::Input& _event); + }; +} + diff --git a/tools/platform_test/appl/debug.cpp b/tools/platform_test/appl/debug.cpp new file mode 100644 index 00000000..c5ce98cd --- /dev/null +++ b/tools/platform_test/appl/debug.cpp @@ -0,0 +1,13 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license GPL v3 (see license file) + */ + + +#include + +int32_t appl::getLogId() { + static int32_t g_val = elog::registerInstance("test_ewol"); + return g_val; +} diff --git a/tools/platform_test/appl/debug.hpp b/tools/platform_test/appl/debug.hpp new file mode 100644 index 00000000..5c66e6b0 --- /dev/null +++ b/tools/platform_test/appl/debug.hpp @@ -0,0 +1,45 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include +#include + +namespace appl { + /** + * @brief Get local id of the library + * @return Unique ID of the library + */ + int32_t getLogId(); +}; + +#define APPL_BASIC(info,data) ELOG_BASE(appl::getLogId(),info,data) + +#define APPL_PRINT(data) APPL_BASIC(-1, data) +#define APPL_CRITICAL(data) APPL_BASIC(1, data) +#define APPL_ERROR(data) APPL_BASIC(2, data) +#define APPL_WARNING(data) APPL_BASIC(3, data) +#ifdef DEBUG + #define APPL_INFO(data) APPL_BASIC(4, data) + #define APPL_DEBUG(data) APPL_BASIC(5, data) + #define APPL_VERBOSE(data) APPL_BASIC(6, data) + #define APPL_TODO(data) APPL_BASIC(4, "TODO : " << data) +#else + #define APPL_INFO(data) do { } while(false) + #define APPL_DEBUG(data) do { } while(false) + #define APPL_VERBOSE(data) do { } while(false) + #define APPL_TODO(data) do { } while(false) +#endif + +#define APPL_HIDDEN(data) do { } while(false) + +#define APPL_ASSERT(cond,data) \ + do { \ + if (!(cond)) { \ + APPL_CRITICAL(data); \ + assert(!#cond); \ + } \ + } while (0) diff --git a/tools/platform_test/appl/init.cpp b/tools/platform_test/appl/init.cpp new file mode 100644 index 00000000..f899b9b2 --- /dev/null +++ b/tools/platform_test/appl/init.cpp @@ -0,0 +1,96 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2010, Edouard DUPIN, all right reserved + * @license BSD v3 (see license file) + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +class MainApplication : public ewol::context::Application { + public: + virtual void onCreate(ewol::Context& _context) { + APPL_INFO(" == > CREATE ... (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ") (BEGIN)"); + for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) { + std::string tmpppp = _context.getCmd().get(iii); + if ( tmpppp == "-h" + || tmpppp == "--help") { + APPL_INFO(" -t c-flags-file-name" ); + APPL_INFO(" -h/--help display this help" ); + exit(0); + } + } + //etk::theme::setName("COLOR", "color/black/"); + etk::theme::setName("COLOR", "color/white/"); + + _context.setSize(vec2(800, 600)); + + _context.setTitle("ewol-tools-visual-test"); + + // select internal data for font ... + _context.getFontDefault().setUseExternal(true); + #ifdef __TARGET_OS__Android + _context.getFontDefault().set("FreeSerif", 19); + #else + _context.getFontDefault().set("FreeSerif;DejaVuSansMono",14); + #endif + + // set the application icon ... + _context.setIcon("DATA:icon.png"); + + appl::widget::SizerColor::createManagerWidget(_context.getWidgetManager()); + + APPL_INFO("==> CREATE ... (END)"); + } + + void onStart(ewol::Context& _context) { + APPL_INFO("==> START ... (BEGIN)"); + + ememory::SharedPtr basicWindows = appl::MainWindows::create(); + if (basicWindows == nullptr) { + APPL_ERROR("Can not allocate the basic windows"); + return; + } + // create the specific windows + _context.setWindows(basicWindows); + if (basicWindows == nullptr) { + APPL_ERROR("Can not allocate the basic windows"); + _context.exit(-1); + return; + } + + // create the specific windows + _context.setWindows(basicWindows); + + APPL_INFO("==> START ... (END)"); + return; + } + + void onStop(ewol::Context& _context) { + APPL_INFO("==> STOP ... (START)"); + APPL_INFO("==> STOP ... (END)"); + } +}; + + + +/** + * @brief Main of the program (This can be set in every case, but it is not used in Andoid...). + * @param std IO + * @return std IO + */ +int main(int _argc, const char *_argv[]) { + // second possibility + return ewol::run(new MainApplication(), _argc, _argv); +} + + diff --git a/tools/platform_test/appl/widget/SizerColor.cpp b/tools/platform_test/appl/widget/SizerColor.cpp new file mode 100644 index 00000000..36fe2efc --- /dev/null +++ b/tools/platform_test/appl/widget/SizerColor.cpp @@ -0,0 +1,144 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#include +#include + +appl::widget::SizerColor::SizerColor() : + propertyBorderColor(this, "border-color", etk::color::none, "Color of the border"), + propertyLeftColor(this, "color-left", etk::color::purple), + propertyRightColor(this, "color-right", etk::color::orange), + propertyTopColor(this, "color-top", etk::color::cyan), + propertyButtomColor(this, "color-buttom", etk::color::brown) { + addObjectType("appl::widget::SizerColor"); +} + +void appl::widget::SizerColor::init(enum displayMode _mode) { + ewol::widget::Sizer::init(); +} + +appl::widget::SizerColor::~SizerColor() { + +} + +void appl::widget::SizerColor::onRegenerateDisplay() { + ewol::widget::Sizer::onRegenerateDisplay(); + m_draw.clear(); + vec2 tmpBorderSize = propertyBorderSize->getPixel(); + if (tmpBorderSize == vec2(0.0f, 0.0f)) { + return; + } + if (propertyBorderColor->a() == 0) { + return; + } + m_draw.setColor(*propertyBorderColor); + m_draw.setPos(vec3(0, 0, 0) ); + m_draw.rectangleWidth(vec3(tmpBorderSize.x(), m_size.y(),0) ); + m_draw.setPos(vec3(m_size.x() - tmpBorderSize.x(), 0, 0) ); + m_draw.rectangleWidth(vec3(tmpBorderSize.x(), m_size.y(),0) ); + m_draw.setPos(vec3(tmpBorderSize.x(), 0, 0) ); + m_draw.rectangleWidth(vec3(m_size.x()-tmpBorderSize.x()*2.0f, tmpBorderSize.y(),0) ); + m_draw.setPos(vec3(tmpBorderSize.x(), m_size.y()-tmpBorderSize.y(), 0) ); + m_draw.rectangleWidth(vec3(m_size.x()-tmpBorderSize.x()*2.0f, tmpBorderSize.y(),0) ); + vec2 underSize(0,0); + vec2 underOrigin(999999999999.0,999999999999.0); + for (auto &it : m_subWidget) { + if (it == nullptr) { + continue; + } + vec2 size = it->getSize(); + if (*propertyMode == ewol::widget::Sizer::modeVert) { + underSize += vec2(0.0f, size.y()); + underSize.setX(std::max(underSize.x(), size.x())); + } else { + underSize += vec2(size.x(), 0.0f); + underSize.setY(std::max(underSize.y(), size.y())); + } + underOrigin.setX(std::min(it->getOrigin().x(), underOrigin.x())); + underOrigin.setY(std::min(it->getOrigin().y(), underOrigin.y())); + } + vec2 localWidgetSize = m_size - tmpBorderSize*2.0f; + vec2 localWidgetOrigin = m_origin + tmpBorderSize; + for (auto &it : m_subWidget) { + if (it == nullptr) { + continue; + } + vec2 origin = it->getOrigin(); + vec2 size = it->getSize(); + // now we display around the widget every element needed + if (*propertyMode == ewol::widget::Sizer::modeHori) { + if (size.y() < localWidgetSize.y()) { + // under + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_buttom)) == 0) { + m_draw.setColor(*propertyButtomColor); + m_draw.setPos(vec2(origin.x(), localWidgetOrigin.y()) - m_origin); + m_draw.rectangleWidth(vec2(it->getSize().x(), origin.y()-localWidgetOrigin.y()) ); + } + // upper + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_top)) == 0) { + m_draw.setColor(*propertyTopColor); + float startDraw = origin.y()+it->getSize().y() - m_origin.y(); + m_draw.setPos(vec2(origin.x()-m_origin.x(), startDraw)); + m_draw.rectangleWidth(vec2(it->getSize().x(), localWidgetSize.y()-startDraw+tmpBorderSize.y()) ); + } + } + } else { + if (size.x() < localWidgetSize.x()) { + // left + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_left)) == 0) { + m_draw.setColor(*propertyLeftColor); + m_draw.setPos(vec2(localWidgetOrigin.x(), origin.y()) - m_origin); + m_draw.rectangleWidth(vec2(origin.x()-localWidgetOrigin.x(), it->getSize().y()) ); + } + // right + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_right)) == 0) { + m_draw.setColor(*propertyRightColor); + float startDraw = origin.x()+it->getSize().x() - m_origin.x(); + m_draw.setPos(vec2(startDraw, origin.y()-m_origin.y())); + m_draw.rectangleWidth(vec2(localWidgetSize.x()-startDraw+tmpBorderSize.x(), it->getSize().y()) ); + } + } + } + } + // now we do the rest of the sizer: + if (*propertyMode == ewol::widget::Sizer::modeHori) { + if (underSize.x() < localWidgetSize.x()) { + // left + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_left)) == 0) { + m_draw.setColor(*propertyLeftColor); + m_draw.setPos(localWidgetOrigin - m_origin); + m_draw.rectangleWidth(vec2(underOrigin.x()-localWidgetOrigin.x(), localWidgetSize.y()) ); + } + // right + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_right)) == 0) { + m_draw.setColor(*propertyRightColor); + float startDraw = underOrigin.x() + underSize.x() - m_origin.x(); + m_draw.setPos(vec2(startDraw, localWidgetOrigin.y()-m_origin.y())); + m_draw.rectangleWidth(vec2(localWidgetSize.x()-startDraw+tmpBorderSize.x(), localWidgetSize.y()) ); + } + } + } else { + if (underSize.y() < localWidgetSize.y()) { + // under + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_buttom)) == 0) { + m_draw.setColor(*propertyButtomColor); + m_draw.setPos(localWidgetOrigin - m_origin); + m_draw.rectangleWidth(vec2(localWidgetSize.x(), underOrigin.y()-localWidgetOrigin.y()) ); + } + // upper + if ((uint32_t(*propertyGravity) & uint32_t(ewol::gravity_top)) == 0) { + m_draw.setColor(*propertyTopColor); + float startDraw = underOrigin.y() + underSize.y() - m_origin.y(); + m_draw.setPos(vec2(localWidgetOrigin.x()-m_origin.x(), startDraw)); + m_draw.rectangleWidth(vec2(localWidgetSize.x(), localWidgetSize.y()-startDraw+tmpBorderSize.y()) ); + } + } + } +} +void appl::widget::SizerColor::onDraw() { + m_draw.draw(); + ewol::widget::Sizer::onDraw(); +} diff --git a/tools/platform_test/appl/widget/SizerColor.hpp b/tools/platform_test/appl/widget/SizerColor.hpp new file mode 100644 index 00000000..0eef9dc4 --- /dev/null +++ b/tools/platform_test/appl/widget/SizerColor.hpp @@ -0,0 +1,48 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ +#pragma once + +#include +#include +#include +#include + +namespace appl { + namespace widget { + class SizerColor : public ewol::widget::Sizer { + public: + /** + * @brief Main call of recording the widget on the List of "widget named creator" + */ + static void init(ewol::widget::Manager& _widgetManager); + protected: + /** + * @brief Constructor + * @param[in] _mode The mode to display the elements + */ + SizerColor(); + void init(enum displayMode _mode=ewol::widget::Sizer::modeHori); + public: + DECLARE_WIDGET_FACTORY(SizerColor, "SizerColor"); + /** + * @brief Desstructor + */ + virtual ~SizerColor(); + private: + eproperty::Value> propertyBorderColor; //!< Border color. + eproperty::Value> propertyLeftColor; //!< Left color. + eproperty::Value> propertyRightColor; //!< Right color. + eproperty::Value> propertyTopColor; //!< Top color. + eproperty::Value> propertyButtomColor; //!< Buttom color. + private: + ewol::compositing::Drawing m_draw; //!< Compositing drawing element for display the border. + public: + virtual void onRegenerateDisplay(); + virtual void onDraw(); + }; + } +} + diff --git a/tools/platform_test/data/FreeSerif.ttf b/tools/platform_test/data/FreeSerif.ttf new file mode 100644 index 00000000..b8906f50 Binary files /dev/null and b/tools/platform_test/data/FreeSerif.ttf differ diff --git a/tools/platform_test/data/FreeSerifBold.ttf b/tools/platform_test/data/FreeSerifBold.ttf new file mode 100644 index 00000000..59a7a90f Binary files /dev/null and b/tools/platform_test/data/FreeSerifBold.ttf differ diff --git a/tools/platform_test/data/FreeSerifBoldItalic.ttf b/tools/platform_test/data/FreeSerifBoldItalic.ttf new file mode 100644 index 00000000..c187d0e2 Binary files /dev/null and b/tools/platform_test/data/FreeSerifBoldItalic.ttf differ diff --git a/tools/platform_test/data/FreeSerifItalic.ttf b/tools/platform_test/data/FreeSerifItalic.ttf new file mode 100644 index 00000000..73674188 Binary files /dev/null and b/tools/platform_test/data/FreeSerifItalic.ttf differ diff --git a/tools/platform_test/data/gui.xml b/tools/platform_test/data/gui.xml new file mode 100644 index 00000000..6b299782 --- /dev/null +++ b/tools/platform_test/data/gui.xml @@ -0,0 +1,69 @@ + + + + basic text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/platform_test/data/icon.png b/tools/platform_test/data/icon.png new file mode 100644 index 00000000..a37ddaf5 Binary files /dev/null and b/tools/platform_test/data/icon.png differ diff --git a/tools/platform_test/lutin_ewol-tools-platform-test.py b/tools/platform_test/lutin_ewol-tools-platform-test.py new file mode 100755 index 00000000..9b7e8781 --- /dev/null +++ b/tools/platform_test/lutin_ewol-tools-platform-test.py @@ -0,0 +1,73 @@ +#!/usr/bin/python +import lutin.debug as debug +import lutin.tools as tools +import os + +def get_type(): + return "BINARY" + +def get_sub_type(): + return "TOOL" + +def get_desc(): + return "ewol tools software (visual)" + +def get_licence(): + return "APACHE-2" + +def get_compagny_type(): + return "com" + +def get_compagny_name(): + return "atria-soft" + +def get_maintainer(): + return ["Mr DUPIN Edouard "] + +def configure(target, my_module): + # add the file to compile: + my_module.add_src_file([ + 'appl/debug.cpp', + 'appl/init.cpp', + 'appl/MainWindows.cpp', + 'appl/TestDistanceField.cpp', + 'appl/widget/SizerColor.cpp' + ]) + + my_module.add_depend(['ewol']) + + my_module.copy_file('data/icon.png','icon.png') + + my_module.copy_path('data/icon.*','') + my_module.copy_path('data/cube.*','') + my_module.copy_path('data/grass.*','') + my_module.copy_path('data/stone*','') + my_module.copy_path('data/sphere.png','') + my_module.copy_path('data/sphere.obj','') + my_module.copy_path('data/gui.xml','') + + my_module.add_path(".") + + my_module.copy_path("data/FreeSerif*","fonts/") + + """ + # set the package properties : + my_module.pkg_set("VERSION", versionID) + my_module.pkg_set("COMPAGNY_TYPE", "org") + my_module.pkg_set("COMPAGNY_NAME", "Edouard DUPIN") + my_module.pkg_set("MAINTAINER", ["Mr DUPIN Edouard "]) + my_module.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png") + my_module.pkg_set("SECTION", ["Development"]) + my_module.pkg_set("PRIORITY", "optional") + my_module.pkg_set("DESCRIPTION", "ewol test software") + my_module.pkg_set("NAME", "test software") + + my_module.pkg_add("RIGHT", "SET_ORIENTATION") + my_module.pkg_add("RIGHT", "VIBRATE") + """ + + return True + + + +