[DEV] generate warning when delete in an error state and rework pop-up and contextmenu

This commit is contained in:
Edouard DUPIN 2013-04-15 21:18:54 +02:00
parent 3e29816651
commit 87676f657a
20 changed files with 202 additions and 335 deletions

View File

@ -111,11 +111,16 @@ vec2 ewol::Dimension::Get(ewol::Dimension::distance_te type) const
void ewol::Dimension::Set(const vec2& _size, ewol::Dimension::distance_te type)
{
// Set min max on input to limit error :
vec2 size(etk_avg(0,_size.x(),999999999999999.0),
etk_avg(0,_size.y(),999999999999999.0));
vec2 size(etk_avg(0.0f,_size.x(),9999999.0f),
etk_avg(0.0f,_size.y(),9999999.0f));
switch(type) {
case ewol::Dimension::Pourcent:
m_data = vec2(size.x()*0.01f, size.y()*0.01f);
{
vec2 size2(etk_avg(0.0f,_size.x(),100.0f),
etk_avg(0.0f,_size.y(),100.0f));
m_data = vec2(size2.x()*0.01f, size2.y()*0.01f);
//EWOL_VERBOSE("Set % : " << size2 << " ==> " << m_data);
}
break;
case ewol::Dimension::Pixel:
m_data = size;
@ -148,7 +153,9 @@ vec2 ewol::Dimension::GetPixel(void) const
return m_data;
} else {
vec2 windDim = windowsSize.GetPixel();
return vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y());
vec2 res = vec2(windDim.x()*m_data.x(), windDim.y()*m_data.y());
//EWOL_DEBUG("Get % : " << m_data << " / " << windDim << "==> " << res);
return res;
}
}

View File

@ -447,7 +447,7 @@ void ewol::Drawing::LineTo(vec3 dest)
{
ResetCount();
InternalSetColor(m_color);
EWOL_DEBUG("DrawLine : " << m_position << " to " << dest);
//EWOL_DEBUG("DrawLine : " << m_position << " to " << dest);
if (m_position.x() == dest.x() && m_position.y() == dest.y() && m_position.z() == dest.z()) {
EWOL_WARNING("Try to draw an line width 0");
return;

View File

@ -146,6 +146,7 @@ void ewol::EObject::AddEventId(const char * generateEventId)
void ewol::EObject::GenerateEventId(const char * generateEventId, const etk::UString& data)
{
int32_t nbObject = ewol::EObjectManager::GetNumberObject();
// for every element registered ...
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
@ -157,11 +158,18 @@ void ewol::EObject::GenerateEventId(const char * generateEventId, const etk::USt
}
}
}
if (nbObject > ewol::EObjectManager::GetNumberObject()) {
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous");
}
}
void ewol::EObject::SendMultiCast(const char* const messageId, const etk::UString& data)
{
int32_t nbObject = ewol::EObjectManager::GetNumberObject();
MultiCastSend(this, messageId, data);
if (nbObject > ewol::EObjectManager::GetNumberObject()) {
EWOL_CRITICAL("It if really dangerous ro remove (delete) element inside a callback ... use ->RemoveObject() which is asynchronous");
}
}
void ewol::EObject::RegisterMultiCast(const char* const messageId)

View File

@ -20,6 +20,7 @@ static etk::Vector<ewol::EObject*> m_eObjectList; // all widget al
static etk::Vector<ewol::EObject*> m_eObjectAutoRemoveList; // all widget allocated
void ewol::EObjectManager::Init(void)
{
EWOL_DEBUG("==> Init EObject-Manager");
@ -56,6 +57,11 @@ void ewol::EObjectManager::Add(ewol::EObject* object)
}
}
int32_t ewol::EObjectManager::GetNumberObject(void)
{
return m_eObjectList.Size() + m_eObjectAutoRemoveList.Size();
}
void informOneObjectIsRemoved(ewol::EObject* object)
{
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {

View File

@ -14,12 +14,13 @@
namespace ewol {
namespace EObjectManager {
void Init( void);
void UnInit( void);
void Add( ewol::EObject* object);
void Rm( ewol::EObject* object);
void Init(void);
void UnInit(void);
void Add(ewol::EObject* object);
void Rm(ewol::EObject* object);
int32_t GetNumberObject(void);
void AutoRemove( ewol::EObject* object);
void AutoRemove(ewol::EObject* object);
void RemoveAllAutoRemove(void);
};
};

View File

@ -201,7 +201,7 @@ bool widget::ButtonColor::OnEventInput(ewol::keyEvent::type_te type, int32_t IdI
widget::ColorChooser * myColorChooser = new widget::ColorChooser();
myColorChooser->SetColor(m_textColorFg);
// set it in the pop-up-system :
m_widgetContextMenu->SubWidgetSet(myColorChooser);
m_widgetContextMenu->SetSubWidget(myColorChooser);
myColorChooser->RegisterOnEvent(this, ewolEventColorChooserChange, ewolEventColorChooserChange);
ewol::WindowsPopUpAdd(m_widgetContextMenu);
MarkToRedraw();

View File

@ -20,7 +20,7 @@ namespace widget
*/
class Container : public ewol::Widget
{
private:
protected:
ewol::Widget* m_subWidget;
public:
/**

View File

@ -164,7 +164,7 @@ void widget::ContainerN::OnObjectRemove(ewol::EObject* removeObject)
void widget::ContainerN::OnDraw(ewol::DrawProperty& displayProp)
{
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
for (int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(displayProp);
}

View File

@ -16,13 +16,13 @@
widget::ContextMenu::ContextMenu(void)
{
m_userExpand.setValue(true,true);
m_userExpand.setValue(false,false);
m_padding.setValue(4,4);
m_offset = 20;
m_colorBackGroung = draw::color::white;
m_colorBorder = draw::color::black;
m_colorBorder.a = 0x7F;
@ -33,7 +33,7 @@ widget::ContextMenu::ContextMenu(void)
widget::ContextMenu::~ContextMenu(void)
{
SubWidgetRemove();
}
@ -107,49 +107,21 @@ void widget::ContextMenu::CalculateSize(const vec2& availlable)
void widget::ContextMenu::CalculateMinMaxSize(void)
{
EWOL_DEBUG("CalculateMinSize");
//EWOL_DEBUG("CalculateMinSize");
m_userExpand.setValue(false,false);
m_minSize.setValue(50,50);
if (NULL != m_subWidget) {
m_subWidget->CalculateMinMaxSize();
m_minSize = m_subWidget->GetCalculateMinSize();
}
EWOL_DEBUG("CalculateMinSize=>>" << m_minSize);
//EWOL_DEBUG("CalculateMinSize=>>" << m_minSize);
MarkToRedraw();
}
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::SetExpand(const bvec2& newExpand)
{
EWOL_ERROR("Pop-up can not have a user expand settings X (herited from under elements)");
}
void widget::ContextMenu::SubWidgetSet(ewol::Widget* newWidget)
{
if (NULL == newWidget) {
return;
}
m_subWidget = newWidget;
}
void widget::ContextMenu::SubWidgetRemove(void)
{
if (NULL != m_subWidget) {
delete(m_subWidget);
m_subWidget = NULL;
}
}
void widget::ContextMenu::OnDraw(ewol::DrawProperty& displayProp)
{
//EWOL_DEBUG("On Draw " << m_currentDrawId);
widget::Drawable::OnDraw(displayProp);
m_compositing.Draw();
if (NULL != m_subWidget) {
m_subWidget->GenDraw(displayProp);
}
@ -159,91 +131,68 @@ void widget::ContextMenu::OnDraw(ewol::DrawProperty& displayProp)
void widget::ContextMenu::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
}
// generate a white background and take gray on other surfaces
ClearOObjectList();
ewol::Drawing * BGOObjects = new ewol::Drawing();
AddOObject(BGOObjects);
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
// display border ...
BGOObjects->SetColor(m_colorBorder);
switch (m_arrawBorder)
{
case widget::CONTEXT_MENU_MARK_TOP:
BGOObjects->SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0.0f) );
BGOObjects->AddVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
float laking = m_offset - m_padding.y();
BGOObjects->SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
BGOObjects->AddVertex();
BGOObjects->SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()-laking, 0.0f) );
BGOObjects->AddVertex();
} else {
float laking = m_offset - m_padding.y();
BGOObjects->SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
BGOObjects->AddVertex();
BGOObjects->SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()-laking, 0.0f) );
BGOObjects->AddVertex();
}
break;
case widget::CONTEXT_MENU_MARK_BOTTOM:
BGOObjects->SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0) );
BGOObjects->AddVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
int32_t laking = m_offset - m_padding.y();
BGOObjects->SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
BGOObjects->AddVertex();
BGOObjects->SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()+laking, 0.0f) );
BGOObjects->AddVertex();
} else {
int32_t laking = m_offset - m_padding.y();
BGOObjects->SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
BGOObjects->AddVertex();
BGOObjects->SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()+laking, 0.0f) );
BGOObjects->AddVertex();
}
break;
default:
case widget::CONTEXT_MENU_MARK_RIGHT:
case widget::CONTEXT_MENU_MARK_LEFT:
EWOL_TODO("later");
break;
m_compositing.Clear();
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
// display border ...
m_compositing.SetColor(m_colorBorder);
switch (m_arrawBorder)
{
case widget::CONTEXT_MENU_MARK_TOP:
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0.0f) );
m_compositing.AddVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
float laking = m_offset - m_padding.y();
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
m_compositing.AddVertex();
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()-laking, 0.0f) );
m_compositing.AddVertex();
} else {
float laking = m_offset - m_padding.y();
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
m_compositing.AddVertex();
m_compositing.SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()-laking, 0.0f) );
m_compositing.AddVertex();
}
break;
case widget::CONTEXT_MENU_MARK_BOTTOM:
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0) );
m_compositing.AddVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
int32_t laking = m_offset - m_padding.y();
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
m_compositing.AddVertex();
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()+laking, 0.0f) );
m_compositing.AddVertex();
} else {
int32_t laking = m_offset - m_padding.y();
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
m_compositing.AddVertex();
m_compositing.SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()+laking, 0.0f) );
m_compositing.AddVertex();
}
break;
default:
case widget::CONTEXT_MENU_MARK_RIGHT:
case widget::CONTEXT_MENU_MARK_LEFT:
EWOL_TODO("later");
break;
}
m_compositing.SetPos(vec3(tmpOrigin.x()-m_padding.x(), tmpOrigin.y() - m_padding.y(), 0.0f) );
m_compositing.RectangleWidth(vec3(tmpSize.x() + m_padding.x()*2, tmpSize.y() + m_padding.y()*2, 0.0f) );
// set the area in white ...
m_compositing.SetColor(m_colorBackGroung);
m_compositing.SetPos(vec3(tmpOrigin.x(), tmpOrigin.y(), 0.0f) );
m_compositing.RectangleWidth(vec3(tmpSize.x(), tmpSize.y(), 0.0f) );
}
BGOObjects->SetPos(vec3(tmpOrigin.x()-m_padding.x(), tmpOrigin.y() - m_padding.y(), 0.0f) );
BGOObjects->RectangleWidth(vec3(tmpSize.x() + m_padding.x()*2, tmpSize.y() + m_padding.y()*2, 0.0f) );
// set the area in white ...
BGOObjects->SetColor(m_colorBackGroung);
BGOObjects->SetPos(vec3(tmpOrigin.x(), tmpOrigin.y(), 0.0f) );
BGOObjects->RectangleWidth(vec3(tmpSize.x(), tmpSize.y(), 0.0f) );
}
if (NULL != m_subWidget) {
m_subWidget->OnRegenerateDisplay();
}
}
ewol::Widget * widget::ContextMenu::GetWidgetAtPos(const vec2& pos)
{
// calculate relative position
vec2 relativePos = RelativePosition(pos);
// Check for sub Element
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
if( (tmpOrigin.x() <= relativePos.x() && tmpOrigin.x() + tmpSize.x() >= relativePos.x())
&& (tmpOrigin.y() <= relativePos.y() && tmpOrigin.y() + tmpSize.y() >= relativePos.y()) )
{
return m_subWidget->GetWidgetAtPos(pos);
}
}
return this;
}
bool widget::ContextMenu::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos)
{
//EWOL_INFO("Event ouside the context menu");
@ -271,3 +220,11 @@ void widget::ContextMenu::SetPositionMark(markPosition_te position, vec2 arrowPo
MarkToRedraw();
}
ewol::Widget* widget::ContextMenu::GetWidgetAtPos(const vec2& pos)
{
ewol::Widget* val = widget::Container::GetWidgetAtPos(pos);
if (NULL != val) {
return val;
}
return this;
}

View File

@ -12,8 +12,8 @@
#include <etk/types.h>
#include <draw/Color.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Drawable.h>
#include <ewol/widget/Container.h>
#include <ewol/compositing/Drawing.h>
namespace widget {
typedef enum {
@ -23,38 +23,30 @@ namespace widget {
CONTEXT_MENU_MARK_LEFT,
CONTEXT_MENU_MARK_NONE
}markPosition_te;
class ContextMenu : public widget::Drawable
class ContextMenu : public widget::Container
{
public:
ContextMenu(void);
virtual ~ContextMenu(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolContextMenu"; };
public:
virtual void CalculateSize(const vec2& availlable); // this generate the current size ...
virtual void CalculateMinMaxSize(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:
ewol::Drawing m_compositing;
draw::Color m_colorBackGroung;
draw::Color m_colorBorder;
vec2 m_padding;
vec2 m_arrowPos;
float m_offset;
markPosition_te m_arrawBorder;
ewol::Widget* m_subWidget;
public:
void SubWidgetSet(ewol::Widget* newWidget);
void SubWidgetRemove(void);
void SetPositionMark(markPosition_te position, vec2 arrowPos);
protected:
// Derived function
void SetPositionMark(markPosition_te position, vec2 arrowPos);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public:
// Derived function
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, const vec2& pos);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::ContextMenu"; };
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
};
};

View File

@ -127,7 +127,7 @@ void widget::Image::OnRegenerateDisplay(void)
// set the somposition properties :
m_compositing.SetPos(origin);
m_compositing.Print(imageRealSize);
EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin);
//EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin);
}
}

View File

@ -134,7 +134,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
SendMultiCast(m_listElement[iii]->m_generateEvent, m_listElement[iii]->m_message);
if (NULL != m_widgetContextMenu) {
EWOL_DEBUG("Mark the menu to remove ...");
delete(m_widgetContextMenu);
m_widgetContextMenu->RemoveObject();
m_widgetContextMenu = NULL;
}
return;
@ -177,7 +177,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
mySizer = new widget::Sizer(widget::Sizer::modeVert);
mySizer->LockExpand(vec2(true,true));
// set it in the pop-up-system :
m_widgetContextMenu->SubWidgetSet(mySizer);
m_widgetContextMenu->SetSubWidget(mySizer);
for(int32_t jjj=m_listElement.Size()-1; jjj>=0; jjj--) {
if (m_listElement[iii]!=NULL) {

View File

@ -13,53 +13,45 @@
#undef __class__
#define __class__ "PopUp"
widget::PopUp::PopUp(void) :
m_subWidgetNext(NULL)
widget::PopUp::PopUp(void)
{
m_userExpand.setValue(true, true);
m_userExpand.setValue(false, false);
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
m_colorBackGroung = draw::color::white;
m_colorEmptyArea = draw::color::black;
m_colorEmptyArea.a = 0x7F;
m_colorBorder = draw::color::black;
m_colorBorder.a = 0x7F;
m_subWidget = 0;
}
widget::PopUp::~PopUp(void)
{
SubWidgetRemove();
}
void widget::PopUp::CalculateSize(const vec2& availlable)
{
//EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display :
m_size = availlable;
if (NULL != m_subWidget) {
vec2 subWidgetSize;
vec2 subWidgetOrigin;
subWidgetSize = m_subWidget->GetCalculateMinSize();
vec2 subElementSize = m_minSize;
vec2 subElementOrigin = m_origin + (m_size-m_minSize)/2.0f;
vec2 subWidgetSize = m_subWidget->GetCalculateMinSize();
if (true == m_subWidget->CanExpand().x()) {
subWidgetSize.setX(m_size.x());
subWidgetSize.setX(m_minSize.x());
}
if (true == m_subWidget->CanExpand().y()) {
subWidgetSize.setY(m_size.y());
subWidgetSize.setY(m_minSize.y());
}
if (m_displayRatio>0.1 && m_displayRatio<=1) {
subWidgetSize.setValue(etk_max(m_size.x()*m_displayRatio, subWidgetSize.x()),
etk_max(m_size.y()*m_displayRatio, subWidgetSize.y()) );
}
// force to be an integer ...
subWidgetSize.setValue((int32_t)subWidgetSize.x(), (int32_t)subWidgetSize.y());
// limit the size of the element :
subWidgetSize.setMin(m_minSize);
// posiition at a int32_t pos :
subWidgetSize = vec2ClipInt32(subWidgetSize);
// set config to the Sub-widget
subWidgetOrigin.setValue((int32_t)(m_size.x() - m_origin.x() - subWidgetSize.x())/2 + m_origin.x(),
(int32_t)(m_size.y() - m_origin.y() - subWidgetSize.y())/2 + m_origin.y());
vec2 subWidgetOrigin = m_origin + (m_size-subWidgetSize)/2.0f;
m_subWidget->SetOrigin(subWidgetOrigin);
m_subWidget->CalculateSize(subWidgetSize);
@ -70,55 +62,28 @@ void widget::PopUp::CalculateSize(const vec2& availlable)
void widget::PopUp::CalculateMinMaxSize(void)
{
//EWOL_DEBUG("CalculateMinMaxSize");
// remove expand of sub widget ==> not needed ...
m_userExpand.setValue(false,false);
m_minSize.setValue(50, 50);
if (m_userMinSize.GetType() != ewol::Dimension::Pourcent) {
EWOL_ERROR(" ==> Please set pourcent size of the popo_up view");
m_minSize.setValue(50, 50);
} else {
m_minSize = m_userMinSize.GetPixel();
}
if (NULL != m_subWidget) {
m_subWidget->CalculateMinMaxSize();
vec2 tmpSize = m_subWidget->GetCalculateMinSize();
m_minSize = tmpSize;
m_minSize.setMax(tmpSize);
}
//EWOL_DEBUG("CalculateMinSize(" << m_minSize.x << "," << m_minSize.y << ")");
EWOL_DEBUG("CalculateMinSize=" << m_minSize);
MarkToRedraw();
}
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::SetExpand(const bvec2& newExpand)
{
EWOL_ERROR("Pop-up can not have a user expand settings X (herited from under elements)");
}
void widget::PopUp::SubWidgetSet(ewol::Widget* newWidget)
{
if (NULL == newWidget) {
EWOL_ERROR("Try to set a sub wiget with NULL pointer ...");
return;
}
SubWidgetRemove();
m_subWidget = newWidget;
//EWOL_DEBUG("SetSubWidget on Pop-Up : " << (int64_t)m_subWidget);
MarkToRedraw();
}
void widget::PopUp::SubWidgetRemove(void)
{
if (NULL != m_subWidget) {
delete(m_subWidget);
m_subWidget = NULL;
}
MarkToRedraw();
}
void widget::PopUp::OnDraw(ewol::DrawProperty& displayProp)
{
// draw upper classes
widget::Drawable::OnDraw(displayProp);
m_compositing.Draw();
if (NULL != m_subWidget) {
m_subWidget->GenDraw(displayProp);
}
@ -128,68 +93,33 @@ void widget::PopUp::OnDraw(ewol::DrawProperty& displayProp)
void widget::PopUp::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_compositing.Clear();
m_compositing.SetColor(m_colorEmptyArea);
m_compositing.SetPos(vec3(0,0,0));
m_compositing.RectangleWidth(vec3(m_size.x(), m_size.y(), 0));
// set the area in white ...
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
m_compositing.SetColor(m_colorBorder);
m_compositing.SetPos(vec3(tmpOrigin.x()-BORDER_SIZE_TMP, tmpOrigin.y()-BORDER_SIZE_TMP,0) );
m_compositing.RectangleWidth(vec3(tmpSize.x()+2*BORDER_SIZE_TMP, tmpSize.y()+2*BORDER_SIZE_TMP, 0) );
m_compositing.SetColor(m_colorBackGroung);
m_compositing.SetPos(vec3(tmpOrigin.x(), tmpOrigin.y(),0) );
m_compositing.RectangleWidth(vec3(tmpSize.x(), tmpSize.y(), 0) );
}
}
// generate a white background and take gray on other surfaces
ClearOObjectList();
ewol::Drawing * BGOObjects = new ewol::Drawing();
AddOObject(BGOObjects);
BGOObjects->SetColor(m_colorEmptyArea);
BGOObjects->SetPos(vec3(0,0,0));
BGOObjects->RectangleWidth(vec3(m_size.x(), m_size.y(), 0));
// set the area in white ...
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
BGOObjects->SetColor(m_colorBorder);
BGOObjects->SetPos(vec3(tmpOrigin.x()-BORDER_SIZE_TMP, tmpOrigin.y()-BORDER_SIZE_TMP,0) );
BGOObjects->RectangleWidth(vec3(tmpSize.x()+2*BORDER_SIZE_TMP, tmpSize.y()+2*BORDER_SIZE_TMP, 0) );
BGOObjects->SetColor(m_colorBackGroung);
BGOObjects->SetPos(vec3(tmpOrigin.x(), tmpOrigin.y(),0) );
BGOObjects->RectangleWidth(vec3(tmpSize.x(), tmpSize.y(), 0) );
}
// SUBwIDGET GENERATION ...
if (NULL != m_subWidget) {
m_subWidget->OnRegenerateDisplay();
}
}
ewol::Widget * widget::PopUp::GetWidgetAtPos(const vec2& pos)
ewol::Widget* widget::PopUp::GetWidgetAtPos(const vec2& pos)
{
// calculate relative position
vec2 relativePos = RelativePosition(pos);
// for the element in the pop-up ...
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
vec2 tmpOrigin = m_subWidget->GetOrigin();
if( (tmpOrigin.x() <= relativePos.x() && tmpOrigin.x() + tmpSize.x() >= relativePos.x())
&& (tmpOrigin.y() <= relativePos.y() && tmpOrigin.y() + tmpSize.y() >= relativePos.y()) )
{
return m_subWidget->GetWidgetAtPos(pos);
} else {
//EWOL_INFO("Event ouside the Pop-up");
}
ewol::Widget* val = widget::Container::GetWidgetAtPos(pos);
if (NULL != val) {
return val;
}
// otherwise the event go to this widget ...
return this;
}
void widget::PopUp::SetDisplayRatio(float ratio)
{
m_displayRatio = ratio;
MarkToRedraw();
}
void widget::PopUp::OnObjectRemove(ewol::EObject * removeObject)
{
// First step call parrent :
widget::Drawable::OnObjectRemove(removeObject);
// second step find if in all the elements ...
if(m_subWidget == removeObject) {
EWOL_DEBUG("Remove pop-up sub Element ==> destroyed object");
m_subWidget = NULL;
}
}

View File

@ -13,43 +13,28 @@
#include <draw/Color.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Drawable.h>
#include <ewol/widget/Container.h>
#include <ewol/compositing/Drawing.h>
namespace widget {
class PopUp : public widget::Drawable
class PopUp : public widget::Container
{
public:
PopUp(void);
virtual ~PopUp(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolPopUp"; };
public:
// Derived function
private:
draw::Color m_colorBackGroung;
draw::Color m_colorBorder;
draw::Color m_colorEmptyArea;
ewol::Drawing m_compositing;
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateMinMaxSize(void);
virtual void SetMinSize(const vec2& size);
virtual void SetExpand(const bvec2& newExpend);
void SetDisplayRatio(float ratio);
private:
draw::Color m_colorBackGroung;
draw::Color m_colorBorder;
draw::Color m_colorEmptyArea;
ewol::Widget* m_subWidgetNext;
ewol::Widget* m_subWidget;
float m_displayRatio;
public:
void SubWidgetSet(ewol::Widget* newWidget);
void SubWidgetRemove(void);
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
virtual const char * const GetObjectType(void) { return "ewol::PopUp"; };
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
};
};

View File

@ -33,7 +33,7 @@ void widget::Spacer::UnInit(void)
widget::Spacer::Spacer(void)
{
m_localSize = 10;
m_userMinSize = vec2(10,10);
SetCanHaveFocus(false);
m_color = draw::color::black;
m_color.a = 0;
@ -44,20 +44,6 @@ widget::Spacer::~Spacer(void)
}
void widget::Spacer::CalculateMinMaxSize(void)
{
m_minSize.setValue(m_localSize, m_localSize);
}
void widget::Spacer::SetSize(float size)
{
m_localSize = size;
MarkToRedraw();
}
void widget::Spacer::OnDraw(ewol::DrawProperty& displayProp)
{
m_draw.Draw();

View File

@ -23,8 +23,6 @@ namespace widget {
static void UnInit(void);
private:
ewol::Drawing m_draw; //!< Compositing drawing element
float m_localSize; //!< Local request size of the display
draw::Color m_color; //!< Background color
public:
/**
* @brief Main constructer
@ -34,11 +32,9 @@ namespace widget {
* @brief Main destructer
*/
virtual ~Spacer(void);
/**
* @brief Set the minimum size requested
* @param[in] size Requested size of the minimum display (in X and Y)
*/
void SetSize(float size);
protected:
draw::Color m_color; //!< Background color
public:
/**
* @brief Spziby the background color (basicly transparent)
* @param[in] newColor the display background color
@ -46,8 +42,7 @@ namespace widget {
void SetColor(draw::Color newColor) { m_color = newColor; MarkToRedraw(); };
public:
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Spacer"; };
virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::spacer"; };
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos) { return NULL; };
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);

View File

@ -214,7 +214,7 @@ void ewol::widgetManager::PeriodicCallAdd(ewol::Widget * pWidget)
void ewol::widgetManager::PeriodicCallRm(ewol::Widget * pWidget)
{
int32_t nbElement = 0;
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
for (int32_t iii=l_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (l_listOfPeriodicWidget[iii] == pWidget) {
l_listOfPeriodicWidget[iii] = NULL;
} else {
@ -228,7 +228,7 @@ void ewol::widgetManager::PeriodicCallRm(ewol::Widget * pWidget)
void ewol::widgetManager::PeriodicCall(int64_t localTime)
{
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
for (int32_t iii=l_listOfPeriodicWidget.Size()-1; iii>=0 ; iii--) {
if (NULL != l_listOfPeriodicWidget[iii]) {
l_listOfPeriodicWidget[iii]->PeriodicCall(localTime);
}

View File

@ -28,8 +28,8 @@ namespace ewol {
ewol::Widget* FocusGet(void);
void FocusRemoveIfRemove(ewol::Widget * newWidget);
void PeriodicCallAdd(ewol::Widget * pWidget);
void PeriodicCallRm( ewol::Widget * pWidget);
void PeriodicCallAdd(ewol::Widget* pWidget);
void PeriodicCallRm(ewol::Widget* pWidget);
void PeriodicCall(int64_t localTime);
bool PeriodicCallHave(void);

View File

@ -70,11 +70,11 @@ widget::FileChooser::FileChooser(void)
widget::Image * myImage = NULL;
m_folder = etk::GetUserHomeFolder();
#if defined(__TARGET_OS__Android)
SetDisplayRatio(0.90);
SetMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent));;
#elif defined(__TARGET_OS__Windows)
SetDisplayRatio(0.80);
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));;
#else
SetDisplayRatio(0.80);
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));;
#endif
m_file = "";
@ -120,7 +120,7 @@ widget::FileChooser::FileChooser(void)
} else {
mySizerVert->LockExpand(bvec2(true,true));
// set it in the pop-up-system :
SubWidgetSet(mySizerVert);
SetSubWidget(mySizerVert);
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
if (NULL == mySizerHori) {
@ -182,7 +182,7 @@ widget::FileChooser::FileChooser(void)
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetSize(2);
mySpacer->SetMinSize(vec2(2,2));
mySizerHori->SubWidgetAdd(mySpacer);
}
m_widgetListFolder = new widget::ListFileSystem();
@ -201,7 +201,7 @@ widget::FileChooser::FileChooser(void)
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetSize(2);
mySpacer->SetMinSize(vec2(2,2));
mySizerHori->SubWidgetAdd(mySpacer);
}
m_widgetListFile = new widget::ListFileSystem();
@ -221,7 +221,7 @@ widget::FileChooser::FileChooser(void)
if (NULL == mySpacer) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetSize(2);
mySpacer->SetMinSize(vec2(2,2));
mySizerHori->SubWidgetAdd(mySpacer);
}
}

View File

@ -38,9 +38,9 @@ widget::Parameter::Parameter(void) :
widget::Sizer * mySizerHori = NULL;
widget::Spacer * mySpacer = NULL;
#ifdef __TARGET_OS__Android
SetDisplayRatio(0.90);
SetMinSize(ewol::Dimension(vec2(90,90),ewol::Dimension::Pourcent));
#else
SetDisplayRatio(0.80);
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
#endif
mySizerVert = new widget::Sizer(widget::Sizer::modeVert);
@ -50,7 +50,7 @@ widget::Parameter::Parameter(void) :
EWOL_INFO("add widget");
mySizerVert->LockExpand(bvec2(true,true));
// set it in the pop-up-system :
SubWidgetSet(mySizerVert);
SetSubWidget(mySizerVert);
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
if (NULL == mySizerHori) {
@ -100,7 +100,7 @@ widget::Parameter::Parameter(void) :
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetFill(bvec2(false,true));
mySpacer->SetSize(5);
mySpacer->SetMinSize(vec2(5,5));
mySpacer->SetColor(0x000000BF);
mySizerHori->SubWidgetAdd(mySpacer);
}
@ -116,7 +116,7 @@ widget::Parameter::Parameter(void) :
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpand(bvec2(true,false));
mySpacer->SetSize(5);
mySpacer->SetMinSize(vec2(5,5));
mySpacer->SetColor(0x000000BF);
mySizerVert2->SubWidgetAdd(mySpacer);
}
@ -136,7 +136,7 @@ widget::Parameter::Parameter(void) :
EWOL_ERROR("Can not allocate widget ==> display might be in error");
} else {
mySpacer->SetExpand(bvec2(true,false));
mySpacer->SetSize(5);
mySpacer->SetMinSize(vec2(5,5));
mySpacer->SetColor(0x000000BF);
mySizerVert->SubWidgetAdd(mySpacer);
}