[DEV] add property on progress bar

This commit is contained in:
Edouard DUPIN 2013-11-05 21:01:02 +01:00
parent 3af8ef44cc
commit adc4ad0c45
14 changed files with 160 additions and 29 deletions

2
external/egami vendored

@ -1 +1 @@
Subproject commit ae00cd17e33ed3d0a8f0f8065b4b0ab2c2490343
Subproject commit 9ead15a4d1cb533db919dfe5f6638dae7f788479

2
external/etk vendored

@ -1 +1 @@
Subproject commit a3f4d0d129221ea06c6331f0c8fa9a8bd9b0d458
Subproject commit 8806c4e44ff918b1be25e1bd8958512e11ffe27e

View File

@ -32,7 +32,9 @@ namespace widget {
protected: // Derived function
virtual void onDraw(void);
public: // Derived function
virtual const char * const getObjectType(void) { return "widget::ColorBar"; };
virtual const char * const getObjectType(void) {
return "widget::ColorBar";
};
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);

View File

@ -82,7 +82,9 @@ namespace widget
const char * _eventIdgenerated = NULL,
const etk::UString& _overloadData="");
public: // herited functions:
virtual const char * const getObjectType(void) { return "ewol::widget::Composer"; };
virtual const char * const getObjectType(void) {
return "ewol::widget::Composer";
};
};
};

View File

@ -57,7 +57,9 @@ namespace widget {
virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const etk::UString& _widgetName);
virtual const char * const getObjectType(void) { return "ewol::widget::Container"; };
virtual const char * const getObjectType(void) {
return "ewol::widget::Container";
};
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};

View File

@ -55,15 +55,21 @@ namespace widget {
* @return the ID of the set element
*/
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
inline int32_t subWidgetAddBack(ewol::Widget* _newWidget) { return subWidgetAdd(_newWidget); };
inline int32_t subWidgetAddEnd(ewol::Widget* _newWidget) { return subWidgetAdd(_newWidget); };
inline int32_t subWidgetAddBack(ewol::Widget* _newWidget) {
return subWidgetAdd(_newWidget);
};
inline int32_t subWidgetAddEnd(ewol::Widget* _newWidget) {
return subWidgetAdd(_newWidget);
};
/**
* @brief add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param[in] _newWidget the element pointer
* @return the ID of the set element
*/
virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget);
inline int32_t subWidgetAddFront(ewol::Widget* _newWidget) { return subWidgetAddStart(_newWidget); };
inline int32_t subWidgetAddFront(ewol::Widget* _newWidget) {
return subWidgetAddStart(_newWidget);
};
/**
* @brief remove definitly a widget from the system and this layer.
* @param[in] _newWidget the element pointer.
@ -82,7 +88,9 @@ namespace widget {
virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const etk::UString& _widgetName);
virtual const char * const getObjectType(void) { return "Ewol::ContainerN"; };
virtual const char * const getObjectType(void) {
return "Ewol::ContainerN";
};
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};

View File

@ -64,7 +64,9 @@ namespace widget {
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void calculateSize(const vec2& availlable);
virtual void calculateMinMaxSize(void);
virtual const char * const getObjectType(void) { return "ewol::ContextMenu"; };
virtual const char * const getObjectType(void) {
return "ewol::ContextMenu";
};
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
};
};

View File

@ -75,7 +75,9 @@ namespace widget {
* @brief get the current value in the entry
* @return The current display value
*/
etk::UString getValue(void) const { return m_data; };
etk::UString getValue(void) const {
return m_data;
};
private:
int32_t m_maxCharacter; //!< number max of xharacter in the list
@ -89,7 +91,9 @@ namespace widget {
* @brief Limit the number of Unicode character in the entry
* @return Number of max character set in the List.
*/
int32_t getMaxChar(void) const { return m_maxCharacter; };
int32_t getMaxChar(void) const {
return m_maxCharacter;
};
private:
etk::RegExp<etk::UString> m_regExp; //!< regular expression to limit the input of an entry
@ -103,7 +107,9 @@ namespace widget {
* @brief get the regualar expression limitation
* @param The regExp string
*/
const etk::UString& getRegExp(void) const { return m_regExp.getRegExp(); };
const etk::UString& getRegExp(void) const {
return m_regExp.getRegExp();
};
private:
bool m_needUpdateTextPos; //!< text position can have change
@ -152,7 +158,9 @@ namespace widget {
* @brief get the color for the text.
* @return The color requested.
*/
const etk::Color<>& getColorText(void) const { return m_textColorFg; };
const etk::Color<>& getColorText(void) const {
return m_textColorFg;
};
private:
etk::Color<> m_textColorBg; //!< Background color.
@ -166,7 +174,9 @@ namespace widget {
* @brief get the selected color for the text in selection mode.
* @return The color requested.
*/
const etk::Color<>& getColorTextSelected(void) const { return m_textColorBg; };
const etk::Color<>& getColorTextSelected(void) const {
return m_textColorBg;
};
private:
etk::UString m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...)
@ -180,14 +190,18 @@ namespace widget {
* @brief get The text displayed when nothing is in the entry.
* @return Text display when nothing
*/
const etk::UString& getEmptyText(void) const { return m_textWhenNothing; };
const etk::UString& getEmptyText(void) const {
return m_textWhenNothing;
};
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onEventClipboard(ewol::clipBoard::clipboardListe_te _clipboardID);
virtual const char * const getObjectType(void) { return "EwolEntry"; };
virtual const char * const getObjectType(void) {
return "EwolEntry";
};
virtual void calculateMinMaxSize(void);
protected: // Derived function
virtual void onDraw(void);

View File

@ -134,7 +134,9 @@ namespace widget {
virtual void onRegenerateDisplay(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual const char * const getObjectType(void) { return "Ewol::sizer"; };
virtual const char * const getObjectType(void) {
return "ewol::gird";
};
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
};

View File

@ -114,17 +114,37 @@ void widget::Image::onRegenerateDisplay(void) {
vec2 imageRealSize = m_minSize - imageBoder;
vec2 imageRealSizeMax = m_size - imageBoder;
vec2 tmpSize = m_compositing.getRealSize();
if (m_userFill.x()) {
bool xSizeBigger = false;
if (imageRealSize.x() > imageRealSize.y()) {
xSizeBigger = true;
}
if (m_userFill.x() == true) {
imageRealSize.setX(imageRealSizeMax.x());
} else {
origin.setX(origin.x() + (m_size.x()-m_minSize.x())*0.5f);
}
if (m_userFill.y()) {
if (m_userFill.y() == true) {
imageRealSize.setY(imageRealSizeMax.y());
} else {
origin.setY(origin.y() + (m_size.y()-m_minSize.y())*0.5f);
}
if (m_keepRatio == true) {
vec2 tmpSize = m_compositing.getRealSize();
float ratio = tmpSize.x() / tmpSize.y();
float ratioCurrent = imageRealSize.x() / imageRealSize.y();
if (ratio == ratioCurrent) {
// nothing to do ...
} else if (ratio < ratioCurrent) {
float oldX = imageRealSize.x();
imageRealSize.setX(imageRealSize.y()*ratio);
origin += vec2((oldX - imageRealSize.x()) * 0.5f, 0);
} else {
float oldY = imageRealSize.y();
imageRealSize.setY(imageRealSize.x()/ratio);
origin += vec2(0, (oldY - imageRealSize.y()) * 0.5f);
}
}
// set the somposition properties :
m_compositing.setPos(origin);

View File

@ -63,7 +63,9 @@ namespace widget {
* @brief get the file displayed
* @return the filename of the image
*/
const etk::UString& getFile(void) const { return m_fileName; };
const etk::UString& getFile(void) const {
return m_fileName;
};
protected:
ewol::Dimension m_border; //!< border to add at the image.
public:
@ -76,7 +78,9 @@ namespace widget {
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getBorder(void) const { return m_border; };
const ewol::Dimension& getBorder(void) const {
return m_border;
};
protected:
ewol::Dimension m_imageSize; //!< border to add at the image.
public:
@ -89,7 +93,9 @@ namespace widget {
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getImageSize(void) const { return m_imageSize; };
const ewol::Dimension& getImageSize(void) const {
return m_imageSize;
};
protected:
bool m_keepRatio; //!< keep the image ratio between width and hight
public:
@ -102,13 +108,17 @@ namespace widget {
* @brief get the current status of keeping ratio.
* @return The status of keeping the ratio of this image.
*/
bool getKeepRatio(void) const { return m_keepRatio; };
bool getKeepRatio(void) const {
return m_keepRatio;
};
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 const char * const getObjectType(void) { return "Ewol::Image"; };
virtual const char * const getObjectType(void) {
return "Ewol::Image";
};
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);

View File

@ -33,7 +33,9 @@ namespace widget {
Menu(void);
virtual ~Menu(void);
// Derived functionv
virtual const char * const getObjectType(void) { return "EwolMenu"; };
virtual const char * const getObjectType(void) {
return "ewol::menu";
};
private:
virtual void subWidgetRemoveAll(void);
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);

View File

@ -22,6 +22,10 @@ void widget::ProgressBar::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create);
}
const char* const widget::ProgressBar::configColorBg = "color-bg";
const char* const widget::ProgressBar::configColorFgOn = "color-on";
const char* const widget::ProgressBar::configColorFgOff = "color-off";
const char* const widget::ProgressBar::configValue = "value";
const int32_t dotRadius = 6;
@ -35,6 +39,11 @@ widget::ProgressBar::ProgressBar(void) {
m_textColorBgOff = etk::color::black;
m_textColorBgOff.setA(0x3F);
setCanHaveFocus(true);
registerConfig(configColorBg, "color", NULL, "Background color");
registerConfig(configColorFgOn, "color", NULL, "Corlor of the true value");
registerConfig(configColorFgOff, "color", NULL, "Corlor of the false value");
registerConfig(configValue, "integer", NULL, "Value of the progress bar");
}
widget::ProgressBar::~ProgressBar(void) {
@ -87,3 +96,50 @@ void widget::ProgressBar::onRegenerateDisplay(void) {
bool widget::ProgressBar::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) {
return true;
}
if (_conf.getConfig() == configColorBg) {
m_textColorFg = _conf.getData();
return true;
}
if (_conf.getConfig() == configColorFgOn) {
m_textColorBgOn = _conf.getData();
return true;
}
if (_conf.getConfig() == configColorFgOff) {
m_textColorBgOff = _conf.getData();
return true;
}
if (_conf.getConfig() == configValue) {
m_value = _conf.getData().toFloat();
return true;
}
return false;
}
bool widget::ProgressBar::onGetConfig(const char* _config, etk::UString& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true;
}
if (_config == configColorBg) {
_result = m_textColorFg.getString();
return true;
}
if (_config == configColorFgOn) {
_result = m_textColorBgOn.getString();
return true;
}
if (_config == configColorFgOff) {
_result = m_textColorBgOff.getString();
return true;
}
if (_config == configValue) {
_result = m_value;
return true;
}
return false;
}

View File

@ -20,6 +20,11 @@ namespace widget {
class ProgressBar : public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configColorBg;
static const char* const configColorFgOn;
static const char* const configColorFgOff;
static const char* const configValue;
private:
ewol::Drawing m_draw; // basic drawing element
public:
@ -27,7 +32,9 @@ namespace widget {
virtual ~ProgressBar(void);
void valueSet(float _val);
float valueGet(void);
void setColor(etk::Color<> _newColor) { m_textColorFg = _newColor; };
void setColor(etk::Color<> _newColor) {
m_textColorFg = _newColor;
};
private:
float m_value; //!< % used
etk::Color<> m_textColorFg; //!< forder bar color
@ -35,9 +42,13 @@ namespace widget {
etk::Color<> m_textColorBgOff; //!< bar color disable
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, etk::UString& _result) const;
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual const char * const getObjectType(void) { return "EwolProgressBar"; };
virtual const char * const getObjectType(void) {
return "ewol::progressBar";
};
virtual void calculateMinMaxSize(void);
};