[DOC] better compleate doc

This commit is contained in:
Edouard DUPIN 2016-03-24 21:54:13 +01:00
parent d82ea4335e
commit a1e59a95e3
6 changed files with 125 additions and 26 deletions

View File

@ -82,7 +82,7 @@ Then for basic resource:
[code style=c++]
#include <ewol/object/Resource.h>
namespace appl {
class MyResource : public ewol::Resource {
class MyResource : public gale::Resource {
protected:
//! @brief Constructor
MyResource() :

View File

@ -12,20 +12,58 @@ The first things to do is to choice a methode to display you widget:
#include <ewol/widget/Widget.h>
namespace appl {
class myWidget : public ewol::Widget {
private:
ewol::compositing::Drawing m_draw; //!< simple openGL drawing tool
public:
myWidget(void) {};
~myWidget(void) {};
public: // herited function
void draw(void);
void onDraw(void);
void onRegenerateDisplay(void);
}
}
[/code]
We can show that we had two function, the first is call every time we render the widget (as the number of fps) "draw()".
We can show that we have two function, the first is call every time we render the widget (as the number of fps) "onDraw()".
And the second that is call only when we need to redraw the widget (after the user call markToRedraw() ) "onRegenerateDisplay()".
===basic code===
we can define some basic functions:
The constructor:
[code style=c++]
appl::myWidget::myWidget() {
addObjectType("appl::widget::VectorDisplay");
}
[/code]
The draw function:
[code style=c++]
void appl::myWidget::onDraw() {
m_draw.draw();
}
[/code]
The drawing area function (where we create the patern.).
[code style=c++]
void appl::myWidget::onRegenerateDisplay() {
//!< Check if we really need to redraw the display, if not needed, we redraw the previous data ...
if (needRedraw() == false) {
return;
}
// remove previous data
m_draw.clear();
// set background
m_draw.setColor(etk::color::black);
m_draw.setPos(vec2(0,0));
m_draw.rectangleWidth(m_size);
m_draw.setColor(etk::color::green);
m_draw.setPos(m_size*0.2);
m_draw.rectangleWidth(m_size*0.5);
}
[/code]
A more complex sample is availlable in [b]"ewol-sample-CustomWidget"[/b]

View File

@ -5,11 +5,69 @@ Object can be declared in some XML, (like gui decription), then we need to decla
=== Declare Object ===
The fist step is to add a methode to create the object
In your application "void onCreate(ewol::Context& _context) override" add the function:
[code style=c++]
YourWidgetClass::createManagerWidget(_context.getWidgetManager());
[/code]
The simple question is: I does not define this function, where it is done ?
The createManagerWidget is instancuate when you use the macro:
[code style=c++]
DECLARE_WIDGET_FACTORY(YourWidgetClass, "YourWidgetClass");
[/code]
it create 2 function: "create(...)" and "createManagerWidget()"
=== Declare on XML and configuration ===
in the xml instance simply request it like:
[code style=xml]
<YourWidgetClass name="jkjkj">
...
</YourWidgetClass>
[/code]
The xml attribute are automaticaly parsed to configure properties of you object (this is the reason of naming it).
=== Special case SubParsing XML element ===
If you want to parse sub-node of the xml just override the function member:
[code style=c++]
bool loadXML(const std::shared_ptr<const exml::Element>& _node) override;
[/code]
Many example are availlable in container widget.
Simple example:
[code style=c++]
if (_node == nullptr) {
return false;
}
// parse generic properties:
ewol::Widget::loadXML(_node);
// parse all the elements:
for (size_t iii=0; iii < _node->size(); iii++) {
std::shared_ptr<const exml::Element> pNode = _node->getElement(iii);
if (pNode == nullptr) {
// trash here all that is not element
continue;
}
// Get the sub-node name:
std::string widgetName = pNode->getValue();
if (getWidgetManager().exist(widgetName) == false) {
APPL_ERROR("[" << getId() << "] (l "<<pNode->getPos()<<") Unknown basic node='" << widgetName << "' not in : [" << getWidgetManager().list() << "]" );
continue;
}
...
}
return true;
[/code]

View File

@ -39,11 +39,11 @@ namespace ewol {
* // no need of this event watching ...
* tmpWidget->signalCancel.connect(shared_from_this(), &****::onCallbackClosePopUp);
* // set the title:
* tmpWidget->setTitle("Open files ...");
* tmpWidget->propertyLabelTitle.set("Open files ...");
* // Set the validate Label:
* tmpWidget->setValidateLabel("Open");
* tmpWidget->propertyLabelValidate.set("Open");
* // simply set a folder (by default this is the home folder)
* //tmpWidget->setFolder("/home/me");
* //tmpWidget->propertyPath.set("/home/me");
* // add the widget as windows pop-up ...
* ewol::widget::WindowsShared tmpWindows = getWindows();
* if (tmpWindows == nullptr) {
@ -67,14 +67,14 @@ namespace ewol {
*/
class FileChooser : public ewol::widget::Composer {
public: // signals
esignal::ISignal<> signalCancel;
esignal::ISignal<std::string> signalValidate;
esignal::ISignal<> signalCancel; //!< abort the display of the pop-up or press cancel button
esignal::ISignal<std::string> signalValidate; //!< select file(s)
public: // properties
eproperty::Value<std::string> propertyPath;
eproperty::Value<std::string> propertyFile;
eproperty::Value<std::string> propertyLabelTitle;
eproperty::Value<std::string> propertyLabelValidate;
eproperty::Value<std::string> propertyLabelCancel;
eproperty::Value<std::string> propertyPath; //!< Current path to explore
eproperty::Value<std::string> propertyFile; //!< Selected file
eproperty::Value<std::string> propertyLabelTitle; //!< Label of the pop-up (can use translation)
eproperty::Value<std::string> propertyLabelValidate; //!< Label of validate button of the pop-up (can use translation)
eproperty::Value<std::string> propertyLabelCancel; //!< Label of cancel/close button of the pop-up (can use translation)
protected:
FileChooser();
void init() override;

View File

@ -22,6 +22,8 @@ appl::widget::VectorDisplay::VectorDisplay() :
void appl::widget::VectorDisplay::init() {
ewol::Widget::init();
markToRedraw();
// set call all time (sample ...).
getObjectManager().periodicCall.connect(shared_from_this(), &appl::widget::VectorDisplay::periodicEvent);
}
@ -37,10 +39,8 @@ void appl::widget::VectorDisplay::setValue(const std::vector<float>& _data) {
void appl::widget::VectorDisplay::ToggleAuto() {
if (m_autoDisplay == false) {
periodicCallEnable();
m_autoDisplay = true;
} else {
periodicCallDisable();
m_autoDisplay = false;
}
}
@ -79,7 +79,10 @@ void appl::widget::VectorDisplay::onRegenerateDisplay() {
}
}
void appl::widget::VectorDisplay::periodicCall(const ewol::event::Time& _event) {
void appl::widget::VectorDisplay::periodicEvent(const ewol::event::Time& _event) {
if (m_autoDisplay == false) {
return;
}
for (size_t iii=0; iii<std::max(m_data.size()/200.0f, 50.0f); ++iii) {
if (m_data.size() > 50) {
m_data.erase(m_data.begin());

View File

@ -12,7 +12,7 @@
namespace appl {
namespace widget {
class VectorDisplay : public ewol::Widget {
private:
protected:
ewol::compositing::Drawing m_draw; //!< drawing instance
protected:
//! @brief constructor
@ -22,21 +22,21 @@ namespace appl {
DECLARE_WIDGET_FACTORY(VectorDisplay, "VectorDisplay");
//! @brief destructor
virtual ~VectorDisplay();
private:
protected:
std::vector<float> m_data; //!< data that might be displayed
public:
void setValue(const std::vector<float>& _data);
private:
protected:
bool m_autoDisplay;
public:
void ToggleAuto();
private:
protected:
float m_minVal; //!< display minimum value
float m_maxVal; //!< display maximum value
public: // herited function
virtual void onDraw();
virtual void onRegenerateDisplay();
virtual void periodicCall(const ewol::event::Time& _event);
public:
void onDraw() override;
void onRegenerateDisplay() override;
void periodicEvent(const ewol::event::Time& _event);
};
}
}