[DEV] start to reworks the widget class to simplify and normalize it (last rework)

This commit is contained in:
Edouard DUPIN 2013-04-09 21:17:47 +02:00
parent 56eafd762f
commit 100fbd43e2
48 changed files with 1066 additions and 619 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 64812713c7bfa87ab1f3368cf58cca7d6d996007
Subproject commit f9951e9f5566eca104348a1bbf84f5721f5ce63d

View File

@ -576,8 +576,8 @@ void eSystem::ForceRedrawAll(void)
{
ewol::Windows* tmpWindows = eSystem::GetCurrentWindows();
if (NULL != tmpWindows) {
ivec2 tmpSize = eSystem::GetSize();
tmpWindows->CalculateSize(tmpSize.x(), tmpSize.y());
ivec2 systemSize = eSystem::GetSize();
tmpWindows->CalculateSize(vec2(systemSize.x(), systemSize.y()));
}
}

View File

@ -29,6 +29,23 @@ extern const char * const ewolEventButtonValue = "ewol-button-value";
#define STATUS_DOWN (3)
static ewol::Widget* Create(void)
{
return new widget::Button();
}
void widget::Button::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Button::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Button::Button(const etk::UString& shaperName) :
m_shaper(shaperName),
m_toggleMode(false),
@ -68,16 +85,9 @@ void widget::Button::SetShaperName(const etk::UString& shaperName)
m_shaper.SetSource(shaperName);
}
void widget::Button::SetSubWidget(ewol::Widget* subWidget, bool forToggle)
void widget::Button::SetSubWidget(ewol::Widget* subWidget)
{
if (subWidget==NULL) {
EWOL_WARNING("try to set an empty widget in the Button entity");
return;
}
int32_t idWidget=0;
if (forToggle==true) {
idWidget = 1;
}
if (NULL!=m_subWidget[idWidget]) {
delete(m_subWidget[idWidget]);
// the pointer might already set at NULL:
@ -91,17 +101,36 @@ void widget::Button::SetSubWidget(ewol::Widget* subWidget, bool forToggle)
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
}
ewol::Widget* widget::Button::GetSubWidget(bool fromToggle)
void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget)
{
int32_t idWidget=0;
if (fromToggle==true) {
idWidget = 1;
int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) {
delete(m_subWidget[idWidget]);
// the pointer might already set at NULL:
if (NULL != m_subWidget[idWidget]) {
EWOL_ERROR("error while removing previous widget...");
m_subWidget[idWidget]=NULL;
}
return m_subWidget[idWidget];
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget);
m_subWidget[idWidget] = subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
}
ewol::Widget* widget::Button::GetSubWidget(void)
{
return m_subWidget[0];
}
ewol::Widget* widget::Button::GetSubWidgetToggle(void)
{
return m_subWidget[1];
}
bool widget::Button::CalculateSize(float availlableX, float availlableY)
void widget::Button::CalculateSize(const vec2& availlable)
{
vec2 padding = m_shaper.GetPadding();
// set minimal size
@ -111,10 +140,10 @@ bool widget::Button::CalculateSize(float availlableX, float availlableY)
vec2 minimumSizeToggle(0,0);
// Checking the expend properties :
if (m_userExpend.x() == true) {
m_size.setX(availlableX);
m_size.setX(availlable.x());
}
if (m_userExpend.y() == true) {
m_size.setY(availlableY);
m_size.setY(availlable.y());
}
// Checkin the filling properties ==> for the subElements:
vec2 subElementSize = m_minSize;
@ -127,22 +156,21 @@ bool widget::Button::CalculateSize(float availlableX, float availlableY)
vec2 origin = (m_size - subElementSize)/2.0f + padding;
subElementSize -= padding*2.0f;
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y());
m_subWidget[0]->CalculateSize(subElementSize.x(), subElementSize.y());
m_subWidget[0]->SetOrigin(m_origin+origin);
m_subWidget[0]->CalculateSize(subElementSize);
}
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y());
m_subWidget[1]->CalculateSize(subElementSize.x(), subElementSize.y());
m_subWidget[1]->SetOrigin(m_origin+origin);
m_subWidget[1]->CalculateSize(subElementSize);
}
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
m_selectableAreaSize = subElementSize + (padding*2.0f);
m_selectableAreaPos = origin-padding;
MarkToRedraw();
return true;
}
bool widget::Button::CalculateMinSize(void)
void widget::Button::CalculateMinSize(void)
{
vec2 padding = m_shaper.GetPadding();
vec2 minimumSizeBase(0,0);
@ -164,7 +192,6 @@ bool widget::Button::CalculateMinSize(void)
// verify the min max of the min size ...
CheckMinSize();
MarkToRedraw();
return true;
}
void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
@ -189,10 +216,10 @@ void widget::Button::OnRegenerateDisplay(void)
if (true == NeedRedraw()) {
vec2 padding = m_shaper.GetPadding();
m_shaper.Clear();
m_shaper.SetOrigin(m_selectableAreaPos);
m_shaper.SetSize(m_selectableAreaSize);
m_shaper.SetInsidePos(m_selectableAreaPos+padding );
m_shaper.SetInsideSize(m_selectableAreaSize-padding*2.0f);
m_shaper.SetOrigin(vec2ClipInt32(m_selectableAreaPos));
m_shaper.SetSize(vec2ClipInt32(m_selectableAreaSize));
m_shaper.SetInsidePos(vec2ClipInt32(m_selectableAreaPos+padding));
m_shaper.SetInsideSize(vec2ClipInt32(m_selectableAreaSize-padding*2.0f));
}
if( false == m_toggleMode
|| false == m_value) {
@ -227,6 +254,7 @@ void widget::Button::SetToggleMode(bool togg)
m_value = false;
// TODO : Change display and send event ...
}
CheckStatus();
MarkToRedraw();
}
}
@ -286,19 +314,7 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
}
if( m_mouseHover != previousHoverState
|| m_buttonPressed != previousPressed) {
if (true==m_buttonPressed) {
ChangeStatusIn(STATUS_PRESSED);
} else {
if (true==m_mouseHover) {
ChangeStatusIn(STATUS_HOVER);
} else {
if (true == m_value) {
ChangeStatusIn(STATUS_DOWN);
} else {
ChangeStatusIn(STATUS_UP);
}
}
}
CheckStatus();
}
return m_mouseHover;
}
@ -314,7 +330,22 @@ bool widget::Button::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t un
return false;
}
void widget::Button::CheckStatus(void)
{
if (true==m_buttonPressed) {
ChangeStatusIn(STATUS_PRESSED);
} else {
if (true==m_mouseHover) {
ChangeStatusIn(STATUS_HOVER);
} else {
if (true == m_value) {
ChangeStatusIn(STATUS_DOWN);
} else {
ChangeStatusIn(STATUS_UP);
}
}
}
}
void widget::Button::ChangeStatusIn(int32_t newStatusId)
{

View File

@ -31,6 +31,9 @@ namespace widget {
*/
class Button : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Widget* m_subWidget[2]; //!< subwidget of the button
@ -58,15 +61,25 @@ namespace widget {
*/
void SetShaperName(const etk::UString& shaperName);
/**
* @brief Specify the current composition string
* @param[in] newLabel The string that might be displayed
* @brief Specify the current widget
* @param[in] subWidget Widget to add normal
*/
void SetSubWidget(ewol::Widget* subWidget, bool forToggle=false);
void SetSubWidget(ewol::Widget* subWidget);
/**
* @brief Specify the current widget
* @param[in] subWidget Widget to add Toggle
*/
void SetSubWidgetToggle(ewol::Widget* subWidget);
/**
* @brief Get the current displayed composition
* @return The displayed string.
* @return The base widget
*/
ewol::Widget* GetSubWidget(bool fromToggle=false);
ewol::Widget* GetSubWidget(void);
/**
* @brief Get the current displayed composition
* @return The toggle widget
*/
ewol::Widget* GetSubWidgetToggle(void);
/**
* @brief Set the currentValue of the Button (pressed or not)
* @note Work only in toggle mode
@ -90,11 +103,15 @@ namespace widget {
* @param[in] new state
*/
void ChangeStatusIn(int32_t newStatusId);
/**
* @brief update the status with the internal satte of the button ...
*/
void CheckStatus(void);
public:
// Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual bool CalculateMinSize(void);
virtual bool CalculateSize(float availlableX, float availlableY);
virtual void CalculateMinSize(void);
virtual void CalculateSize(const vec2& availlable);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);

View File

@ -28,6 +28,24 @@ extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Cha
#undef __class__
#define __class__ "ButtonColor"
static ewol::Widget* Create(void)
{
return new widget::ButtonColor();
}
void widget::ButtonColor::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::ButtonColor::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::ButtonColor::ButtonColor(draw::Color baseColor, etk::UString shaperName) :
m_shaper(shaperName),
m_textColorFg(baseColor),
@ -53,7 +71,7 @@ void widget::ButtonColor::SetShaperName(etk::UString shaperName)
}
bool widget::ButtonColor::CalculateMinSize(void)
void widget::ButtonColor::CalculateMinSize(void)
{
vec2 padding = m_shaper.GetPadding();
etk::UString label = draw::GetString(m_textColorFg);
@ -61,7 +79,6 @@ bool widget::ButtonColor::CalculateMinSize(void)
m_minSize.setX(padding.x()*2 + minSize.x() + 7);
m_minSize.setY(padding.y()*2 + minSize.y() );
MarkToRedraw();
return true;
}

View File

@ -22,6 +22,9 @@ extern const char * const ewolEventButtonColorChange;
namespace widget {
class ButtonColor : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Text m_text; //!< Compositing Test display.
@ -60,16 +63,11 @@ namespace widget {
void SetValue(draw::Color color);
public:
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual void CalculateMinSize(void);
virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; };
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
private:
/**

View File

@ -15,9 +15,25 @@ extern const char * const ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
#undef __class__
#define __class__ "CheckBox"
static ewol::Widget* Create(void)
{
return new widget::CheckBox();
}
void widget::CheckBox::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::CheckBox::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::CheckBox::CheckBox(const etk::UString& newLabel)
{
m_label = newLabel;
AddEventId(ewolEventCheckBoxClicked);
m_textColorFg = draw::color::black;
m_textColorBg = draw::color::white;
@ -26,18 +42,6 @@ void widget::CheckBox::Init(void)
SetMouseLimit(1);
}
widget::CheckBox::CheckBox(void)
{
m_label = "No Label";
Init();
}
widget::CheckBox::CheckBox(etk::UString newLabel)
{
m_label = newLabel;
Init();
}
widget::CheckBox::~CheckBox(void)
{
@ -45,14 +49,13 @@ widget::CheckBox::~CheckBox(void)
}
bool widget::CheckBox::CalculateMinSize(void)
void widget::CheckBox::CalculateMinSize(void)
{
vec3 minSize = m_oObjectText.CalculateSize(m_label);
float boxSize = etk_max(20, minSize.y()) + 5;
m_minSize.setX(boxSize+minSize.x());
m_minSize.setY(etk_max(boxSize, minSize.y())+3);
MarkToRedraw();
return true;
}

View File

@ -21,14 +21,11 @@ namespace widget {
class CheckBox : public ewol::Widget
{
public:
CheckBox(void);
CheckBox(etk::UString newLabel);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolCheckBox"; };
void Init(void);
static void Init(void);
static void UnInit(void);
public:
CheckBox(const etk::UString& newLabel = "No Label");
virtual ~CheckBox(void);
// Derived function
virtual bool CalculateMinSize(void);
void SetLabel(etk::UString newLabel);
void SetValue(bool val);
bool GetValue(void);
@ -41,12 +38,11 @@ namespace widget {
draw::Color m_textColorBg; //!< Background color
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::CheckBox"; };
virtual void CalculateMinSize(void);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
};

View File

@ -35,11 +35,10 @@ widget::ColorBar::~ColorBar(void)
}
bool widget::ColorBar::CalculateMinSize(void)
void widget::ColorBar::CalculateMinSize(void)
{
m_minSize.setValue(160, 80);
MarkToRedraw();
return true;
}
static draw::Color s_listColorWhite(0xFFFFFFFF);
static draw::Color s_listColorBlack(0x000000FF);

View File

@ -32,13 +32,9 @@ namespace widget {
public:
// Derived function
virtual const char * const GetObjectType(void) { return "widget::ColorBar"; };
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual void CalculateMinSize(void);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
};

View File

@ -8,25 +8,28 @@
#include <ewol/ewol.h>
#include <ewol/widget/XmlComposer.h>
#include <ewol/widget/Composer.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/WidgetManager.h>
/*
ewol::Widget* m_widget;
etk::UString composerString;
etk::Vector<ComposerWidgetListNamed> m_list;
*/
widget::XmlComposer::XmlComposer(const etk::UString& composerXmlString)
widget::Composer::Composer(void) :
m_subWidget(NULL)
{
// TODO ...
// nothing to do ...
}
widget::XmlComposer::~XmlComposer(void)
widget::Composer::~Composer(void)
{
if (NULL != m_widget) {
delete(m_widget);
Clean();
}
void widget::Composer::Clean(void)
{
if (NULL != m_subWidget) {
delete(m_subWidget);
// might have been destroy first here :
if (m_widget!=NULL) {
if (m_subWidget!=NULL) {
EWOL_ERROR("Composer : An error Occured when removing main node");
}
}
@ -36,13 +39,99 @@ widget::XmlComposer::~XmlComposer(void)
}
}
ewol::Widget* widget::XmlComposer::GetMainWidget(void)
bool widget::Composer::LoadFromFile(const etk::UString& _fileName)
{
// nothing else to do ...
return m_widget;
// open the curent File
etk::FSNode fileName(_fileName);
if (false == fileName.Exist()) {
EWOL_ERROR("File Does not exist : " << fileName);
return false;
}
int32_t fileSize = fileName.FileSize();
if (0==fileSize) {
EWOL_ERROR("This file is empty : " << fileName);
return false;
}
if (false == fileName.FileOpenRead()) {
EWOL_ERROR("Can not open the file : " << fileName);
return false;
}
// allocate data
char * fileBuffer = new char[fileSize+5];
if (NULL == fileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << fileSize);
return false;
}
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file :
fileName.FileRead(fileBuffer, 1, fileSize);
// close the file:
fileName.FileClose();
bool ret = CommonLoadXML((const char*)fileBuffer);
if (NULL != fileBuffer) {
delete[] fileBuffer;
}
return ret;
}
ewol::Widget* widget::XmlComposer::GetWidgetNamed(const etk::UString& widgetName)
bool widget::Composer::LoadFromString(const etk::UString& composerXmlString)
{
etk::Char tmpData = composerXmlString.c_str();
return CommonLoadXML(tmpData);
}
bool widget::Composer::CommonLoadXML(const char* data)
{
if (NULL==data) {
return false;
}
TiXmlDocument XmlDocument;
// load the XML from the memory
XmlDocument.Parse(data, 0, TIXML_ENCODING_UTF8);
TiXmlElement* root = XmlDocument.FirstChildElement("composer");
if (NULL == root ) {
EWOL_ERROR("(l ?) main node not find: \"composer\" ...");
return false;
}
// remove previous elements ...
Clean();
ewol::Widget::LoadXML(root);
for(TiXmlNode * pNode = root->FirstChild() ;
NULL != pNode ;
pNode = pNode->NextSibling() ) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
// nothing to do, just proceed to next step
continue;
}
etk::UString widgetName = pNode->Value();
if (ewol::widgetManager::Exist(widgetName) == false) {
EWOL_ERROR("(l "<<pNode->Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" );
continue;
}
if (NULL != m_subWidget) {
EWOL_ERROR("(l "<<pNode->Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
continue;
}
ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName);
if (tmpWidget == NULL) {
EWOL_ERROR ("(l "<<pNode->Row()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}
if (false == tmpWidget->LoadXML(pNode)) {
EWOL_ERROR ("(l "<<pNode->Row()<<") can not load widget properties : \"" << widgetName << "\"");
return false;
}
}
return true;
}
ewol::Widget* widget::Composer::GetWidgetNamed(const etk::UString& widgetName)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (m_list[iii].widgetName == widgetName) {
@ -52,11 +141,40 @@ ewol::Widget* widget::XmlComposer::GetWidgetNamed(const etk::UString& widgetName
return NULL;
}
virtual void widget::XmlComposer::OnObjectRemove(ewol::EObject* removeObject)
void widget::Composer::OnObjectRemove(ewol::EObject* removeObject)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (m_list[iii].widgetName == widgetName) {
if (m_list[iii].widget == removeObject) {
m_list.Erase(iii);
}
}
if (m_subWidget==removeObject) {
m_subWidget=NULL;
}
}
void widget::Composer::OnDraw(ewol::DrawProperty& displayProp)
{
if (NULL!=m_subWidget) {
m_subWidget->GenDraw(displayProp);
}
}
void widget::Composer::CalculateSize(const vec2& availlable)
{
if (NULL!=m_subWidget) {
m_subWidget->CalculateSize(availlable);
// copy all sub parameters:
m_hide = m_subWidget->IsHide();
}
}
void widget::Composer::CalculateMinSize(void)
{
if (NULL!=m_subWidget) {
m_subWidget->CalculateMinSize();
// copy all sub parameters :
m_hide = m_subWidget->IsHide();
m_userFill = m_subWidget->CanFill();
}
}

View File

@ -6,8 +6,8 @@
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_XML_COMPOSER_H__
#define __EWOL_XML_COMPOSER_H__
#ifndef __EWOL_WIDGET_COMPOSER_H__
#define __EWOL_WIDGET_COMPOSER_H__
#include <etk/types.h>
#include <ewol/debug.h>
@ -15,26 +15,54 @@
namespace widget
{
class XmlComposer : public ewol::EObject
/**
* @brief the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
*/
class Composer : public ewol::Widget
{
private:
class ComposerWidgetListNamed {
public:
ewol::Widget* widget;
etk::UString widgetName;
}
ewol::Widget* m_widget;
etk::UString composerString;
};
ewol::Widget* m_subWidget;
etk::Vector<ComposerWidgetListNamed> m_list;
public:
/**
* @brief Constructor
*/
XmlComposer(const etk::UString& composerXmlString);
Composer(void);
/**
* @brief Destructor
*/
~XmlComposer(void);
~Composer(void);
/**
* @brief Remove all sub elements
*/
void Clean(void);
/**
* @brief Load a composition with a file
* @param[in] fileName Name of the file
* @return true ==> all done OK
* @return false ==> some error occured
*/
bool LoadFromFile(const etk::UString& fileName);
/**
* @brief Load a composition with a file
* @param[in] composerXmlString xml to parse directly
* @return true ==> all done OK
* @return false ==> some error occured
*/
bool LoadFromString(const etk::UString& composerXmlString);
private:
/**
* @brief Load a composition with a file.
* @param[in] data pointer on the file data.
* @return true ==> all done OK.
* @return false ==> some error occured.
*/
bool CommonLoadXML(const char* data);
public:
/**
* @brief Get the main node widget
@ -48,9 +76,13 @@ namespace widget
*/
ewol::Widget* GetWidgetNamed(const etk::UString& widgetName);
public:
// herited function :
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public:// Derived function
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinSize(void);
// TODO : Call all sub element getter an setter ==> this object might be transparent ...
};
};

View File

@ -37,20 +37,20 @@ widget::ContextMenu::~ContextMenu(void)
}
bool widget::ContextMenu::CalculateSize(float availlableX, float availlableY)
void widget::ContextMenu::CalculateSize(const vec2& availlable)
{
EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")");
//EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display :
m_size.setValue(availlableX, availlableY);
m_size = availlable;
if (NULL != m_subWidget) {
vec2 subWidgetSize;
vec2 subWidgetOrigin;
subWidgetSize = m_subWidget->GetMinSize();
if (true == m_subWidget->CanExpentX()) {
if (true == m_subWidget->CanExpand().x()) {
subWidgetSize.setX(m_size.x());
}
if (true == m_subWidget->CanExpentY()) {
if (true == m_subWidget->CanExpand().y()) {
subWidgetSize.setY(m_size.y());
}
int32_t minWidth = 100;
@ -98,15 +98,14 @@ bool widget::ContextMenu::CalculateSize(float availlableX, float availlableY)
}
break;
}
m_subWidget->SetOrigin(subWidgetOrigin.x(), subWidgetOrigin.y());
m_subWidget->CalculateSize(subWidgetSize.x(), subWidgetSize.y());
m_subWidget->SetOrigin(subWidgetOrigin);
m_subWidget->CalculateSize(subWidgetSize);
}
MarkToRedraw();
return true;
}
bool widget::ContextMenu::CalculateMinSize(void)
void widget::ContextMenu::CalculateMinSize(void)
{
EWOL_DEBUG("CalculateMinSize");
m_userExpend.setValue(false,false);
@ -117,24 +116,18 @@ bool widget::ContextMenu::CalculateMinSize(void)
}
EWOL_DEBUG("CalculateMinSize=>>" << m_minSize);
MarkToRedraw();
return true;
}
void widget::ContextMenu::SetMinSise(float x, float y)
void widget::ContextMenu::SetMinSize(const vec2& size)
{
EWOL_ERROR("Pop-up can not have a user Minimum size (herited from under elements)");
}
void widget::ContextMenu::SetExpendX(bool newExpend)
void widget::ContextMenu::SetExpand(const bvec2& newExpend)
{
EWOL_ERROR("Pop-up can not have a user expend settings X (herited from under elements)");
}
void widget::ContextMenu::SetExpendY(bool newExpend)
{
EWOL_ERROR("Pop-up can not have a user expend settings Y (herited from under elements)");
}
void widget::ContextMenu::SubWidgetSet(ewol::Widget* newWidget)
{

View File

@ -31,11 +31,10 @@ namespace widget {
// Derived function
virtual const char * const GetObjectType(void) { return "EwolContextMenu"; };
public:
virtual bool CalculateSize(float availlableX, float availlableY); // this generate the current size ...
virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer
virtual void SetMinSise(float x=-1, float y=-1);
virtual void SetExpendX(bool newExpend=false);
virtual void SetExpendY(bool newExpend=false);
virtual void CalculateSize(const vec2& availlable); // this generate the current size ...
virtual void CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer
virtual void SetMinSize(const vec2& size);
virtual void SetExpand(const bvec2& newExpend);
private:
draw::Color m_colorBackGroung;
draw::Color m_colorBorder;
@ -54,9 +53,7 @@ namespace widget {
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual ewol::Widget* GetWidgetAtPos(vec2 pos);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
};

View File

@ -31,6 +31,21 @@ const char * const ewolEventEntrySelect = "ewol-Entry-Select";
#define STATUS_HOVER (1)
#define STATUS_SELECTED (2)
static ewol::Widget* Create(void)
{
return new widget::Entry();
}
void widget::Entry::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Entry::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Entry::Entry(etk::UString newData) :
m_shaper("THEME:GUI:widgetEntry.conf"),
@ -66,7 +81,7 @@ widget::Entry::~Entry(void)
}
bool widget::Entry::CalculateMinSize(void)
void widget::Entry::CalculateMinSize(void)
{
vec2 padding = m_shaper.GetPadding();
@ -75,7 +90,6 @@ bool widget::Entry::CalculateMinSize(void)
minHeight + 2*padding.y());
UpdateTextPosition();
MarkToRedraw();
return true;
}

View File

@ -33,6 +33,9 @@ namespace widget {
*/
class Entry : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Shaper m_shaper;
ewol::Text m_oObjectText; //!< text display
@ -54,10 +57,6 @@ namespace widget {
* @brief Destuctor
*/
virtual ~Entry(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
// Derived function
virtual bool CalculateMinSize(void);
void SetValue(etk::UString newData);
etk::UString GetValue(void);
void SetWidth(int32_t width)
@ -67,16 +66,13 @@ namespace widget {
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
// Derived function
virtual bool OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent);
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
// Derived function
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
virtual void CalculateMinSize(void);
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);

View File

@ -15,11 +15,27 @@
#define __class__ "Gird"
static ewol::Widget* Create(void)
{
return new widget::Gird();
}
void widget::Gird::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Gird::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Gird::Gird(int32_t colNumber) :
m_tmpWidget(NULL),
m_sizeRow(0),
m_borderSize(0,0),
m_gavityButtom(true)
m_tmpWidget(NULL),
m_gavityButtom(true),
m_borderSize(0,0)
{
SetColNumber(colNumber);
ewol::RequestUpdateSize();
@ -46,15 +62,11 @@ void widget::Gird::SetBorderSize(const ivec2& newBorderSize)
ewol::RequestUpdateSize();
}
bool widget::Gird::CalculateSize(float availlableX, float availlableY)
void widget::Gird::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("Update Size");
m_size.setValue(availlableX, availlableY);
m_size = availlable;
m_size -= m_borderSize*2;
// calculate unExpendable Size :
float unexpendableSize=0.0;
int32_t nbWidgetFixedSize=0;
int32_t nbWidgetNotFixedSize=0;
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
@ -79,18 +91,17 @@ bool widget::Gird::CalculateSize(float availlableX, float availlableY)
EWOL_DEBUG(" [" << iii << "] set subwidget origin=" <<tmpOrigin << " size=" << ivec2(abs(m_sizeCol[m_subWidget[iii].col]), m_uniformSizeRow) );
// Set the origin :
m_subWidget[iii].widget->SetOrigin(tmpOrigin.x(), tmpOrigin.y());
m_subWidget[iii].widget->SetOrigin(tmpOrigin);
// all time set oll the space .
m_subWidget[iii].widget->CalculateSize(abs(m_sizeCol[m_subWidget[iii].col]), m_uniformSizeRow);
m_subWidget[iii].widget->CalculateSize(vec2(abs(m_sizeCol[m_subWidget[iii].col]), m_uniformSizeRow));
}
}
m_size += m_borderSize*2;
EWOL_DEBUG("Calculate size : " << m_size);
MarkToRedraw();
return true;
}
bool widget::Gird::CalculateMinSize(void)
void widget::Gird::CalculateMinSize(void)
{
for (int32_t iii=0; iii<m_sizeCol.Size(); iii++ ){
if (m_sizeCol[iii] <= 0) {
@ -140,7 +151,6 @@ bool widget::Gird::CalculateMinSize(void)
EWOL_DEBUG("Calculate min size : " << m_minSize);
//EWOL_DEBUG("Vert Result : expend="<< m_userExpend << " minSize="<< m_minSize);
return true;
}
void widget::Gird::SetColNumber(int32_t colNumber)
@ -343,7 +353,6 @@ void widget::Gird::SubWidgetUnLink(int32_t colId, int32_t rowId)
EWOL_WARNING("[" << GetId() << "] try to Unlink widget with id < 0 col=" << colId << " row=" << rowId);
return;
}
int32_t errorControl = m_subWidget.Size();
// try to find it ...
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if( m_subWidget[iii].row == rowId

View File

@ -17,6 +17,9 @@
namespace widget {
class Gird :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
class GirdProperties {
public:
@ -136,8 +139,8 @@ namespace widget {
virtual ewol::Widget* GetWidgetAtPos(vec2 pos);
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual const char * const GetObjectType(void) { return "Ewol::Sizer"; };
virtual bool CalculateSize(float availlableX, float availlableY);
virtual bool CalculateMinSize(void);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinSize(void);
};
};

View File

@ -17,9 +17,25 @@ extern const char * const ewolEventImagePressed = "ewol-image-Pressed";
#undef __class__
#define __class__ "Image"
static ewol::Widget* Create(void)
{
return new widget::Image();
}
void widget::Image::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Image::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Image::Image(const etk::UString& dataFile, int32_t size)
{
m_imageSelected = dataFile;
AddEventId(ewolEventImagePressed);
#ifdef __TARGET_OS__Android
@ -33,13 +49,6 @@ void widget::Image::Init(void)
m_imageSize = 32;
// Limit event at 1:
SetMouseLimit(1);
}
widget::Image::Image(etk::UString dataFile, int32_t size)
{
m_imageSelected = dataFile;
Init();
if (size>0) {
m_imageSize = size;
}
@ -57,12 +66,11 @@ void widget::Image::SetPadding(vec2 newPadding)
m_padding = newPadding;
}
bool widget::Image::CalculateMinSize(void)
void widget::Image::CalculateMinSize(void)
{
m_minSize.setValue(m_padding.x()*2 + m_imageSize,
m_padding.y()*2 + m_imageSize );
MarkToRedraw();
return true;
}

View File

@ -20,13 +20,11 @@ namespace widget {
class Image :public widget::Drawable
{
public:
Image(etk::UString dataFile, int32_t size=-1); // automatic considering in the appl Data older
// Derived function
virtual const char * const GetObjectType(void) { return "EwolImage"; };
void Init(void);
static void Init(void);
static void UnInit(void);
public:
Image(const etk::UString& dataFile="", int32_t size=-1); // automatic considering in the appl Data older
virtual ~Image(void);
// Derived function
virtual bool CalculateMinSize(void);
void SetFile(etk::UString newFile);
void SetPadding(vec2 newPadding);
private:
@ -36,8 +34,9 @@ namespace widget {
int32_t m_imageSize;
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Image"; };
virtual void CalculateMinSize(void);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
};
};

View File

@ -58,12 +58,11 @@ widget::Joystick::~Joystick(void)
}
bool widget::Joystick::CalculateSize(float availlableX, float availlableY)
void widget::Joystick::CalculateSize(const vec2& availlable)
{
float minimumSize = etk_min(availlableX, availlableY);
float minimumSize = etk_min(availlable.x(), availlable.y());
m_size.setValue(minimumSize, minimumSize);
MarkToRedraw();
return true;
}
void widget::Joystick::OnRegenerateDisplay(void)

View File

@ -43,13 +43,11 @@ namespace widget {
Joystick(void);
virtual ~Joystick(void);
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol"; };
// Derived function
virtual bool CalculateSize(float availlableX, float availlableY);
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Joystick"; };
virtual void CalculateSize(const vec2& availlable);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
void SetLockMode(bool lockWhenOut) { m_lock = lockWhenOut; };
void SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; };
/**

View File

@ -20,6 +20,21 @@ extern const char * const ewolEventLabelPressed = "ewol Label Pressed";
#undef __class__
#define __class__ "Label"
static ewol::Widget* Create(void)
{
return new widget::Label();
}
void widget::Label::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Label::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Label::Label(etk::UString newLabel)
{
@ -33,7 +48,7 @@ widget::Label::~Label(void)
}
bool widget::Label::CalculateMinSize(void)
void widget::Label::CalculateMinSize(void)
{
if (m_userMaxSize.x() != -1) {
m_text.SetTextAlignement(0, m_userMaxSize.x()-4, ewol::Text::alignLeft);
@ -49,7 +64,6 @@ bool widget::Label::CalculateMinSize(void)
} else {
m_minSize.setY(4 + minSize.y());
}
return true;
}
@ -136,4 +150,14 @@ bool widget::Label::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
return false;
}
bool widget::Label::LoadXML(TiXmlNode* node)
{
if (NULL==node) {
return false;
}
ewol::Widget::LoadXML(node);
// get internal data :
// TODO : Unparse data type XML ...
SetLabel(node->ToElement()->GetText());
return true;
}

View File

@ -19,6 +19,9 @@ extern const char * const ewolEventLabelPressed;
namespace widget {
class Label : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Text m_text; //!< Compositing text element.
etk::UString m_label; //!< decorated text to display.
@ -42,16 +45,14 @@ namespace widget {
* @return The displayed decorated text.
*/
etk::UString GetLabel(void);
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Label"; };
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual void CalculateMinSize(void);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
virtual bool LoadXML(TiXmlNode* node);
};
};

View File

@ -13,6 +13,21 @@
#undef __class__
#define __class__ "Layer"
static ewol::Widget* Create(void)
{
return new widget::Layer();
}
void widget::Layer::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Layer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Layer::Layer(void)
{
@ -27,32 +42,31 @@ widget::Layer::~Layer(void)
}
bool widget::Layer::CalculateSize(float availlableX, float availlableY)
void widget::Layer::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("Update Size");
m_size.setValue(availlableX, availlableY);
m_size = availlable;
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->SetOrigin(m_origin.x(), m_origin.y());
m_subWidget[iii]->CalculateSize(m_size.x(), m_size.y());
m_subWidget[iii]->SetOrigin(m_origin);
m_subWidget[iii]->CalculateSize(m_size);
}
}
MarkToRedraw();
return true;
}
bool widget::Layer::CalculateMinSize(void)
void widget::Layer::CalculateMinSize(void)
{
m_userExpend.setValue(false, false);
m_minSize.setValue(0,0);
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->CalculateMinSize();
if (true == m_subWidget[iii]->CanExpentX()) {
if (true == m_subWidget[iii]->CanExpand().x()) {
m_userExpend.setX(true);
}
if (true == m_subWidget[iii]->CanExpentY()) {
if (true == m_subWidget[iii]->CanExpand().y()) {
m_userExpend.setY(true);
}
vec2 tmpSize = m_subWidget[iii]->GetMinSize();
@ -60,38 +74,20 @@ bool widget::Layer::CalculateMinSize(void)
etk_max(tmpSize.y(), m_minSize.y()) );
}
}
return true;
}
void widget::Layer::SetMinSise(float x, float y)
void widget::Layer::SetMinSize(const vec2& size)
{
EWOL_ERROR("Layer can not have a user Minimum size (herited from under elements)");
}
void widget::Layer::SetExpendX(bool newExpend)
{
EWOL_ERROR("Layer can not have a user expend settings X (herited from under elements)");
}
bool widget::Layer::CanExpentX(void)
bvec2 widget::Layer::CanExpand(void)
{
if (true == m_lockExpendContamination) {
return false;
return bvec2(false,false);
}
return m_userExpend.x();
}
void widget::Layer::SetExpendY(bool newExpend)
{
EWOL_ERROR("Sizer can not have a user expend settings Y (herited from under elements)");
}
bool widget::Layer::CanExpentY(void)
{
if (true == m_lockExpendContamination) {
return false;
}
return m_userExpend.y();
return m_userExpend;
}
void widget::Layer::LockExpendContamination(bool lockExpend)

View File

@ -16,20 +16,12 @@
namespace widget {
class Layer :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
public:
Layer(void);
virtual ~Layer(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolLayer"; };
public:
// Derived function
virtual bool CalculateSize(float availlableX, float availlableY);
virtual bool CalculateMinSize(void);
virtual void SetMinSise(float x=-1, float y=-1);
virtual void SetExpendX(bool newExpend=false);
virtual bool CanExpentX(void);
virtual void SetExpendY(bool newExpend=false);
virtual bool CanExpentY(void);
void LockExpendContamination(bool lockExpend=false);
private:
bool m_lockExpendContamination;
@ -46,10 +38,14 @@ namespace widget {
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual ewol::Widget * GetWidgetAtPos(vec2 pos);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinSize(void);
virtual void SetMinSize(const vec2& size);
virtual void SetExpand(const bvec2& newExpend);
virtual bvec2 CanExpand(void);
virtual const char * const GetObjectType(void) { return "EwolLayer"; };
};
};

View File

@ -43,7 +43,7 @@ widget::List::~List(void)
}
bool widget::List::CalculateMinSize(void)
void widget::List::CalculateMinSize(void)
{
/*int32_t fontId = GetDefaultFontId();
int32_t minWidth = ewol::GetWidth(fontId, m_label);
@ -52,7 +52,6 @@ bool widget::List::CalculateMinSize(void)
m_minSize.y = 3+minHeight;
*/
m_minSize.setValue(200, 150);
return true;
}

View File

@ -22,9 +22,9 @@ namespace widget {
List(void);
void Init(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolList"; };
virtual const char * const GetObjectType(void) { return "ewol::List"; };
virtual ~List(void);
virtual bool CalculateMinSize(void);
virtual void CalculateMinSize(void);
void SetLabel(etk::UString newLabel);
// Drawing capabilities ....
private:

View File

@ -164,7 +164,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
widget::Button * myButton = NULL;
mySizer = new widget::Sizer(widget::Sizer::modeVert);
mySizer->LockExpendContamination(true);
mySizer->LockExpendContamination(vec2(true,true));
// set it in the pop-up-system :
m_widgetContextMenu->SubWidgetSet(mySizer);

View File

@ -52,7 +52,6 @@ namespace widget {
void AddSpacer(void);
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
};

View File

@ -35,20 +35,20 @@ widget::PopUp::~PopUp(void)
}
bool widget::PopUp::CalculateSize(float availlableX, float availlableY)
void widget::PopUp::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")");
//EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display :
m_size.setValue(availlableX, availlableY);
m_size = availlable;
if (NULL != m_subWidget) {
vec2 subWidgetSize;
vec2 subWidgetOrigin;
subWidgetSize = m_subWidget->GetMinSize();
if (true == m_subWidget->CanExpentX()) {
if (true == m_subWidget->CanExpand().x()) {
subWidgetSize.setX(m_size.x());
}
if (true == m_subWidget->CanExpentY()) {
if (true == m_subWidget->CanExpand().y()) {
subWidgetSize.setY(m_size.y());
}
if (m_displayRatio>0.1 && m_displayRatio<=1) {
@ -65,11 +65,10 @@ bool widget::PopUp::CalculateSize(float availlableX, float availlableY)
m_subWidget->CalculateSize(subWidgetSize.x(), subWidgetSize.y());
}
MarkToRedraw();
return true;
}
bool widget::PopUp::CalculateMinSize(void)
void widget::PopUp::CalculateMinSize(void)
{
//EWOL_DEBUG("CalculateMinSize");
m_userExpend.setValue(false,false);
@ -81,25 +80,18 @@ bool widget::PopUp::CalculateMinSize(void)
}
//EWOL_DEBUG("CalculateMinSize(" << m_minSize.x << "," << m_minSize.y << ")");
MarkToRedraw();
return true;
}
void widget::PopUp::SetMinSise(float x, float y)
void widget::PopUp::SetMinSize(const vec2& size)
{
EWOL_ERROR("Pop-up can not have a user Minimum size (herited from under elements)");
}
void widget::PopUp::SetExpendX(bool newExpend)
void widget::PopUp::SetExpand(const bvec2& newExpend)
{
EWOL_ERROR("Pop-up can not have a user expend settings X (herited from under elements)");
}
void widget::PopUp::SetExpendY(bool newExpend)
{
EWOL_ERROR("Pop-up can not have a user expend settings Y (herited from under elements)");
}
void widget::PopUp::SubWidgetSet(ewol::Widget* newWidget)
{
if (NULL == newWidget) {

View File

@ -25,15 +25,10 @@ namespace widget {
virtual const char * const GetObjectType(void) { return "EwolPopUp"; };
public:
// Derived function
virtual bool CalculateSize(float availlableX, float availlableY);
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual void SetMinSise(float x=-1, float y=-1);
// Derived function
virtual void SetExpendX(bool newExpend=false);
// Derived function
virtual void SetExpendY(bool newExpend=false);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinSize(void);
virtual void SetMinSize(const vec2& size);
virtual void SetExpand(const bvec2& newExpend);
void SetDisplayRatio(float ratio);
private:
draw::Color m_colorBackGroung;

View File

@ -12,7 +12,23 @@
#include <ewol/widget/WidgetManager.h>
#undef __class__
#define __class__ "Slider"
#define __class__ "ProgressBar"
static ewol::Widget* Create(void)
{
return new widget::ProgressBar();
}
void widget::ProgressBar::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::ProgressBar::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
const int32_t dotRadius = 6;
@ -35,12 +51,11 @@ widget::ProgressBar::~ProgressBar(void)
}
bool widget::ProgressBar::CalculateMinSize(void)
void widget::ProgressBar::CalculateMinSize(void)
{
m_minSize.setValue( etk_max(m_userMinSize.x(), 40),
etk_max(m_userMinSize.y(), dotRadius*2) );
MarkToRedraw();
return true;
}

View File

@ -18,12 +18,15 @@
namespace widget {
class ProgressBar :public widget::Drawable
{
public:
static void Init(void);
static void UnInit(void);
public:
ProgressBar(void);
virtual ~ProgressBar(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolProgressBar"; };
virtual bool CalculateMinSize(void);
virtual void CalculateMinSize(void);
void ValueSet(float val);
float ValueGet(void);
void SetColor(draw::Color newColor) { m_textColorFg = newColor; };

View File

@ -14,6 +14,21 @@
#undef __class__
#define __class__ "Sizer"
static ewol::Widget* Create(void)
{
return new widget::Sizer();
}
void widget::Sizer::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Sizer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Sizer::Sizer(widget::Sizer::displayMode_te mode):
m_mode(mode),
@ -57,10 +72,10 @@ widget::Sizer::displayMode_te widget::Sizer::GetMode(void)
return m_mode;
}
bool widget::Sizer::CalculateSize(float availlableX, float availlableY)
void widget::Sizer::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("Update Size");
m_size.setValue(availlableX, availlableY);
m_size = availlable;
m_size -= m_borderSize*2;
// calculate unExpendable Size :
float unexpendableSize=0.0;
@ -128,11 +143,10 @@ bool widget::Sizer::CalculateSize(float availlableX, float availlableY)
}
m_size += m_borderSize*2;
MarkToRedraw();
return true;
}
bool widget::Sizer::CalculateMinSize(void)
void widget::Sizer::CalculateMinSize(void)
{
//EWOL_DEBUG("Update minimum Size");
m_userExpend.setValue(false, false);
@ -169,52 +183,29 @@ bool widget::Sizer::CalculateMinSize(void)
}
}
}
//EWOL_DEBUG("Vert Result : expend="<< m_userExpend << " minSize="<< m_minSize);
return true;
}
void widget::Sizer::SetMinSize(float x, float y)
void widget::Sizer::SetMinSize(const vec2& size)
{
EWOL_ERROR("[" << GetId() << "] Sizer can not have a user Minimum size (herited from under elements)");
}
void widget::Sizer::SetExpendX(bool newExpend)
void widget::Sizer::SetExpand(const bvec2& newExpend)
{
EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings X (herited from under elements)");
EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings (herited from under elements)");
}
bool widget::Sizer::CanExpentX(void)
bvec2 widget::Sizer::CanExpentY(void)
{
if (true == m_lockExpendContamination.x()) {
return false;
if (true == m_lockExpendContamination)) {
return bvec2(false,false);
}
return m_userExpend.x();
return m_userExpend;
}
void widget::Sizer::SetExpendY(bool newExpend)
void widget::Sizer::LockExpendContamination(const bvec2& lockExpend)
{
EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings Y (herited from under elements)");
}
bool widget::Sizer::CanExpentY(void)
{
if (true == m_lockExpendContamination.y()) {
return false;
}
return m_userExpend.y();
}
void widget::Sizer::LockExpendContamination(bool lockExpend)
{
m_lockExpendContamination.setValue(lockExpend,lockExpend);
}
void widget::Sizer::LockExpendContaminationVert(bool lockExpend)
{
m_lockExpendContamination.setY(lockExpend);
}
void widget::Sizer::LockExpendContaminationHori(bool lockExpend)
{
m_lockExpendContamination.setX(lockExpend);
m_lockExpendContamination = lockExpend;
}
void widget::Sizer::SubWidgetRemoveAll(void)

View File

@ -16,6 +16,9 @@
namespace widget {
class Sizer :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
public:
typedef enum {
modeVert, //!< Vertical mode
@ -51,17 +54,7 @@ namespace widget {
* @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget)
* @param[in] lockExpend New expend state in vertical and horisantal
*/
void LockExpendContamination(bool lockExpend);
/**
* @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget)
* @param[in] lockExpend New expend state in vertical
*/
void LockExpendContaminationVert(bool lockExpend);
/**
* @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget)
* @param[in] lockExpend New expend state in horisantal
*/
void LockExpendContaminationHori(bool lockExpend);
void LockExpendContamination(const bvec2& lockExpend);
public:
/**
* @brief Remove all sub element from the widget.
@ -107,13 +100,11 @@ namespace widget {
virtual ewol::Widget* GetWidgetAtPos(vec2 pos);
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual const char * const GetObjectType(void) { return "Ewol::Sizer"; };
virtual bool CalculateSize(float availlableX, float availlableY);
virtual bool CalculateMinSize(void);
virtual void SetMinSize(float x=-1, float y=-1);
virtual void SetExpendX(bool newExpend=false);
virtual bool CanExpentX(void);
virtual void SetExpendY(bool newExpend=false);
virtual bool CanExpentY(void);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinSize(void);
virtual void SetMinSize(const vec2& size);
virtual void SetExpand(const bvec2& newExpend);
virtual bvec2 CanExpent(void);;
};
};

View File

@ -19,6 +19,24 @@ extern const char * const ewolEventSliderChange = "ewol-event-slider-change";
#undef __class__
#define __class__ "Slider"
static ewol::Widget* Create(void)
{
return new widget::Slider();
}
void widget::Slider::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Slider::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
const int32_t dotRadius = 6;
widget::Slider::Slider(void)
@ -44,12 +62,11 @@ widget::Slider::~Slider(void)
}
bool widget::Slider::CalculateMinSize(void)
void widget::Slider::CalculateMinSize(void)
{
m_minSize.setValue(etk_max(m_userMinSize.x(), 40),
etk_max(m_userMinSize.y(), dotRadius*2) );
MarkToRedraw();
return true;
}

View File

@ -19,13 +19,12 @@ extern const char * const ewolEventSliderChange;
namespace widget {
class Slider :public widget::Drawable
{
public:
static void Init(void);
static void UnInit(void);
public:
Slider(void);
virtual ~Slider(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolSlider"; } ;
// Derived function
virtual bool CalculateMinSize(void);
void SetValue(int32_t val);
int32_t GetValue(void);
void SetMin(int32_t val);
@ -39,8 +38,9 @@ namespace widget {
draw::Color m_textColorBg; //!< Background color
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Slider"; } ;
virtual void CalculateMinSize(void);
virtual void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
};

View File

@ -15,6 +15,21 @@
#undef __class__
#define __class__ "Spacer"
static ewol::Widget* Create(void)
{
return new widget::Spacer();
}
void widget::Spacer::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::Spacer::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::Spacer::Spacer(void)
{
@ -30,10 +45,9 @@ widget::Spacer::~Spacer(void)
}
bool widget::Spacer::CalculateMinSize(void)
void widget::Spacer::CalculateMinSize(void)
{
m_minSize.setValue(m_localSize, m_localSize);
return true;
}

View File

@ -18,6 +18,9 @@
namespace widget {
class Spacer :public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Drawing m_draw; //!< Compositing drawing element
float m_localSize; //!< Local request size of the display
@ -43,14 +46,10 @@ namespace widget {
void SetColor(draw::Color newColor) { m_color = newColor; MarkToRedraw(); };
public:
// Derived function
virtual const char * const GetObjectType(void) { return "EwolSpacer"; };
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Spacer"; };
virtual void CalculateMinSize(void);
virtual ewol::Widget * GetWidgetAtPos(vec2 pos) { return NULL; };
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
};

View File

@ -20,15 +20,15 @@
#define __class__ "Widget"
ewol::Widget::Widget(void) :
m_hide(false),
m_zoom(1.0f),
m_origin(0,0),
m_size(10,10),
m_minSize(-1,-1),
m_zoom(1.0f),
m_origin(0,0),
m_userMinSize(-1,-1),
m_userMaxSize(-1,-1),
m_userExpend(false,false),
m_userFill(false,false),
m_hide(false),
m_hasFocus(false),
m_canFocus(false),
m_limitMouseEvent(3),
@ -66,11 +66,10 @@ void ewol::Widget::Show(void)
}
bool ewol::Widget::CalculateSize(float availlableX, float availlableY)
void ewol::Widget::CalculateSize(const vec2& availlable)
{
m_size.setValue(availlableX, availlableY);
m_size = availlable;
MarkToRedraw();
return true;
}
@ -206,9 +205,9 @@ float ewol::Widget::GetZoom(void)
return m_zoom;
}
void ewol::Widget::SetOrigin(float x, float y)
void ewol::Widget::SetOrigin(const vec2& pos)
{
m_origin.setValue(x, y);
m_origin = pos;
}
vec2 ewol::Widget::GetOrigin(void)
@ -221,16 +220,15 @@ vec2 ewol::Widget::RelativePosition(vec2 pos)
return pos - m_origin;
}
bool ewol::Widget::CalculateMinSize(void)
void ewol::Widget::CalculateMinSize(void)
{
m_minSize = m_userMinSize;
MarkToRedraw();
return true;
}
void ewol::Widget::SetMinSize(float x, float y)
void ewol::Widget::SetMinSize(const vec2& size)
{
m_userMinSize.setValue(x, y);
m_userMinSize = size;
}
void ewol::Widget::CheckMinSize(void)
@ -270,37 +268,17 @@ vec2 ewol::Widget::GetSize(void)
return vec2(0,0);
}
void ewol::Widget::SetExpendX(bool newExpend)
void ewol::Widget::SetExpand(const bvec2& newExpend)
{
m_userExpend.setX(newExpend);
if( m_userExpend.x() != newExpend.x()
|| m_userExpend.y() != newExpend.y()) {
m_userExpend = newExpend;
ewol::RequestUpdateSize();
MarkToRedraw();
}
bool ewol::Widget::CanExpentX(void)
{
if (false==IsHide()) {
return m_userExpend.x();
}
return false;
}
void ewol::Widget::SetExpendY(bool newExpend)
{
m_userExpend.setY(newExpend);
ewol::RequestUpdateSize();
MarkToRedraw();
}
bool ewol::Widget::CanExpentY(void)
{
if (false==IsHide()) {
return m_userExpend.y();
}
return false;
}
bvec2 ewol::Widget::CanExpent(void)
bvec2 ewol::Widget::CanExpand(void)
{
if (false==IsHide()) {
return m_userExpend;
@ -309,27 +287,19 @@ bvec2 ewol::Widget::CanExpent(void)
}
void ewol::Widget::SetFillX(bool newFill)
void ewol::Widget::SetFill(const bvec2& newFill)
{
m_userFill.setX(newFill);
if( m_userFill.x() != newFill.x()
|| m_userFill.y() != newFill.y()) {
m_userFill = newFill;
ewol::RequestUpdateSize();
MarkToRedraw();
}
bool ewol::Widget::CanFillX(void)
{
return m_userFill.x();
}
void ewol::Widget::SetFillY(bool newFill)
const bvec2& ewol::Widget::CanFill(void)
{
m_userFill.setY(newFill);
MarkToRedraw();
}
bool ewol::Widget::CanFillY(void)
{
return m_userFill.y();
return m_userFill;
}
// ----------------------------------------------------------------------------------------------------------------
@ -514,3 +484,118 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void)
{
return m_cursorDisplay;
}
bool ewol::Widget::LoadXML(TiXmlNode* node)
{
if (NULL==node) {
return false;
}
bool ret = true;
const char *tmpAttributeValue = node->ToElement()->Attribute("name");
if (NULL != tmpAttributeValue) {
m_widgetName = tmpAttributeValue;
}
tmpAttributeValue = node->ToElement()->Attribute("fill");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false));
} else if (strcmp("false,true", tmpAttributeValue)==0) {
SetFill(bvec2(false,true));
} else if (strcmp("true,false", tmpAttributeValue)==0) {
SetFill(bvec2(true,false));
} else if (strcmp("false", tmpAttributeValue)==0) {
SetFill(bvec2(false,false));
} else {
SetFill(bvec2(true,true));
}
}
tmpAttributeValue = node->ToElement()->Attribute("expand");
if (NULL != tmpAttributeValue) {
if (strcmp("false,false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false));
} else if (strcmp("false,true", tmpAttributeValue)==0) {
SetExpand(bvec2(false,true));
} else if (strcmp("true,false", tmpAttributeValue)==0) {
SetExpand(bvec2(true,false));
} else if (strcmp("false", tmpAttributeValue)==0) {
SetExpand(bvec2(false,false));
} else {
SetExpand(bvec2(true,true));
}
}
tmpAttributeValue = node->ToElement()->Attribute("hide");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
Hide();
} else {
Show();
}
}
tmpAttributeValue = node->ToElement()->Attribute("focus");
if (NULL != tmpAttributeValue) {
if (strcmp("true", tmpAttributeValue)==0) {
KeepFocus();
}
}
tmpAttributeValue = node->ToElement()->Attribute("min-size");
if (NULL != tmpAttributeValue) {
float x,y;
if (2!=sscanf(tmpAttributeValue, "%f,%f", &x, &y)) {
SetMinSize(vec2(x,y));
} else {
EWOL_ERROR("(l "<<node->Row()<<") An error occured when parsing element min-size : " << tmpAttributeValue);
ret = false;
}
}
tmpAttributeValue = node->ToElement()->Attribute("max-size");
if (NULL != tmpAttributeValue) {
float x,y;
if (2!=sscanf(tmpAttributeValue, "%f,%f", &x, &y)) {
SetMaxSize(vec2(x,y));
} else {
EWOL_ERROR("(l "<<node->Row()<<") An error occured when parsing element max-size : " << tmpAttributeValue);
ret = false;
}
}
return ret;
}
bool ewol::Widget::StoreXML(TiXmlNode* node)
{
if (NULL==node) {
return false;
}
/*
TiXmlElement * element = new TiXmlElement(__class__);
if (NULL == element) {
EWOL_ERROR("TinyXML node allocation error");
return false;
}
node->LinkEndChild(element);
*/
if (m_widgetName.Size()!=0) {
node->ToElement()->SetAttribute("name", m_widgetName.c_str() );
}
if (m_userMinSize != vec2(-1,-1)) {
etk::UString tmpVal = etk::UString(m_userMinSize.x()) + "," + etk::UString(m_userMinSize.y());
node->ToElement()->SetAttribute("min-size", tmpVal.c_str() );
}
if (m_userMaxSize != vec2(-1,-1)) {
etk::UString tmpVal = etk::UString(m_userMaxSize.x()) + "," + etk::UString(m_userMaxSize.y());
node->ToElement()->SetAttribute("max-size", tmpVal.c_str() );
}
if (m_userExpend != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userExpend.x()) + "," + etk::UString(m_userExpend.y());
node->ToElement()->SetAttribute("expand", tmpVal.c_str() );
}
if (m_userFill != bvec2(false,false)) {
etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y());
node->ToElement()->SetAttribute("fill", tmpVal.c_str() );
}
if (IsHide() != false) {
node->ToElement()->SetAttribute("hide", "true" );
}
return true;
}

View File

@ -10,6 +10,7 @@
#define __EWOL_WIDGET_H__
#include <ewol/eObject/EObject.h>
#include <tinyXML/tinyxml.h>
namespace ewol {
class Widget;
@ -70,40 +71,10 @@ namespace ewol {
// ----------------------------------------------------------------------------------------------------------------
// -- Widget Size:
// ----------------------------------------------------------------------------------------------------------------
private:
bool m_hide; //!< hide a widget on the display
protected:
// internal element calculated by the system
float m_zoom; //!< generic widget zoom
vec2 m_origin; //!< internal ... I do not really known how i can use it ...
vec2 m_size; //!< internal : current size of the widget
vec2 m_minSize; //!< user define the minimum size of the widget
// user configuaration
vec2 m_userMinSize; //!< user define the minimum size of the widget
vec2 m_userMaxSize; //!< user define the maximum size of the widget
public:
/**
* @brief Set the zoom property of the widget
* @param[in] newVal newZoom value
*/
void SetZoom(float newVal);
/**
* @brief Get the zoom property of the widget
* @return the current zoom value
*/
float GetZoom(void);
/**
* @brief Set origin at the widget (must be an parrent widget that set this parameter).
* This represent the absolute origin in the program windows
* @param[in] x Position ot hte horizantal origin
* @param[in] y Position ot hte vertical origin
*/
void SetOrigin(float x, float y);
/**
* @brief Get the origin (obsolute position in the windows)
* @return coordonate of the origin requested
*/
vec2 GetOrigin(void);
/**
* @brief Convert the absolute position in the local Position (Relative)
* @param[in] pos Absolute position that you request convertion
@ -113,34 +84,62 @@ namespace ewol {
/**
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
* By default this save the widget availlable size in the widget size
* @param[in] availlableX Availlable horisantal pixel size
* @param[in] availlableY Availlable vertical pixel size
* @param[in] availlable Availlable x&y pixel size
*/
// TODO : Remove bool ==> deprecated ...
// TODO : Rename in SetSize()
virtual bool CalculateSize(float availlableX, float availlableY);
//update the min Size ... and the expend parameters for the sizer
virtual void CalculateSize(const vec2& availlable);
/**
* @brief Calculate the minimum size of the widget that is needed to display or the user requested)
*/
// TODO : Remove bool ==> deprecated ...
virtual bool CalculateMinSize(void);
virtual void CalculateMinSize(void);
protected:
// internal element calculated by the system
float m_zoom; //!< generic widget zoom
public:
/**
* @brief Set the zoom property of the widget
* @param[in] newVal newZoom value
*/
virtual void SetZoom(float newVal);
/**
* @brief Get the zoom property of the widget
* @return the current zoom value
*/
virtual float GetZoom(void);
protected:
vec2 m_origin; //!< internal ... I do not really known how i can use it ...
public:
/**
* @brief Set origin at the widget (must be an parrent widget that set this parameter).
* This represent the absolute origin in the program windows
* @param[in] pos Position of the origin
*/
virtual void SetOrigin(const vec2& pos);
/**
* @brief Get the origin (obsolute position in the windows)
* @return coordonate of the origin requested
*/
virtual vec2 GetOrigin(void);
protected:
vec2 m_userMinSize; //!< user define the minimum size of the widget
public:
/**
* @brief User set the minimum size he want to set the display
* @param[in] x Set minimum horizontal size (-1 : no requested)
* @param[in] y Set minimum vertical size (-1 : no requested)
* @param[in] size Set minimum size (none : 0)
*/
virtual void SetMinSize(float x=-1, float y=-1);
virtual void SetMinSize(const vec2& size);
/**
* @brief Get the current calculated min size
* @return the size requested
*/
vec2 GetMinSize(void);
virtual vec2 GetMinSize(void);
/**
* @brief Check if the current min size is compatible wit hte user minimum size
* If it is not the user minimum size will overWrite the minimum size set.
*/
void CheckMinSize(void);
virtual void CheckMinSize(void);
protected:
vec2 m_userMaxSize; //!< user define the maximum size of the widget
public:
/**
* @brief User set the maximum size he want to set the display
* @param[in] size The new maximum size requested (vec2(-1,-1) to unset)
@ -150,78 +149,54 @@ namespace ewol {
* @brief Get the current maximum size
* @return the size requested
*/
vec2 GetMaxSize(void);
virtual vec2 GetMaxSize(void);
/**
* @brief Get the widget size
* @return Requested size
*/
vec2 GetSize(void);
virtual vec2 GetSize(void);
protected:
bvec2 m_userExpend;
bvec2 m_userExpend; // TODO : Rename expand ... :p
public:
/**
* @brief Set the horizontal expend capacity
* @param[in] newExpend new Expend state
* @brief Set the expend capabilities (x&y)
* @param[in] newExpend 2D boolean repensent the capacity to expend
*/
virtual void SetExpendX(bool newExpend=false);
/**
* @brief Get the horizontal expend capabilities
* @return boolean repensent the capacity to expend
*/
virtual bool CanExpentX(void);
/**
* @brief Set the vertical expend capacity
* @param[in] newExpend new Expend state
*/
virtual void SetExpendY(bool newExpend=false);
/**
* @brief Get the vertical expend capabilities
* @return boolean repensent the capacity to expend
*/
virtual bool CanExpentY(void);
virtual void SetExpand(const bvec2& newExpend);
/**
* @brief Get the expend capabilities (x&y)
* @return 2D boolean repensent the capacity to expend
*/
virtual bvec2 CanExpent(void);
virtual bvec2 CanExpand(void);
protected:
bvec2 m_userFill;
public:
/**
* @brief Set the horizontal filling capacity
* @param[in] newFill new fill state
* @brief Set the x&y filling capacity
* @param[in] newFill new x&y fill state
*/
virtual void SetFillX(bool newFill=false);
virtual void SetFill(const bvec2& newFill);
/**
* @brief Get the horizontal filling capabilities
* @return boolean repensent the capacity to horizontal filling
* @brief Get the filling capabilities x&y
* @return bvec2 repensent the capacity to x&y filling
*/
bool CanFillX(void);
/**
* @brief Set the vertical filling capacity
* @param[in] newFill new fill state
*/
virtual void SetFillY(bool newFill=false);
/**
* @brief Get the vertical filling capabilities
* @return boolean repensent the capacity to vertical filling
*/
bool CanFillY(void);
const bvec2& CanFill(void);
protected:
bool m_hide; //!< hide a widget on the display
public:
/**
* @brief Set the widget hidden
*/
void Hide(void);
virtual void Hide(void);
/**
* @brief Set the widget visible
*/
void Show(void);
virtual void Show(void);
/**
* @brief Get the visibility of the widget
* @return true: if the widget is hiden, false: it is visible
*/
bool IsHide(void) { return m_hide; };
virtual bool IsHide(void) { return m_hide; };
// ----------------------------------------------------------------------------------------------------------------
// -- Focus Area
// ----------------------------------------------------------------------------------------------------------------
@ -233,31 +208,31 @@ namespace ewol {
* @brief Get the focus state of the widget
* @return Focus state
*/
bool GetFocus(void) { return m_hasFocus;};
virtual bool GetFocus(void) { return m_hasFocus;};
/**
* @brief Get the capability to have focus
* @return State capability to have focus
*/
bool CanHaveFocus(void) { return m_canFocus;};
virtual bool CanHaveFocus(void) { return m_canFocus;};
/**
* @brief Set focus on this widget
* @return return true if the widget keep the focus
*/
bool SetFocus(void);
virtual bool SetFocus(void);
/**
* @brief Remove the focus on this widget
* @return return true if the widget have release his focus (if he has it)
*/
bool RmFocus(void);
virtual bool RmFocus(void);
/**
* @brief Set the capability to have the focus
* @param[in] canFocusState new focus capability
*/
void SetCanHaveFocus(bool canFocusState);
virtual void SetCanHaveFocus(bool canFocusState);
/**
* @brief Keep the focus on this widget ==> this remove the previous focus on all other widget
*/
void KeepFocus(void);
virtual void KeepFocus(void);
protected:
/**
* @brief Event of the focus has been grep by the current widget
@ -278,12 +253,12 @@ namespace ewol {
* @brief Get the number of mouse event supported
* @return return the number of event that the mouse supported [0..3]
*/
int32_t GetMouseLimit(void) { return m_limitMouseEvent; };
virtual int32_t GetMouseLimit(void) { return m_limitMouseEvent; };
/**
* @brief Get the number of mouse event supported
* @param[in] numberState The number of event that the mouse supported [0..3]
*/
void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; };
virtual void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; };
// ----------------------------------------------------------------------------------------------------------------
// -- keyboard event properties Area
@ -296,12 +271,12 @@ namespace ewol {
* @return true : the event can be repeated.
* @return false : the event must not be repeated.
*/
bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; };
virtual bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; };
/**
* @brief Set the keyboard repeating event supporting.
* @param[in] state The repeating status (true: enable, false disable).
*/
void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; };
virtual void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; };
// ----------------------------------------------------------------------------------------------------------------
// -- Periodic call Area
@ -311,7 +286,7 @@ namespace ewol {
* @brief Request that the current widegt have a periodic call
* @param statusToSet true if the periodic call is needed
*/
void PeriodicCallSet(bool statusToSet);
virtual void PeriodicCallSet(bool statusToSet);
public:
/**
* @brief Periodic call of this widget
@ -370,11 +345,11 @@ namespace ewol {
* @param[in] generateEventId Event generic of the element
* @param[in] data Associate data wit the event
*/
void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false);
virtual void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false);
/**
* @brief Remove all curent shortCut
*/
void ShortCutClean(void);
virtual void ShortCutClean(void);
public:
/**
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
@ -394,13 +369,13 @@ namespace ewol {
/**
* @brief The widget mark itself that it need to regenerate the nest time.
*/
void MarkToRedraw(void);
virtual void MarkToRedraw(void);
/**
* @brief Get the need of the redrawing of the widget and reset it to false
* @return true if we need to redraw
* @return false if we have no need to redraw
*/
bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; };
virtual bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; };
public:
/**
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
@ -429,16 +404,16 @@ namespace ewol {
* @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget.
* @note This done nothing in "Finger" or "Stylet" mode.
*/
void GrabCursor(void);
virtual void GrabCursor(void);
/**
* @brief Un-Grab the cursor (default mode cursor offset)
*/
void UnGrabCursor(void);
virtual void UnGrabCursor(void);
/**
* @brief Get the grabbing status of the cursor.
* @return true if the cursor is curently grabbed
*/
bool GetGrabStatus(void);
virtual bool GetGrabStatus(void);
// DisplayCursorType
private:
ewol::cursorDisplay_te m_cursorDisplay;
@ -447,13 +422,29 @@ namespace ewol {
* @brief Set the cursor display type.
* @param[in] newCursor selected new cursor.
*/
void SetCursor(ewol::cursorDisplay_te newCursor);
virtual void SetCursor(ewol::cursorDisplay_te newCursor);
/**
* @brief Get the currrent cursor.
* @return the type of the cursor.
*/
ewol::cursorDisplay_te GetCursor(void);
virtual ewol::cursorDisplay_te GetCursor(void);
private:
etk::UString m_widgetName;
public:
/**
* @brief Load properties with an XML node.
* @param[in] node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool LoadXML(TiXmlNode* node);
/**
* @brief Store properties in this XML node.
* @param[in,out] node Pointer on the tinyXML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool StoreXML(TiXmlNode* node);
}; // end of the class Widget declaration

View File

@ -10,7 +10,16 @@
#include <ewol/widget/Joystick.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/ButtonColor.h>
//#include <ewol/widget/Scene.h>
#include <ewol/widget/Spacer.h>
#include <ewol/widget/Slider.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/ProgressBar.h>
#include <ewol/widget/Layer.h>
#include <ewol/widget/Label.h>
#include <ewol/widget/Image.h>
#include <ewol/widget/Gird.h>
#include <ewol/widget/Entry.h>
#include <ewol/widget/CheckBox.h>
#include <etk/Vector.h>
#undef __class__
@ -26,16 +35,41 @@ static bool l_havePeriodic = false;
static bool l_haveRedraw = true;
class dataStructCreator
{
public:
etk::UString name;
ewol::widgetManager::creator_tf pointer;
};
static etk::Vector<dataStructCreator> l_creatorList;
void ewol::widgetManager::Init(void)
{
EWOL_DEBUG("==> Init Widget-Manager");
// prevent android error ==> can create memory leak but I prefer
m_focusWidgetDefault = NULL;
m_focusWidgetCurrent = NULL;
l_creatorList.Clear();
l_listOfPeriodicWidget.Clear();
l_havePeriodic = false;
l_haveRedraw = true;
//ewol::WIDGET_SceneInit();
widget::Button::Init();
widget::ButtonColor::Init();
widget::Spacer::Init();
widget::Slider::Init();
widget::Sizer::Init();
widget::ProgressBar::Init();
widget::Layer::Init();
widget::Label::Init();
widget::Image::Init();
widget::Gird::Init();
widget::Entry::Init();
widget::CheckBox::Init();
IsInit = true;
}
@ -46,9 +80,24 @@ void ewol::widgetManager::UnInit(void)
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
widget::CheckBox::UnInit();
widget::Entry::UnInit();
widget::Gird::UnInit();
widget::Image::UnInit();
widget::Label::UnInit();
widget::Layer::UnInit();
widget::ProgressBar::UnInit();
widget::Sizer::UnInit();
widget::Slider::UnInit();
widget::Spacer::UnInit();
widget::ButtonColor::UnInit();
widget::Button::UnInit();
IsInit = false;
l_listOfPeriodicWidget.Clear();
l_creatorList.Clear();
}
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
@ -203,3 +252,64 @@ bool ewol::widgetManager::IsDrawingNeeded(void)
l_haveRedraw = false;
return tmp;
}
// element that generate the list of elements
void ewol::widgetManager::AddWidgetCreator(const etk::UString& name, ewol::widgetManager::creator_tf pointer)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name == l_creatorList[iii].name) {
if (NULL==pointer) {
EWOL_INFO("Remove Creator of a specify widget : " << name);
} else {
EWOL_WARNING("Replace Creator of a specify widget : " << name);
l_creatorList[iii].pointer = pointer;
}
return;
}
}
if (NULL==pointer) {
return;
}
EWOL_INFO("Add Creator of a specify widget : " << name);
dataStructCreator tmpStruct;
tmpStruct.name = name;
tmpStruct.pointer = pointer;
l_creatorList.PushBack(tmpStruct);
}
ewol::Widget* ewol::widgetManager::Create(const etk::UString& name)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name == l_creatorList[iii].name) {
if (NULL != l_creatorList[iii].pointer) {
return (*l_creatorList[iii].pointer)();
}
}
}
EWOL_WARNING("try to create an UnExistant widget : " << name);
return NULL;
}
bool ewol::widgetManager::Exist(const etk::UString& name)
{
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
if (name == l_creatorList[iii].name) {
return true;
}
}
return false;
}
etk::UString ewol::widgetManager::List(void)
{
etk::UString tmpVal;
for (int32_t iii=0; iii<l_creatorList.Size() ; iii++) {
tmpVal += l_creatorList[iii].name;
tmpVal += ",";
}
return tmpVal;
}

View File

@ -13,6 +13,7 @@
#include <ewol/debug.h>
#include <etk/Vector.h>
#include <ewol/widget/Widget.h>
#include <tinyXML/tinyxml.h>
namespace ewol {
namespace widgetManager {
@ -34,6 +35,13 @@ namespace ewol {
void MarkDrawingIsNeeded(void);
bool IsDrawingNeeded(void);
typedef ewol::Widget* (*creator_tf)(void);
// element that generate the list of elements
void AddWidgetCreator(const etk::UString& name, creator_tf pointer);
ewol::Widget* Create(const etk::UString& name);
bool Exist(const etk::UString& name);
etk::UString List(void);
};
};

View File

@ -50,23 +50,22 @@ ewol::Windows::~Windows(void)
}
bool ewol::Windows::CalculateSize(float availlableX, float availlableY)
void ewol::Windows::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("calculateMinSize on : " << m_currentCreateId);
m_size.setValue(availlableX, availlableY);
m_size = availlable;
if (NULL != m_subWidget) {
m_subWidget->CalculateMinSize();
// TODO : Check if min Size is possible ...
// TODO : Herited from MinSize .. and expand ???
m_subWidget->CalculateSize(m_size.x(), m_size.y());
m_subWidget->CalculateSize(m_size);
}
for(int32_t iii=0; iii<m_popUpWidgetList.Size(); iii++) {
if (NULL != m_popUpWidgetList[iii]) {
m_popUpWidgetList[iii]->CalculateMinSize();
m_popUpWidgetList[iii]->CalculateSize(m_size.x(), m_size.y());
m_popUpWidgetList[iii]->CalculateSize(m_size);
}
}
return true;
}
@ -191,7 +190,7 @@ void ewol::Windows::SetSubWidget(ewol::Widget * widget)
}
m_subWidget = widget;
// Regenerate the size calculation :
CalculateSize(m_size.x(), m_size.y());
CalculateSize(m_size);
}
@ -199,7 +198,7 @@ void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget)
{
m_popUpWidgetList.PushBack(widget);
// Regenerate the size calculation :
CalculateSize(m_size.x(), m_size.y());
CalculateSize(m_size);
// TODO : it is dansgerous to access directly to the system ...
eSystem::ResetIOEvent();
}

View File

@ -21,7 +21,7 @@ namespace ewol {
Windows(void);
virtual ~Windows(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolWindows"; };
virtual const char * const GetObjectType(void) { return "Ewol::Windows"; };
// internal event at ewol system :
public:
void SysDraw(void);
@ -36,7 +36,7 @@ namespace ewol {
virtual void On(void) { };
public:
// Derived function
virtual bool CalculateSize(float availlableX, float availlableY);
virtual void CalculateSize(const vec2& availlable);
// Derived function
virtual ewol::Widget * GetWidgetAtPos(vec2 pos);
private:

View File

@ -28,10 +28,8 @@ namespace widget {
FileChooser(void);
virtual ~FileChooser(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolFileChooser"; };
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::FileChooser"; };
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
void SetTitle(etk::UString label);
void SetValidateLabel(etk::UString label);

View File

@ -64,6 +64,7 @@ FILE_LIST+= ewol/widget/Widget.cpp \
ewol/widget/CheckBox.cpp \
ewol/widget/ColorBar.cpp \
ewol/widget/ContextMenu.cpp \
ewol/widget/Composer.cpp \
ewol/widget/Drawable.cpp \
ewol/widget/Entry.cpp \
ewol/widget/Joystick.cpp \