[DEV] corection of the Display widget clipping and add some capabilities

This commit is contained in:
Edouard DUPIN 2013-05-12 21:02:30 +02:00
parent 66924458eb
commit 1fd5b53688
70 changed files with 1199 additions and 369 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 249870fc130e93ee3bec51701f1fb595a02f8671
Subproject commit 91c6690daab788cbf7ee5f759fd8e8ec8dbfec88

View File

@ -97,11 +97,13 @@ namespace ewol
* @param[in] pos Position of the text (in 3D)
*/
void SetPos(vec3 pos);
inline void SetPos(const vec2& pos) { SetPos(vec3(pos.x(), pos.y(), 0)); };
/**
* @brief Set relative position for the next text writen
* @param[in] pos ofset apply of the text (in 3D)
*/
void SetRelPos(vec3 pos);
inline void SetRelPos(const vec2& pos) { SetRelPos(vec3(pos.x(), pos.y(), 0)); };
/**
* @brief Set the Color of the current foreground font
* @param[in] color Color to set on foreground (for next print)
@ -143,21 +145,25 @@ namespace ewol
* @param[in] dest Position of the end of the line.
*/
void LineTo(vec3 dest);
inline void LineTo(const vec2& dest) { LineTo(vec3(dest.x(), dest.y(), 0)); };
/**
* @brief Relative drawing a line (spacial vector)
* @param[in] vect Vector of the curent line.
*/
void LineRel(vec3 vect);
inline void LineRel(const vec2& vect) { LineRel(vec3(vect.x(), vect.y(), 0)); };
/**
* @brief Draw a 2D rectangle to the position requested.
* @param[in] dest Position the the end of the rectangle
*/
void Rectangle(vec3 dest);
inline void Rectangle(const vec2& dest) { Rectangle(vec3(dest.x(), dest.y(), 0)); };
/**
* @brief Draw a 2D rectangle to the requested size.
* @param[in] width size of the rectangle
*/
void RectangleWidth(vec3 size);
inline void RectangleWidth(const vec2& size) { RectangleWidth(vec3(size.x(), size.y(), 0)); };
/**
* @brief Draw a 3D rectangle to the position requested.
* @param[in] dest Position the the end of the rectangle

View File

@ -0,0 +1,24 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/eObject/EObject.h>
#undef __class__
#define __class__ "EMessage"
etk::CCout& ewol::operator <<(etk::CCout &os, const ewol::EMessage &obj)
{
if (NULL != obj.GetMessage()) {
os << " msg=\"" << obj.GetMessage() << "\"";
} else {
os << " msg=\"NULL\"";
}
os << " data=\"" << obj.GetData() << "\"";
return os;
}

View File

@ -0,0 +1,41 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_E_MESSAGE_H__
#define __EWOL_E_MESSAGE_H__
#include <etk/types.h>
#include <etk/Stream.h>
namespace ewol {
class EMessage {
private:
ewol::EObject* m_callerObject; //!< Caller class.
const char* m_event; //!< Event pointer ==> unique Id define by the system ...
etk::UString m_data; //!< compositing additionnal message Value.
public:
EMessage(ewol::EObject* _caller,
const char* _message,
const etk::UString& _data) :
m_callerObject(_caller),
m_event(_message),
m_data(_data)
{ };
void SetCaller(ewol::EObject* _caller) { m_callerObject = _caller; };
inline ewol::EObject* GetCaller(void) const { return m_callerObject; };
void SetMessage(const char* _message) { m_event = _message; };
inline const char* GetMessage(void) const { return m_event; };
void SetData(const etk::UString& _data) { m_data = _data; };
inline const etk::UString& GetData(void) const { return m_data; };
};
etk::CCout& operator <<(etk::CCout &os, const ewol::EMessage &obj);
};
#endif

View File

@ -85,8 +85,9 @@ static void MultiCastSend(ewol::EObject* _object, const char* const _message, co
{
if (NULL != m_messageList[iii].object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].object->GetId() << " type=" << m_messageList[iii].object->GetObjectType());
// generate event ...
m_messageList[iii].object->OnReceiveMessage(_object, m_messageList[iii].message, _data);
// generate event ... (create message before ...
ewol::EMessage tmpMsg(_object, m_messageList[iii].message, _data);
m_messageList[iii].object->OnReceiveMessage(tmpMsg);
}
}
}
@ -154,10 +155,12 @@ void ewol::EObject::GenerateEventId(const char * _generateEventId, const etk::US
if (m_externEvent[iii]->localEventId == _generateEventId) {
if (NULL != m_externEvent[iii]->destEObject) {
if (m_externEvent[iii]->overloadData.Size()<=0){
m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, _data);
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, _data);
m_externEvent[iii]->destEObject->OnReceiveMessage(tmpMsg);
} else {
// set the user requested data ...
m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
m_externEvent[iii]->destEObject->OnReceiveMessage(tmpMsg);
}
}
}

View File

@ -12,6 +12,12 @@
#include <etk/types.h>
#include <etk/UString.h>
#include <etk/Vector.h>
namespace ewol {
// some class need to define element befor other ...
class EObject;
};
#include <ewol/eObject/EMessage.h>
namespace ewol {
namespace EObjectMessageMultiCast {
@ -20,7 +26,6 @@ namespace ewol {
void AnonymousSend(const char* const _messageId, const etk::UString& _data);
};
class EObject;
/**
* local class for event generation
*/
@ -110,7 +115,10 @@ namespace ewol {
* @param[in] _eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...)
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
*/
void RegisterOnEvent(ewol::EObject * _destinationObject, const char * _eventId, const char * _eventIdgenerated = NULL, const etk::UString& _overloadData="");
void RegisterOnEvent(ewol::EObject * _destinationObject,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const etk::UString& _overloadData="");
/**
* @brief Inform object that an other object is removed ...
@ -121,11 +129,9 @@ namespace ewol {
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] _CallerObject Pointer on the EObject that information came from
* @param[in] _eventId Message registered by this class
* @param[in] _data Data registered by this class
* @param[in] _msg Message handle
*/
virtual void OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data) { };
virtual void OnReceiveMessage(const ewol::EMessage& _msg) { };
protected:
etk::UString m_name; //!< name of the element ...

View File

@ -0,0 +1,29 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/widget/Widget.h>
#undef __class__
#define __class__ "EventEntry"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventEntry& _obj)
{
_os << "{type=" << _obj.GetType();
_os << " status=" << _obj.GetStatus();
if (_obj.GetType() == ewol::keyEvent::keyboardChar) {
_os << " char=" << _obj.GetChar();
}
_os << "}";
return _os;
}
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntrySystem& _obj)
{
_os << _obj.m_event;
return _os;
}

View File

@ -32,6 +32,7 @@ namespace ewol {
void SetChar(uniChar_t _char) { m_unicodeData = _char; };
inline const uniChar_t& GetChar(void) const { return m_unicodeData; };
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntry& _obj);
class EventEntrySystem {
public:
@ -42,6 +43,7 @@ namespace ewol {
{ };
ewol::EventEntry m_event;
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventEntrySystem& _obj);
};
#endif

View File

@ -0,0 +1,28 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/widget/Widget.h>
#undef __class__
#define __class__ "EventInput"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::EventInput& _obj)
{
_os << "{type=" << _obj.GetType();
_os << " status=" << _obj.GetStatus();
_os << " id=" << _obj.GetId();
_os << " pos=" << _obj.GetPos();
_os << "}";
return _os;
}
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj)
{
_os << _obj.m_event;
return _os;
}

View File

@ -37,16 +37,29 @@ namespace ewol {
void SetPos(const vec2& _pos) { m_pos = _pos; };
inline const vec2& GetPos(void) const { return m_pos; };
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInput& _obj);
class EventInputSystem {
public:
EventInputSystem(ewol::keyEvent::type_te _type,
ewol::keyEvent::status_te _status,
uint8_t _id,
const vec2& _pos) :
m_event(_type, _status, _id, _pos)
const vec2& _pos,
ewol::Widget* _dest,
int32_t _realIdEvent) :
m_event(_type, _status, _id, _pos),
m_dest(_dest),
m_realIdEvent(_realIdEvent)
{ };
ewol::EventInput m_event;
private:
ewol::Widget* m_dest;
int32_t m_realIdEvent;
public:
void SetDestWidget(ewol::Widget* _dest) { m_dest = _dest; };
inline ewol::Widget* GetDestWidget(void) const { return m_dest; };
void SetRealId(int32_t _realIdEvent) { m_realIdEvent = _realIdEvent; };
inline int32_t GetRealId(void) const { return m_realIdEvent; };
/*
private:
int64_t m_lastTime;
@ -61,6 +74,7 @@ namespace ewol {
vec2 m_pos;
*/
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::EventInputSystem& _obj);
};
#endif

View File

@ -74,7 +74,7 @@ bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te _type,
if (NULL != _destWidget) {
if (_type == ewol::keyEvent::typeMouse || _type == ewol::keyEvent::typeFinger) {
// create the system Event :
ewol::EventInputSystem tmpEventSystem(_type, _status, _IdInput, _pos);
ewol::EventInputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0); // TODO : set the real ID ...
// generate the event :
return _destWidget->SystemEventInput(tmpEventSystem);
} else {

View File

@ -48,11 +48,11 @@ void widget::Button::UnInit(void)
widget::Button::Button(const etk::UString& _shaperName) :
m_shaper(_shaperName),
m_toggleMode(false),
m_value(false),
m_lock(widget::Button::lockNone),
m_toggleMode(false),
m_mouseHover(false),
m_buttonPressed(false),
m_imageDisplaySize(32),
m_selectableAreaPos(0,0),
m_selectableAreaSize(0,0)
{
@ -66,8 +66,8 @@ widget::Button::Button(const etk::UString& _shaperName) :
AddEventId(ewolEventButtonEnter);
AddEventId(ewolEventButtonLeave);
AddEventId(ewolEventButtonValue);
// set basic status for the shaper :
m_shaper.ChangeStatusIn(STATUS_UP);
// shaper satatus update:
CheckStatus();
// This widget can have the focus ...
SetCanHaveFocus(true);
// Limit event at 1:
@ -80,6 +80,7 @@ widget::Button::~Button(void)
}
void widget::Button::SetShaperName(const etk::UString& _shaperName)
{
m_shaper.SetSource(_shaperName);
@ -120,17 +121,6 @@ void widget::Button::SetSubWidgetToggle(ewol::Widget* _subWidget)
ewol::RequestUpdateSize();
}
ewol::Widget* widget::Button::GetSubWidget(void)
{
return m_subWidget[0];
}
ewol::Widget* widget::Button::GetSubWidgetToggle(void)
{
return m_subWidget[1];
}
void widget::Button::CalculateSize(const vec2& _availlable)
{
vec2 padding = m_shaper.GetPadding();
@ -195,22 +185,31 @@ void widget::Button::CalculateMinMaxSize(void)
MarkToRedraw();
}
void widget::Button::OnDraw(ewol::DrawProperty& _displayProp)
void widget::Button::SystemDraw(const ewol::DrawProperty& _displayProp)
{
// draw the shaaper (if needed indeed)
m_shaper.Draw();
if (true==m_hide){
// widget is hidden ...
return;
}
ewol::Widget::SystemDraw(_displayProp);
// draw the widget that need something ...
if( false == m_toggleMode
|| false == m_value) {
|| false == m_value
|| NULL==m_subWidget[1]) {
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->GenDraw(_displayProp);
m_subWidget[0]->SystemDraw(_displayProp);
}
} else {
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->GenDraw(_displayProp);
m_subWidget[1]->SystemDraw(_displayProp);
}
}
}
void widget::Button::OnDraw(void)
{
// draw the shaaper (if needed indeed)
m_shaper.Draw();
}
void widget::Button::OnRegenerateDisplay(void)
{
@ -223,7 +222,8 @@ void widget::Button::OnRegenerateDisplay(void)
m_shaper.SetInsideSize(vec2ClipInt32(m_selectableAreaSize-padding*2.0f));
}
if( false == m_toggleMode
|| false == m_value) {
|| false == m_value
|| NULL==m_subWidget[1]) {
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->OnRegenerateDisplay();
}
@ -234,17 +234,26 @@ void widget::Button::OnRegenerateDisplay(void)
}
}
void widget::Button::SetValue(bool _val)
void widget::Button::SetLock(buttonLock_te _lock)
{
if (m_value != _val) {
m_value = _val;
if (m_lock != _lock) {
m_lock = _lock;
if(widget::Button::lockAccess == _lock) {
m_buttonPressed = false;
m_mouseHover = false;
}
CheckStatus();
MarkToRedraw();
}
}
bool widget::Button::GetValue(void)
void widget::Button::SetValue(bool _val)
{
return m_value;
if (m_value != _val) {
m_value = _val;
CheckStatus();
MarkToRedraw();
}
}
void widget::Button::SetToggleMode(bool _togg)
@ -262,6 +271,10 @@ void widget::Button::SetToggleMode(bool _togg)
bool widget::Button::OnEventInput(const ewol::EventInput& _event)
{
// disable event in the lock access mode :
if(widget::Button::lockAccess == m_lock) {
return false;
}
bool previousHoverState = m_mouseHover;
if( ewol::keyEvent::statusLeave == _event.GetStatus()
|| ewol::keyEvent::statusAbort == _event.GetStatus()) {
@ -297,17 +310,25 @@ bool widget::Button::OnEventInput(const ewol::EventInput& _event)
MarkToRedraw();
}
if(ewol::keyEvent::statusSingle == _event.GetStatus()) {
// inverse value :
m_value = (m_value)?false:true;
//EWOL_DEBUG("Generate event : " << ewolEventButtonPressed);
GenerateEventId(ewolEventButtonPressed);
//EWOL_DEBUG("Generate event : " << ewolEventButtonValue << " val=" << m_value);
GenerateEventId(ewolEventButtonValue, m_value);
if( false == m_toggleMode
&& true == m_value) {
m_value = false;
if( ( m_value == true
&& widget::Button::lockWhenPressed == m_lock)
|| ( m_value == false
&& widget::Button::lockWhenReleased == m_lock) ) {
// nothing to do : Lock mode ...
// user might set himself the new correct value with @ref SetValue(xxx)
} else {
// inverse value :
m_value = (m_value)?false:true;
//EWOL_DEBUG("Generate event : " << ewolEventButtonPressed);
GenerateEventId(ewolEventButtonPressed);
//EWOL_DEBUG("Generate event : " << ewolEventButtonValue << " val=" << m_value);
GenerateEventId(ewolEventButtonValue, m_value);
if( false == m_toggleMode
&& true == m_value) {
m_value = false;
//EWOL_DEBUG("Generate event : " << ewolEventButtonValue << " val=" << m_value);
GenerateEventId(ewolEventButtonValue, m_value);
}
}
MarkToRedraw();
}
@ -379,6 +400,39 @@ bool widget::Button::LoadXML(TiXmlNode* _node)
SetSubWidget(NULL);
SetSubWidgetToggle(NULL);
etk::UString tmpAttributeValue = _node->ToElement()->Attribute("toggle");
if (true == tmpAttributeValue.CompareNoCase("true")) {
m_toggleMode = true;
} else if (true == tmpAttributeValue.CompareNoCase("1")) {
m_toggleMode = true;
} else {
m_toggleMode = false;
}
tmpAttributeValue = _node->ToElement()->Attribute("lock");
if( true == tmpAttributeValue.CompareNoCase("true")
|| true == tmpAttributeValue.CompareNoCase("1")) {
m_lock = widget::Button::lockAccess;
} else if( true == tmpAttributeValue.CompareNoCase("down")
|| true == tmpAttributeValue.CompareNoCase("pressed")) {
m_lock = widget::Button::lockWhenPressed;
} else if( true == tmpAttributeValue.CompareNoCase("up")
|| true == tmpAttributeValue.CompareNoCase("released")) {
m_lock = widget::Button::lockWhenReleased;
} else {
m_lock = widget::Button::lockNone;
}
tmpAttributeValue = _node->ToElement()->Attribute("value");
if( true == tmpAttributeValue.CompareNoCase("true")
|| true == tmpAttributeValue.CompareNoCase("1")) {
if (m_toggleMode==true) {
m_value = true;
} else {
m_value = false;
}
} else {
m_value = false;
}
// parse all the elements :
for(TiXmlNode * pNode = _node->FirstChild() ;
NULL != pNode ;

View File

@ -34,17 +34,14 @@ namespace widget {
public:
static void Init(void);
static void UnInit(void);
typedef enum {
lockNone, //!< normal status of the button
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
lockWhenReleased, //!< When the state is set in not pressed, the status stay in this one
lockAccess, //!< all event are trashed ==> acctivity of the button is disable
} buttonLock_te;
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Widget* m_subWidget[2]; //!< subwidget of the button
bool m_toggleMode; //!< The button is able to toggle.
bool m_value; //!< Current state of the button.
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
int32_t m_imageDisplaySize; //!< Display size of the Image.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
vec2 m_selectableAreaSize; //!< Size of the event positions
public:
/**
* @brief Constructor
@ -60,6 +57,9 @@ namespace widget {
* @param[in] _shaperName The new shaper filename
*/
void SetShaperName(const etk::UString& _shaperName);
protected:
ewol::Widget* m_subWidget[2]; //!< subwidget of the button
public:
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add normal
@ -74,12 +74,15 @@ namespace widget {
* @brief Get the current displayed composition
* @return The base widget
*/
ewol::Widget* GetSubWidget(void);
ewol::Widget* GetSubWidget(void) { return m_subWidget[0]; };
/**
* @brief Get the current displayed composition
* @return The toggle widget
*/
ewol::Widget* GetSubWidgetToggle(void);
ewol::Widget* GetSubWidgetToggle(void) { return m_subWidget[1]; };
protected:
bool m_value; //!< Current state of the button.
public:
/**
* @brief Set the currentValue of the Button (pressed or not)
* @note Work only in toggle mode
@ -91,12 +94,39 @@ namespace widget {
* @return True : The button is pressed.
* @return false : The button is released.
*/
bool GetValue(void);
bool GetValue(void) { return m_value; };
protected:
buttonLock_te m_lock; //!< Current lock state of the button.
public:
/**
* @brief Change the Toggle mode.
* @brief Set the button lock state.
* @param[in] _lock New lock mode of the button
*/
void SetLock(buttonLock_te _lock);
/**
* @brief Get the current button lock value.
* @return The requested lock mode
*/
buttonLock_te GetLock(void) { return m_lock; };
protected:
bool m_toggleMode; //!< The button is able to toggle.
public:
/**
* @brief Change the toggle mode.
* @param[in] _togg New toggle mode
*/
void SetToggleMode(bool _togg);
/**
* @brief Get the current toggle mode.
* @return the current toggle mode.
*/
bool GetToggleMode(void) { return m_toggleMode; };
private:
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
vec2 m_selectableAreaSize; //!< Size of the event positions
private:
/**
* @brief Internal system to Change the property of the current status
@ -107,18 +137,18 @@ namespace widget {
* @brief update the status with the internal satte of the button ...
*/
void CheckStatus(void);
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual void CalculateMinMaxSize(void);
virtual void CalculateSize(const vec2& _availlable);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual bool LoadXML(TiXmlNode* _node);
private:
// derived function
private: // derived function
virtual void PeriodicCall(int64_t _localTime);
};
};

View File

@ -83,7 +83,7 @@ void widget::ButtonColor::CalculateMinMaxSize(void)
void widget::ButtonColor::OnDraw(ewol::DrawProperty& displayProp)
void widget::ButtonColor::OnDraw(void)
{
m_shaper.Draw();
m_text.Draw();
@ -236,12 +236,12 @@ draw::Color widget::ButtonColor::GetValue(void)
}
void widget::ButtonColor::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data)
void widget::ButtonColor::OnReceiveMessage(const ewol::EMessage& _msg)
{
EWOL_INFO("Receive MSG : \"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventId == ewolEventColorChooserChange) {
draw::ParseColor(data.c_str(), m_textColorFg);
GenerateEventId(ewolEventButtonColorChange, data);
EWOL_INFO("Receive MSG : " << _msg.GetData());
if (_msg.GetMessage() == ewolEventColorChooserChange) {
draw::ParseColor(_msg.GetData().c_str(), m_textColorFg);
GenerateEventId(ewolEventButtonColorChange, _msg.GetData());
MarkToRedraw();
}
}

View File

@ -61,14 +61,14 @@ namespace widget {
* @param[in] color The new display color.
*/
void SetValue(draw::Color color);
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual void CalculateMinMaxSize(void);
virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; };
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
virtual void OnReceiveMessage(const ewol::EMessage& _msg);
private:
/**
* @brief Internal system to Change the property of the current status

View File

@ -79,7 +79,7 @@ bool widget::CheckBox::GetValue(void)
return m_value;
}
void widget::CheckBox::OnDraw(ewol::DrawProperty& displayProp)
void widget::CheckBox::OnDraw(void)
{
m_oObjectDecoration.Draw();
m_oObjectText.Draw();

View File

@ -36,12 +36,12 @@ namespace widget {
bool m_value;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "Ewol::CheckBox"; };
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
};

View File

@ -65,7 +65,7 @@ void widget::ColorBar::SetCurrentColor(draw::Color newOne)
// TODO : Later when really needed ...
}
void widget::ColorBar::OnDraw(ewol::DrawProperty& displayProp)
void widget::ColorBar::OnDraw(void)
{
m_draw.Draw();
}

View File

@ -12,8 +12,8 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <draw/Color.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Drawable.h>
extern const char * const ewolEventColorBarChange;
@ -29,12 +29,12 @@ namespace widget {
ewol::Drawing m_draw; //!< Compositing drawing element
draw::Color m_currentColor;
vec2 m_currentUserPos;
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "widget::ColorBar"; };
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
};

View File

@ -39,6 +39,9 @@ void widget::Container::SetSubWidget(ewol::Widget* _newWidget)
}
SubWidgetRemove();
m_subWidget = _newWidget;
if (m_subWidget!=NULL) {
m_subWidget->SetUpperWidget(this);
}
MarkToRedraw();
ewol::RequestUpdateSize();
}
@ -47,6 +50,7 @@ void widget::Container::SetSubWidget(ewol::Widget* _newWidget)
void widget::Container::SubWidgetRemove(void)
{
if (NULL != m_subWidget) {
m_subWidget->RemoveUpperWidget();
delete(m_subWidget);
// might have been destroy first here :
if (m_subWidget!=NULL) {
@ -77,17 +81,43 @@ void widget::Container::OnObjectRemove(ewol::EObject* _removeObject)
}
}
void widget::Container::OnDraw(ewol::DrawProperty& _displayProp)
void widget::Container::SystemDraw(const ewol::DrawProperty& _displayProp)
{
if (true==m_hide){
// widget is hidden ...
return;
}
ewol::Widget::SystemDraw(_displayProp);
if (NULL!=m_subWidget) {
m_subWidget->GenDraw(_displayProp);
ewol::DrawProperty prop = _displayProp;
prop.Limit(m_origin, m_size);
m_subWidget->SystemDraw(prop);
}
}
void widget::Container::CalculateSize(const vec2& _availlable)
{
if (NULL!=m_subWidget) {
m_subWidget->SetOrigin(m_origin);
vec2 origin = m_origin+m_offset;
vec2 minSize = m_subWidget->GetCalculateMinSize();
bvec2 expand = m_subWidget->GetExpand();
if ( expand.x() == false
|| minSize.x()>_availlable.x()) {
if (m_gravity == ewol::gravityCenter) {
origin -= vec2((minSize.x() - _availlable.x())/2.0f, 0);
} else if (((int32_t)m_gravity & (int32_t)ewol::gravityRight) != 0) {
origin -= vec2((minSize.x() - _availlable.x()), 0);
}
}
if( expand.y() == false
|| minSize.y()>_availlable.y()) {
if (m_gravity == ewol::gravityCenter) {
origin -= vec2(0, (minSize.y() - _availlable.y())/2.0f);
} else if (((int32_t)m_gravity & (int32_t)ewol::gravityTop) != 0) {
origin -= vec2(0, (minSize.y() - _availlable.y()));
}
}
m_subWidget->SetOrigin(origin);
m_subWidget->CalculateSize(_availlable);
}
ewol::Widget::CalculateSize(_availlable);
@ -165,3 +195,14 @@ bool widget::Container::LoadXML(TiXmlNode* _node)
}
return true;
}
void widget::Container::SetOffset(const vec2& _newVal)
{
if (m_offset != _newVal) {
ewol::Widget::SetOffset(_newVal);
// recalculate the new sise and position of sub widget ...
CalculateSize(m_size);
}
}

View File

@ -47,9 +47,8 @@ namespace widget
*/
void SubWidgetRemove(void);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& _availlable);
@ -58,6 +57,7 @@ namespace widget
virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
virtual const char * const GetObjectType(void) { return "ewol::widget::Container"; };
virtual bool LoadXML(TiXmlNode* _node);
virtual void SetOffset(const vec2& _newVal);
};
};

View File

@ -61,6 +61,9 @@ void widget::ContainerN::SubWidgetAdd(ewol::Widget* _newWidget)
EWOL_ERROR("[" << GetId() << "] Try to add An empty Widget ... ");
return;
}
if (_newWidget!=NULL) {
_newWidget->SetUpperWidget(this);
}
m_subWidget.PushBack(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
@ -72,6 +75,9 @@ void widget::ContainerN::SubWidgetAddStart(ewol::Widget* _newWidget)
EWOL_ERROR("[" << GetId() << "] Try to add start An empty Widget ... ");
return;
}
if (_newWidget!=NULL) {
_newWidget->SetUpperWidget(this);
}
m_subWidget.PushFront(_newWidget);
MarkToRedraw();
ewol::RequestUpdateSize();
@ -85,6 +91,7 @@ void widget::ContainerN::SubWidgetRemove(ewol::Widget* _newWidget)
int32_t errorControl = m_subWidget.Size();
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (_newWidget == m_subWidget[iii]) {
m_subWidget[iii]->RemoveUpperWidget();
delete(m_subWidget[iii]);
// no remove, this element is removed with the function OnObjectRemove ==> it does not exist anymore ...
if (errorControl == m_subWidget.Size()) {
@ -106,6 +113,7 @@ void widget::ContainerN::SubWidgetUnLink(ewol::Widget* _newWidget)
}
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (_newWidget == m_subWidget[iii]) {
m_subWidget[iii]->RemoveUpperWidget();
m_subWidget[iii] = NULL;
m_subWidget.Erase(iii);
MarkToRedraw();
@ -121,6 +129,7 @@ void widget::ContainerN::SubWidgetRemoveAll(void)
// the size automaticly decrement with the auto call of the OnObjectRemove function
while (m_subWidget.Size() > 0 ) {
if (NULL != m_subWidget[0]) {
m_subWidget[0]->RemoveUpperWidget();
delete(m_subWidget[0]);
// no remove, this element is removed with the function OnObjectRemove ==> it does not exist anymore ...
if (errorControl == m_subWidget.Size()) {
@ -166,11 +175,20 @@ void widget::ContainerN::OnObjectRemove(ewol::EObject* _removeObject)
}
}
void widget::ContainerN::OnDraw(ewol::DrawProperty& _displayProp)
void widget::ContainerN::SystemDraw(const ewol::DrawProperty& _displayProp)
{
if (true==m_hide){
// widget is hidden ...
return;
}
// local widget draw
ewol::Widget::SystemDraw(_displayProp);
// subwidget draw
ewol::DrawProperty prop = _displayProp;
prop.Limit(m_origin, m_size);
for (int32_t iii=m_subWidget.Size()-1; iii>=0; iii--) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(_displayProp);
m_subWidget[iii]->SystemDraw(prop);
}
}
}
@ -181,7 +199,7 @@ void widget::ContainerN::CalculateSize(const vec2& _availlable)
m_size = _availlable;
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->SetOrigin(m_origin);
m_subWidget[iii]->SetOrigin(m_origin+m_offset);
m_subWidget[iii]->CalculateSize(m_size);
}
}
@ -298,3 +316,14 @@ bool widget::ContainerN::LoadXML(TiXmlNode* _node)
}
return true;
}
void widget::ContainerN::SetOffset(const vec2& _newVal)
{
if (m_offset != _newVal) {
ewol::Widget::SetOffset(_newVal);
// recalculate the new sise and position of sub widget ...
CalculateSize(m_size);
}
}

View File

@ -70,9 +70,8 @@ namespace widget
* @param[in] _newWidget the element pointer.
*/
virtual void SubWidgetUnLink(ewol::Widget* _newWidget);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& _displayProp);
public:// Derived function
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual void OnRegenerateDisplay(void);
virtual void OnObjectRemove(ewol::EObject* _removeObject);
virtual void CalculateSize(const vec2& _availlable);
@ -81,6 +80,7 @@ namespace widget
virtual ewol::Widget* GetWidgetNamed(const etk::UString& _widgetName);
virtual const char * const GetObjectType(void) { return "Ewol::ContainerN"; };
virtual bool LoadXML(TiXmlNode* _node);
virtual void SetOffset(const vec2& _newVal);
};
};

View File

@ -118,16 +118,21 @@ void widget::ContextMenu::CalculateMinMaxSize(void)
MarkToRedraw();
}
void widget::ContextMenu::OnDraw(ewol::DrawProperty& displayProp)
void widget::ContextMenu::SystemDraw(const ewol::DrawProperty& _displayProp)
{
//EWOL_DEBUG("On Draw " << m_currentDrawId);
m_compositing.Draw();
ewol::Widget::SystemDraw(_displayProp);
if (NULL != m_subWidget) {
m_subWidget->GenDraw(displayProp);
m_subWidget->SystemDraw(_displayProp);
}
}
void widget::ContextMenu::OnDraw(void)
{
m_compositing.Draw();
}
void widget::ContextMenu::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {

View File

@ -39,8 +39,9 @@ namespace widget {
public:
void SetPositionMark(markPosition_te position, vec2 arrowPos);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual void OnDraw(void);
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void CalculateSize(const vec2& availlable);

View File

@ -43,7 +43,7 @@ void widget::Drawable::ClearOObjectList(void)
m_listOObject.Clear();
}
void widget::Drawable::OnDraw(ewol::DrawProperty& displayProp)
void widget::Drawable::OnDraw(void)
{
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
if (NULL != m_listOObject[iii]) {

View File

@ -27,9 +27,8 @@ namespace widget {
public:
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1);
void ClearOObjectList(void);
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
protected: // Derived function
virtual void OnDraw(void);
};
};

View File

@ -137,7 +137,7 @@ etk::UString widget::Entry::GetValue(void)
}
void widget::Entry::OnDraw(ewol::DrawProperty& _displayProp)
void widget::Entry::OnDraw(void)
{
m_shaper.Draw();
m_oObjectText.Draw();
@ -483,25 +483,25 @@ void widget::Entry::OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboa
}
void widget::Entry::OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data)
void widget::Entry::OnReceiveMessage(const ewol::EMessage& _msg)
{
ewol::Widget::OnReceiveMessage(_CallerObject, _eventId, _data);
if(_eventId == ewolEventEntryClean) {
ewol::Widget::OnReceiveMessage(_msg);
if(_msg.GetMessage() == ewolEventEntryClean) {
m_data = "";
m_displayStartPosition = 0;
m_displayCursorPos = 0;
m_displayCursorPosSelection = m_displayCursorPos;
MarkToRedraw();
} else if(_eventId == ewolEventEntryCut) {
} else if(_msg.GetMessage() == ewolEventEntryCut) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
RemoveSelected();
GenerateEventId(ewolEventEntryModify, m_data);
} else if(_eventId == ewolEventEntryCopy) {
} else if(_msg.GetMessage() == ewolEventEntryCopy) {
CopySelectionToClipBoard(ewol::clipBoard::clipboardStd);
} else if(_eventId == ewolEventEntryPaste) {
} else if(_msg.GetMessage() == ewolEventEntryPaste) {
ewol::clipBoard::Request(ewol::clipBoard::clipboardStd);
} else if(_eventId == ewolEventEntrySelect) {
if(_data == "ALL") {
} else if(_msg.GetMessage() == ewolEventEntrySelect) {
if(_msg.GetData() == "ALL") {
m_displayCursorPosSelection = 0;
m_displayCursorPos = m_data.Size();
} else {

View File

@ -179,12 +179,12 @@ namespace widget {
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnReceiveMessage(ewol::EObject * _CallerObject, const char * _eventId, const etk::UString& _data);
virtual void OnReceiveMessage(const ewol::EMessage& _msg);
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID);
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
virtual void CalculateMinMaxSize(void);
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual void OnDraw(void);
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
virtual void ChangeStatusIn(int32_t _newStatusId);

View File

@ -360,19 +360,18 @@ void widget::Gird::SubWidgetUnLink(int32_t colId, int32_t rowId)
EWOL_WARNING("[" << GetId() << "] Can not unLink unExistant widget");
}
void widget::Gird::OnDraw(ewol::DrawProperty& displayProp)
void widget::Gird::SystemDraw(const ewol::DrawProperty& _displayProp)
{
// TODO : Only display the Widget inside the view ...
ewol::Widget::SystemDraw(_displayProp);
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
m_subWidget[iii].widget->GenDraw(displayProp);
m_subWidget[iii].widget->SystemDraw(_displayProp);
}
}
}
void widget::Gird::OnRegenerateDisplay(void)
{
// TODO : Only display the Widget inside the view ...
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
m_subWidget[iii].widget->OnRegenerateDisplay();

View File

@ -132,9 +132,8 @@ namespace widget {
* @return the border size (0 if not used)
*/
const ivec2& GetBorderSize(void) { return m_borderSize; };
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
virtual void OnRegenerateDisplay(void);
virtual ewol::Widget* GetWidgetAtPos(const vec2& pos);
virtual void OnObjectRemove(ewol::EObject* removeObject);

View File

@ -94,7 +94,7 @@ void widget::Image::Set(const etk::UString& _file, const ewol::Dimension& _borde
}
void widget::Image::OnDraw(ewol::DrawProperty& _displayProp)
void widget::Image::OnDraw(void)
{
m_compositing.Draw();
}

View File

@ -99,12 +99,12 @@ namespace widget {
* @return The status of keeping the ratio of this image.
*/
bool GetKeepRatio(void) { return m_keepRatio; };
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Image"; };
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool LoadXML(TiXmlNode* _node);
};

View File

@ -63,7 +63,7 @@ etk::UString widget::Label::GetLabel(void)
return m_label;
}
void widget::Label::OnDraw(ewol::DrawProperty& _displayProp)
void widget::Label::OnDraw(void)
{
m_text.Draw();
}

View File

@ -51,12 +51,12 @@ namespace widget {
* @return The displayed decorated text.
*/
etk::UString GetLabel(void);
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Label"; };
virtual void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool LoadXML(TiXmlNode* _node);
};

View File

@ -78,19 +78,16 @@ void widget::List::ClearOObjectList(void)
m_listOObject.Clear();
}
void widget::List::OnDraw(ewol::DrawProperty& displayProp)
void widget::List::OnDraw(void)
{
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
if (NULL != m_listOObject[iii]) {
m_listOObject[iii]->Draw();
}
}
WidgetScrooled::OnDraw(displayProp);
WidgetScrooled::OnDraw();
}
void widget::List::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {

View File

@ -33,20 +33,12 @@ namespace widget {
public:
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1);
void ClearOObjectList(void);
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// list properties ...
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_displayCurrentNbLine; //!< Number of line in the display
public:
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(const ewol::EventInput& _event);
protected:
// function call to display the list :
virtual draw::Color GetBasicBG(void) {
@ -77,11 +69,13 @@ namespace widget {
virtual bool OnItemEvent(int32_t IdInput, ewol::keyEvent::status_te typeEvent, int32_t colomn, int32_t raw, float x, float y) {
return false;
}
protected:
// Derived function
protected: // Derived function
virtual void OnGetFocus(void);
// Derived function
virtual void OnLostFocus(void);
virtual void OnDraw(void);
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
};
};

View File

@ -117,16 +117,16 @@ void widget::Menu::AddSpacer(void)
}
void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data)
void widget::Menu::OnReceiveMessage(const ewol::EMessage& _msg)
{
/*
if (true == ewol::Sizer$::OnReceiveMessage(CallerObject, eventId, data)) {
if (true == ewol::Sizer$::OnReceiveMessage(_msg) {
return true;
}
*/
if (eventId == ewolEventButtonPressed) {
if (_msg.GetMessage() == ewolEventButtonPressed) {
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
if (CallerObject == m_listElement[iii]->m_widgetPointer) {
if (_msg.GetCaller() == m_listElement[iii]->m_widgetPointer) {
// 2 posible case (have a message or have a child ...
if (m_listElement[iii]->m_generateEvent != NULL) {
EWOL_DEBUG("Menu ==> Generate Event");
@ -159,7 +159,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
}
// Get the button widget :
vec2 newPosition;
ewol::Widget * eventFromWidget = static_cast<ewol::Widget*>(CallerObject);
ewol::Widget * eventFromWidget = static_cast<ewol::Widget*>(_msg.GetCaller());
if (NULL != eventFromWidget) {
vec2 tmpOri = eventFromWidget->GetOrigin();
vec2 tmpSize = eventFromWidget->GetSize();
@ -218,15 +218,15 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
}
void widget::Menu::OnObjectRemove(ewol::EObject * removeObject)
void widget::Menu::OnObjectRemove(ewol::EObject * _removeObject)
{
widget::Sizer::OnObjectRemove(removeObject);
if (m_widgetContextMenu == removeObject) {
widget::Sizer::OnObjectRemove(_removeObject);
if (m_widgetContextMenu == _removeObject) {
m_widgetContextMenu = NULL;
}
for(int32_t jjj=0; jjj<m_listElement.Size(); jjj++) {
if (NULL != m_listElement[jjj]) {
if (m_listElement[jjj]->m_widgetPointer == removeObject) {
if (m_listElement[jjj]->m_widgetPointer == _removeObject) {
m_listElement[jjj]->m_widgetPointer = NULL;
}
}

View File

@ -51,8 +51,8 @@ namespace widget {
int32_t Add(int32_t parent, etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = "");
void AddSpacer(void);
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
virtual void OnObjectRemove(ewol::EObject * removeObject);
virtual void OnReceiveMessage(const ewol::EMessage& _msg);
virtual void OnObjectRemove(ewol::EObject * _removeObject);
};
};

View File

@ -46,7 +46,7 @@ widget::Mesh::~Mesh(void)
m_object = NULL;
}
}
void widget::Mesh::OnDraw(ewol::DrawProperty& displayProp)
void widget::Mesh::OnDraw(void)
{
mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance))
* etk::matTranslate(m_position)
@ -58,7 +58,7 @@ void widget::Mesh::OnDraw(ewol::DrawProperty& displayProp)
}
}
void widget::Mesh::GenDraw(ewol::DrawProperty displayProp)
void widget::Mesh::SystemDraw(const ewol::DrawProperty& displayProp)
{
ewol::openGL::Push();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
@ -74,11 +74,7 @@ void widget::Mesh::GenDraw(ewol::DrawProperty displayProp)
//ewol::openGL::SetMatrix(tmpMat);
ewol::openGL::SetMatrix(tmpProjection);
// Call the widget drawing methode
displayProp.m_origin = m_origin;
displayProp.m_size = m_size;
// Call the widget drawing methode
OnDraw(displayProp);
OnDraw();
ewol::openGL::Pop();
}

View File

@ -35,8 +35,8 @@ namespace widget {
public: // Derived function
virtual const char * const GetObjectType(void) { return "widget::Mesh"; };
virtual void OnRegenerateDisplay(void);
virtual void GenDraw(ewol::DrawProperty displayProp);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
virtual void OnDraw(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void PeriodicCall(int64_t localTime);
public:

View File

@ -60,15 +60,19 @@ void widget::PopUp::CalculateSize(const vec2& availlable)
MarkToRedraw();
}
void widget::PopUp::OnDraw(ewol::DrawProperty& displayProp)
void widget::PopUp::SystemDraw(const ewol::DrawProperty& _displayProp)
{
// draw upper classes
m_compositing.Draw();
ewol::Widget::SystemDraw(_displayProp);
if (NULL != m_subWidget) {
m_subWidget->GenDraw(displayProp);
m_subWidget->SystemDraw(_displayProp);
}
}
void widget::PopUp::OnDraw(void)
{
m_compositing.Draw();
}
#define BORDER_SIZE_TMP (4)
void widget::PopUp::OnRegenerateDisplay(void)
{

View File

@ -28,8 +28,9 @@ namespace widget {
draw::Color m_colorEmptyArea;
ewol::Drawing m_compositing;
protected: // Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual void OnDraw(void);
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
virtual void OnRegenerateDisplay(void);
virtual void CalculateSize(const vec2& availlable);
//virtual void CalculateMinMaxSize(void);

View File

@ -73,32 +73,33 @@ float widget::ProgressBar::ValueGet(void)
}
void widget::ProgressBar::OnDraw(void)
{
m_draw.Draw();
}
void widget::ProgressBar::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
// clean the object list ...
ClearOObjectList();
m_draw.Clear();
ewol::Drawing * tmpDraw = new ewol::Drawing;
tmpDraw->SetColor(m_textColorFg);
m_draw.SetColor(m_textColorFg);
int32_t tmpSizeX = m_size.x() - 10;
int32_t tmpSizeY = m_size.y() - 10;
int32_t tmpOriginX = 5;
int32_t tmpOriginY = 5;
tmpDraw->SetColor(m_textColorBgOn);
tmpDraw->SetPos(vec3(tmpOriginX, tmpOriginY, 0) );
tmpDraw->RectangleWidth(vec3(tmpSizeX*m_value, tmpSizeY, 0) );
tmpDraw->SetColor(m_textColorBgOff);
tmpDraw->SetPos(vec3(tmpOriginX+tmpSizeX*m_value, tmpOriginY, 0) );
tmpDraw->RectangleWidth(vec3(tmpSizeX*(1.0-m_value), tmpSizeY, 0) );
m_draw.SetColor(m_textColorBgOn);
m_draw.SetPos(vec3(tmpOriginX, tmpOriginY, 0) );
m_draw.RectangleWidth(vec3(tmpSizeX*m_value, tmpSizeY, 0) );
m_draw.SetColor(m_textColorBgOff);
m_draw.SetPos(vec3(tmpOriginX+tmpSizeX*m_value, tmpOriginY, 0) );
m_draw.RectangleWidth(vec3(tmpSizeX*(1.0-m_value), tmpSizeY, 0) );
// TODO : Create a better progress Bar ...
//tmpDraw->SetColor(m_textColorFg);
//tmpDraw->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
AddOObject(tmpDraw);
//m_draw.SetColor(m_textColorFg);
//m_draw.RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
}
}

View File

@ -12,21 +12,21 @@
#include <etk/types.h>
#include <draw/Color.h>
#include <ewol/debug.h>
#include <ewol/widget/Drawable.h>
#include <ewol/widget/Widget.h>
#include <ewol/compositing/Drawing.h>
namespace widget {
class ProgressBar :public widget::Drawable
class ProgressBar : public ewol::Widget
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Drawing m_draw; // basic drawing element
public:
ProgressBar(void);
virtual ~ProgressBar(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolProgressBar"; };
virtual void CalculateMinMaxSize(void);
void ValueSet(float val);
float ValueGet(void);
void SetColor(draw::Color newColor) { m_textColorFg = newColor; };
@ -35,9 +35,12 @@ namespace widget {
draw::Color m_textColorFg; //!< forder bar color
draw::Color m_textColorBgOn; //!< bar color enable
draw::Color m_textColorBgOff; //!< bar color disable
public:
// Derived function
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual void OnRegenerateDisplay(void);
virtual const char * const GetObjectType(void) { return "EwolProgressBar"; };
virtual void CalculateMinMaxSize(void);
};
};

View File

@ -885,7 +885,7 @@ void widget::Scene::renderscene(int pass)
}
void widget::Scene::OnDraw(ewol::DrawProperty& displayProp)
void widget::Scene::OnDraw(void)
{
if (m_dynamicsWorld) {
/*
@ -1078,7 +1078,7 @@ void widget::Scene::PeriodicCall(int64_t localTime)
}
void widget::Scene::GenDraw(ewol::DrawProperty displayProp)
void widget::Scene::SystemDraw(const ewol::DrawProperty& _displayProp)
{
ewol::openGL::Push();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
@ -1095,11 +1095,10 @@ void widget::Scene::GenDraw(ewol::DrawProperty displayProp)
//ewol::openGL::SetMatrix(tmpMat);
ewol::openGL::SetMatrix(tmpProjection);
ewol::DrawProperty prop = _displayProp;
_displayProp.Limit(m_origin, m_size);
// Call the widget drawing methode
displayProp.m_origin = m_origin;
displayProp.m_size = m_size;
// Call the widget drawing methode
OnDraw(displayProp);
OnDraw(prop);
ewol::openGL::Pop();
}

View File

@ -75,7 +75,7 @@ namespace widget {
*/
void PauseToggle(void);
// Derived function
virtual void GenDraw(ewol::DrawProperty displayProp);
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
protected:
// Derived function
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
@ -97,11 +97,12 @@ namespace widget {
* @return the relative position
*/
virtual vec2 RelativePosition(vec2 pos);
protected: // Derived function
virtual void OnDraw(void);
public: // dericed function:
virtual const char * const GetObjectType(void) { return "Ewol::Scene"; };
virtual void OnRegenerateDisplay(void);
virtual void PeriodicCall(int64_t localTime);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual bool OnEventEntry(const ewol::EventEntry& _event);
virtual void OnGetFocus(void);

View File

@ -30,8 +30,12 @@ void widget::Scroll::UnInit(void)
}
widget::Scroll::Scroll(void) :
m_scrollOrigin(0,0),
m_scrollSize(0,0)
m_limit(0.15,0.5),
m_pixelScrolling(20),
m_highSpeedStartPos(0,0),
m_highSpeedMode(SCROLL_DISABLE),
m_highSpeedButton(-1),
m_highSpeedType(ewol::keyEvent::typeUnknow)
{
}
@ -41,19 +45,306 @@ widget::Scroll::~Scroll(void)
}
ewol::Widget* widget::Scroll::GetWidgetAtPos(const vec2& _pos)
void widget::Scroll::SetLimit(const vec2& _limit)
{
if (false==IsHide()) {
return this;
m_limit = _limit;
MarkToRedraw();
}
#define SCROLL_BAR_SPACE (15)
void widget::Scroll::CalculateMinMaxSize(void)
{
// call main class !! and not containter class ...
ewol::Widget::CalculateMinMaxSize();
// call sub classes
if (NULL!=m_subWidget) {
m_subWidget->CalculateMinMaxSize();
}
}
void widget::Scroll::SystemDraw(const ewol::DrawProperty& _displayProp)
{
if (m_hide==true) {
return;
}
if (NULL!=m_subWidget) {
ewol::DrawProperty prop = _displayProp;
prop.Limit(m_origin, m_size);
m_subWidget->SystemDraw(prop);
}
ewol::Widget::SystemDraw(_displayProp);
}
void widget::Scroll::OnDraw(void)
{
m_draw.Draw();
}
void widget::Scroll::OnRegenerateDisplay(void)
{
// call upper class
widget::Container::OnRegenerateDisplay();
if (true == NeedRedraw()) {
// clear all previous display
m_draw.Clear();
m_draw.SetColor(0xFF00007F);
vec2 scrollOffset(0,0);
vec2 scrollSize(0,0);
if (NULL!=m_subWidget) {
scrollOffset = m_subWidget->GetOffset();
scrollSize = m_subWidget->GetSize();
}
m_draw.SetThickness(1);
if( m_size.y() < scrollSize.y()
|| scrollOffset.y()!=0) {
//EWOL_DEBUG("plop : " << vec2(m_size.x()-(SCROLL_BAR_SPACE/2), 0) << " " << vec2(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y()));
m_draw.SetPos(vec2(m_size.x()-(SCROLL_BAR_SPACE/2), 0) );
m_draw.LineTo(vec2(m_size.x()-(SCROLL_BAR_SPACE/2), m_size.y()) );
float lenScrollBar = m_size.y()*m_size.y() / scrollSize.y();
lenScrollBar = etk_avg(10, lenScrollBar, m_size.y());
float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*m_limit.y());
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
originScrollBar *= (m_size.y()-lenScrollBar);
m_draw.SetPos(vec2(m_size.x()-SCROLL_BAR_SPACE, m_size.y() - originScrollBar - lenScrollBar) );
m_draw.RectangleWidth(vec2(SCROLL_BAR_SPACE, lenScrollBar));
}
if( m_size.x() < scrollSize.x()
|| scrollOffset.x()!=0) {
m_draw.SetPos(vec2(0, (SCROLL_BAR_SPACE/2)) );
m_draw.LineTo(vec2(m_size.x()-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2)) );
float lenScrollBar = m_size.x()*(m_size.x()-SCROLL_BAR_SPACE) / scrollSize.x();
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-SCROLL_BAR_SPACE));
float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*m_limit.x());
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
originScrollBar *= (m_size.x()-SCROLL_BAR_SPACE-lenScrollBar);
m_draw.SetPos(vec2(originScrollBar, 0) );
m_draw.Rectangle(vec2(lenScrollBar, SCROLL_BAR_SPACE) );
}
}
return NULL;
}
bool widget::Scroll::OnEventInput(const ewol::EventInput& _event)
{
EWOL_DEBUG("event from the scroll ... " << _event.GetType() << " idinput=" << _event.GetId() << " status=" << _event.GetStatus());
vec2 relativePos = RelativePosition(_event.GetPos());
vec2 scrollOffset(0,0);
vec2 scrollSize(0,0);
if (NULL!=m_subWidget) {
scrollOffset = m_subWidget->GetOffset();
scrollSize = m_subWidget->GetSize();
}
relativePos.setY(m_size.y() - relativePos.y());
if( _event.GetType() == ewol::keyEvent::typeMouse
&& ( ewol::keyEvent::typeUnknow==m_highSpeedType
|| ewol::keyEvent::typeMouse==m_highSpeedType ) ) {
if( _event.GetId() == 1
&& _event.GetStatus() == ewol::keyEvent::statusDown) {
// check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (m_size.x()-SCROLL_BAR_SPACE)) {
if( m_size.y() < scrollSize.y()
|| scrollOffset.y() != 0) {
m_highSpeedMode = widget::SCROLL_ENABLE_VERTICAL;
m_highSpeedType = ewol::keyEvent::typeMouse;
m_highSpeedStartPos.setX(relativePos.x());
m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2));
m_highSpeedButton = 1;
// force direct scrolling in this case
scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2)));
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
} else if (relativePos.y() >= (m_size.y()-SCROLL_BAR_SPACE)) {
if( m_size.x() < scrollSize.x()
|| scrollOffset.x()!=0) {
m_highSpeedMode = widget::SCROLL_ENABLE_HORIZONTAL;
m_highSpeedType = ewol::keyEvent::typeMouse;
m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2));
m_highSpeedStartPos.setY(relativePos.y());
m_highSpeedButton = 1;
// force direct scrolling in this case
scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2)));
scrollOffset.setY(etk_avg(0, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit.x())));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
}
return false;
} else if( _event.GetId() == 4
&& _event.GetStatus() == ewol::keyEvent::statusUp) {
if(m_size.y() < scrollSize.y()) {
scrollOffset.setY(scrollOffset.y()-m_pixelScrolling);
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
} else if( _event.GetId() == 5
&& _event.GetStatus() == ewol::keyEvent::statusUp) {
if(m_size.y() < scrollSize.y()) {
scrollOffset.setY(scrollOffset.y()+m_pixelScrolling);
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
}else if (_event.GetId() == 2) {
if (_event.GetStatus() == ewol::keyEvent::statusDown) {
m_highSpeedMode = widget::SCROLL_INIT;
m_highSpeedType = ewol::keyEvent::typeMouse;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
m_highSpeedButton = 2;
// not really use... ==> just keep some informations
return false;
}
} else if( widget::SCROLL_DISABLE!=m_highSpeedMode
&& _event.GetStatus() == ewol::keyEvent::statusLeave) {
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
MarkToRedraw();
return true;
}
if (_event.GetId()==m_highSpeedButton && widget::SCROLL_DISABLE!=m_highSpeedMode) {
if (_event.GetStatus() == ewol::keyEvent::statusUp) {
if (widget::SCROLL_INIT==m_highSpeedMode) {
// TODO : Generate back the down event ...
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
return false;
} else {
m_highSpeedMode = widget::SCROLL_GREP_END_EVENT;
MarkToRedraw();
return true;
}
} else if (widget::SCROLL_GREP_END_EVENT == m_highSpeedMode) {
if (_event.GetStatus() == ewol::keyEvent::statusSingle) {
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
m_highSpeedButton = -1;
MarkToRedraw();
}
return true;
} else if( widget::SCROLL_INIT==m_highSpeedMode
&& _event.GetStatus() == ewol::keyEvent::statusMove) {
// wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
// the scrooling can start :
// select the direction :
if (relativePos.x() == m_highSpeedStartPos.x()) {
m_highSpeedMode = widget::SCROLL_ENABLE_VERTICAL;
} else if (relativePos.y() == m_highSpeedStartPos.y()) {
m_highSpeedMode = widget::SCROLL_ENABLE_HORIZONTAL;
} else {
float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x());
if (abs(coef) <= 1 ) {
m_highSpeedMode = widget::SCROLL_ENABLE_HORIZONTAL;
} else {
m_highSpeedMode = widget::SCROLL_ENABLE_VERTICAL;
}
}
if (m_highSpeedMode == widget::SCROLL_ENABLE_HORIZONTAL) {
m_highSpeedStartPos.setX(scrollOffset.x() / scrollSize.x() * (m_size.x()-SCROLL_BAR_SPACE*2));
} else {
m_highSpeedStartPos.setY(scrollOffset.y() / scrollSize.y() * (m_size.y()-SCROLL_BAR_SPACE*2));
}
MarkToRedraw();
}
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
if( widget::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode
&& _event.GetStatus() == ewol::keyEvent::statusMove) {
scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2)));
scrollOffset.setX(etk_avg(0, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit.x() )));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
if( widget::SCROLL_ENABLE_VERTICAL==m_highSpeedMode
&& _event.GetStatus() == ewol::keyEvent::statusMove) {
scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2)));
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.x())));
MarkToRedraw();
if (NULL!=m_subWidget) {
m_subWidget->SetOffset(scrollOffset);
}
return true;
}
}
} else if( ewol::keyEvent::typeFinger==_event.GetType()
&& ( ewol::keyEvent::typeUnknow==m_highSpeedType
|| ewol::keyEvent::typeFinger==m_highSpeedType ) ) {
if (1 == _event.GetId()) {
//EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
if (ewol::keyEvent::statusDown == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_INIT;
m_highSpeedType = ewol::keyEvent::typeFinger;
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
EWOL_VERBOSE("SCROOL ==> INIT");
return true;
} else if (ewol::keyEvent::statusUp == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
EWOL_VERBOSE("SCROOL ==> DISABLE");
MarkToRedraw();
return true;
} else if (widget::SCROLL_INIT==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
// wait that the cursor move more than 10 px to enable it :
if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10
|| abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) {
// the scrooling can start :
// select the direction :
m_highSpeedMode = widget::SCROLL_ENABLE_FINGER;
EWOL_VERBOSE("SCROOL ==> ENABLE");
MarkToRedraw();
}
return true;
} if (widget::SCROLL_ENABLE_FINGER==m_highSpeedMode && ewol::keyEvent::statusMove == _event.GetStatus()) {
//scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x);
scrollOffset.setX(scrollOffset.x() - relativePos.x() - m_highSpeedStartPos.x());
scrollOffset.setY(scrollOffset.y() - relativePos.y() - m_highSpeedStartPos.y());
scrollOffset.setX(etk_avg(0, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit.x())));
scrollOffset.setY(etk_avg(0, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit.y())));
m_highSpeedStartPos.setValue(relativePos.x(), relativePos.y());
EWOL_VERBOSE("SCROOL ==> MOVE (" << scrollOffset.x() << "," << scrollOffset.y() << ")");
MarkToRedraw();
return true;
}
} else if (widget::SCROLL_DISABLE!=m_highSpeedMode && ewol::keyEvent::statusLeave == _event.GetStatus()) {
m_highSpeedMode = widget::SCROLL_DISABLE;
m_highSpeedType = ewol::keyEvent::typeUnknow;
EWOL_VERBOSE("SCROOL ==> DISABLE");
MarkToRedraw();
return true;
}
}
return false;
}
ewol::Widget* widget::Scroll::GetWidgetAtPos(const vec2& _pos)
{
ewol::Widget* tmpWidget = widget::Container::GetWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
return this;
}

View File

@ -16,28 +16,54 @@
#include <ewol/compositing/Drawing.h>
namespace widget {
typedef enum {
SCROLL_DISABLE,
SCROLL_INIT,
SCROLL_ENABLE_FINGER, // Specific for touchpad
SCROLL_ENABLE_HORIZONTAL, // Specific for mouse
SCROLL_ENABLE_VERTICAL, // Specific for mouse
SCROLL_GREP_END_EVENT,
}highSpeedMode_te;
class Scroll : public widget::Container
{
public:
static void Init(void);
static void UnInit(void);
private:
ewol::Drawing m_draw;
ewol::Drawing m_draw; // TODO : Change in shaper ... ==> better for annimation and dynamic display ...
protected:
vec2 m_scrollOrigin;
vec2 m_scrollSize;
//float m_limitScrolling;
vec2 m_limit;
private:
float m_pixelScrolling;
vec2 m_highSpeedStartPos;
highSpeedMode_te m_highSpeedMode;
int32_t m_highSpeedButton;
ewol::keyEvent::type_te m_highSpeedType;
public:
Scroll(void);
virtual ~Scroll(void);
/**
* @brief Set the limit of scrolling
* @note This permit to scoll element upper the end of the display
* @param[in] _limit scrolling limit [0..1] (represent a pourcent)
*/
void SetLimit(const vec2& _limit);
/**
* @brief Get the limit of scrolling
* @return scrolling limit
*/
const vec2& GetLimit(void) { return m_limit; };
public: // Derived function
virtual const char * const GetObjectType(void) { return "ewol::widget::Scroll"; };
//virtual void OnRegenerateDisplay(void);
//virtual void OnDraw(ewol::DrawProperty& _displayProp);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
void CalculateMinMaxSize(void);
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
//virtual void GenDraw(ewol::DrawProperty _displayProp);
protected:
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
virtual ewol::Widget* GetWidgetAtPos(const vec2& _pos);
protected: // Derived function
virtual void OnDraw(void);
};
};

View File

@ -30,8 +30,8 @@ void widget::Sizer::UnInit(void)
}
widget::Sizer::Sizer(widget::Sizer::displayMode_te mode):
m_mode(mode),
widget::Sizer::Sizer(widget::Sizer::displayMode_te _mode):
m_mode(_mode),
m_borderSize()
{
@ -43,16 +43,16 @@ widget::Sizer::~Sizer(void)
}
void widget::Sizer::SetBorderSize(const ewol::Dimension& newBorderSize)
void widget::Sizer::SetBorderSize(const ewol::Dimension& _newBorderSize)
{
m_borderSize = newBorderSize;
m_borderSize = _newBorderSize;
MarkToRedraw();
ewol::RequestUpdateSize();
}
void widget::Sizer::SetMode(widget::Sizer::displayMode_te mode)
void widget::Sizer::SetMode(widget::Sizer::displayMode_te _mode)
{
m_mode = mode;
m_mode = _mode;
MarkToRedraw();
ewol::RequestUpdateSize();
}
@ -62,11 +62,11 @@ widget::Sizer::displayMode_te widget::Sizer::GetMode(void)
return m_mode;
}
void widget::Sizer::CalculateSize(const vec2& availlable)
void widget::Sizer::CalculateSize(const vec2& _availlable)
{
ewol::Widget::CalculateSize(_availlable);
vec2 tmpBorderSize = m_borderSize.GetPixel();
//EWOL_DEBUG("[" << GetId() << "] Update Size : " << availlable << " nbElement : " << m_subWidget.Size());
m_size = availlable;
m_size -= tmpBorderSize*2;
// calculate unExpandable Size :
float unexpandableSize=0.0;
@ -111,7 +111,7 @@ void widget::Sizer::CalculateSize(const vec2& availlable)
vec2 tmpSize = m_subWidget[iii]->GetCalculateMinSize();
// Set the origin :
//EWOL_DEBUG("[" << GetId() << "] Set ORIGIN : " << tmpOrigin);
m_subWidget[iii]->SetOrigin(vec2ClipInt32(tmpOrigin));
m_subWidget[iii]->SetOrigin(vec2ClipInt32(tmpOrigin+m_offset));
// Now Update his Size his size in X and the curent sizer size in Y:
if (m_mode==widget::Sizer::modeVert) {
if (true == m_subWidget[iii]->CanExpand().y()) {
@ -172,19 +172,19 @@ void widget::Sizer::CalculateMinMaxSize(void)
}
}
bool widget::Sizer::LoadXML(TiXmlNode* node)
bool widget::Sizer::LoadXML(TiXmlNode* _node)
{
if (NULL==node) {
if (NULL==_node) {
return false;
}
// parse generic properties :
widget::ContainerN::LoadXML(node);
widget::ContainerN::LoadXML(_node);
const char* tmpAttributeValue = node->ToElement()->Attribute("borderSize");
const char* tmpAttributeValue = _node->ToElement()->Attribute("borderSize");
if (NULL != tmpAttributeValue) {
m_borderSize = tmpAttributeValue;
}
tmpAttributeValue = node->ToElement()->Attribute("mode");
tmpAttributeValue = _node->ToElement()->Attribute("mode");
if (NULL != tmpAttributeValue) {
etk::UString val(tmpAttributeValue);
if( val.CompareNoCase("vert")
@ -196,3 +196,5 @@ bool widget::Sizer::LoadXML(TiXmlNode* node)
}
return true;
}

View File

@ -35,18 +35,18 @@ namespace widget {
public:
/**
* @brief Constructor
* @param[in] mode The mode to display the elements
* @param[in] _mode The mode to display the elements
*/
Sizer(displayMode_te mode=widget::Sizer::modeHori);
Sizer(displayMode_te _mode=widget::Sizer::modeHori);
/**
* @brief Desstructor
*/
virtual ~Sizer(void);
/**
* @brief Set the mode to display elements.
* @param[in] mode The mode to display the elements.
* @param[in] _mode The mode to display the elements.
*/
void SetMode(displayMode_te mode);
void SetMode(displayMode_te _mode);
/**
* @brief Get the mode to display elements.
* @return The current mode to display the elements.
@ -57,9 +57,9 @@ namespace widget {
public:
/**
* @brief Set the current border size of the current element:
* @param[in] newBorderSize The border size to set (0 if not used)
* @param[in] _newBorderSize The border size to set (0 if not used)
*/
void SetBorderSize(const ewol::Dimension& newBorderSize);
void SetBorderSize(const ewol::Dimension& _newBorderSize);
/**
* @brief Get the current border size of the current element:
* @return the border size (0 if not used)
@ -67,9 +67,9 @@ namespace widget {
const ewol::Dimension& GetBorderSize(void) { return m_borderSize; };
public: // Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Sizer"; };
virtual void CalculateSize(const vec2& availlable);
virtual void CalculateSize(const vec2& _availlable);
virtual void CalculateMinMaxSize(void);
virtual bool LoadXML(TiXmlNode* node);
virtual bool LoadXML(TiXmlNode* _node);
};
};

View File

@ -44,7 +44,7 @@ widget::Spacer::~Spacer(void)
}
void widget::Spacer::OnDraw(ewol::DrawProperty& displayProp)
void widget::Spacer::OnDraw(void)
{
m_draw.Draw();
}

View File

@ -45,7 +45,7 @@ namespace widget {
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);
virtual void OnDraw(void);
};
};

View File

@ -196,8 +196,9 @@ void widget::WSlider::PeriodicCall(int64_t localTime)
}
void widget::WSlider::OnDraw(ewol::DrawProperty& displayProp)
void widget::WSlider::SystemDraw(const ewol::DrawProperty& _displayProp)
{
ewol::Widget::SystemDraw(_displayProp);
if (m_windowsDestination == m_windowsSources) {
//EWOL_DEBUG("Draw : " << m_windowsDestination);
int32_t iii = m_windowsDestination;
@ -205,7 +206,7 @@ void widget::WSlider::OnDraw(ewol::DrawProperty& displayProp)
return;
}
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(displayProp);
m_subWidget[iii]->SystemDraw(_displayProp);
}
} else {
//EWOL_DEBUG("Draw : " << m_windowsSources << "=>" << m_windowsDestination << "progress=" << ((float)m_slidingProgress/1000.) );
@ -215,7 +216,7 @@ void widget::WSlider::OnDraw(ewol::DrawProperty& displayProp)
return;
}
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(displayProp);
m_subWidget[iii]->SystemDraw(_displayProp);
}
// Draw Destination :
iii = m_windowsDestination;
@ -223,7 +224,7 @@ void widget::WSlider::OnDraw(ewol::DrawProperty& displayProp)
return;
}
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->GenDraw(displayProp);
m_subWidget[iii]->SystemDraw(_displayProp);
}
}
}

View File

@ -44,11 +44,8 @@ namespace widget {
void SubWidgetSelectSet(int32_t id);
int32_t SubWidgetSelectGet(void) { return (int32_t)m_slidingProgress; };
int32_t SubWidgetNumber(void) { return m_subWidget.Size(); };
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public:
// Derived function
public: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
virtual void OnRegenerateDisplay(void);
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos);
virtual void OnObjectRemove(ewol::EObject * removeObject);

View File

@ -14,15 +14,91 @@
#include <ewol/renderer/os/eSystem.h>
#include <ewol/renderer/os/gui.h>
#undef __class__
#define __class__ "DrawProperty"
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::DrawProperty& _obj)
{
_os << "{ windowsSize=" << _obj.m_windowsSize << " start=" << _obj.m_origin << " stop=" << (_obj.m_origin+_obj.m_size) << "}";
return _os;
}
void ewol::DrawProperty::Limit(const vec2& _origin, const vec2& _size)
{
m_size += m_origin;
m_origin.setMax(_origin);
m_size.setMin(_origin+_size);
m_size -= m_origin;
}
#undef __class__
#define __class__ "Widget"
#define __class__ "gravity"
etk::UString ewol::GravityToString(const ewol::gravity_te _obj)
{
switch(_obj) {
case ewol::gravityCenter:
return "center";
case ewol::gravityTopLeft:
return "top-left";
case ewol::gravityTop:
return "top";
case ewol::gravityTopRight:
return "top-right";
case ewol::gravityRight:
return "right";
case ewol::gravityButtomRight:
return "buttom-right";
case ewol::gravityButtom:
return "buttom";
case ewol::gravityButtomLeft:
return "buttom-left";
case ewol::gravityLeft:
return "left";
}
return "unknow";
}
ewol::gravity_te ewol::StringToGravity(const etk::UString& _obj)
{
if (_obj == "center") {
return ewol::gravityCenter;
} else if (_obj == "top-left") {
return ewol::gravityTopLeft;
} else if (_obj == "top") {
return ewol::gravityTop;
} else if (_obj == "top-right") {
return ewol::gravityTopRight;
} else if (_obj == "right") {
return ewol::gravityRight;
} else if (_obj == "buttom-right") {
return ewol::gravityButtomRight;
} else if (_obj == "buttom") {
return ewol::gravityButtom;
} else if (_obj == "buttom-left") {
return ewol::gravityButtomLeft;
} else if (_obj == "left") {
return ewol::gravityLeft;
}
return ewol::gravityCenter;
}
etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::gravity_te _obj)
{
_os << ewol::GravityToString(_obj);
return _os;
}
#undef __class__
#define __class__ "Widget"
ewol::Widget::Widget(void) :
m_up(NULL),
m_size(10,10),
m_minSize(0,0),
m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)),
m_offset(0,0),
m_zoom(1.0f),
m_origin(0,0),
m_userMinSize(vec2(0,0),ewol::Dimension::Pixel),
@ -30,6 +106,7 @@ ewol::Widget::Widget(void) :
m_userExpand(false,false),
m_userFill(false,false),
m_hide(false),
m_gravity(ewol::gravityButtomLeft),
m_hasFocus(false),
m_canFocus(false),
m_limitMouseEvent(3),
@ -90,6 +167,7 @@ void ewol::Widget::Show(void)
void ewol::Widget::CalculateSize(const vec2& _availlable)
{
m_size = _availlable;
m_size.setMax(m_minSize);
MarkToRedraw();
}
@ -130,22 +208,92 @@ void ewol::Widget::KeepFocus(void)
ewol::widgetManager::FocusKeep(this);
}
void ewol::Widget::SetOffset(const vec2& _newVal)
{
if (m_offset != _newVal) {
m_offset = _newVal;
MarkToRedraw();
}
}
void ewol::Widget::GenDraw(DrawProperty _displayProp)
/*
/--> _displayProp.m_windowsSize
*------------------------------------------------------*
| |
| m_size |
| / |
| *-----------------------* |
| ' ' |
| ' _displayProp.m_size ' |
| Viewport ' / ' |
| o---------'---------o ' |
| | ' | ' |
| | ' | ' |
| | ' | ' |
| | ' | ' |
| | *-----------------------* |
| | / | |
| | m_offset | |
| | | |
| o-------------------o |
| / |
| _displayProp.m_origin |
| |
*------------------------------------------------------*
/
(0,0)
*/
void ewol::Widget::SystemDraw(const DrawProperty& _displayProp)
{
if (true==m_hide){
// widget is hidden ...
return;
}
vec2 displayOrigin = m_origin + m_offset;
// check if the element is displayable in the windows :
if( _displayProp.m_windowsSize.x() < m_origin.x()
|| _displayProp.m_windowsSize.y() < m_origin.y() ) {
// out of the windows ==> nothing to display ...
return;
}
DrawProperty tmpSize = _displayProp;
tmpSize.Limit(m_origin, m_size);
if (tmpSize.m_size.x() <= 0 || tmpSize.m_size.y() <= 0) {
return;
}
glViewport( tmpSize.m_origin.x(),
tmpSize.m_origin.y(),
tmpSize.m_size.x(),
tmpSize.m_size.y());
// special case, when origin < display origin, we need to cut the display :
ivec2 downOffset = m_origin - tmpSize.m_origin;
downOffset.setMin(ivec2(0,0));
mat4 tmpTranslate = etk::matTranslate(vec3(-tmpSize.m_size.x()/2+m_offset.x() + downOffset.x(),
-tmpSize.m_size.y()/2+m_offset.y() + downOffset.y(),
-1.0f));
mat4 tmpScale = etk::matScale(vec3(m_zoom, m_zoom, 1.0f));
mat4 tmpProjection = etk::matOrtho(-tmpSize.m_size.x()/2,
tmpSize.m_size.x()/2,
-tmpSize.m_size.y()/2,
tmpSize.m_size.y()/2,
-1,
1);
mat4 tmpMat = tmpProjection * tmpScale * tmpTranslate;
ewol::openGL::Push();
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
//int64_t ___startTime = ewol::GetTime();
OnDraw();
#ifdef old_PLOP
if( (_displayProp.m_origin.x() > m_origin.x())
|| (_displayProp.m_origin.x() + _displayProp.m_size.x() < m_size.x() + m_origin.x()) ) {
|| (_displayProp.m_origin.x() + _displayewol::Widget::Prop.m_size.x() < m_size.x() + m_origin.x()) ) {
EWOL_CRITICAL("plop");
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
int32_t tmpOriginX = etk_max(_displayProp.m_origin.x(), m_origin.x());
int32_t tmppp1 = _displayProp.m_origin.x() + _displayProp.m_size.x();
@ -175,6 +323,7 @@ void ewol::Widget::GenDraw(DrawProperty _displayProp)
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget1 : " << ___localTime << "ms ");
} else {
EWOL_DEBUG("rasta..");
glViewport( m_origin.x(),
m_origin.y(),
m_size.x(),
@ -193,6 +342,7 @@ void ewol::Widget::GenDraw(DrawProperty _displayProp)
//float ___localTime = (float)(ewol::GetTime() - ___startTime) / 1000.0f;
//EWOL_DEBUG(" Widget2 : " << ___localTime << "ms ");
}
#endif
ewol::openGL::Pop();
return;
}
@ -507,7 +657,8 @@ bool ewol::Widget::OnEventShortCut(ewol::SpecialKey& _special, uniChar_t _unicod
SendMultiCast(m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
}
// send message direct to the current widget (in every case, really useful for some generic windows shortcut)
OnReceiveMessage(this, m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
ewol::EMessage tmpMsg(this, m_localShortcut[iii]->generateEventId, m_localShortcut[iii]->eventData);
OnReceiveMessage(tmpMsg);
} // no else
return true;
}
@ -613,6 +764,10 @@ bool ewol::Widget::LoadXML(TiXmlNode* _node)
if (NULL != tmpAttributeValue) {
m_userMaxSize.SetString(tmpAttributeValue);
}
tmpAttributeValue = _node->ToElement()->Attribute("gravity");
if (NULL != tmpAttributeValue) {
m_gravity = StringToGravity(tmpAttributeValue);
}
EWOL_DEBUG("Widget parse: m_hide=" << m_hide << " m_userMinSize=" << m_userMinSize << " m_userMaxSize=" << m_userMaxSize << " m_userFill=" << m_userFill << " m_userExpand=" << m_userExpand);
MarkToRedraw();
return ret;
@ -649,6 +804,9 @@ bool ewol::Widget::StoreXML(TiXmlNode* _node)
etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y());
_node->ToElement()->SetAttribute("fill", tmpVal.c_str() );
}
if (m_gravity != ewol::gravityButtomLeft) {
_node->ToElement()->SetAttribute("gravity", GravityToString(m_gravity).c_str() );
}
if (IsHide() != false) {
_node->ToElement()->SetAttribute("hide", "true" );
}
@ -685,3 +843,9 @@ bool ewol::Widget::SystemEventInput(ewol::EventInputSystem& _event)
return OnEventInput(_event.m_event);
}
void ewol::Widget::SetGravity(gravity_te _gravity)
{
m_gravity = _gravity;
MarkToRedraw();
}

View File

@ -31,11 +31,53 @@ namespace ewol {
namespace ewol {
class DrawProperty{
/*
/--> m_windowsSize
*--------------------------------------------------*
| |
| |
| m_size |
| / |
| o-------------------o |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| o-------------------o |
| / |
| m_origin |
| |
*--------------------------------------------------*
/
(0,0)
*/
public :
ivec2 m_windowsSize;
ivec2 m_origin;
ivec2 m_size;
ivec2 m_windowsSize; //!< Windows compleate size
ivec2 m_origin; //!< Windows clipping upper widget (can not be <0)
ivec2 m_size; //!< Windows clipping upper widget (can not be <0 and >m_windowsSize)
void Limit(const vec2& _origin, const vec2& _size);
};
etk::CCout& operator <<(etk::CCout& _os, const ewol::DrawProperty& _obj);
typedef enum {
gravityCenter=0x00,
gravityTopLeft=0x05,
gravityTop=0x01,
gravityTopRight=0x03,
gravityRight=0x02,
gravityButtomRight=0x06,
gravityButtom=0x04,
gravityButtomLeft=0x0C,
gravityLeft=0x08,
}gravity_te;
etk::CCout& operator <<(etk::CCout& _os, const ewol::gravity_te _obj);
etk::UString GravityToString(const ewol::gravity_te _obj);
ewol::gravity_te StringToGravity(const etk::UString& _obj);
class EventShortCut {
public:
bool broadcastEvent; //!< if it is true, then the message is sent to all the system
@ -134,6 +176,19 @@ namespace ewol {
* @note : INTERNAL EWOL SYSTEM
*/
virtual vec2 GetCalculateMaxSize(void);
protected:
vec2 m_offset; //!< Offset of the display in the viewport
public:
/**
* @brief Set the zoom property of the widget.
* @param[in] _newVal offset value.
*/
virtual void SetOffset(const vec2& _newVal);
/**
* @brief Get the offset property of the widget.
* @return The current offset value.
*/
virtual const vec2& GetOffset(void) { return m_offset; };
protected:
// internal element calculated by the system
float m_zoom; //!< generic widget zoom
@ -263,6 +318,20 @@ namespace ewol {
* @return true: if the widget is hiden, false: it is visible
*/
virtual bool IsHide(void) { return m_hide; };
protected:
gravity_te m_gravity; //!< Gravity of the widget
public:
/**
* @brief Set the widget gravity
* @param[in] _gravity New gravity of the widget
*/
virtual void SetGravity(gravity_te _gravity);
/**
* @brief Get the widget gravity
* @return the gravity type
*/
virtual gravity_te GetGravity(void) { return m_gravity; };
// ----------------------------------------------------------------------------------------------------------------
// -- Focus Area
// ----------------------------------------------------------------------------------------------------------------
@ -472,14 +541,12 @@ namespace ewol {
* @param[in] _displayProp properties of the current display
* @note : INTERNAL EWOL SYSTEM
*/
// TODO : Rename SystemDraw()
virtual void GenDraw(DrawProperty _displayProp);
virtual void SystemDraw(const DrawProperty& _displayProp);
protected:
/**
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
* @param[in] _displayProp properties of the current display
*/
virtual void OnDraw(DrawProperty& _displayProp) { };
virtual void OnDraw(void) { };
public:
/**
* @brief Event generated when a redraw is needed

View File

@ -332,7 +332,7 @@ void widget::WidgetScrooled::ClearOObjectList(void)
m_listOObject.Clear();
}
void widget::WidgetScrooled::OnDraw(ewol::DrawProperty& displayProp)
void widget::WidgetScrooled::OnDraw(void)
{
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
if (NULL != m_listOObject[iii]) {
@ -342,7 +342,7 @@ void widget::WidgetScrooled::OnDraw(ewol::DrawProperty& displayProp)
}
void widget::WidgetScrooled::GenDraw(ewol::DrawProperty displayProp)
void widget::WidgetScrooled::SystemDraw(const ewol::DrawProperty& displayProp)
{
ewol::openGL::Push();
if (SCROLL_MODE_CENTER == m_scroollingMode) {
@ -358,7 +358,7 @@ void widget::WidgetScrooled::GenDraw(ewol::DrawProperty displayProp)
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode
OnDraw(displayProp);
OnDraw();
} if (SCROLL_MODE_GAME == m_scroollingMode) {
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x(),
@ -372,9 +372,9 @@ void widget::WidgetScrooled::GenDraw(ewol::DrawProperty displayProp)
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
// Call the widget drawing methode
OnDraw(displayProp);
OnDraw();
} else {
ewol::Widget::GenDraw(displayProp);
ewol::Widget::SystemDraw(displayProp);
}
ewol::openGL::Pop();
}

View File

@ -12,17 +12,10 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Scroll.h>
#include <ewol/compositing/Compositing.h>
namespace widget {
typedef enum {
SCROLL_DISABLE,
SCROLL_INIT,
SCROLL_ENABLE_FINGER, // Specific for touchpad
SCROLL_ENABLE_HORIZONTAL, // Specific for mouse
SCROLL_ENABLE_VERTICAL, // Specific for mouse
SCROLL_GREP_END_EVENT,
}highSpeedMode_te;
typedef enum {
SCROLL_MODE_NORMAL, //!< No Zoom , can UP and down, left and right
@ -49,12 +42,13 @@ namespace widget {
public:
WidgetScrooled(void);
virtual ~WidgetScrooled(void);
protected: // Derived function
virtual void OnDraw(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "EwolWidgetScrooled"; };
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void GenDraw(ewol::DrawProperty displayProp);
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
protected:
/**
* @brief For mouse event when we have a scrolling UP and dows, specify the number of pixel that we scrooled

View File

@ -119,7 +119,7 @@ void ewol::Windows::SysDraw(void)
displayProp.m_origin.setValue(0,0);
displayProp.m_size = m_size;
GenDraw(displayProp);
SystemDraw(displayProp);
ewol::openGL::Disable(ewol::openGL::FLAG_BLEND);
return;
@ -139,8 +139,9 @@ void ewol::Windows::OnRegenerateDisplay(void)
//#define TEST_PERFO_WINDOWS
void ewol::Windows::OnDraw(ewol::DrawProperty& displayProp)
void ewol::Windows::SystemDraw(const ewol::DrawProperty& _displayProp)
{
ewol::Widget::SystemDraw(_displayProp);
#ifdef TEST_PERFO_WINDOWS
int64_t ___startTime0 = ewol::GetTime();
#endif
@ -157,7 +158,7 @@ void ewol::Windows::OnDraw(ewol::DrawProperty& displayProp)
//EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId);
// first display the windows on the display
if (NULL != m_subWidget) {
m_subWidget->GenDraw(displayProp);
m_subWidget->SystemDraw(_displayProp);
//EWOL_DEBUG("Draw Windows");
}
#ifdef TEST_PERFO_WINDOWS
@ -169,7 +170,7 @@ void ewol::Windows::OnDraw(ewol::DrawProperty& displayProp)
// second display the pop-up
for(int32_t iii=0; iii<m_popUpWidgetList.Size(); iii++) {
if (NULL != m_popUpWidgetList[iii]) {
m_popUpWidgetList[iii]->GenDraw(displayProp);
m_popUpWidgetList[iii]->SystemDraw(_displayProp);
//EWOL_DEBUG("Draw Pop-up");
}
}

View File

@ -20,8 +20,6 @@ namespace ewol {
public:
Windows(void);
virtual ~Windows(void);
// Derived function
virtual const char * const GetObjectType(void) { return "Ewol::Windows"; };
// internal event at ewol system :
public:
void SysDraw(void);
@ -34,11 +32,6 @@ namespace ewol {
virtual bool OnKill(void) { return true; };
virtual void OnReduce(void) { };
virtual void On(void) { };
public:
// Derived function
virtual void CalculateSize(const vec2& availlable);
// Derived function
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos);
private:
bool m_hasDecoration;
public:
@ -57,14 +50,14 @@ namespace ewol {
public:
void SetSubWidget(ewol::Widget * widget);
void PopUpWidgetPush(ewol::Widget * widget);
protected:
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
public:
// Derived function
protected: // Derived function
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
public: // Derived function
virtual const char * const GetObjectType(void) { return "ewol::Windows"; };
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);
virtual void CalculateSize(const vec2& availlable);
virtual ewol::Widget * GetWidgetAtPos(const vec2& pos);
};
};

View File

@ -129,13 +129,13 @@ draw::Color widget::ColorChooser::GetColor(void)
}
void widget::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data)
void widget::ColorChooser::OnReceiveMessage(const ewol::EMessage& _msg)
{
if (NULL == CallerObject) {
if (NULL == _msg.GetCaller()) {
return;
}
//EWOL_INFO("Receive Extern Event ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
if (eventColorBarHasChange == eventId) {
if (eventColorBarHasChange == _msg.GetMessage()) {
//==> colorBar has change ...
uint8_t tmpAlpha = m_currentColor.a;
// the colorbar has no notion of the alpha ==> keep it ...
@ -156,18 +156,18 @@ void widget::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const
m_widgetAlpha->SetValue(m_currentColor.a);
}
GenerateEventId(ewolEventColorChooserChange, draw::GetString(m_currentColor));
} else if (eventColorSpecificHasChange == eventId) {
} else if (eventColorSpecificHasChange == _msg.GetMessage()) {
// Slider has changes his color ==> get the one change ...
if (CallerObject == m_widgetRed) {
if (_msg.GetCaller() == m_widgetRed) {
m_currentColor.r = m_widgetRed->GetValue();
}
if (CallerObject == m_widgetGreen) {
if (_msg.GetCaller() == m_widgetGreen) {
m_currentColor.g = m_widgetGreen->GetValue();
}
if (CallerObject == m_widgetBlue) {
if (_msg.GetCaller() == m_widgetBlue) {
m_currentColor.b = m_widgetBlue->GetValue();
}
if (CallerObject == m_widgetAlpha) {
if (_msg.GetCaller() == m_widgetAlpha) {
m_currentColor.a = m_widgetAlpha->GetValue();
}
if (NULL != m_widgetColorBar) {
@ -178,24 +178,24 @@ void widget::ColorChooser::OnReceiveMessage(ewol::EObject * CallerObject, const
};
void widget::ColorChooser::OnObjectRemove(ewol::EObject * removeObject)
void widget::ColorChooser::OnObjectRemove(ewol::EObject * _removeObject)
{
// First step call parrent :
widget::Sizer::OnObjectRemove(removeObject);
widget::Sizer::OnObjectRemove(_removeObject);
// second step find if in all the elements ...
if(removeObject == m_widgetRed) {
if(_removeObject == m_widgetRed) {
m_widgetRed = NULL;
}
if(removeObject == m_widgetGreen) {
if(_removeObject == m_widgetGreen) {
m_widgetGreen = NULL;
}
if(removeObject == m_widgetBlue) {
if(_removeObject == m_widgetBlue) {
m_widgetBlue = NULL;
}
if(removeObject == m_widgetAlpha) {
if(_removeObject == m_widgetAlpha) {
m_widgetAlpha = NULL;
}
if(removeObject == m_widgetColorBar) {
if(_removeObject == m_widgetColorBar) {
m_widgetColorBar = NULL;
}
}

View File

@ -30,9 +30,9 @@ namespace widget {
// Derived function
virtual const char * const GetObjectType(void) { return "widget::ColorChooser"; };
// Derived function
virtual void OnReceiveMessage(ewol::EObject* CallerObject, const char * eventId, const etk::UString& data);
virtual void OnReceiveMessage(const ewol::EMessage& _msg);
// Derived function
virtual void OnObjectRemove(ewol::EObject* removeObject);
virtual void OnObjectRemove(ewol::EObject* _removeObject);
void SetColor(draw::Color newColor);
draw::Color GetColor(void);

View File

@ -350,33 +350,25 @@ void widget::FileChooser::SetFileName(etk::UString filename)
m_widgetCurrentFileName->SetValue(filename);
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void widget::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data)
void widget::FileChooser::OnReceiveMessage(const ewol::EMessage& _msg)
{
EWOL_INFO("Receive Event from the LIST ... : widgetPointer=" << CallerObject << "\"" << eventId << "\" ==> data=\"" << data << "\"" );
if (ewolEventFileChooserEntryFolder == eventId) {
EWOL_INFO("Receive Event from the LIST ... : " << _msg);
if (ewolEventFileChooserEntryFolder == _msg.GetMessage()) {
//==> change the folder name
// TODO : Change the folder, if it exit ...
} else if (ewolEventFileChooserEntryFile == eventId) {
} else if (ewolEventFileChooserEntryFile == _msg.GetMessage()) {
//==> change the file name
m_file = data;
m_file = _msg.GetData();
// Update the selected file in the list :
if (m_widgetListFile != NULL) {
m_widgetListFile->SetSelect(m_file);
}
} else if (ewolEventFileChooserCancel == eventId) {
} else if (ewolEventFileChooserCancel == _msg.GetMessage()) {
//==> Auto remove ...
GenerateEventId(eventId);
GenerateEventId(_msg.GetMessage());
AutoDestroy();
} else if (ewolEventFileChooserHidenFileChange == eventId) {
if (data == "true") {
} else if (ewolEventFileChooserHidenFileChange == _msg.GetMessage()) {
if (_msg.GetData() == "true") {
if (NULL!=m_widgetListFolder) {
m_widgetListFolder->SetShowHiddenFiles(true);
}
@ -391,32 +383,32 @@ void widget::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const c
m_widgetListFile->SetShowHiddenFiles(false);
}
}
} else if (ewolEventFileChooserListFolder == eventId) {
} else if (ewolEventFileChooserListFolder == _msg.GetMessage()) {
//==> this is an internal event ...
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << data << "\"");
m_folder = m_folder + data;
EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _msg.GetData() << "\"");
m_folder = m_folder + _msg.GetData();
EWOL_DEBUG("new PATH : \"" << m_folder << "\"");
m_folder = etk::tool::SimplifyPath(m_folder);
SetFileName("");
UpdateCurrentFolder();
} else if (ewolEventFileChooserListFile == eventId) {
SetFileName(data);
} else if (ewolEventFileChooserListFile == _msg.GetMessage()) {
SetFileName(_msg.GetData());
etk::UString tmpFileCompleatName = m_folder;
tmpFileCompleatName += m_file;
GenerateEventId(eventId, tmpFileCompleatName);
} else if( eventId == ewolEventFileChooserListFileValidate
|| (eventId == ewolEventFileChooserValidate && m_file != "" )
|| (eventId == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) {
GenerateEventId(_msg.GetMessage(), tmpFileCompleatName);
} else if( _msg.GetMessage() == ewolEventFileChooserListFileValidate
|| (_msg.GetMessage() == ewolEventFileChooserValidate && m_file != "" )
|| (_msg.GetMessage() == ewolEventFileChooserEntryFileEnter && m_file != "" ) ) {
// select the File ==> generate a validate
if (data != "") {
SetFileName(data);
if (_msg.GetData() != "") {
SetFileName(_msg.GetData());
}
EWOL_VERBOSE(" generate a fiel opening : \"" << m_folder << "\" / \"" << m_file << "\"");
etk::UString tmpFileCompleatName = m_folder;
tmpFileCompleatName += m_file;
GenerateEventId(ewolEventFileChooserValidate, tmpFileCompleatName);
AutoDestroy();
} else if(ewolEventFileChooserHome == eventId) {
} else if(ewolEventFileChooserHome == _msg.GetMessage()) {
etk::UString tmpUserFolder = etk::GetUserHomeFolder();
EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\"");

View File

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

View File

@ -175,20 +175,20 @@ void widget::Parameter::SetTitle(etk::UString label)
}
void widget::Parameter::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data)
void widget::Parameter::OnReceiveMessage(const ewol::EMessage& _msg)
{
widget::PopUp::OnReceiveMessage(CallerObject, eventId, data);
EWOL_DEBUG("event on the parameter : " << eventId << " data=\"" << data << "\"");
if (eventId == ewolEventParameterClose) {
widget::PopUp::OnReceiveMessage(_msg);
EWOL_DEBUG("event on the parameter : " << _msg);
if (_msg.GetMessage() == ewolEventParameterClose) {
// inform that the parameter windows is closed
GenerateEventId(ewolEventParameterClose);
// Close this widget ...
AutoDestroy();
} else if (eventId == l_eventMenuSelected) {
} else if (_msg.GetMessage() == l_eventMenuSelected) {
if (NULL != m_wSlider) {
int32_t value = 0;
sscanf(data.c_str(), "%d", &value);
EWOL_DEBUG("event on the parameter : " << eventId << " select ID=" << value << "");
sscanf(_msg.GetData().c_str(), "%d", &value);
EWOL_DEBUG("event on the parameter : " << _msg.GetMessage() << " select ID=" << value << "");
m_wSlider->SubWidgetSelectSet(value);
}
}

View File

@ -31,7 +31,7 @@ namespace widget {
// Derived function
virtual const char * const GetObjectType(void) { return "EwolParameter"; };
// Derived function
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data);
virtual void OnReceiveMessage(const ewol::EMessage& _msg);
// Derived function
virtual void OnObjectRemove(ewol::EObject * removeObject);

View File

@ -86,14 +86,14 @@ void widget::ParameterList::ClearOObjectList(void)
m_listOObject.Clear();
}
void widget::ParameterList::OnDraw(ewol::DrawProperty& displayProp)
void widget::ParameterList::OnDraw(void)
{
for (int32_t iii=0; iii<m_listOObject.Size(); iii++) {
if (NULL != m_listOObject[iii]) {
m_listOObject[iii]->Draw();
}
}
WidgetScrooled::OnDraw(displayProp);
WidgetScrooled::OnDraw();
}

View File

@ -42,11 +42,7 @@ namespace widget {
etk::Vector<widget::elementPL *> m_list;
public:
ParameterList(void);
// Derived function
virtual const char * const GetObjectType(void) { return "EwolParameterList"; };
virtual ~ParameterList(void);
// Derived function
virtual void CalculateMinMaxSize(void);
void SetLabel(etk::UString newLabel);
// Drawing capabilities ....
private:
@ -54,30 +50,27 @@ namespace widget {
public:
void AddOObject(ewol::Compositing* newObject, int32_t pos=-1);
void ClearOObjectList(void);
protected:
// Derived function
void OnDraw(ewol::DrawProperty& displayProp);
// list properties ...
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_displayCurrentNbLine; //!< Number of line in the display
public:
// Derived function
void OnRegenerateDisplay(void);
// Derived function
virtual bool OnEventInput(const ewol::EventInput& _event);
protected:
// Derived function
void OnGetFocus(void);
// Derived function
void OnLostFocus(void);
public:
void MenuAdd(etk::UString& label, int32_t refId, etk::UString& image);
void MenuAddGroup(etk::UString& label);
void MenuClear(void);
void MenuSeparator(void);
public: // Derived function
virtual const char * const GetObjectType(void) { return "EwolParameterList"; };
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(const ewol::EventInput& _event);
virtual void CalculateMinMaxSize(void);
protected: // Derived function
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
virtual void OnDraw(void);
};
};

View File

@ -23,12 +23,15 @@ def Create(target):
# Basic Eobject of EWOL
myModule.AddSrcFile([
'ewol/eObject/EMessage.cpp',
'ewol/eObject/EObject.cpp',
'ewol/eObject/EObjectManager.cpp'])
#openGl Basic access abstraction (for the model matrix and include
myModule.AddSrcFile([
'ewol/renderer/openGL.cpp',
'ewol/renderer/EventInput.cpp',
'ewol/renderer/EventEntry.cpp',
'ewol/renderer/Light.cpp',
'ewol/renderer/Material.cpp'])