[DEV] update to the ewol interface

This commit is contained in:
Edouard DUPIN 2014-08-19 19:01:57 +02:00
parent 8dcb98a91c
commit 00a225c379
17 changed files with 299 additions and 289 deletions

View File

@ -41,53 +41,55 @@ static const char * l_eventChangeWidgetPrevious = "event-change-widget-test-pre
#undef __class__ #undef __class__
#define __class__ "MainWindows" #define __class__ "MainWindows"
MainWindows::MainWindows() : appl::MainWindows::MainWindows() :
m_idWidget(0), m_idWidget(0) {
m_subWidget(nullptr),
m_testName(nullptr) {
APPL_DEBUG("CREATE WINDOWS ... "); APPL_DEBUG("CREATE WINDOWS ... ");
addObjectType("appl::MainWindows"); addObjectType("appl::MainWindows");
ewol::object::Shared<ewol::widget::Sizer> mySizerHori = nullptr; }
ewol::object::Shared<ewol::widget::Button> myButton = nullptr;
m_sizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); void appl::MainWindows::init() {
ewol::widget::Windows::init();
std::shared_ptr<ewol::widget::Sizer> mySizerHori = nullptr;
std::shared_ptr<ewol::widget::Button> myButton = nullptr;
m_sizerVert = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert);
if (nullptr == m_sizerVert) { if (nullptr == m_sizerVert) {
APPL_DEBUG("Allocation error mySizerVert"); APPL_DEBUG("Allocation error mySizerVert");
return; return;
} }
setSubWidget(m_sizerVert); setSubWidget(m_sizerVert);
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
m_sizerVert->subWidgetAdd(mySizerHori); m_sizerVert->subWidgetAdd(mySizerHori);
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("default theme (cube)"))); myButton->setSubWidget(ewol::widget::Label::create("default theme (cube)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("rounded theme"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("rounded theme"));
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->registerOnEvent(this, "value", l_eventChangeTheme); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeTheme);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Previous Widget test"))); myButton->setSubWidget(ewol::widget::Label::create("Previous Widget test"));
myButton->registerOnEvent(this, "pressed", l_eventChangeWidgetPrevious); myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeWidgetPrevious);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Next Widget test"))); myButton->setSubWidget(ewol::widget::Label::create("Next Widget test"));
myButton->registerOnEvent(this, "pressed", l_eventChangeWidgetNext); myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeWidgetNext);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
m_testName = new ewol::widget::Label("none"); m_testName = ewol::widget::Label::create("none");
if (nullptr != m_testName) { if (nullptr != m_testName) {
mySizerHori->subWidgetAdd(m_testName); mySizerHori->subWidgetAdd(m_testName);
} }
ewol::object::Shared<ewol::widget::Spacer> mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); std::shared_ptr<ewol::widget::Spacer> mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
@ -100,12 +102,8 @@ MainWindows::MainWindows() :
onReceiveMessage(msg); onReceiveMessage(msg);
} }
MainWindows::~MainWindows() { void appl::MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
if( _msg.getCaller() != std::shared_ptr<ewol::Object>(this)
}
void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
if( _msg.getCaller() != ewol::object::Shared<ewol::Object>(this)
&& _msg.getCaller() != nullptr) { && _msg.getCaller() != nullptr) {
ewol::widget::Windows::onReceiveMessage(_msg); ewol::widget::Windows::onReceiveMessage(_msg);
} }
@ -127,7 +125,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
} }
if (m_subWidget != nullptr) { if (m_subWidget != nullptr) {
m_subWidget->removeObject(); m_subWidget->destroy();
// in theory it must be removed ... // in theory it must be removed ...
m_subWidget.reset(); m_subWidget.reset();
} }
@ -137,7 +135,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
} }
switch(m_idWidget) { switch(m_idWidget) {
case 0: case 0:
m_subWidget = ewol::object::makeShared(new appl::TestButton()); m_subWidget = appl::TestButton::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -146,7 +144,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
case 1: case 1:
m_subWidget = ewol::object::makeShared(new TestDistanceField()); m_subWidget = TestDistanceField::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -155,7 +153,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
case 2: case 2:
m_subWidget = ewol::object::makeShared(new TestButtonColor()); m_subWidget = TestButtonColor::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -164,7 +162,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
case 3: case 3:
m_subWidget = ewol::object::makeShared(new TestLabel()); m_subWidget = TestLabel::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -173,7 +171,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
case 4: case 4:
m_subWidget = ewol::object::makeShared(new TestImage()); m_subWidget = TestImage::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -182,7 +180,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
case 5: case 5:
m_subWidget = ewol::object::makeShared(new appl::TestCheckBox()); m_subWidget = appl::TestCheckBox::create();
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
} }
@ -191,7 +189,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
break; break;
default: default:
m_subWidget = ewol::object::makeShared(new ewol::widget::Label("Test software for EWOL")); m_subWidget = ewol::widget::Label::create("Test software for EWOL");
if (nullptr != m_subWidget) { if (nullptr != m_subWidget) {
m_subWidget->setExpand(bvec2(true,true)); m_subWidget->setExpand(bvec2(true,true));
m_sizerVert->subWidgetAdd(m_subWidget); m_sizerVert->subWidgetAdd(m_subWidget);
@ -201,16 +199,6 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
}; };
m_idWidget = -1; m_idWidget = -1;
break; break;
/*case 5:
m_subWidget = ewol::object::makeShared(new TestScene());
if (nullptr != m_subWidget) {
m_sizerVert->subWidgetAdd(m_subWidget);
}
if (m_testName!=nullptr) {
m_testName->setLabel("TestScene");
};
break;
*/
} }
} }

View File

@ -16,21 +16,24 @@
#include <ewol/widget/Button.h> #include <ewol/widget/Button.h>
#include <ewol/widget/Label.h> #include <ewol/widget/Label.h>
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
namespace appl {
class MainWindows : public ewol::widget::Windows { class MainWindows : public ewol::widget::Windows {
private: private:
ewol::object::Shared<ewol::widget::Sizer> m_sizerVert; std::shared_ptr<ewol::widget::Sizer> m_sizerVert;
ewol::object::Shared<ewol::Widget> m_subWidget; std::shared_ptr<ewol::Widget> m_subWidget;
ewol::object::Shared<ewol::widget::Label> m_testName; std::shared_ptr<ewol::widget::Label> m_testName;
int32_t m_idWidget; int32_t m_idWidget;
public: public:
// Constructeur // Constructeur
MainWindows(); MainWindows();
~MainWindows(); void init();
public:
DECLARE_FACTORY(MainWindows);
~MainWindows() {};
public: // derived fuction public: // derived fuction
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
};
}; };
#endif #endif

View File

@ -39,10 +39,13 @@ static const char * l_eventChangeImageToggle = "event-change-image-toggle";
#undef __class__ #undef __class__
#define __class__ "TestButton" #define __class__ "TestButton"
appl::TestButton::TestButton() : appl::TestButton::TestButton() {
m_testWidget(nullptr) {
APPL_INFO("Create " __class__ " (start)");
addObjectType("appl::TestButton"); addObjectType("appl::TestButton");
}
void appl::TestButton::init() {
ewol::widget::Composer::init();
APPL_INFO("Create " __class__ " (start)");
std::string myDescription = std::string("") std::string myDescription = std::string("")
+ "<sizer mode='vert' fill='true' expand='true'>\n" + "<sizer mode='vert' fill='true' expand='true'>\n"
@ -101,7 +104,7 @@ appl::TestButton::TestButton() :
registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText); registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText);
// show all event from a button : // show all event from a button :
registerOnEventNameWidget("[TEST]Button:TO-TEST", "*"); registerOnEventNameWidget("[TEST]Button:TO-TEST", "*");
m_testWidget = ewol::dynamic_pointer_cast<ewol::widget::Button>(getWidgetNamed("[TEST]Button:TO-TEST")); m_testWidget = std::dynamic_pointer_cast<ewol::widget::Button>(getWidgetNamed("[TEST]Button:TO-TEST"));
if (m_testWidget == nullptr) { if (m_testWidget == nullptr) {
APPL_CRITICAL("Can not get the pointer of the widget button pointer"); APPL_CRITICAL("Can not get the pointer of the widget button pointer");
} }
@ -159,7 +162,7 @@ void appl::TestButton::onReceiveMessage(const ewol::object::Message& _msg) {
} else if (_msg.getMessage() == l_eventChangeTextToggle) { } else if (_msg.getMessage() == l_eventChangeTextToggle) {
if (nullptr!=m_testWidget) { if (nullptr!=m_testWidget) {
if (_msg.getData()=="true") { if (_msg.getData()=="true") {
m_testWidget->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("A stupid very long text on toggle <br/><br/> and on multiple lines"))); m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle <br/><br/> and on multiple lines"));
} else { } else {
m_testWidget->setSubWidgetToggle(nullptr); m_testWidget->setSubWidgetToggle(nullptr);
} }
@ -169,55 +172,50 @@ void appl::TestButton::onReceiveMessage(const ewol::object::Message& _msg) {
static int32_t countTextID = 1; static int32_t countTextID = 1;
switch (countTextID) { switch (countTextID) {
case 0: case 0:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text"));
break; break;
case 1: case 1:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<left>Align Left</left>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<left>Align Left</left>"));
break; break;
case 2: case 2:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<right>Align right</right>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<right>Align right</right>"));
break; break;
case 3: case 3:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<center>Align center</center>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<center>Align center</center>"));
break; break;
case 4: case 4:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text<br/> With Some Other Lines<br/> and more if you want ...<br/> plop"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text<br/> With Some Other Lines<br/> and more if you want ...<br/> plop"));
break; break;
case 5: case 5:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <bold>Text</bold> with bold"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <bold>Text</bold> with bold"));
break; break;
case 6: case 6:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <italic>Text</italic> with italic"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <italic>Text</italic> with italic"));
break; break;
case 7: case 7:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <italic><bold>Text</bold></italic> with italic bold"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <italic><bold>Text</bold></italic> with italic bold"));
break; break;
case 8: case 8:
m_testWidget->setSubWidget(nullptr); m_testWidget->setSubWidget(nullptr);
break; break;
case 9: case 9:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <font color=\"#FFFF0088\">Text</font> with colored text"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <font color=\"#FFFF0088\">Text</font> with colored text"));
break; break;
case 10: case 10:
m_testWidget->setSubWidget(ewol::object::makeShared( m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "<label>ploppp</label>\n"));
new ewol::widget::Composer(ewol::widget::Composer::String,
"<label>ploppp</label>\n")));
break; break;
case 11: case 11:
m_testWidget->setSubWidget(ewol::object::makeShared( m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String,
new ewol::widget::Composer(ewol::widget::Composer::String,
" <sizer mode=\"vert\" addmode=\"invert\">\n" " <sizer mode=\"vert\" addmode=\"invert\">\n"
" <label>ploppp</label>\n" " <label>ploppp</label>\n"
" <label expand=\"true,true\"><center>** ** * *<br/>** * * * *</center></label>\n" " <label expand=\"true,true\"><center>** ** * *<br/>** * * * *</center></label>\n"
" </sizer>\n"))); " </sizer>\n"));
break; break;
case 12: case 12:
m_testWidget->setSubWidget(ewol::object::makeShared( m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "<spacer color='red' min-size='30,30px'/>\n"));
new ewol::widget::Composer(ewol::widget::Composer::String,
"<spacer color='red' min-size='30,30px'/>\n")));
break; break;
default: default:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("My <font color=\"#FF0000\">Button</font> <br/> And Some under line<br/> plop <br/> and an other super long line ..."))); m_testWidget->setSubWidget(ewol::widget::Label::create("My <font color=\"#FF0000\">Button</font> <br/> And Some under line<br/> plop <br/> and an other super long line ..."));
countTextID=-1; countTextID=-1;
break; break;
} }

View File

@ -15,10 +15,13 @@
namespace appl { namespace appl {
class TestButton : public ewol::widget::Composer { class TestButton : public ewol::widget::Composer {
private: private:
ewol::object::Shared<ewol::widget::Button> m_testWidget; std::shared_ptr<ewol::widget::Button> m_testWidget;
public: public:
// Constructeur // Constructeur
TestButton(); TestButton();
void init();
public:
DECLARE_FACTORY(TestButton);
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
}; };

View File

@ -33,109 +33,108 @@ static const char * l_eventChangeFillY = "event-change-fill-Y";
#undef __class__ #undef __class__
#define __class__ "TestButton" #define __class__ "TestButton"
TestButtonColor::TestButtonColor() : appl::TestButtonColor::TestButtonColor() {
ewol::widget::Sizer(ewol::widget::Sizer::modeVert),
m_testWidget(nullptr) {
APPL_INFO("CREATE " __class__ " ... ");
addObjectType("appl::TestButtonColor"); addObjectType("appl::TestButtonColor");
ewol::object::Shared<ewol::widget::Sizer> mySizerVert2; }
ewol::object::Shared<ewol::widget::Sizer> mySizerHori;
ewol::object::Shared<ewol::widget::Button> myButton;
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); void appl::TestButtonColor::init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
APPL_INFO("CREATE " __class__ " ... ");
std::shared_ptr<ewol::widget::Sizer> mySizerVert2;
std::shared_ptr<ewol::widget::Sizer> mySizerHori;
std::shared_ptr<ewol::widget::Button> myButton;
mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand X (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expand X (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand X (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand X (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand Y (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expand Y (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand Y (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand Y (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill X (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill Y (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
ewol::object::Shared<ewol::widget::Spacer> mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); std::shared_ptr<ewol::widget::Spacer> mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0xFF000080); mySpacer->setColor(etk::Color<>(0xFF, 0x00, 0x00, 0x80));
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x00FF0080); mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0x00, 0x80));
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
m_testWidget = ewol::object::makeShared(new ewol::widget::ButtonColor(etk::color::olive)); m_testWidget = ewol::widget::ButtonColor::create(etk::color::olive);
if (nullptr != m_testWidget) { if (nullptr != m_testWidget) {
m_testWidget->setExpand(bvec2(false,false)); m_testWidget->setExpand(bvec2(false,false));
m_testWidget->setFill(bvec2(false,false)); m_testWidget->setFill(bvec2(false,false));
m_testWidget->registerOnEvent(this, "*"); m_testWidget->registerOnEvent(shared_from_this(), "*");
mySizerHori->subWidgetAdd(m_testWidget); mySizerHori->subWidgetAdd(m_testWidget);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x0000FF80); mySpacer->setColor(etk::Color<>(0x00, 0x00, 0xFF, 0x80));
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x00FFFF80); mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0xFF, 0x80));
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
} }
TestButtonColor::~TestButtonColor() { void appl::TestButtonColor::onReceiveMessage(const ewol::object::Message& _msg) {
}
void TestButtonColor::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::Sizer::onReceiveMessage(_msg); ewol::widget::Sizer::onReceiveMessage(_msg);
//APPL_INFO("Receive Event from the main windows : " << _msg); //APPL_INFO("Receive Event from the main windows : " << _msg);
if (m_testWidget == _msg.getCaller()) { if (m_testWidget == _msg.getCaller()) {

View File

@ -16,15 +16,20 @@
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
#include <ewol/widget/Sizer.h> #include <ewol/widget/Sizer.h>
class TestButtonColor : public ewol::widget::Sizer { namespace appl {
class TestButtonColor : public ewol::widget::Sizer {
private: private:
ewol::object::Shared<ewol::widget::ButtonColor> m_testWidget; std::shared_ptr<ewol::widget::ButtonColor> m_testWidget;
public: public:
// Constructeur // Constructeur
TestButtonColor(); TestButtonColor();
virtual ~TestButtonColor(); void init();
public:
DECLARE_FACTORY(TestButtonColor);
virtual ~TestButtonColor() {};
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
};
}; };
#endif #endif

View File

@ -39,10 +39,14 @@ static const char * l_eventChangeImageToggle = "event-change-image-toggle";
#undef __class__ #undef __class__
#define __class__ "TestCheckBox" #define __class__ "TestCheckBox"
appl::TestCheckBox::TestCheckBox() : appl::TestCheckBox::TestCheckBox() {
m_testWidget(nullptr) {
APPL_INFO("Create " __class__ " (start)");
addObjectType("appl::TestCheckBox"); addObjectType("appl::TestCheckBox");
}
void appl::TestCheckBox::init() {
ewol::widget::Composer::init();
APPL_INFO("Create " __class__ " (start)");
std::string myDescription = std::string("") std::string myDescription = std::string("")
+ "<sizer mode='vert' fill='true' expand='true'>\n" + "<sizer mode='vert' fill='true' expand='true'>\n"
@ -101,7 +105,7 @@ appl::TestCheckBox::TestCheckBox() :
registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText); registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText);
// show all event from a button : // show all event from a button :
registerOnEventNameWidget("[TEST]TO-TEST", "*"); registerOnEventNameWidget("[TEST]TO-TEST", "*");
m_testWidget = ewol::dynamic_pointer_cast<ewol::widget::CheckBox>(getWidgetNamed("[TEST]TO-TEST")); m_testWidget = std::dynamic_pointer_cast<ewol::widget::CheckBox>(getWidgetNamed("[TEST]TO-TEST"));
if (m_testWidget == nullptr) { if (m_testWidget == nullptr) {
APPL_CRITICAL("Can not get the pointer of the widget button pointer"); APPL_CRITICAL("Can not get the pointer of the widget button pointer");
} }
@ -149,7 +153,7 @@ void appl::TestCheckBox::onReceiveMessage(const ewol::object::Message& _msg) {
} else if (_msg.getMessage() == l_eventChangeTextToggle) { } else if (_msg.getMessage() == l_eventChangeTextToggle) {
if (nullptr!=m_testWidget) { if (nullptr!=m_testWidget) {
if (_msg.getData()=="true") { if (_msg.getData()=="true") {
m_testWidget->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("A stupid very long text on toggle <br/><br/> and on multiple lines"))); m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle <br/><br/> and on multiple lines"));
} else { } else {
m_testWidget->setSubWidgetToggle(nullptr); m_testWidget->setSubWidgetToggle(nullptr);
} }
@ -159,28 +163,28 @@ void appl::TestCheckBox::onReceiveMessage(const ewol::object::Message& _msg) {
static int32_t countTextID = 1; static int32_t countTextID = 1;
switch (countTextID) { switch (countTextID) {
case 0: case 0:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text"));
break; break;
case 1: case 1:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<left>Align Left</left>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<left>Align Left</left>"));
break; break;
case 2: case 2:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<right>Align right</right>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<right>Align right</right>"));
break; break;
case 3: case 3:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("<center>Align center</center>"))); m_testWidget->setSubWidget(ewol::widget::Label::create("<center>Align center</center>"));
break; break;
case 4: case 4:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text<br/> With Some Other Lines<br/> and more if you want ...<br/> plop"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text<br/> With Some Other Lines<br/> and more if you want ...<br/> plop"));
break; break;
case 5: case 5:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <bold>Text</bold> with bold"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <bold>Text</bold> with bold"));
break; break;
case 6: case 6:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <italic>Text</italic> with italic"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <italic>Text</italic> with italic"));
break; break;
case 7: case 7:
m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple <italic><bold>Text</bold></italic> with italic bold"))); m_testWidget->setSubWidget(ewol::widget::Label::create("simple <italic><bold>Text</bold></italic> with italic bold"));
break; break;
case 8: case 8:
m_testWidget->setSubWidget(nullptr); m_testWidget->setSubWidget(nullptr);

View File

@ -16,10 +16,13 @@
namespace appl { namespace appl {
class TestCheckBox : public ewol::widget::Composer { class TestCheckBox : public ewol::widget::Composer {
private: private:
ewol::object::Shared<ewol::widget::CheckBox> m_testWidget; std::shared_ptr<ewol::widget::CheckBox> m_testWidget;
public: public:
// Constructeur // Constructeur
TestCheckBox(); TestCheckBox();
void init();
public:
DECLARE_FACTORY(TestCheckBox);
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
}; };

View File

@ -28,8 +28,12 @@
#undef __class__ #undef __class__
#define __class__ "TestDistanceField" #define __class__ "TestDistanceField"
TestDistanceField::TestDistanceField(){ appl::TestDistanceField::TestDistanceField(){
addObjectType("appl::TestDistanceField"); addObjectType("appl::TestDistanceField");
}
void appl::TestDistanceField::init() {
ewol::Widget::init();
APPL_INFO("Create " __class__ " (start)"); APPL_INFO("Create " __class__ " (start)");
setExpand(bvec2(true, true)); setExpand(bvec2(true, true));
setFill(bvec2(true, true)); setFill(bvec2(true, true));
@ -37,24 +41,19 @@ TestDistanceField::TestDistanceField(){
} }
TestDistanceField::~TestDistanceField() { void appl::TestDistanceField::calculateSize(const vec2& _availlable) {
APPL_INFO("Remove " __class__ " ...");
}
void TestDistanceField::calculateSize(const vec2& _availlable) {
// set minimal size // set minimal size
m_size = _availlable; m_size = _availlable;
} }
void TestDistanceField::calculateMinMaxSize() { void appl::TestDistanceField::calculateMinMaxSize() {
m_minSize = vec2(256,256); m_minSize = vec2(256,256);
markToRedraw(); markToRedraw();
} }
void TestDistanceField::onDraw() { void appl::TestDistanceField::onDraw() {
m_text2.draw(); m_text2.draw();
m_text1.draw(); m_text1.draw();
@ -62,7 +61,7 @@ void TestDistanceField::onDraw() {
void TestDistanceField::onRegenerateDisplay() { void appl::TestDistanceField::onRegenerateDisplay() {
if (false == needRedraw()) { if (false == needRedraw()) {
return; return;
} }
@ -77,7 +76,7 @@ void TestDistanceField::onRegenerateDisplay() {
} }
bool TestDistanceField::onEventInput(const ewol::event::Input& _event) { bool appl::TestDistanceField::onEventInput(const ewol::event::Input& _event) {
if (_event.getId() == 4) { if (_event.getId() == 4) {
setZoom(getZoom() + 0.01f); setZoom(getZoom() + 0.01f);
} else if (_event.getId() == 5) { } else if (_event.getId() == 5) {

View File

@ -16,19 +16,24 @@
#include <ewol/resource/Program.h> #include <ewol/resource/Program.h>
#include <ewol/resource/DistanceFieldFont.h> #include <ewol/resource/DistanceFieldFont.h>
class TestDistanceField : public ewol::Widget { namespace appl {
class TestDistanceField : public ewol::Widget {
ewol::compositing::Text m_text1; ewol::compositing::Text m_text1;
ewol::compositing::TextDF m_text2; ewol::compositing::TextDF m_text2;
public: public:
// Constructeur // Constructeur
TestDistanceField(); TestDistanceField();
virtual ~TestDistanceField(); void init();
public:
DECLARE_FACTORY(TestDistanceField);
virtual ~TestDistanceField() {};
public: // Derived function public: // Derived function
virtual void onDraw(); virtual void onDraw();
virtual void calculateMinMaxSize(); virtual void calculateMinMaxSize();
virtual void calculateSize(const vec2& _availlable); virtual void calculateSize(const vec2& _availlable);
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventInput(const ewol::event::Input& _event);
};
}; };
#endif #endif

View File

@ -35,68 +35,69 @@ static const char * l_eventChangeImage = "event-change-image";
#undef __class__ #undef __class__
#define __class__ "TestImage" #define __class__ "TestImage"
TestImage::TestImage() : appl::TestImage::TestImage() {
ewol::widget::Sizer(ewol::widget::Sizer::modeVert),
m_testWidget(nullptr) {
APPL_INFO("Create " __class__ " (start)");
addObjectType("appl::TestImage"); addObjectType("appl::TestImage");
ewol::object::Shared<ewol::widget::Sizer> mySizerVert2; }
ewol::object::Shared<ewol::widget::Sizer> mySizerHori; void appl::TestImage::init() {
ewol::object::Shared<ewol::widget::Button> myButton; ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
APPL_INFO("Create " __class__ " (start)");
std::shared_ptr<ewol::widget::Sizer> mySizerVert2;
std::shared_ptr<ewol::widget::Sizer> mySizerHori;
std::shared_ptr<ewol::widget::Button> myButton;
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expend X <br/> (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expend X <br/> (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expend X <br/><b>(true)</b>"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expend X <br/><b>(true)</b>"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expend Y <br/> (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expend Y <br/> (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expend Y <br/><b>(true)</b>"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expend Y <br/><b>(true)</b>"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X <br/> (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill X <br/> (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X <br/> (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X <br/> (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y <br/> (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill Y <br/> (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y <br/> (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y <br/> (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Change Image"))); myButton->setSubWidget(ewol::widget::Label::create("Change Image"));
myButton->registerOnEvent(this, "value", l_eventChangeImage); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeImage);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
ewol::object::Shared<ewol::widget::Spacer> mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); std::shared_ptr<ewol::widget::Spacer> mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
@ -105,14 +106,14 @@ TestImage::TestImage() :
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
@ -121,15 +122,15 @@ TestImage::TestImage() :
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
m_testWidget = ewol::object::makeShared(new ewol::widget::Image("DATA:sphere.png")); m_testWidget = ewol::widget::Image::create("DATA:sphere.png");
if (nullptr != m_testWidget) { if (nullptr != m_testWidget) {
m_testWidget->setExpand(bvec2(false,false)); m_testWidget->setExpand(bvec2(false,false));
m_testWidget->setFill(bvec2(false,false)); m_testWidget->setFill(bvec2(false,false));
//m_testWidget->registerOnEvent(this, ewolEventButtonValue); //m_testWidget->registerOnEvent(shared_from_this(), ewolEventButtonValue);
mySizerHori->subWidgetAdd(m_testWidget); mySizerHori->subWidgetAdd(m_testWidget);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
@ -138,7 +139,7 @@ TestImage::TestImage() :
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
@ -150,12 +151,7 @@ TestImage::TestImage() :
} }
TestImage::~TestImage() { void appl::TestImage::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_INFO("Remove " __class__ " ...");
}
void TestImage::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::Sizer::onReceiveMessage(_msg); ewol::widget::Sizer::onReceiveMessage(_msg);
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (m_testWidget == _msg.getCaller()) { if (m_testWidget == _msg.getCaller()) {

View File

@ -16,15 +16,20 @@
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
#include <ewol/widget/Sizer.h> #include <ewol/widget/Sizer.h>
class TestImage : public ewol::widget::Sizer { namespace appl {
class TestImage : public ewol::widget::Sizer {
private: private:
ewol::object::Shared<ewol::widget::Image> m_testWidget; std::shared_ptr<ewol::widget::Image> m_testWidget;
public: public:
// Constructeur // Constructeur
TestImage(); TestImage();
virtual ~TestImage(); void init();
public:
DECLARE_FACTORY(TestImage);
virtual ~TestImage() {};
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
};
}; };
#endif #endif

View File

@ -35,126 +35,123 @@ static const char * l_eventChangeLabel = "event-change-label";
#undef __class__ #undef __class__
#define __class__ "TestButton" #define __class__ "TestButton"
TestLabel::TestLabel() : appl::TestLabel::TestLabel() {
ewol::widget::Sizer(ewol::widget::Sizer::modeVert),
m_labelId(0) {
APPL_DEBUG("CREATE " __class__ " ... ");
addObjectType("appl::TestLabel"); addObjectType("appl::TestLabel");
ewol::object::Shared<ewol::widget::Sizer> mySizerVert2; }
ewol::object::Shared<ewol::widget::Sizer> mySizerHori;
ewol::object::Shared<ewol::widget::Button> myButton;
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); void appl::TestLabel::init() {
ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert);
APPL_DEBUG("CREATE " __class__ " ... ");
std::shared_ptr<ewol::widget::Sizer> mySizerVert2;
std::shared_ptr<ewol::widget::Sizer> mySizerHori;
std::shared_ptr<ewol::widget::Button> myButton;
mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand X (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expand X (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand X (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand X (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand Y (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Expand Y (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand Y (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand Y (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeExpendY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill X (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillX); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y (false)"))); myButton->setSubWidget( ewol::widget::Label::create("Fill Y (false)"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y (true)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y (true)"));
myButton->registerOnEvent(this, "value", l_eventChangeFillY); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setToggleMode(true); myButton->setToggleMode(true);
myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("no Max size"))); myButton->setSubWidget( ewol::widget::Label::create("no Max size"));
myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("maxSize (400,99999999)"))); myButton->setSubWidgetToggle(ewol::widget::Label::create("maxSize (400,99999999)"));
myButton->registerOnEvent(this, "value", l_eventChangeMaxSize); myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeMaxSize);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
myButton = ewol::object::makeShared(new ewol::widget::Button()); myButton = ewol::widget::Button::create();
if (nullptr != myButton) { if (nullptr != myButton) {
myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Next Label"))); myButton->setSubWidget(ewol::widget::Label::create("Next Label"));
myButton->registerOnEvent(this, "pressed", l_eventChangeLabel); myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeLabel);
mySizerHori->subWidgetAdd(myButton); mySizerHori->subWidgetAdd(myButton);
} }
ewol::object::Shared<ewol::widget::Spacer> mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); std::shared_ptr<ewol::widget::Spacer> mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0xFF000080); mySpacer->setColor(etk::Color<>(0xFF, 0x00, 0x00, 0x80));
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
APPL_DEBUG("Allocation error mySizerHori"); APPL_DEBUG("Allocation error mySizerHori");
return; return;
} }
subWidgetAdd(mySizerHori); subWidgetAdd(mySizerHori);
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x00FF0080); mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0x00, 0x80));
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
m_testWidget = ewol::object::makeShared(new ewol::widget::Label("Basic label")); m_testWidget = ewol::widget::Label::create("Basic label");
if (nullptr != m_testWidget) { if (nullptr != m_testWidget) {
m_testWidget->setExpand(bvec2(false,false)); m_testWidget->setExpand(bvec2(false,false));
m_testWidget->setFill(bvec2(false,false)); m_testWidget->setFill(bvec2(false,false));
//m_testWidget->registerOnEvent(this, ewolEventButtonColorChange); //m_testWidget->registerOnEvent(shared_from_this(), ewolEventButtonColorChange);
mySizerHori->subWidgetAdd(m_testWidget); mySizerHori->subWidgetAdd(m_testWidget);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(false,true)); mySpacer->setFill(bvec2(false,true));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x0000FF80); mySpacer->setColor(etk::Color<>(0x00, 0x00, 0xFF, 0x80));
mySizerHori->subWidgetAdd(mySpacer); mySizerHori->subWidgetAdd(mySpacer);
} }
mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); mySpacer = ewol::widget::Spacer::create();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));
mySpacer->setMinSize(vec2(10,10)); mySpacer->setMinSize(vec2(10,10));
mySpacer->setColor(0x00FFFF80); mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0xFF, 0x80));
subWidgetAdd(mySpacer); subWidgetAdd(mySpacer);
} }
} }
TestLabel::~TestLabel() { void appl::TestLabel::onReceiveMessage(const ewol::object::Message& _msg) {
}
void TestLabel::onReceiveMessage(const ewol::object::Message& _msg) {
ewol::widget::Sizer::onReceiveMessage(_msg); ewol::widget::Sizer::onReceiveMessage(_msg);
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (m_testWidget == _msg.getCaller()) { if (m_testWidget == _msg.getCaller()) {

View File

@ -16,21 +16,26 @@
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
#include <ewol/widget/Sizer.h> #include <ewol/widget/Sizer.h>
class TestLabel : public ewol::widget::Sizer { namespace appl {
class TestLabel : public ewol::widget::Sizer {
private: private:
ewol::object::Shared<ewol::widget::Label> m_testWidget; std::shared_ptr<ewol::widget::Label> m_testWidget;
int32_t m_labelId; int32_t m_labelId;
public: public:
/** /**
* @brief Constructeur * @brief Constructeur
*/ */
TestLabel(); TestLabel();
void init();
public:
DECLARE_FACTORY(TestLabel);
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~TestLabel(); virtual ~TestLabel() {};
public: // Derived function public: // Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual void onReceiveMessage(const ewol::object::Message& _msg);
};
}; };
#endif #endif

View File

@ -57,9 +57,9 @@ TestScene::TestScene() :
*/ */
APPL_CRITICAL("Create "__class__" (start)"); APPL_CRITICAL("Create "__class__" (start)");
ewol::object::Shared<ewol::widget::Sizer> mySizerVert2 = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerVert2 = nullptr;
ewol::object::Shared<ewol::widget::Sizer> mySizerHori = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerHori = nullptr;
ewol::object::Shared<ewol::widget::Button> myButton = nullptr; std::shared_ptr<ewol::widget::Button> myButton = nullptr;
/* /*
mySizerHori = new ewol::widget::SizerHori(); mySizerHori = new ewol::widget::SizerHori();
if (nullptr == mySizerHori) { if (nullptr == mySizerHori) {
@ -139,7 +139,7 @@ TestScene::TestScene() :
mySizerHori->SubWidgetAdd(myButton); mySizerHori->SubWidgetAdd(myButton);
} }
*/ */
ewol::object::Shared<ewol::widget::Spacer> mySpacer = new widget::Spacer(); std::shared_ptr<ewol::widget::Spacer> mySpacer = new widget::Spacer();
if (nullptr != mySpacer) { if (nullptr != mySpacer) {
mySpacer->setExpand(bvec2(false,false)); mySpacer->setExpand(bvec2(false,false));
mySpacer->setFill(bvec2(true,false)); mySpacer->setFill(bvec2(true,false));

View File

@ -16,7 +16,7 @@
class TestScene : public ewol::widget::Sizer { class TestScene : public ewol::widget::Sizer {
private: private:
ewol::object::Shared<ewol::widget::Scene> m_testWidget; std::shared_ptr<ewol::widget::Scene> m_testWidget;
public: public:
// Constructeur // Constructeur
TestScene(); TestScene();

View File

@ -39,7 +39,7 @@ class MainApplication : public ewol::context::Application {
// set the application icon ... // set the application icon ...
_context.setIcon("DATA:icon.png"); _context.setIcon("DATA:icon.png");
ewol::object::Shared<MainWindows> basicWindows = ewol::object::makeShared(new MainWindows()); std::shared_ptr<appl::MainWindows> basicWindows = appl::MainWindows::create();
if (basicWindows == nullptr) { if (basicWindows == nullptr) {
APPL_ERROR("Can not allocate the basic windows"); APPL_ERROR("Can not allocate the basic windows");
return false; return false;