From 00a225c37953554b3691ad2ef9fb3895c87ba5b8 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 19 Aug 2014 19:01:57 +0200 Subject: [PATCH] [DEV] update to the ewol interface --- sources/appl/MainWindows.cpp | 76 ++++++++++-------------- sources/appl/MainWindows.h | 31 +++++----- sources/appl/TestButton.cpp | 46 +++++++-------- sources/appl/TestButton.h | 5 +- sources/appl/TestButtonColor.cpp | 79 +++++++++++++------------ sources/appl/TestButtonColor.h | 23 +++++--- sources/appl/TestCheckBox.cpp | 30 +++++----- sources/appl/TestCheckBox.h | 5 +- sources/appl/TestDistanceField.cpp | 21 ++++--- sources/appl/TestDistanceField.h | 31 +++++----- sources/appl/TestImage.cpp | 78 ++++++++++++------------- sources/appl/TestImage.h | 23 +++++--- sources/appl/TestLabel.cpp | 93 +++++++++++++++--------------- sources/appl/TestLabel.h | 35 ++++++----- sources/appl/TestScene.cpp | 8 +-- sources/appl/TestScene.h | 2 +- sources/appl/init.cpp | 2 +- 17 files changed, 299 insertions(+), 289 deletions(-) diff --git a/sources/appl/MainWindows.cpp b/sources/appl/MainWindows.cpp index 8dbd75c..7f4489a 100644 --- a/sources/appl/MainWindows.cpp +++ b/sources/appl/MainWindows.cpp @@ -41,53 +41,55 @@ static const char * l_eventChangeWidgetPrevious = "event-change-widget-test-pre #undef __class__ #define __class__ "MainWindows" -MainWindows::MainWindows() : - m_idWidget(0), - m_subWidget(nullptr), - m_testName(nullptr) { +appl::MainWindows::MainWindows() : + m_idWidget(0) { APPL_DEBUG("CREATE WINDOWS ... "); addObjectType("appl::MainWindows"); - ewol::object::Shared mySizerHori = nullptr; - ewol::object::Shared myButton = nullptr; +} + +void appl::MainWindows::init() { + ewol::widget::Windows::init(); + std::shared_ptr mySizerHori = nullptr; + std::shared_ptr myButton = nullptr; - m_sizerVert = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeVert)); + m_sizerVert = ewol::widget::Sizer::create(ewol::widget::Sizer::modeVert); if (nullptr == m_sizerVert) { APPL_DEBUG("Allocation error mySizerVert"); return; } 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } m_sizerVert->subWidgetAdd(mySizerHori); - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { - myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("default theme (cube)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("rounded theme"))); + myButton->setSubWidget(ewol::widget::Label::create("default theme (cube)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("rounded theme")); myButton->setToggleMode(true); - myButton->registerOnEvent(this, "value", l_eventChangeTheme); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeTheme); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { - myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Previous Widget test"))); - myButton->registerOnEvent(this, "pressed", l_eventChangeWidgetPrevious); + myButton->setSubWidget(ewol::widget::Label::create("Previous Widget test")); + myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeWidgetPrevious); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { - myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Next Widget test"))); - myButton->registerOnEvent(this, "pressed", l_eventChangeWidgetNext); + myButton->setSubWidget(ewol::widget::Label::create("Next Widget test")); + myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeWidgetNext); mySizerHori->subWidgetAdd(myButton); } - m_testName = new ewol::widget::Label("none"); + m_testName = ewol::widget::Label::create("none"); if (nullptr != m_testName) { mySizerHori->subWidgetAdd(m_testName); } - ewol::object::Shared mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); @@ -100,12 +102,8 @@ MainWindows::MainWindows() : onReceiveMessage(msg); } -MainWindows::~MainWindows() { - -} - -void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { - if( _msg.getCaller() != ewol::object::Shared(this) +void appl::MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { + if( _msg.getCaller() != std::shared_ptr(this) && _msg.getCaller() != nullptr) { ewol::widget::Windows::onReceiveMessage(_msg); } @@ -127,7 +125,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } if (m_subWidget != nullptr) { - m_subWidget->removeObject(); + m_subWidget->destroy(); // in theory it must be removed ... m_subWidget.reset(); } @@ -137,7 +135,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } switch(m_idWidget) { case 0: - m_subWidget = ewol::object::makeShared(new appl::TestButton()); + m_subWidget = appl::TestButton::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -146,7 +144,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; case 1: - m_subWidget = ewol::object::makeShared(new TestDistanceField()); + m_subWidget = TestDistanceField::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -155,7 +153,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; case 2: - m_subWidget = ewol::object::makeShared(new TestButtonColor()); + m_subWidget = TestButtonColor::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -164,7 +162,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; case 3: - m_subWidget = ewol::object::makeShared(new TestLabel()); + m_subWidget = TestLabel::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -173,7 +171,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; case 4: - m_subWidget = ewol::object::makeShared(new TestImage()); + m_subWidget = TestImage::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -182,7 +180,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; case 5: - m_subWidget = ewol::object::makeShared(new appl::TestCheckBox()); + m_subWidget = appl::TestCheckBox::create(); if (nullptr != m_subWidget) { m_sizerVert->subWidgetAdd(m_subWidget); } @@ -191,7 +189,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; break; 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) { m_subWidget->setExpand(bvec2(true,true)); m_sizerVert->subWidgetAdd(m_subWidget); @@ -201,16 +199,6 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { }; m_idWidget = -1; 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; - */ } } diff --git a/sources/appl/MainWindows.h b/sources/appl/MainWindows.h index 83064da..d3e54b2 100644 --- a/sources/appl/MainWindows.h +++ b/sources/appl/MainWindows.h @@ -16,21 +16,24 @@ #include #include #include - -class MainWindows : public ewol::widget::Windows { - private: - ewol::object::Shared m_sizerVert; - ewol::object::Shared m_subWidget; - ewol::object::Shared m_testName; - int32_t m_idWidget; - public: - // Constructeur - MainWindows(); - ~MainWindows(); - public: // derived fuction - virtual void onReceiveMessage(const ewol::object::Message& _msg); +namespace appl { + class MainWindows : public ewol::widget::Windows { + private: + std::shared_ptr m_sizerVert; + std::shared_ptr m_subWidget; + std::shared_ptr m_testName; + int32_t m_idWidget; + public: + // Constructeur + MainWindows(); + void init(); + public: + DECLARE_FACTORY(MainWindows); + ~MainWindows() {}; + public: // derived fuction + virtual void onReceiveMessage(const ewol::object::Message& _msg); + }; }; - #endif diff --git a/sources/appl/TestButton.cpp b/sources/appl/TestButton.cpp index d7ff014..9fd0bdb 100644 --- a/sources/appl/TestButton.cpp +++ b/sources/appl/TestButton.cpp @@ -39,10 +39,13 @@ static const char * l_eventChangeImageToggle = "event-change-image-toggle"; #undef __class__ #define __class__ "TestButton" -appl::TestButton::TestButton() : - m_testWidget(nullptr) { - APPL_INFO("Create " __class__ " (start)"); +appl::TestButton::TestButton() { addObjectType("appl::TestButton"); +} + +void appl::TestButton::init() { + ewol::widget::Composer::init(); + APPL_INFO("Create " __class__ " (start)"); std::string myDescription = std::string("") + "\n" @@ -101,7 +104,7 @@ appl::TestButton::TestButton() : registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText); // show all event from a button : registerOnEventNameWidget("[TEST]Button:TO-TEST", "*"); - m_testWidget = ewol::dynamic_pointer_cast(getWidgetNamed("[TEST]Button:TO-TEST")); + m_testWidget = std::dynamic_pointer_cast(getWidgetNamed("[TEST]Button:TO-TEST")); if (m_testWidget == nullptr) { 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) { if (nullptr!=m_testWidget) { if (_msg.getData()=="true") { - m_testWidget->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("A stupid very long text on toggle

and on multiple lines"))); + m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle

and on multiple lines")); } else { m_testWidget->setSubWidgetToggle(nullptr); } @@ -169,55 +172,50 @@ void appl::TestButton::onReceiveMessage(const ewol::object::Message& _msg) { static int32_t countTextID = 1; switch (countTextID) { case 0: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text")); break; case 1: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Align Left"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("Align Left")); break; case 2: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Align right"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("Align right")); break; case 3: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("
Align center
"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("
Align center
")); break; case 4: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text
With Some Other Lines
and more if you want ...
plop"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text
With Some Other Lines
and more if you want ...
plop")); break; case 5: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with bold"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with bold")); break; case 6: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with italic"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic")); break; case 7: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with italic bold"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic bold")); break; case 8: m_testWidget->setSubWidget(nullptr); break; case 9: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with colored text"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with colored text")); break; case 10: - m_testWidget->setSubWidget(ewol::object::makeShared( - new ewol::widget::Composer(ewol::widget::Composer::String, - "\n"))); + m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "\n")); break; case 11: - m_testWidget->setSubWidget(ewol::object::makeShared( - new ewol::widget::Composer(ewol::widget::Composer::String, + m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, " \n" " \n" " \n" - " \n"))); + "
\n")); break; case 12: - m_testWidget->setSubWidget(ewol::object::makeShared( - new ewol::widget::Composer(ewol::widget::Composer::String, - "\n"))); + m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "\n")); break; default: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("My Button
And Some under line
plop
and an other super long line ..."))); + m_testWidget->setSubWidget(ewol::widget::Label::create("My Button
And Some under line
plop
and an other super long line ...")); countTextID=-1; break; } diff --git a/sources/appl/TestButton.h b/sources/appl/TestButton.h index 685d9aa..5bc1ce4 100644 --- a/sources/appl/TestButton.h +++ b/sources/appl/TestButton.h @@ -15,10 +15,13 @@ namespace appl { class TestButton : public ewol::widget::Composer { private: - ewol::object::Shared m_testWidget; + std::shared_ptr m_testWidget; public: // Constructeur TestButton(); + void init(); + public: + DECLARE_FACTORY(TestButton); public: // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); }; diff --git a/sources/appl/TestButtonColor.cpp b/sources/appl/TestButtonColor.cpp index 31347cf..1dd07a6 100644 --- a/sources/appl/TestButtonColor.cpp +++ b/sources/appl/TestButtonColor.cpp @@ -33,109 +33,108 @@ static const char * l_eventChangeFillY = "event-change-fill-Y"; #undef __class__ #define __class__ "TestButton" -TestButtonColor::TestButtonColor() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert), - m_testWidget(nullptr) { - APPL_INFO("CREATE " __class__ " ... "); +appl::TestButtonColor::TestButtonColor() { addObjectType("appl::TestButtonColor"); - ewol::object::Shared mySizerVert2; - ewol::object::Shared mySizerHori; - ewol::object::Shared myButton; +} + +void appl::TestButtonColor::init() { + ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); + APPL_INFO("CREATE " __class__ " ... "); - mySizerHori = ewol::object::makeShared(new ewol::widget::Sizer(ewol::widget::Sizer::modeHori)); + std::shared_ptr mySizerVert2; + std::shared_ptr mySizerHori; + std::shared_ptr myButton; + + mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); if (nullptr == mySizerHori) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand X (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand X (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendX); + myButton->setSubWidget( ewol::widget::Label::create("Expand X (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand X (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand Y (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand Y (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendY); + myButton->setSubWidget( ewol::widget::Label::create("Expand Y (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand Y (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillX); + myButton->setSubWidget( ewol::widget::Label::create("Fill X (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillY); + myButton->setSubWidget( ewol::widget::Label::create("Fill Y (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY); mySizerHori->subWidgetAdd(myButton); } - ewol::object::Shared mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0xFF000080); + mySpacer->setColor(etk::Color<>(0xFF, 0x00, 0x00, 0x80)); 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FF0080); + mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0x00, 0x80)); 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) { m_testWidget->setExpand(bvec2(false,false)); m_testWidget->setFill(bvec2(false,false)); - m_testWidget->registerOnEvent(this, "*"); + m_testWidget->registerOnEvent(shared_from_this(), "*"); mySizerHori->subWidgetAdd(m_testWidget); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x0000FF80); + mySpacer->setColor(etk::Color<>(0x00, 0x00, 0xFF, 0x80)); mySizerHori->subWidgetAdd(mySpacer); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FFFF80); + mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0xFF, 0x80)); subWidgetAdd(mySpacer); } } -TestButtonColor::~TestButtonColor() { - -} - -void TestButtonColor::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::TestButtonColor::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::Sizer::onReceiveMessage(_msg); //APPL_INFO("Receive Event from the main windows : " << _msg); if (m_testWidget == _msg.getCaller()) { diff --git a/sources/appl/TestButtonColor.h b/sources/appl/TestButtonColor.h index 0691b6c..04dd217 100644 --- a/sources/appl/TestButtonColor.h +++ b/sources/appl/TestButtonColor.h @@ -16,15 +16,20 @@ #include #include -class TestButtonColor : public ewol::widget::Sizer { - private: - ewol::object::Shared m_testWidget; - public: - // Constructeur - TestButtonColor(); - virtual ~TestButtonColor(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); +namespace appl { + class TestButtonColor : public ewol::widget::Sizer { + private: + std::shared_ptr m_testWidget; + public: + // Constructeur + TestButtonColor(); + void init(); + public: + DECLARE_FACTORY(TestButtonColor); + virtual ~TestButtonColor() {}; + public: // Derived function + virtual void onReceiveMessage(const ewol::object::Message& _msg); + }; }; #endif diff --git a/sources/appl/TestCheckBox.cpp b/sources/appl/TestCheckBox.cpp index 3acf2ce..e47ffbe 100644 --- a/sources/appl/TestCheckBox.cpp +++ b/sources/appl/TestCheckBox.cpp @@ -39,10 +39,14 @@ static const char * l_eventChangeImageToggle = "event-change-image-toggle"; #undef __class__ #define __class__ "TestCheckBox" -appl::TestCheckBox::TestCheckBox() : - m_testWidget(nullptr) { - APPL_INFO("Create " __class__ " (start)"); +appl::TestCheckBox::TestCheckBox() { addObjectType("appl::TestCheckBox"); +} + +void appl::TestCheckBox::init() { + ewol::widget::Composer::init(); + + APPL_INFO("Create " __class__ " (start)"); std::string myDescription = std::string("") + "\n" @@ -101,7 +105,7 @@ appl::TestCheckBox::TestCheckBox() : registerOnEventNameWidget("[TEST]Button:ChangeText", "pressed", l_eventChangeText); // show all event from a button : registerOnEventNameWidget("[TEST]TO-TEST", "*"); - m_testWidget = ewol::dynamic_pointer_cast(getWidgetNamed("[TEST]TO-TEST")); + m_testWidget = std::dynamic_pointer_cast(getWidgetNamed("[TEST]TO-TEST")); if (m_testWidget == nullptr) { 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) { if (nullptr!=m_testWidget) { if (_msg.getData()=="true") { - m_testWidget->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("A stupid very long text on toggle

and on multiple lines"))); + m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle

and on multiple lines")); } else { m_testWidget->setSubWidgetToggle(nullptr); } @@ -159,28 +163,28 @@ void appl::TestCheckBox::onReceiveMessage(const ewol::object::Message& _msg) { static int32_t countTextID = 1; switch (countTextID) { case 0: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text")); break; case 1: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Align Left"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("Align Left")); break; case 2: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Align right"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("Align right")); break; case 3: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("
Align center
"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("
Align center
")); break; case 4: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text
With Some Other Lines
and more if you want ...
plop"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text
With Some Other Lines
and more if you want ...
plop")); break; case 5: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with bold"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with bold")); break; case 6: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with italic"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic")); break; case 7: - m_testWidget->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("simple Text with italic bold"))); + m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic bold")); break; case 8: m_testWidget->setSubWidget(nullptr); diff --git a/sources/appl/TestCheckBox.h b/sources/appl/TestCheckBox.h index 0387f3c..257678b 100644 --- a/sources/appl/TestCheckBox.h +++ b/sources/appl/TestCheckBox.h @@ -16,10 +16,13 @@ namespace appl { class TestCheckBox : public ewol::widget::Composer { private: - ewol::object::Shared m_testWidget; + std::shared_ptr m_testWidget; public: // Constructeur TestCheckBox(); + void init(); + public: + DECLARE_FACTORY(TestCheckBox); public: // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); }; diff --git a/sources/appl/TestDistanceField.cpp b/sources/appl/TestDistanceField.cpp index f1afee6..66e605d 100644 --- a/sources/appl/TestDistanceField.cpp +++ b/sources/appl/TestDistanceField.cpp @@ -28,8 +28,12 @@ #undef __class__ #define __class__ "TestDistanceField" -TestDistanceField::TestDistanceField(){ +appl::TestDistanceField::TestDistanceField(){ addObjectType("appl::TestDistanceField"); +} + +void appl::TestDistanceField::init() { + ewol::Widget::init(); APPL_INFO("Create " __class__ " (start)"); setExpand(bvec2(true, true)); setFill(bvec2(true, true)); @@ -37,24 +41,19 @@ TestDistanceField::TestDistanceField(){ } -TestDistanceField::~TestDistanceField() { - APPL_INFO("Remove " __class__ " ..."); -} - - -void TestDistanceField::calculateSize(const vec2& _availlable) { +void appl::TestDistanceField::calculateSize(const vec2& _availlable) { // set minimal size m_size = _availlable; } -void TestDistanceField::calculateMinMaxSize() { +void appl::TestDistanceField::calculateMinMaxSize() { m_minSize = vec2(256,256); markToRedraw(); } -void TestDistanceField::onDraw() { +void appl::TestDistanceField::onDraw() { m_text2.draw(); m_text1.draw(); @@ -62,7 +61,7 @@ void TestDistanceField::onDraw() { -void TestDistanceField::onRegenerateDisplay() { +void appl::TestDistanceField::onRegenerateDisplay() { if (false == needRedraw()) { 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) { setZoom(getZoom() + 0.01f); } else if (_event.getId() == 5) { diff --git a/sources/appl/TestDistanceField.h b/sources/appl/TestDistanceField.h index 70b0bef..d657295 100644 --- a/sources/appl/TestDistanceField.h +++ b/sources/appl/TestDistanceField.h @@ -16,19 +16,24 @@ #include #include -class TestDistanceField : public ewol::Widget { - ewol::compositing::Text m_text1; - ewol::compositing::TextDF m_text2; - public: - // Constructeur - 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); +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); + }; }; #endif diff --git a/sources/appl/TestImage.cpp b/sources/appl/TestImage.cpp index e7a6ee5..cf40afa 100644 --- a/sources/appl/TestImage.cpp +++ b/sources/appl/TestImage.cpp @@ -35,68 +35,69 @@ static const char * l_eventChangeImage = "event-change-image"; #undef __class__ #define __class__ "TestImage" -TestImage::TestImage() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert), - m_testWidget(nullptr) { - APPL_INFO("Create " __class__ " (start)"); +appl::TestImage::TestImage() { addObjectType("appl::TestImage"); - ewol::object::Shared mySizerVert2; - ewol::object::Shared mySizerHori; - ewol::object::Shared myButton; +} +void appl::TestImage::init() { + ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); + APPL_INFO("Create " __class__ " (start)"); + std::shared_ptr mySizerVert2; + std::shared_ptr mySizerHori; + std::shared_ptr 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expend X
(false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expend X
(true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendX); + myButton->setSubWidget( ewol::widget::Label::create("Expend X
(false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expend X
(true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expend Y
(false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expend Y
(true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendY); + myButton->setSubWidget( ewol::widget::Label::create("Expend Y
(false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expend Y
(true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY); 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X
(false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X
(true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillX); + myButton->setSubWidget( ewol::widget::Label::create("Fill X
(false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X
(true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y
(false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y
(true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillY); + myButton->setSubWidget( ewol::widget::Label::create("Fill Y
(false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y
(true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { - myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Change Image"))); - myButton->registerOnEvent(this, "value", l_eventChangeImage); + myButton->setSubWidget(ewol::widget::Label::create("Change Image")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeImage); mySizerHori->subWidgetAdd(myButton); } - ewol::object::Shared mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); @@ -105,14 +106,14 @@ TestImage::TestImage() : 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); @@ -121,15 +122,15 @@ TestImage::TestImage() : 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) { m_testWidget->setExpand(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); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); @@ -138,7 +139,7 @@ TestImage::TestImage() : mySizerHori->subWidgetAdd(mySpacer); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); @@ -150,12 +151,7 @@ TestImage::TestImage() : } -TestImage::~TestImage() { - APPL_INFO("Remove " __class__ " ..."); -} - - -void TestImage::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::TestImage::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::Sizer::onReceiveMessage(_msg); //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); if (m_testWidget == _msg.getCaller()) { diff --git a/sources/appl/TestImage.h b/sources/appl/TestImage.h index 506941f..a0b642a 100644 --- a/sources/appl/TestImage.h +++ b/sources/appl/TestImage.h @@ -16,15 +16,20 @@ #include #include -class TestImage : public ewol::widget::Sizer { - private: - ewol::object::Shared m_testWidget; - public: - // Constructeur - TestImage(); - virtual ~TestImage(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); +namespace appl { + class TestImage : public ewol::widget::Sizer { + private: + std::shared_ptr m_testWidget; + public: + // Constructeur + TestImage(); + void init(); + public: + DECLARE_FACTORY(TestImage); + virtual ~TestImage() {}; + public: // Derived function + virtual void onReceiveMessage(const ewol::object::Message& _msg); + }; }; #endif diff --git a/sources/appl/TestLabel.cpp b/sources/appl/TestLabel.cpp index ad0d483..2f7ada3 100644 --- a/sources/appl/TestLabel.cpp +++ b/sources/appl/TestLabel.cpp @@ -35,126 +35,123 @@ static const char * l_eventChangeLabel = "event-change-label"; #undef __class__ #define __class__ "TestButton" -TestLabel::TestLabel() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert), - m_labelId(0) { - APPL_DEBUG("CREATE " __class__ " ... "); +appl::TestLabel::TestLabel() { addObjectType("appl::TestLabel"); - ewol::object::Shared mySizerVert2; - ewol::object::Shared mySizerHori; - ewol::object::Shared myButton; +} + +void appl::TestLabel::init() { + ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); + APPL_DEBUG("CREATE " __class__ " ... "); + std::shared_ptr mySizerVert2; + std::shared_ptr mySizerHori; + std::shared_ptr 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand X (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand X (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendX); + myButton->setSubWidget( ewol::widget::Label::create("Expand X (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand X (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Expand Y (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Expand Y (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeExpendY); + myButton->setSubWidget( ewol::widget::Label::create("Expand Y (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Expand Y (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeExpendY); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill X (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill X (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillX); + myButton->setSubWidget( ewol::widget::Label::create("Fill X (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill X (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillX); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("Fill Y (false)"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("Fill Y (true)"))); - myButton->registerOnEvent(this, "value", l_eventChangeFillY); + myButton->setSubWidget( ewol::widget::Label::create("Fill Y (false)")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("Fill Y (true)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeFillY); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { myButton->setToggleMode(true); - myButton->setSubWidget( ewol::object::makeShared(new ewol::widget::Label("no Max size"))); - myButton->setSubWidgetToggle(ewol::object::makeShared(new ewol::widget::Label("maxSize (400,99999999)"))); - myButton->registerOnEvent(this, "value", l_eventChangeMaxSize); + myButton->setSubWidget( ewol::widget::Label::create("no Max size")); + myButton->setSubWidgetToggle(ewol::widget::Label::create("maxSize (400,99999999)")); + myButton->registerOnEvent(shared_from_this(), "value", l_eventChangeMaxSize); mySizerHori->subWidgetAdd(myButton); } - myButton = ewol::object::makeShared(new ewol::widget::Button()); + myButton = ewol::widget::Button::create(); if (nullptr != myButton) { - myButton->setSubWidget(ewol::object::makeShared(new ewol::widget::Label("Next Label"))); - myButton->registerOnEvent(this, "pressed", l_eventChangeLabel); + myButton->setSubWidget(ewol::widget::Label::create("Next Label")); + myButton->registerOnEvent(shared_from_this(), "pressed", l_eventChangeLabel); mySizerHori->subWidgetAdd(myButton); } - ewol::object::Shared mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0xFF000080); + mySpacer->setColor(etk::Color<>(0xFF, 0x00, 0x00, 0x80)); 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) { APPL_DEBUG("Allocation error mySizerHori"); return; } subWidgetAdd(mySizerHori); - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FF0080); + mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0x00, 0x80)); 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) { m_testWidget->setExpand(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); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(false,true)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x0000FF80); + mySpacer->setColor(etk::Color<>(0x00, 0x00, 0xFF, 0x80)); mySizerHori->subWidgetAdd(mySpacer); } - mySpacer = ewol::object::makeShared(new ewol::widget::Spacer()); + mySpacer = ewol::widget::Spacer::create(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FFFF80); + mySpacer->setColor(etk::Color<>(0x00, 0xFF, 0xFF, 0x80)); subWidgetAdd(mySpacer); } } -TestLabel::~TestLabel() { - -} - - -void TestLabel::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::TestLabel::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::Sizer::onReceiveMessage(_msg); //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); if (m_testWidget == _msg.getCaller()) { diff --git a/sources/appl/TestLabel.h b/sources/appl/TestLabel.h index 3b6c964..d52f397 100644 --- a/sources/appl/TestLabel.h +++ b/sources/appl/TestLabel.h @@ -16,21 +16,26 @@ #include #include -class TestLabel : public ewol::widget::Sizer { - private: - ewol::object::Shared m_testWidget; - int32_t m_labelId; - public: - /** - * @brief Constructeur - */ - TestLabel(); - /** - * @brief Destructor - */ - virtual ~TestLabel(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); +namespace appl { + class TestLabel : public ewol::widget::Sizer { + private: + std::shared_ptr m_testWidget; + int32_t m_labelId; + public: + /** + * @brief Constructeur + */ + TestLabel(); + void init(); + public: + DECLARE_FACTORY(TestLabel); + /** + * @brief Destructor + */ + virtual ~TestLabel() {}; + public: // Derived function + virtual void onReceiveMessage(const ewol::object::Message& _msg); + }; }; #endif diff --git a/sources/appl/TestScene.cpp b/sources/appl/TestScene.cpp index a357290..11bf4d1 100644 --- a/sources/appl/TestScene.cpp +++ b/sources/appl/TestScene.cpp @@ -57,9 +57,9 @@ TestScene::TestScene() : */ APPL_CRITICAL("Create "__class__" (start)"); - ewol::object::Shared mySizerVert2 = nullptr; - ewol::object::Shared mySizerHori = nullptr; - ewol::object::Shared myButton = nullptr; + std::shared_ptr mySizerVert2 = nullptr; + std::shared_ptr mySizerHori = nullptr; + std::shared_ptr myButton = nullptr; /* mySizerHori = new ewol::widget::SizerHori(); if (nullptr == mySizerHori) { @@ -139,7 +139,7 @@ TestScene::TestScene() : mySizerHori->SubWidgetAdd(myButton); } */ - ewol::object::Shared mySpacer = new widget::Spacer(); + std::shared_ptr mySpacer = new widget::Spacer(); if (nullptr != mySpacer) { mySpacer->setExpand(bvec2(false,false)); mySpacer->setFill(bvec2(true,false)); diff --git a/sources/appl/TestScene.h b/sources/appl/TestScene.h index 99b26a9..67c2fa4 100644 --- a/sources/appl/TestScene.h +++ b/sources/appl/TestScene.h @@ -16,7 +16,7 @@ class TestScene : public ewol::widget::Sizer { private: - ewol::object::Shared m_testWidget; + std::shared_ptr m_testWidget; public: // Constructeur TestScene(); diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 1c310e3..93ff8a7 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -39,7 +39,7 @@ class MainApplication : public ewol::context::Application { // set the application icon ... _context.setIcon("DATA:icon.png"); - ewol::object::Shared basicWindows = ewol::object::makeShared(new MainWindows()); + std::shared_ptr basicWindows = appl::MainWindows::create(); if (basicWindows == nullptr) { APPL_ERROR("Can not allocate the basic windows"); return false;