[DEV] better pop-up

This commit is contained in:
Edouard DUPIN 2013-07-03 22:25:54 +02:00
parent 532812d50c
commit fa22a42572
9 changed files with 110 additions and 19 deletions

2
build

@ -1 +1 @@
Subproject commit 422cc3d78db6261d510c67158e2020d28a4cf602
Subproject commit 84ccc7605e19e6f3c126ded0abf310b6f6040eac

View File

@ -12,6 +12,8 @@
#include <etk/os/FSNode.h>
#include <ewol/widget/WidgetManager.h>
#undef __class__
#define __class__ "widget::Composer"
widget::Composer::Composer(void)
{
@ -48,8 +50,16 @@ bool widget::Composer::LoadFromFile(const etk::UString& _fileName)
}
exml::Element* root = (exml::Element*)doc.GetNamed("composer");
if (NULL == root ) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
// Maybe a multiple node XML for internal config:
root = doc.ToElement();
if (NULL == root ) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
}
if (root->Size()==0) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) no node in the Container XML element.");
return false;
}
}
// call upper class to parse his elements ...
widget::Container::LoadXML(root);
@ -66,8 +76,16 @@ bool widget::Composer::LoadFromString(const etk::UString& _composerXmlString)
}
exml::Element* root = (exml::Element*)doc.GetNamed("composer");
if (NULL == root ) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
// Maybe a multiple node XML for internal config:
root = doc.ToElement();
if (NULL == root ) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
}
if (root->Size()==0) {
EWOL_ERROR("[" << GetId() << "] {" << GetObjectType() << "} (l ?) no node in the Container XML element.");
return false;
}
}
// call upper class to parse his elements ...
widget::Container::LoadXML(root);

View File

@ -81,6 +81,8 @@ namespace widget
const char * _eventId,
const char * _eventIdgenerated = NULL,
const etk::UString& _overloadData="");
public: // herited functions:
virtual const char * const GetObjectType(void) { return "ewol::widget::Composer"; };
};
};

View File

@ -10,6 +10,7 @@
#include <ewol/widget/WidgetManager.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/ewol.h>
@ -19,6 +20,7 @@
const char* const widget::PopUp::configShaper="shaper";
const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove";
const char* const widget::PopUp::configAnimation="animation";
const char* const widget::PopUp::configLockExpand="lock";
static ewol::Widget* Create(void)
{
@ -38,12 +40,14 @@ void widget::PopUp::UnInit(void)
widget::PopUp::PopUp(const etk::UString& _shaperName) :
m_shaper(_shaperName),
m_lockExpand(true,true),
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");
RegisterConfig(configLockExpand, "bool", NULL, "Lock expand contamination");
RegisterConfig(configAnimation, "list", "none;increase", "Remove the widget if the use click outside");
SetAnimationMode(animationNone);
@ -54,26 +58,43 @@ widget::PopUp::~PopUp(void)
}
void widget::PopUp::LockExpand(const bvec2& _lockExpand)
{
if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand;
MarkToRedraw();
ewol::RequestUpdateSize();
}
}
void widget::PopUp::SetShaperName(const etk::UString& _shaperName)
{
m_shaper.SetSource(_shaperName);
MarkToRedraw();
}
void widget::PopUp::CalculateSize(const vec2& _availlable)
void widget::PopUp::CalculateSize(const vec2& _available)
{
ewol::Widget::CalculateSize(_availlable);
ewol::Widget::CalculateSize(_available);
if (NULL != m_subWidget) {
vec2 padding = m_shaper.GetPadding();
vec2 subWidgetSize = m_subWidget->GetCalculateMinSize();
if (true == m_subWidget->CanExpand().x()) {
subWidgetSize.setX(m_minSize.x());
if (m_lockExpand.x()==true) {
subWidgetSize.setX(m_minSize.x());
} else {
subWidgetSize.setX(m_size.x()-padding.x());
}
}
if (true == m_subWidget->CanExpand().y()) {
subWidgetSize.setY(m_minSize.y());
if (m_lockExpand.y()==true) {
subWidgetSize.setY(m_minSize.y());
} else {
subWidgetSize.setY(m_size.y()-padding.y());
}
}
// limit the size of the element :
subWidgetSize.setMin(m_minSize);
//subWidgetSize.setMin(m_minSize);
// posiition at a int32_t pos :
subWidgetSize = vec2ClipInt32(subWidgetSize);
@ -164,6 +185,10 @@ bool widget::PopUp::OnSetConfig(const ewol::EConfig& _conf)
SetRemoveOnExternClick(_conf.GetData().ToBool());
return true;
}
if (_conf.GetConfig() == configLockExpand) {
LockExpand(_conf.GetData());
return true;
}
if (_conf.GetConfig() == configAnimation) {
if (_conf.GetData().CompareNoCase("increase")==true) {
SetAnimationMode(animationIncrease);
@ -184,6 +209,10 @@ bool widget::PopUp::OnGetConfig(const char* _config, etk::UString& _result) cons
_result = m_shaper.GetSource();
return true;
}
if (_config == configLockExpand) {
_result = m_lockExpand;
return true;
}
if (_config == configRemoveOnExternClick) {
if (GetRemoveOnExternClick()==true) {
_result = "true";

View File

@ -27,6 +27,7 @@ namespace widget {
static const char* const configShaper;
static const char* const configRemoveOnExternClick;
static const char* const configAnimation;
static const char* const configLockExpand;
private:
ewol::Shaper m_shaper; //!< Compositing theme.
public:
@ -44,6 +45,14 @@ namespace widget {
* @param[in] _shaperName The new shaper filename
*/
void SetShaperName(const etk::UString& _shaperName);
protected:
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one ==> this permit to limit bigger subWidget
public:
/**
* @brief Limit the expend properties to the current widget (no contamination)
* @param[in] _lockExpend Lock mode of the expend properties
*/
void LockExpand(const bvec2& _lockExpand);
private:
bool m_closeOutEvent; //!< ratio progression of a sliding
public:
@ -86,7 +95,7 @@ namespace widget {
virtual void PeriodicCall(const ewol::EventTime& _event);
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual void OnRegenerateDisplay(void);
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateSize(const vec2& _available);
virtual bool OnEventInput(const ewol::EventInput& _event);
//virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "ewol::PopUp"; };

View File

@ -15,6 +15,8 @@
#undef __class__
#define __class__ "Spacer"
const char* const widget::Spacer::configColor = "color";
static ewol::Widget* Create(void)
{
return new widget::Spacer();
@ -37,6 +39,7 @@ widget::Spacer::Spacer(void)
SetCanHaveFocus(false);
m_color = draw::color::black;
m_color.a = 0;
RegisterConfig(configColor, "color", NULL, "background of the spacer");
}
widget::Spacer::~Spacer(void)
@ -66,3 +69,29 @@ void widget::Spacer::OnRegenerateDisplay(void)
m_draw.RectangleWidth(vec3(m_size.x(), m_size.y(),0) );
}
bool widget::Spacer::OnSetConfig(const ewol::EConfig& _conf)
{
if (true == ewol::Widget::OnSetConfig(_conf)) {
return true;
}
if (_conf.GetConfig() == configColor) {
draw::ParseColor(_conf.GetData().c_str(), m_color);
MarkToRedraw();
return true;
}
return false;
}
bool widget::Spacer::OnGetConfig(const char* _config, etk::UString& _result) const
{
if (true == ewol::Widget::OnGetConfig(_config, _result)) {
return true;
}
if (_config == configColor) {
_result = draw::GetString(m_color);
return true;
}
return false;
}

View File

@ -21,6 +21,8 @@ namespace widget {
public:
static void Init(void);
static void UnInit(void);
// Config list of properties
static const char* const configColor;
private:
ewol::Drawing m_draw; //!< Compositing drawing element
public:
@ -46,6 +48,8 @@ namespace widget {
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos) { return NULL; };
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(void);
virtual bool OnSetConfig(const ewol::EConfig& _conf);
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
};
};

View File

@ -126,8 +126,8 @@ ewol::Widget::Widget(void) :
m_cursorDisplay(ewol::cursorArrow)
{
// set all the config in the list :
RegisterConfig(ewol::Widget::configFill, "bvec2", NULL, "Fill the widget availlable size");
RegisterConfig(ewol::Widget::configExpand, "bvec2", NULL, "Request the widget Expand size wile space is availlable");
RegisterConfig(ewol::Widget::configFill, "bvec2", NULL, "Fill the widget available size");
RegisterConfig(ewol::Widget::configExpand, "bvec2", NULL, "Request the widget Expand size wile space is available");
RegisterConfig(ewol::Widget::configHide, "bool", NULL, "The widget start hided");
RegisterConfig(ewol::Widget::configFocus, "bool", NULL, "The widget request focus");
RegisterConfig(ewol::Widget::configMinSize, "dimension", NULL, "User minimum size");
@ -181,9 +181,9 @@ void ewol::Widget::Show(void)
}
void ewol::Widget::CalculateSize(const vec2& _availlable)
void ewol::Widget::CalculateSize(const vec2& _available)
{
m_size = _availlable;
m_size = _available;
m_size.setMax(m_minSize);
MarkToRedraw();
}

View File

@ -157,11 +157,11 @@ namespace ewol {
virtual vec2 RelativePosition(const vec2& _pos);
/**
* @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] _availlable Availlable x&y pixel size
* By default this save the widget available size in the widget size
* @param[in] _available Available x&y pixel size
* @note : INTERNAL EWOL SYSTEM
*/
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateSize(const vec2& _available);
/**
* @brief Get the widget size
* @return Requested size