[DEV] start a dev tool toi tes gale platform API
This commit is contained in:
parent
4632a3b939
commit
f39f7b69a8
@ -1,4 +1,5 @@
|
||||
sample/HelloWord
|
||||
sample/CustomWidgets
|
||||
sample/wallpaper
|
||||
tools/visual_test
|
||||
tools/visual_test
|
||||
tools/platform_test
|
588
tools/platform_test/appl/MainWindows.cpp
Normal file
588
tools/platform_test/appl/MainWindows.cpp
Normal file
@ -0,0 +1,588 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/MainWindows.hpp>
|
||||
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/widget/ContextMenu.hpp>
|
||||
#include <ewol/widget/PopUp.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
#include <ewol/widget/Menu.hpp>
|
||||
#include <ewol/widget/meta/FileChooser.hpp>
|
||||
#include <ewol/widget/meta/Parameter.hpp>
|
||||
#include <ewol/widget/Select.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/widget/Spin.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <appl/TestDistanceField.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
|
||||
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<ewol::widget::Sizer>(m_composer->getSubObjectNamed("appl-upper-test-widget"));
|
||||
if (m_sizerVert == nullptr) {
|
||||
APPL_CRITICAL("Can not get vertical pointer");
|
||||
}
|
||||
m_sizerDynamic = ememory::dynamicPointerCast<ewol::widget::Sizer>(m_composer->getSubObjectNamed("appl-dynamic-config"));
|
||||
if (m_sizerDynamic == nullptr) {
|
||||
APPL_CRITICAL("Can not get dynamic pointer");
|
||||
}
|
||||
m_subWidget = ememory::dynamicPointerCast<ewol::Widget>(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<br/>(" + ewol::gravityToString(m_gravity) + ")");
|
||||
}
|
||||
|
||||
void appl::MainWindows::onCallbackWidgetChange(int32_t _increment) {
|
||||
m_idWidget += _increment;
|
||||
ememory::SharedPtr<ewol::Widget> oldWidget = m_subWidget;
|
||||
std::string tmpDescription;
|
||||
std::string tmpConstruct;
|
||||
switch(m_idWidget) {
|
||||
case 0:
|
||||
tmpConstruct = "<spin/>\n";
|
||||
tmpDescription = "Test ewol::widget::Spin";
|
||||
break;
|
||||
case 1:
|
||||
tmpConstruct = std::string()
|
||||
+ "<select>\n"
|
||||
+ " <option id='1'>plop 1</option>\n"
|
||||
+ " <option id='2'>plop 2</option>\n"
|
||||
+ " <option id='3' select='true'>plop 3</option>\n"
|
||||
+ " <option id='4'>plop 4</option>\n"
|
||||
+ " <option id='5'>plop 5</option>\n"
|
||||
+ "</select>\n";
|
||||
tmpDescription = "Test ewol::widget::Select";
|
||||
break;
|
||||
case 2:
|
||||
tmpConstruct = "<ButtonColor/>";
|
||||
tmpDescription = "Test ewol::widget::ButtonColor";
|
||||
break;
|
||||
case 3:
|
||||
tmpConstruct = "<label>Simple string</label>\n";
|
||||
tmpDescription = "Test ewol::widget::Label";
|
||||
break;
|
||||
case 4:
|
||||
tmpConstruct = "<image src='DATA:sphere.png'/>\n";
|
||||
tmpDescription = "Test ewol::widget::Image";
|
||||
break;
|
||||
case 5:
|
||||
tmpConstruct = "<checkbox><label>Simple string</label></checkbox>\n";
|
||||
tmpDescription = "Test ewol::widget::Checkbox";
|
||||
break;
|
||||
case 6:
|
||||
tmpConstruct = "<entry/>\n";
|
||||
tmpDescription = "Test ewol::widget::Entry";
|
||||
break;
|
||||
case 7:
|
||||
tmpConstruct = "<slider/>\n";
|
||||
tmpDescription = "Test ewol::widget::Entry";
|
||||
break;
|
||||
case 8:
|
||||
tmpConstruct = std::string()
|
||||
+ "<button name='[TEST]Button:TO-TEST' expand='false,false' fill='false,false' >\n"
|
||||
+ " <label>My <font color='#FF0000'>Button</font> <br/> And Some under line<br/> plop <br/> and an other super long line ...</label>\n"
|
||||
+ "</button>\n";
|
||||
tmpDescription = "Test ewol::widget::Button";
|
||||
break;
|
||||
default:
|
||||
tmpConstruct = "<label expand=false fill=false>Simple string</label>\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<ewol::widget::Sizer> _sizer, etk::Color<> _color=etk::color::none) {
|
||||
ememory::SharedPtr<ewol::widget::Spacer> 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<ewol::widget::Label> 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; iii<m_subWidget->properties.size(); ++iii) {
|
||||
eproperty::Property* param = m_subWidget->properties.getRaw(iii);
|
||||
if (param == nullptr) {
|
||||
APPL_WARNING("Parameter EMPTY . " << iii << " : nullptr");
|
||||
continue;
|
||||
}
|
||||
ememory::SharedPtr<ewol::widget::Sizer> 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<ewol::widget::Label> 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<std::string>* paramValue = dynamic_cast<eproperty::Value<std::string>*>(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<gale::Dimension>* paramValue = dynamic_cast<eproperty::Value<gale::Dimension>*>(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<bvec2>* paramValue = dynamic_cast<eproperty::Value<bvec2>*>(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<ivec2>* paramValue = dynamic_cast<eproperty::Value<ivec2>*>(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<uivec2>* paramValue = dynamic_cast<eproperty::Value<uivec2>*>(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<vec2>* paramValue = dynamic_cast<eproperty::Value<vec2>*>(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<std::string> 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; iii<listElement.size(); ++iii) {
|
||||
widgetTmp->optionAdd(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
42
tools/platform_test/appl/MainWindows.hpp
Normal file
42
tools/platform_test/appl/MainWindows.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Spacer.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
namespace appl {
|
||||
class MainWindows : public ewol::widget::Windows {
|
||||
private:
|
||||
std::vector<esignal::Connection> 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);
|
||||
};
|
||||
};
|
||||
|
||||
|
82
tools/platform_test/appl/TestDistanceField.cpp
Normal file
82
tools/platform_test/appl/TestDistanceField.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/TestDistanceField.hpp>
|
||||
|
||||
#include <ewol/widget/Button.hpp>
|
||||
#include <ewol/widget/CheckBox.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <ewol/widget/Label.hpp>
|
||||
#include <ewol/widget/Entry.hpp>
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <ewol/widget/ContextMenu.hpp>
|
||||
#include <ewol/widget/PopUp.hpp>
|
||||
#include <ewol/widget/Slider.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <ewol/widget/Menu.hpp>
|
||||
#include <ewol/widget/meta/FileChooser.hpp>
|
||||
#include <ewol/widget/meta/Parameter.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
34
tools/platform_test/appl/TestDistanceField.hpp
Normal file
34
tools/platform_test/appl/TestDistanceField.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/compositing/Text.hpp>
|
||||
#include <ewol/compositing/TextDF.hpp>
|
||||
#include <gale/resource/Program.hpp>
|
||||
#include <ewol/resource/DistanceFieldFont.hpp>
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
13
tools/platform_test/appl/debug.cpp
Normal file
13
tools/platform_test/appl/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("test_ewol");
|
||||
return g_val;
|
||||
}
|
45
tools/platform_test/appl/debug.hpp
Normal file
45
tools/platform_test/appl/debug.hpp
Normal file
@ -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 <elog/log.hpp>
|
||||
#include <cassert>
|
||||
|
||||
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)
|
96
tools/platform_test/appl/init.cpp
Normal file
96
tools/platform_test/appl/init.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/MainWindows.hpp>
|
||||
#include <appl/widget/SizerColor.hpp>
|
||||
|
||||
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<appl::MainWindows> 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);
|
||||
}
|
||||
|
||||
|
144
tools/platform_test/appl/widget/SizerColor.cpp
Normal file
144
tools/platform_test/appl/widget/SizerColor.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/widget/SizerColor.hpp>
|
||||
|
||||
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();
|
||||
}
|
48
tools/platform_test/appl/widget/SizerColor.hpp
Normal file
48
tools/platform_test/appl/widget/SizerColor.hpp
Normal file
@ -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 <etk/types.hpp>
|
||||
#include <ewol/widget/Sizer.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <ewol/compositing/Drawing.hpp>
|
||||
|
||||
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<etk::Color<>> propertyBorderColor; //!< Border color.
|
||||
eproperty::Value<etk::Color<>> propertyLeftColor; //!< Left color.
|
||||
eproperty::Value<etk::Color<>> propertyRightColor; //!< Right color.
|
||||
eproperty::Value<etk::Color<>> propertyTopColor; //!< Top color.
|
||||
eproperty::Value<etk::Color<>> propertyButtomColor; //!< Buttom color.
|
||||
private:
|
||||
ewol::compositing::Drawing m_draw; //!< Compositing drawing element for display the border.
|
||||
public:
|
||||
virtual void onRegenerateDisplay();
|
||||
virtual void onDraw();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
BIN
tools/platform_test/data/FreeSerif.ttf
Normal file
BIN
tools/platform_test/data/FreeSerif.ttf
Normal file
Binary file not shown.
BIN
tools/platform_test/data/FreeSerifBold.ttf
Normal file
BIN
tools/platform_test/data/FreeSerifBold.ttf
Normal file
Binary file not shown.
BIN
tools/platform_test/data/FreeSerifBoldItalic.ttf
Normal file
BIN
tools/platform_test/data/FreeSerifBoldItalic.ttf
Normal file
Binary file not shown.
BIN
tools/platform_test/data/FreeSerifItalic.ttf
Normal file
BIN
tools/platform_test/data/FreeSerifItalic.ttf
Normal file
Binary file not shown.
69
tools/platform_test/data/gui.xml
Normal file
69
tools/platform_test/data/gui.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<composer>
|
||||
<sizer mode="vert"
|
||||
expand="true,true"
|
||||
lock="true,true"
|
||||
fill="true,true"
|
||||
border="2px"
|
||||
border-color="#0F08">
|
||||
<sizer mode="hori"
|
||||
expand="true,false"
|
||||
lock="false,true"
|
||||
fill="true,true">
|
||||
<entry name="appl-entry-clipboard">basic text</entry>
|
||||
<button name="appl-copy">
|
||||
<label expand="false,false" fill="true,true">copy</label>
|
||||
</button>
|
||||
<button name="appl-past">
|
||||
<label expand="false,false" fill="true,true">past</label>
|
||||
</button>
|
||||
<spacer expand="true,true"/>
|
||||
</sizer>
|
||||
<sizer mode="hori"
|
||||
expand="true,false"
|
||||
lock="false,true"
|
||||
fill="true,true">
|
||||
<label name="appl-label-special-key" expand="true,false" fill="true,true">Special Key :</label>
|
||||
<label name="appl-special-key-value" expand="true,false" fill="true,true">---</label>
|
||||
<spacer expand="true,true"/>
|
||||
</sizer>
|
||||
<sizer mode="hori"
|
||||
expand="true,false"
|
||||
lock="false,true"
|
||||
fill="true,true">
|
||||
<label name="appl-label-key" expand="true,false" fill="true,true">LastKey :</label>
|
||||
<label name="appl-last-key-pressed" expand="true,false" fill="true,true">NONE</label>
|
||||
<spacer expand="true,true"/>
|
||||
</sizer>
|
||||
<sizer mode="hori"
|
||||
expand="true,false"
|
||||
lock="false,true"
|
||||
fill="true,true">
|
||||
<label name="appl-label-mouse" expand="true,false" fill="true,true">Mouse Position :</label>
|
||||
<label name="appl-mouse-vamue" expand="true,false" fill="true,true">out</label>
|
||||
<spacer expand="true,true"/>
|
||||
</sizer>
|
||||
<sizer mode="hori"
|
||||
expand="true,false"
|
||||
lock="false,true"
|
||||
fill="true,true">
|
||||
<button name="appl-set-title">
|
||||
<label expand="false,false" fill="true,true">Set title</label>
|
||||
</button>
|
||||
<button name="appl-close">
|
||||
<label expand="false,false" fill="true,true">Close Application</label>
|
||||
</button>
|
||||
<button name="appl-size">
|
||||
<label expand="false,false" fill="true,true">Change Size</label>
|
||||
</button>
|
||||
<button name="appl-move">
|
||||
<label expand="false,false" fill="true,true">Move Windows</label>
|
||||
</button>
|
||||
<button name="appl-full-screen"
|
||||
toggle="true">
|
||||
<label expand="false,false" fill="true,true">set Full screen</label>
|
||||
<label expand="false,false" fill="true,true">set window screen</label>
|
||||
</button>
|
||||
<spacer expand="true,true"/>
|
||||
</sizer>
|
||||
</sizer>
|
||||
</composer>
|
BIN
tools/platform_test/data/icon.png
Normal file
BIN
tools/platform_test/data/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
73
tools/platform_test/lutin_ewol-tools-platform-test.py
Executable file
73
tools/platform_test/lutin_ewol-tools-platform-test.py
Executable file
@ -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 <yui.heero@gmail.com>"]
|
||||
|
||||
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 <yui.heero@gmail.com>"])
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user