[DEV] add capabilities at the pop-up system

This commit is contained in:
Edouard DUPIN 2013-06-11 21:47:23 +02:00
parent 0b3fe6d74a
commit c2cdab446f
8 changed files with 176 additions and 13 deletions

View File

@ -402,7 +402,7 @@ void ewol::Drawing::LineTo(const 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

@ -31,7 +31,7 @@ ewol::Sprite::Sprite(const etk::UString& _imageName, const ivec2& _nbSprite) :
}
void ewol::Sprite::PrintSprite(const ivec2& _spriteID, const vec2& _size)
void ewol::Sprite::PrintSprite(const ivec2& _spriteID, const vec3& _size)
{
if( _spriteID.x()<0
|| _spriteID.y()<0
@ -39,8 +39,9 @@ void ewol::Sprite::PrintSprite(const ivec2& _spriteID, const vec2& _size)
|| _spriteID.y()>=m_nbSprite.y()) {
return;
}
PrintPart(_size, vec2((float)(_spriteID.x() )*m_unitarySpriteSize.x(), (float)(_spriteID.y() )*m_unitarySpriteSize.y()),
vec2((float)(_spriteID.x()+1)*m_unitarySpriteSize.x(), (float)(_spriteID.y()+1)*m_unitarySpriteSize.y()));
PrintPart(vec2(_size.x(),_size.y()),
vec2((float)(_spriteID.x() )*m_unitarySpriteSize.x(), (float)(_spriteID.y() )*m_unitarySpriteSize.y()),
vec2((float)(_spriteID.x()+1)*m_unitarySpriteSize.x(), (float)(_spriteID.y()+1)*m_unitarySpriteSize.y()));
}

View File

@ -23,7 +23,8 @@ namespace ewol
public:
Sprite(const etk::UString& _imageName, const ivec2& _nbSprite);
virtual ~Sprite() {};
void PrintSprite(const ivec2& _spriteID, const vec2& _size);
void PrintSprite(const ivec2& _spriteID, const vec2& _size) { PrintSprite(_spriteID, vec3(_size.x(), _size.y(),0)); };
void PrintSprite(const ivec2& _spriteID, const vec3& _size);
};
};

View File

@ -9,15 +9,40 @@
#include <ewol/widget/PopUp.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
#undef __class__
#define __class__ "PopUp"
const char* const widget::PopUp::configShaper="shaper";
const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove";
static ewol::Widget* Create(void)
{
return new widget::PopUp();
}
void widget::PopUp::Init(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,&Create);
}
void widget::PopUp::UnInit(void)
{
ewol::widgetManager::AddWidgetCreator(__class__,NULL);
}
widget::PopUp::PopUp(const etk::UString& _shaperName) :
m_shaper(_shaperName)
m_shaper(_shaperName),
m_closeOutEvent(false)
{
m_userExpand.setValue(false, false);
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
RegisterConfig(configShaper, "string", NULL, "The shaper properties");
RegisterConfig(configRemoveOnExternClick, "bool", NULL, "Remove the widget if the use click outside");
}
widget::PopUp::~PopUp(void)
@ -37,9 +62,6 @@ void widget::PopUp::CalculateSize(const vec2& _availlable)
ewol::Widget::CalculateSize(_availlable);
m_size = _availlable;
if (NULL != m_subWidget) {
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_minSize.x());
@ -67,7 +89,6 @@ void widget::PopUp::OnDraw(void)
m_shaper.Draw();
}
#define BORDER_SIZE_TMP (4)
void widget::PopUp::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
@ -78,10 +99,9 @@ void widget::PopUp::OnRegenerateDisplay(void)
vec2 tmpSize = m_subWidget->GetSize();
}
tmpSize.setMax(m_minSize);
vec2 tmpOrigin = m_origin + (m_size-tmpSize)/2.0f;
tmpOrigin = vec2ClipInt32(tmpOrigin);
vec2 tmpOrigin = (m_size-tmpSize)/2.0f;
m_shaper.SetOrigin(vec2ClipInt32(m_origin));
m_shaper.SetOrigin(vec2(0,0));
m_shaper.SetSize(vec2ClipInt32(m_size));
m_shaper.SetInsidePos(vec2ClipInt32(tmpOrigin-padding));
m_shaper.SetInsideSize(vec2ClipInt32(tmpSize + padding*2.0f));
@ -102,3 +122,67 @@ ewol::Widget* widget::PopUp::GetWidgetAtPos(const vec2& pos)
}
bool widget::PopUp::OnSetConfig(const ewol::EConfig& _conf)
{
if (true == widget::Container::OnSetConfig(_conf)) {
return true;
}
if (_conf.GetConfig() == configShaper) {
SetShaperName(_conf.GetData());
return true;
}
if (_conf.GetConfig() == configRemoveOnExternClick) {
SetRemoveOnExternClick(_conf.GetData().ToBool());
return true;
}
return false;
}
bool widget::PopUp::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == widget::Container::OnGetConfig(_config, _result)) {
return true;
}
if (_config == configShaper) {
_result = m_shaper.GetSource();
return true;
}
if (_config == configRemoveOnExternClick) {
if (GetRemoveOnExternClick()==true) {
_result = "true";
} else {
_result = "false";
}
return true;
}
return false;
}
bool widget::PopUp::OnEventInput(const ewol::EventInput& _event)
{
if (0 != _event.GetId()) {
if (true==m_closeOutEvent) {
vec2 padding = m_shaper.GetPadding();
vec2 tmpSize(0,0);
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->GetSize();
}
tmpSize.setMax(m_minSize);
vec2 tmpOrigin = (m_size-tmpSize)/2.0f;
tmpOrigin-=padding;
tmpSize += padding*2.0f;
vec2 pos=RelativePosition(_event.GetPos());
if( pos.x() < tmpOrigin.x()
|| pos.y() < tmpOrigin.y()
|| pos.x() > tmpOrigin.x()+tmpSize.x()
|| pos.y() > tmpOrigin.y()+tmpSize.y() ) {
AutoDestroy();
return true;
}
}
}
return false;
}

View File

@ -20,6 +20,12 @@
namespace widget {
class PopUp : public widget::Container
{
public:
static void Init(void);
static void UnInit(void);
// Config list of properties
static const char* const configShaper;
static const char* const configRemoveOnExternClick;
private:
ewol::Shaper m_shaper; //!< Compositing theme.
public:
@ -37,6 +43,19 @@ namespace widget {
* @param[in] _shaperName The new shaper filename
*/
void SetShaperName(const etk::UString& _shaperName);
private:
bool m_closeOutEvent; //!< ratio progression of a sliding
public:
/**
* @brief Request the Auto-remove when the event input is set outside the widget
* @param[in] _state New status
*/
void SetRemoveOnExternClick(bool _state) { m_closeOutEvent = _state; };
/**
* @brief Get the status of the request the Auto-remove when the event input is set outside the widget.
* @return the status of the removing
*/
bool GetRemoveOnExternClick(void) const { return m_closeOutEvent; };
private:
float m_slidingProgress; //!< ratio progression of a sliding
public:
@ -46,9 +65,12 @@ namespace widget {
protected: // Derived function
virtual void OnDraw(void);
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual void CalculateSize(const vec2& _availlable);
virtual bool OnEventInput(const ewol::EventInput& _event);
//virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::PopUp"; };
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);

View File

@ -332,3 +332,54 @@ bool widget::WSlider::OnGetConfig(const char* _config, etk::UString& _result) co
}
ewol::Widget* widget::WSlider::GetWidgetAtPos(const vec2& _pos)
{
if (true == IsHide()) {
return NULL;
}
if (m_windowsDestination == m_windowsSources) {
if (m_windowsDestination<m_subWidget.Size()) {
vec2 tmpSize = m_subWidget[m_windowsDestination]->GetSize();
vec2 tmpOrigin = m_subWidget[m_windowsDestination]->GetOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[m_windowsDestination]->GetWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
return NULL;
}
}
} else {
if (m_windowsDestination<m_subWidget.Size()) {
vec2 tmpSize = m_subWidget[m_windowsDestination]->GetSize();
vec2 tmpOrigin = m_subWidget[m_windowsDestination]->GetOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[m_windowsDestination]->GetWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
return NULL;
}
}
if (m_windowsSources<m_subWidget.Size()) {
vec2 tmpSize = m_subWidget[m_windowsSources]->GetSize();
vec2 tmpOrigin = m_subWidget[m_windowsSources]->GetOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[m_windowsSources]->GetWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
return NULL;
}
}
}
return NULL;
};

View File

@ -85,6 +85,7 @@ namespace widget {
virtual void CalculateSize(const vec2& _availlable);
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual void OnRegenerateDisplay(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
virtual void PeriodicCall(const ewol::EventTime& _event);
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;

View File

@ -23,6 +23,7 @@
#include <ewol/widget/Entry.h>
#include <ewol/widget/CheckBox.h>
#include <ewol/widget/Scroll.h>
#include <ewol/widget/PopUp.h>
#include <etk/Vector.h>
#undef __class__
@ -80,6 +81,7 @@ void ewol::widgetManager::Init(void)
widget::CheckBox::Init();
widget::Scroll::Init();
widget::ContextMenu::Init();
widget::PopUp::Init();
IsInit = true;
}
@ -90,6 +92,7 @@ void ewol::widgetManager::UnInit(void)
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
widget::PopUp::UnInit();
widget::ContextMenu::UnInit();
widget::Scroll::UnInit();
widget::CheckBox::UnInit();