[DEV] better pop-up shaper and list
This commit is contained in:
parent
c2cdab446f
commit
f6713ef18a
@ -168,17 +168,6 @@ bool ewol::Shaper::ChangeStatusIn(int32_t _newStatusId)
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ewol::Shaper::GetCurrentDisplayedStatus(void)
|
||||
{
|
||||
return m_stateNew;
|
||||
}
|
||||
|
||||
int32_t ewol::Shaper::GetNextDisplayedStatus(void)
|
||||
{
|
||||
return m_nextStatusRequested;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Shaper::PeriodicCall(const ewol::EventTime& _event)
|
||||
{
|
||||
//EWOL_DEBUG("call=" << _event);
|
||||
|
@ -95,12 +95,17 @@ namespace ewol
|
||||
* @brief Get the current displayed status of the shaper
|
||||
* @return The Status Id
|
||||
*/
|
||||
int32_t GetCurrentDisplayedStatus(void);;
|
||||
int32_t GetCurrentDisplayedStatus(void) { return m_stateNew; };
|
||||
/**
|
||||
* @brief Get the next displayed status of the shaper
|
||||
* @return The next status Id (-1 if no status in next)
|
||||
*/
|
||||
int32_t GetNextDisplayedStatus(void);
|
||||
int32_t GetNextDisplayedStatus(void) { return m_nextStatusRequested; };
|
||||
/**
|
||||
* @brief Get the current trasion status
|
||||
* @return value of the transition status (0.0f when no activity)
|
||||
*/
|
||||
float GetTransitionStatus(void) { return m_stateTransition; };
|
||||
/**
|
||||
* @brief Same as the widfget periodic call (this is for change display)
|
||||
* @param[in] _event The current time of the call.
|
||||
|
@ -573,6 +573,7 @@ void X11_Init(void)
|
||||
|
||||
void X11_Run(void)
|
||||
{
|
||||
bool specialEventThatNeedARedraw = false;
|
||||
// main cycle
|
||||
while(true == m_run) {
|
||||
//EWOL_ERROR("plop1");
|
||||
@ -738,9 +739,11 @@ void X11_Run(void)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case Expose:
|
||||
X11_INFO("X11 event Expose");
|
||||
specialEventThatNeedARedraw=true;
|
||||
break;
|
||||
case GraphicsExpose:
|
||||
X11_INFO("X11 event GraphicsExpose");
|
||||
specialEventThatNeedARedraw=true;
|
||||
break;
|
||||
case NoExpose:
|
||||
X11_INFO("X11 event NoExpose");
|
||||
@ -764,9 +767,11 @@ void X11_Run(void)
|
||||
X11_INFO("X11 event ReparentNotify");
|
||||
break;
|
||||
case PropertyNotify:
|
||||
specialEventThatNeedARedraw=true;
|
||||
X11_INFO("X11 event PropertyNotify");
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
specialEventThatNeedARedraw=true;
|
||||
X11_INFO("X11 event ConfigureNotify");
|
||||
if (m_display == event.xconfigure.display) {
|
||||
//EWOL_INFO("X11 event ConfigureNotify event=" << (int32_t)event.xconfigure.event << " Window=" << (int32_t)event.xconfigure.window << " above=" << (int32_t)event.xconfigure.above << " border_width=" << (int32_t)event.xconfigure.border_width );
|
||||
@ -861,9 +866,11 @@ void X11_Run(void)
|
||||
break;
|
||||
case FocusIn:
|
||||
X11_INFO("X11 event FocusIn");
|
||||
specialEventThatNeedARedraw=true;
|
||||
break;
|
||||
case FocusOut:
|
||||
X11_INFO("X11 event : FocusOut");
|
||||
specialEventThatNeedARedraw=true;
|
||||
break;
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
@ -1062,10 +1069,12 @@ void X11_Run(void)
|
||||
// break;
|
||||
case MapNotify:
|
||||
X11_INFO("X11 event : MapNotify");
|
||||
specialEventThatNeedARedraw=true;
|
||||
eSystem::Show();
|
||||
break;
|
||||
case UnmapNotify:
|
||||
X11_INFO("X11 event : UnmapNotify");
|
||||
specialEventThatNeedARedraw=true;
|
||||
eSystem::Hide();
|
||||
break;
|
||||
default:
|
||||
@ -1079,7 +1088,9 @@ void X11_Run(void)
|
||||
XSync(m_display,0);
|
||||
}
|
||||
// draw after switch the previous windows ...
|
||||
hasDisplay = eSystem::Draw(false);
|
||||
//EWOL_DEBUG("specialEventThatNeedARedraw"<<specialEventThatNeedARedraw);
|
||||
hasDisplay = eSystem::Draw(specialEventThatNeedARedraw);
|
||||
specialEventThatNeedARedraw=false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -16,7 +16,7 @@
|
||||
#define __class__ "List"
|
||||
|
||||
|
||||
void widget::List::Init(void)
|
||||
widget::List::List(void)
|
||||
{
|
||||
m_paddingSizeX = 2;
|
||||
#ifdef __TARGET_OS__Android
|
||||
@ -24,14 +24,10 @@ void widget::List::Init(void)
|
||||
#else
|
||||
m_paddingSizeY = 2;
|
||||
#endif
|
||||
m_nbVisibleRaw=0;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
widget::List::List(void)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
widget::List::~List(void)
|
||||
{
|
||||
//clean all the object
|
||||
@ -43,6 +39,34 @@ widget::List::~List(void)
|
||||
}
|
||||
|
||||
|
||||
void widget::List::SetRawVisible(int32_t _id)
|
||||
{
|
||||
EWOL_DEBUG("Set Raw visible : " << _id);
|
||||
if (_id<0) {
|
||||
return;
|
||||
}
|
||||
if (_id == m_displayStartRaw) {
|
||||
// nothing to do ...
|
||||
return;
|
||||
}
|
||||
if (_id < m_displayStartRaw) {
|
||||
m_displayStartRaw = _id-2;
|
||||
} else {
|
||||
if (m_displayStartRaw + m_nbVisibleRaw < _id) {
|
||||
m_displayStartRaw = _id - m_nbVisibleRaw + 2;
|
||||
}
|
||||
}
|
||||
if (m_displayStartRaw>GetNuberOfRaw()) {
|
||||
m_displayStartRaw = GetNuberOfRaw()-2;
|
||||
}
|
||||
if (m_displayStartRaw<0) {
|
||||
m_displayStartRaw = 0;
|
||||
}
|
||||
EWOL_DEBUG("Set start raw : " << m_displayStartRaw);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void widget::List::CalculateMinMaxSize(void)
|
||||
{
|
||||
/*int32_t fontId = GetDefaultFontId();
|
||||
@ -152,7 +176,9 @@ void widget::List::OnRegenerateDisplay(void)
|
||||
for(int32_t jjj=0; jjj<nbColomn && displayPositionX < m_size.x() ; jjj++) {
|
||||
int32_t sizeColom = 0;
|
||||
displayPositionY = m_size.y();
|
||||
m_nbVisibleRaw = 0;
|
||||
for(int32_t iii=startRaw; iii<nbRaw && displayPositionY >= 0; iii++) {
|
||||
m_nbVisibleRaw++;
|
||||
etk::UString myTextToWrite;
|
||||
draw::Color fg;
|
||||
draw::Color bg;
|
||||
|
@ -20,7 +20,6 @@ namespace widget {
|
||||
{
|
||||
public:
|
||||
List(void);
|
||||
void Init(void);
|
||||
// Derived function
|
||||
virtual const char * const GetObjectType(void) { return "ewol::List"; };
|
||||
virtual ~List(void);
|
||||
@ -39,6 +38,7 @@ namespace widget {
|
||||
int32_t m_paddingSizeY;
|
||||
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
|
||||
int32_t m_displayCurrentNbLine; //!< Number of line in the display
|
||||
int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display)
|
||||
protected:
|
||||
// function call to display the list :
|
||||
virtual draw::Color GetBasicBG(void) {
|
||||
@ -69,6 +69,11 @@ 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;
|
||||
}
|
||||
/**
|
||||
* @brief Set a raw visible in the main display
|
||||
* @param[in] _id Id of the raw that might be visible.
|
||||
*/
|
||||
void SetRawVisible(int32_t _id);
|
||||
protected: // Derived function
|
||||
virtual void OnGetFocus(void);
|
||||
virtual void OnLostFocus(void);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
const char* const widget::PopUp::configShaper="shaper";
|
||||
const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove";
|
||||
const char* const widget::PopUp::configAnimation="animation";
|
||||
|
||||
static ewol::Widget* Create(void)
|
||||
{
|
||||
@ -43,6 +44,9 @@ widget::PopUp::PopUp(const etk::UString& _shaperName) :
|
||||
SetMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
|
||||
RegisterConfig(configShaper, "string", NULL, "The shaper properties");
|
||||
RegisterConfig(configRemoveOnExternClick, "bool", NULL, "Remove the widget if the use click outside");
|
||||
RegisterConfig(configAnimation, "list", "none;increase", "Remove the widget if the use click outside");
|
||||
|
||||
SetAnimationMode(animationNone);
|
||||
}
|
||||
|
||||
widget::PopUp::~PopUp(void)
|
||||
@ -84,6 +88,24 @@ void widget::PopUp::CalculateSize(const vec2& _availlable)
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
void widget::PopUp::SystemDraw(const ewol::DrawProperty& _displayProp)
|
||||
{
|
||||
if (true==m_hide){
|
||||
// widget is hidden ...
|
||||
return;
|
||||
}
|
||||
ewol::Widget::SystemDraw(_displayProp);
|
||||
if (NULL!=m_subWidget) {
|
||||
if( m_shaper.GetNextDisplayedStatus() == -1
|
||||
&& m_shaper.GetTransitionStatus() >= 1.0) {
|
||||
ewol::DrawProperty prop = _displayProp;
|
||||
prop.Limit(m_origin, m_size);
|
||||
m_subWidget->SystemDraw(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void widget::PopUp::OnDraw(void)
|
||||
{
|
||||
m_shaper.Draw();
|
||||
@ -135,6 +157,14 @@ bool widget::PopUp::OnSetConfig(const ewol::EConfig& _conf)
|
||||
SetRemoveOnExternClick(_conf.GetData().ToBool());
|
||||
return true;
|
||||
}
|
||||
if (_conf.GetConfig() == configAnimation) {
|
||||
if (_conf.GetData().CompareNoCase("increase")==true) {
|
||||
SetAnimationMode(animationIncrease);
|
||||
} else {
|
||||
SetAnimationMode(animationNone);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -155,6 +185,14 @@ bool widget::PopUp::OnGetConfig(const char* _config, etk::UString& _result) cons
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_config == configAnimation) {
|
||||
if (m_animation == animationIncrease) {
|
||||
_result = "increase";
|
||||
} else {
|
||||
_result = "none";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -186,3 +224,19 @@ bool widget::PopUp::OnEventInput(const ewol::EventInput& _event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void widget::PopUp::SetAnimationMode(animation_te _animation)
|
||||
{
|
||||
m_animation = _animation;
|
||||
if (true == m_shaper.ChangeStatusIn((int32_t)_animation) ) {
|
||||
PeriodicCallEnable();
|
||||
}
|
||||
}
|
||||
|
||||
void widget::PopUp::PeriodicCall(const ewol::EventTime& _event)
|
||||
{
|
||||
if (false == m_shaper.PeriodicCall(_event) ) {
|
||||
PeriodicCallDisable();
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ namespace widget {
|
||||
// Config list of properties
|
||||
static const char* const configShaper;
|
||||
static const char* const configRemoveOnExternClick;
|
||||
static const char* const configAnimation;
|
||||
private:
|
||||
ewol::Shaper m_shaper; //!< Compositing theme.
|
||||
public:
|
||||
@ -58,16 +59,32 @@ namespace widget {
|
||||
bool GetRemoveOnExternClick(void) const { return m_closeOutEvent; };
|
||||
private:
|
||||
float m_slidingProgress; //!< ratio progression of a sliding
|
||||
public:
|
||||
typedef enum {
|
||||
animationNone, //!< No annimation
|
||||
animationIncrease, //!< element came strart with no size and increase with the corect size.
|
||||
} animation_te;
|
||||
private:
|
||||
animation_te m_animation; //!< Methode add and remove element (animation)
|
||||
public:
|
||||
/**
|
||||
* @brief
|
||||
* @brief Set an animation mode for the new element set in the Widget container.
|
||||
* @param[in] _animation The new animation mode.
|
||||
*/
|
||||
void SetAnimationMode(animation_te _animation);
|
||||
/**
|
||||
* @brief Get the current animation mode.
|
||||
* @return The animation mode.
|
||||
*/
|
||||
animation_te GetAnimationMode(void) { return m_animation;};
|
||||
|
||||
protected: // Derived function
|
||||
virtual void OnDraw(void);
|
||||
virtual bool OnSetConfig(const ewol::EConfig& _conf);
|
||||
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
|
||||
public: // Derived function
|
||||
virtual void PeriodicCall(const ewol::EventTime& _event);
|
||||
virtual void SystemDraw(const ewol::DrawProperty& _displayProp);
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
virtual void CalculateSize(const vec2& _availlable);
|
||||
virtual bool OnEventInput(const ewol::EventInput& _event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user