add progress bar, and change scene
This commit is contained in:
parent
185e85293d
commit
f445dbd524
@ -213,6 +213,27 @@ etk::UString::UString(unsigned int inputData)
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(float inputData)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%f", inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(double inputData)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%lf", inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::UString &etkS)
|
||||
{
|
||||
|
@ -43,6 +43,8 @@ namespace etk
|
||||
UString(char inputData);
|
||||
UString(int inputData);
|
||||
UString(unsigned int inputData);
|
||||
UString(float inputData);
|
||||
UString(double inputData);
|
||||
UString(const etk::UString &etkS);
|
||||
// destructor :
|
||||
~UString(void);
|
||||
|
@ -31,7 +31,7 @@
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
ewol::GameElement::GameElement(void)
|
||||
ewol::GameElement::GameElement(SceneElement & sceneElement) : m_sceneElement(sceneElement)
|
||||
{
|
||||
m_group = -1;
|
||||
m_type = -1;
|
||||
|
@ -25,17 +25,21 @@
|
||||
#ifndef __EWOL_GAME_ELEMENT_H__
|
||||
#define __EWOL_GAME_ELEMENT_H__
|
||||
|
||||
namespace ewol {
|
||||
class GameElement;
|
||||
};
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Widget.h>
|
||||
#include <ewol/Game/SceneElement.h>
|
||||
|
||||
namespace ewol {
|
||||
// declare the scene element before ...
|
||||
class SceneElement;
|
||||
|
||||
class GameElement
|
||||
{
|
||||
protected:
|
||||
SceneElement & m_sceneElement; //!< all element neede in the scene
|
||||
protected:
|
||||
int32_t m_group;
|
||||
int32_t m_type;
|
||||
@ -51,7 +55,7 @@ namespace ewol {
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
GameElement(void);
|
||||
GameElement(SceneElement & sceneElement);
|
||||
/**
|
||||
* @brief Destructor : This does not remove the sprite requested, they will be supressed when the scene is removed ...
|
||||
* @param ---
|
||||
|
50
Sources/libewol/ewol/Game/SceneElement.h
Normal file
50
Sources/libewol/ewol/Game/SceneElement.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/Game/SceneElement.h
|
||||
* @brief ewol Scene widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 01/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_SCENE_ELEMENT_H__
|
||||
#define __EWOL_SCENE_ELEMENT_H__
|
||||
|
||||
namespace ewol {
|
||||
class SceneElement;
|
||||
};
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Game/GameElement.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class SceneElement {
|
||||
public:
|
||||
etk::VectorType<ewol::OObject*> backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::GameElement*> listAnimatedElements; //!< generic element to display...
|
||||
int32_t id; //!< Unique element ID
|
||||
int32_t AddElement(ewol::GameElement* newElement);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -210,7 +210,8 @@ void ewol::Layer::SubWidgetUnLink(ewol::Widget* newWidget)
|
||||
|
||||
void ewol::Layer::OnDraw(void)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_subWidget[m_currentDrawId].Size(); iii++) {
|
||||
// draw is done in the invert sense of inserting ... the first element inserted is on the top and the last is on the buttom
|
||||
for (int32_t iii=m_subWidget[m_currentDrawId].Size()-1; iii>=0; iii--) {
|
||||
if (NULL != m_subWidget[m_currentDrawId][iii]) {
|
||||
m_subWidget[m_currentDrawId][iii]->GenDraw();
|
||||
}
|
||||
|
151
Sources/libewol/ewol/widget/ProgressBar.cpp
Normal file
151
Sources/libewol/ewol/widget/ProgressBar.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/ProgressBar.cpp
|
||||
* @brief ewol progress bar widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/widget/ProgressBar.h>
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Slider"
|
||||
|
||||
const int32_t dotRadius = 6;
|
||||
|
||||
ewol::ProgressBar::ProgressBar(void)
|
||||
{
|
||||
m_value = 0.0;
|
||||
|
||||
m_textColorFg.red = 0.0;
|
||||
m_textColorFg.green = 0.0;
|
||||
m_textColorFg.blue = 0.0;
|
||||
m_textColorFg.alpha = 1.0;
|
||||
|
||||
m_textColorBgOn.red = 0.0;
|
||||
m_textColorBgOn.green = 1.0;
|
||||
m_textColorBgOn.blue = 0.0;
|
||||
m_textColorBgOn.alpha = 1.0;
|
||||
|
||||
m_textColorBgOff.red = 0.0;
|
||||
m_textColorBgOff.green = 0.0;
|
||||
m_textColorBgOff.blue = 0.0;
|
||||
m_textColorBgOff.alpha = 0.25;
|
||||
SetCanHaveFocus(true);
|
||||
}
|
||||
|
||||
ewol::ProgressBar::~ProgressBar(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//!< EObject name :
|
||||
extern const char * const ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR = "ProgressBar";
|
||||
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
bool ewol::ProgressBar::CheckObjectType(const char * const objectType)
|
||||
{
|
||||
if (NULL == objectType) {
|
||||
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR << "\" != NULL(pointer) ");
|
||||
return false;
|
||||
}
|
||||
if (objectType == ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR) {
|
||||
return true;
|
||||
} else {
|
||||
if(true == ewol::Drawable::CheckObjectType(objectType)) {
|
||||
return true;
|
||||
}
|
||||
EWOL_ERROR("check error : \"" << ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR << "\" != \"" << objectType << "\"");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
const char * const ewol::ProgressBar::GetObjectType(void)
|
||||
{
|
||||
return ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool ewol::ProgressBar::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = etk_max(m_userMinSize.x, 40);
|
||||
m_minSize.y = etk_max(m_userMinSize.y, dotRadius*2);
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ewol::ProgressBar::ValueSet(etkFloat_t val)
|
||||
{
|
||||
m_value = etk_avg(0.0, val, 1.0);
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
etkFloat_t ewol::ProgressBar::ValueGet(void)
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
void ewol::ProgressBar::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
|
||||
tmpOObjects->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;
|
||||
tmpOObjects->SetColor(m_textColorBgOn);
|
||||
tmpOObjects->Rectangle( tmpOriginX, tmpOriginY, tmpSizeX*m_value, tmpSizeY);
|
||||
tmpOObjects->SetColor(m_textColorBgOff);
|
||||
tmpOObjects->Rectangle( tmpOriginX+tmpSizeX*m_value, tmpOriginY, tmpSizeX*(1.0-m_value), tmpSizeY);
|
||||
|
||||
tmpOObjects->SetColor(m_textColorFg);
|
||||
tmpOObjects->RectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1);
|
||||
|
||||
AddOObject(tmpOObjects);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
73
Sources/libewol/ewol/widget/ProgressBar.h
Normal file
73
Sources/libewol/ewol/widget/ProgressBar.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/ProgressBar.h
|
||||
* @brief ewol Progress bar widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 14/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_PROGRESS_BAR_H__
|
||||
#define __EWOL_PROGRESS_BAR_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/widget/Drawable.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class ProgressBar :public ewol::Drawable
|
||||
{
|
||||
public:
|
||||
ProgressBar(void);
|
||||
virtual ~ProgressBar(void);
|
||||
/**
|
||||
* @brief Check if the object has the specific type.
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type of the object we want to check
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
virtual bool CheckObjectType(const char * const objectType);
|
||||
|
||||
/**
|
||||
* @brief Get the current Object type of the EObject
|
||||
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
|
||||
* @param[in] objectType type description
|
||||
* @return true if the object is compatible, otherwise false
|
||||
*/
|
||||
virtual const char * const GetObjectType(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
void ValueSet(etkFloat_t val);
|
||||
etkFloat_t ValueGet(void);
|
||||
void SetColor(color_ts newColor) { m_textColorFg = newColor; };
|
||||
private:
|
||||
etkFloat_t m_value; //!< % used
|
||||
color_ts m_textColorFg; //!< forder bar color
|
||||
color_ts m_textColorBgOn; //!< bar color enable
|
||||
color_ts m_textColorBgOff; //!< bar color disable
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
};
|
||||
|
||||
extern const char * const TYPE_EOBJECT_WIDGET_PROGRESS_BAR;
|
||||
|
||||
};
|
||||
|
||||
#define EWOL_CAST_WIDGET_PROGRESS_BAR(curentPointer) EWOL_CAST(ewol::TYPE_EOBJECT_WIDGET_PROGRESS_BAR,ewol::ProgressBar,curentPointer)
|
||||
|
||||
#endif
|
@ -125,6 +125,7 @@ void ewol::Scene::OnRegenerateDisplay(void)
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
//TODO : Il y a un bug : seg fault ... je ne sais pas trop ou ...
|
||||
void ewol::Scene::OnDraw(void)
|
||||
{
|
||||
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
||||
|
@ -33,17 +33,6 @@
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class SceneElement {
|
||||
public:
|
||||
etk::VectorType<ewol::OObject*> backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::GameElement*> listAnimatedElements; //!< generic element to display...
|
||||
int32_t id; //!< Unique element ID
|
||||
int32_t AddElement(ewol::GameElement* newElement);
|
||||
};
|
||||
|
||||
|
||||
class Scene :public ewol::WidgetScrooled
|
||||
{
|
||||
// TODO : Set it in private ...
|
||||
|
@ -105,8 +105,8 @@ const char * const ewol::Slider::GetObjectType(void)
|
||||
|
||||
bool ewol::Slider::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 40;
|
||||
m_minSize.y = dotRadius*2;
|
||||
m_minSize.x = etk_max(m_userMinSize.x, 40);
|
||||
m_minSize.y = etk_max(m_userMinSize.y, dotRadius*2);
|
||||
MarkToReedraw();
|
||||
return true;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ FILE_LIST = ewol/ewol.cpp \
|
||||
ewol/widget/Layer.cpp \
|
||||
ewol/widget/Menu.cpp \
|
||||
ewol/widget/PopUp.cpp \
|
||||
ewol/widget/ProgressBar.cpp \
|
||||
ewol/widget/Scene.cpp \
|
||||
ewol/widget/SizerHori.cpp \
|
||||
ewol/widget/SizerVert.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user