[DEV] Start rework of the button

This commit is contained in:
Edouard DUPIN 2013-04-08 21:30:25 +02:00
parent b3465bcf44
commit 56eafd762f
18 changed files with 367 additions and 304 deletions

2
build

@ -1 +1 @@
Subproject commit fa06553c5e05de847788c4eb83234350bbe66c48
Subproject commit 77caff070b0b64662b0097a22e42c6a65134e8f0

View File

@ -16,7 +16,7 @@
#undef __class__
#define __class__ "ewol::Shaper"
ewol::Shaper::Shaper(etk::UString shaperName) :
ewol::Shaper::Shaper(const etk::UString& shaperName) :
m_name(shaperName),
m_config(NULL),
m_confIdPaddingX(-1),
@ -263,7 +263,7 @@ vec2 ewol::Shaper::GetPadding(void)
}
void ewol::Shaper::SetSource(etk::UString newFile)
void ewol::Shaper::SetSource(const etk::UString& newFile)
{
Clear();
UnLoadProgram();

View File

@ -70,7 +70,7 @@ namespace ewol
* @brief generic constructor
* @param[in] imageName Name of the file that might be loaded
*/
Shaper(etk::UString shaperName="");
Shaper(const etk::UString& shaperName="");
/**
* @brief generic destructor
*/
@ -137,7 +137,7 @@ namespace ewol
* @brief Change the image Source ==> can not be done to display 2 images at the same time ...
* @param[in] newFile New file of the Image
*/
void SetSource(etk::UString newFile);
void SetSource(const etk::UString& newFile);
/**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources.

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#import <Cocoa/Cocoa.h>

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#import <ewol/renderer/os/gui.MacOs.AppDelegate.h>

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_MM_INTERFACE_H__
#define __EWOL_MM_INTERFACE_H__

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
/*

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/

View File

@ -1,3 +1,10 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>

View File

@ -29,9 +29,8 @@ extern const char * const ewolEventButtonValue = "ewol-button-value";
#define STATUS_DOWN (3)
widget::Button::Button(etk::UString newLabel, etk::UString shaperName) :
widget::Button::Button(const etk::UString& shaperName) :
m_shaper(shaperName),
m_label(newLabel),
m_toggleMode(false),
m_value(false),
m_mouseHover(false),
@ -40,15 +39,19 @@ widget::Button::Button(etk::UString newLabel, etk::UString shaperName) :
m_selectableAreaPos(0,0),
m_selectableAreaSize(0,0)
{
// by default set no widget :
m_subWidget[0] = NULL;
m_subWidget[1] = NULL;
// add basic Event generated :
AddEventId(ewolEventButtonPressed);
AddEventId(ewolEventButtonDown);
AddEventId(ewolEventButtonUp);
AddEventId(ewolEventButtonEnter);
AddEventId(ewolEventButtonLeave);
AddEventId(ewolEventButtonValue);
// set basic status for the shaper :
m_shaper.ChangeStatusIn(STATUS_UP);
// This widget can have the focus ...
SetCanHaveFocus(true);
// Limit event at 1:
SetMouseLimit(1);
@ -60,91 +63,147 @@ widget::Button::~Button(void)
}
void widget::Button::SetShaperName(etk::UString shaperName)
void widget::Button::SetShaperName(const etk::UString& shaperName)
{
m_shaper.SetSource(shaperName);
}
void widget::Button::SetImage(etk::UString imageName, draw::Color color, int32_t size)
void widget::Button::SetSubWidget(ewol::Widget* subWidget, bool forToggle)
{
m_imageColor = color;
m_imageDisplaySize = size;
m_displayImage.SetSource(imageName, size);
MarkToRedraw();
if (subWidget==NULL) {
EWOL_WARNING("try to set an empty widget in the Button entity");
return;
}
int32_t idWidget=0;
if (forToggle==true) {
idWidget = 1;
}
if (NULL!=m_subWidget[idWidget]) {
delete(m_subWidget[idWidget]);
// the pointer might already set at NULL:
if (NULL != m_subWidget[idWidget]) {
EWOL_ERROR("error while removing previous widget...");
m_subWidget[idWidget]=NULL;
}
}
EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget);
m_subWidget[idWidget] = subWidget;
// element change ... We need to recalculate all the subElments :
ewol::RequestUpdateSize();
}
void widget::Button::SetImageToggle(etk::UString imageName, draw::Color color, int32_t size)
ewol::Widget* widget::Button::GetSubWidget(bool fromToggle)
{
m_imageColorToggle = color;
m_imageDisplaySize = size;
m_displayImageToggle.SetSource(imageName, size);
int32_t idWidget=0;
if (fromToggle==true) {
idWidget = 1;
}
return m_subWidget[idWidget];
}
bool widget::Button::CalculateSize(float availlableX, float availlableY)
{
vec2 padding = m_shaper.GetPadding();
// set minimal size
m_size = m_minSize;
vec2 minimumSizeBase(0,0);
vec2 minimumSizeToggle(0,0);
// Checking the expend properties :
if (m_userExpend.x() == true) {
m_size.setX(availlableX);
}
if (m_userExpend.y() == true) {
m_size.setY(availlableY);
}
// Checkin the filling properties ==> for the subElements:
vec2 subElementSize = m_minSize;
if (m_userFill.x() == true) {
subElementSize.setX(m_size.x());
}
if (m_userFill.y() == true) {
subElementSize.setY(m_size.y());
}
vec2 origin = (m_size - subElementSize)/2.0f + padding;
subElementSize -= padding*2.0f;
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y());
m_subWidget[0]->CalculateSize(subElementSize.x(), subElementSize.y());
}
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y());
m_subWidget[1]->CalculateSize(subElementSize.x(), subElementSize.y());
}
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
m_selectableAreaSize = subElementSize + (padding*2.0f);
m_selectableAreaPos = origin-padding;
MarkToRedraw();
ewol::RequestUpdateSize();
return true;
}
bool widget::Button::CalculateMinSize(void)
{
vec2 padding = m_shaper.GetPadding();
m_displayText.Clear();
if( m_label.Size()==0
&& m_labelToggle.Size()==0
&& ( true == m_displayImage.HasSources()
|| true == m_displayImageToggle.HasSources()) ) {
// special case of only one image display ==> certer it ...
m_minSize.setX(padding.x()*2 + m_imageDisplaySize);
m_minSize.setY(padding.y()*2 + m_imageDisplaySize);
} else {
vec3 minSize(0,0,0);
//faster if no text set ...
if (m_label.Size()!=0) {
minSize = m_displayText.CalculateSizeDecorated(m_label);
}
if( true == m_toggleMode
&& m_labelToggle.Size()!=0) {
m_displayText.Clear();
vec3 minSizeToggle = m_displayText.CalculateSizeDecorated(m_labelToggle);
minSize.setValue(etk_max(minSize.x(), minSizeToggle.x()),
etk_max(minSize.y(), minSizeToggle.y()),
etk_max(minSize.z(), minSizeToggle.z()));
}
m_minSize.setX(padding.x()*2 + minSize.x());
m_minSize.setY(padding.y()*2 + minSize.y());
// Add the image element ...
if( true == m_displayImage.HasSources()
|| true == m_displayImageToggle.HasSources()) {
m_minSize.setX(m_minSize.x()+ padding.x()/2 + m_imageDisplaySize);
}
vec2 minimumSizeBase(0,0);
vec2 minimumSizeToggle(0,0);
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->CalculateMinSize();
minimumSizeBase = m_subWidget[0]->GetMinSize();
}
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->CalculateMinSize();
minimumSizeToggle = m_subWidget[1]->GetMinSize();
}
// get the maxixmum min size of the 2 sub-widget (if they are present indeed):
m_minSize.setX(etk_max(minimumSizeBase.x(), minimumSizeToggle.x()) );
m_minSize.setY(etk_max(minimumSizeBase.y(), minimumSizeToggle.y()) );
// add padding :
m_minSize += padding*2.0f;
// verify the min max of the min size ...
CheckMinSize();
MarkToRedraw();
return true;
}
void widget::Button::SetLabel(etk::UString newLabel)
void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
{
m_label = newLabel;
MarkToRedraw();
ewol::RequestUpdateSize();
// draw the shaaper (if needed indeed)
m_shaper.Draw();
// draw the widget that need something ...
if( false == m_toggleMode
|| false == m_value) {
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->GenDraw(displayProp);
}
} else {
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->GenDraw(displayProp);
}
}
}
etk::UString widget::Button::GetLabel(void)
void widget::Button::OnRegenerateDisplay(void)
{
return m_label;
}
void widget::Button::SetLabelToggle(etk::UString newLabel)
{
m_labelToggle = newLabel;
MarkToRedraw();
ewol::RequestUpdateSize();
}
etk::UString widget::Button::GetLabelToggle(void)
{
return m_labelToggle;
if (true == NeedRedraw()) {
vec2 padding = m_shaper.GetPadding();
m_shaper.Clear();
m_shaper.SetOrigin(m_selectableAreaPos);
m_shaper.SetSize(m_selectableAreaSize);
m_shaper.SetInsidePos(m_selectableAreaPos+padding );
m_shaper.SetInsideSize(m_selectableAreaSize-padding*2.0f);
}
if( false == m_toggleMode
|| false == m_value) {
if (NULL!=m_subWidget[0]) {
m_subWidget[0]->OnRegenerateDisplay();
}
} else {
if (NULL!=m_subWidget[1]) {
m_subWidget[1]->OnRegenerateDisplay();
}
}
}
void widget::Button::SetValue(bool val)
@ -172,150 +231,6 @@ void widget::Button::SetToggleMode(bool togg)
}
}
void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
{
m_shaper.Draw();
if( false == m_toggleMode
|| false == m_value) {
m_displayImage.Draw();
} else {
m_displayImageToggle.Draw();
}
m_displayText.Draw();
}
void widget::Button::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
// clear the previous display :
m_displayImage.Clear();
m_displayImageToggle.Clear();
m_shaper.Clear();
m_displayText.Clear();
// know the current padding
vec2 padding = m_shaper.GetPadding();
// to know the size of one Line :
vec3 minSize = m_displayText.CalculateSize('A');
ivec2 localSize = m_minSize;
vec3 sizeText(0,0,0);
vec3 tmpOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
// no change for the text orogin :
vec3 tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
if (true==m_userFill.x()) {
localSize.setX(m_size.x());
tmpOrigin.setX(0);
tmpTextOrigin.setX(0);
}
if (true==m_userFill.y()) {
localSize.setY(m_size.y());
}
tmpOrigin += vec3(padding.x(),padding.y(),0);
tmpTextOrigin += vec3(padding.x(), padding.y(), 0);
localSize -= ivec2(2*padding.x(), 2*padding.y());
if( m_label.Size()==0
&& m_labelToggle.Size()==0
&& ( true == m_displayImage.HasSources()
|| true == m_displayImageToggle.HasSources()) ) {
vec3 imagePos(tmpOrigin.x()-padding.x()/4,
tmpOrigin.y()-padding.x()/4+(m_minSize.y()-m_imageDisplaySize-2*padding.y())/2.0,
0);
vec2 imageSize(m_imageDisplaySize,
m_imageDisplaySize);
if( false==m_toggleMode
|| false==m_value) {
m_displayImage.SetPos(imagePos);
m_displayImage.SetColor(m_imageColor);
m_displayImage.Print(imageSize);
} else {
m_displayImageToggle.SetPos(imagePos);
m_displayImageToggle.SetColor(m_imageColorToggle);
m_displayImageToggle.Print(imageSize);
}
} else {
vec3 curentTextSize(0,0,0);
if( false == m_toggleMode
|| false == m_value
|| m_labelToggle.Size()==0) {
curentTextSize = m_displayText.CalculateSizeDecorated(m_label);
} else {
curentTextSize = m_displayText.CalculateSizeDecorated(m_labelToggle);
}
tmpTextOrigin.setY(tmpTextOrigin.y()+ (m_minSize.y()-2*padding.y()) - minSize.y());
vec2 textPos(tmpTextOrigin.x(), tmpTextOrigin.y());
if( true == m_displayImage.HasSources()
|| true == m_displayImageToggle.HasSources()) {
vec3 imagePos(tmpOrigin.x()-padding.x()/4,
tmpOrigin.y()-padding.x()/4+(m_minSize.y()-m_imageDisplaySize-2*padding.y())/2.0,
0);
vec2 imageSize(m_imageDisplaySize,
m_imageDisplaySize);
if( false==m_toggleMode
|| false==m_value) {
m_displayImage.SetPos(imagePos);
m_displayImage.SetColor(m_imageColor);
m_displayImage.Print(imageSize);
} else {
m_displayImageToggle.SetPos(imagePos);
m_displayImageToggle.SetColor(m_imageColorToggle);
m_displayImageToggle.Print(imageSize);
}
// update the text position ...
tmpTextOrigin.setX(tmpTextOrigin.x() + padding.x()/2 + m_imageDisplaySize);
}
vec3 drawClippingPos(padding.x(), padding.y(), -0.5);
vec3 drawClippingSize((m_size.x() - padding.x()),
(m_size.y() - padding.y()),
1);
// clean the element
m_displayText.Reset();
m_displayText.SetPos(tmpTextOrigin);
if( true == m_displayImage.HasSources()
|| true == m_displayImageToggle.HasSources()) {
m_displayText.SetTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x()-m_imageDisplaySize, ewol::Text::alignCenter);
} else {
m_displayText.SetTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::Text::alignCenter);
}
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
if( false == m_toggleMode
|| false == m_value
|| m_labelToggle.Size()==0) {
m_displayText.PrintDecorated(m_label);
} else {
m_displayText.PrintDecorated(m_labelToggle);
}
//m_displayText.Translate(tmpOrigin);
sizeText = m_displayText.CalculateSize(m_label);
if (true==m_userFill.y()) {
tmpOrigin.setY(padding.y());
}
}
// selection area :
m_selectableAreaPos = vec2(tmpOrigin.x()-padding.x(), tmpOrigin.y()-padding.y());
m_selectableAreaSize = localSize + vec2(2,2)*padding;
m_shaper.SetOrigin(m_selectableAreaPos );
m_shaper.SetSize(m_selectableAreaSize);
m_shaper.SetInsidePos(vec2(tmpTextOrigin.x(), tmpTextOrigin.y()) );
vec2 tmpp2(sizeText.x(), sizeText.y());
m_shaper.SetInsideSize(tmpp2);
}
}
bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos)
{
bool previousHoverState = m_mouseHover;
@ -341,11 +256,13 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
if (true == m_mouseHover) {
if (1 == IdInput) {
if(ewol::keyEvent::statusDown == typeEvent) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonDown);
GenerateEventId(ewolEventButtonDown);
m_buttonPressed = true;
MarkToRedraw();
}
if(ewol::keyEvent::statusUp == typeEvent) {
//EWOL_DEBUG("Generate event : " << ewolEventButtonUp);
GenerateEventId(ewolEventButtonUp);
m_buttonPressed = false;
MarkToRedraw();
@ -353,11 +270,14 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
if(ewol::keyEvent::statusSingle == typeEvent) {
// 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();
@ -413,12 +333,4 @@ void widget::Button::PeriodicCall(int64_t localTime)
MarkToRedraw();
}
void widget::Button::SetImageSize(int32_t size)
{
MarkToRedraw();
ewol::RequestUpdateSize();
m_imageDisplaySize = size;
}

View File

@ -24,32 +24,30 @@ extern const char * const ewolEventButtonEnter;
extern const char * const ewolEventButtonLeave;
extern const char * const ewolEventButtonValue;
namespace widget {
/**
* @brief a composed button is a button with an inside composed with the specify XML element ==> this permit to generate standard element simple
*/
class Button : public ewol::Widget
{
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Text m_displayText; //!< compositing Text.
ewol::Image m_displayImage; //!< Image to display in normal mode.
draw::Color m_imageColor; //!< Image color to display it.
ewol::Image m_displayImageToggle; //!< Image to display in toggle mode.
draw::Color m_imageColorToggle; //!< Image color Toggle to display it.
etk::UString m_label; //!< Labe to display in normal mode.
etk::UString m_labelToggle; //!< Label to display when toggle mode is set ("" whenit is the same).
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.
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
vec2 m_selectableAreaPos; //!< Start position of the events
vec2 m_selectableAreaSize; //!< Size of the event positions
public:
/**
* @brief Constructor
* @param[in] newLabel Button Label to display
*/
Button(etk::UString newLabel="No Label", etk::UString shaperName="THEME:GUI:widgetButton.conf");
Button(const etk::UString& shaperName="THEME:GUI:widgetButton.conf");
/**
* @brief Destructor
*/
@ -58,39 +56,17 @@ namespace widget {
* @brief Set the shaper name (use the contructer one this permit to not noad unused shaper)
* @param[in] shaperName The new shaper filename
*/
void SetShaperName(etk::UString shaperName);
void SetShaperName(const etk::UString& shaperName);
/**
* @brief Specify the current label of the Button
* @brief Specify the current composition string
* @param[in] newLabel The string that might be displayed
*/
void SetLabel(etk::UString newLabel);
void SetSubWidget(ewol::Widget* subWidget, bool forToggle=false);
/**
* @brief Get the current displayed text
* @brief Get the current displayed composition
* @return The displayed string.
*/
etk::UString GetLabel(void);
/**
* @brief Specify the current label of the Button when the button value is true
* @param[in] newLabel The string that might be displayed
*/
void SetLabelToggle(etk::UString newLabel);
/**
* @brief Get the current displayed text when the button value is true
* @return The displayed string.
*/
etk::UString GetLabelToggle(void);
/**
* @brief Set an image to set at the button.
* @param[in] imageName Filename of the image.
* @param[in] color The required color for the image.
*/
void SetImage(etk::UString imageName, draw::Color color=draw::color::white, int32_t size=32);
/**
* @brief Set the image when button is pressed.
* @param[in] imageName Filename of the image.
* @param[in] color The required color for the image.
*/
void SetImageToggle(etk::UString imageName, draw::Color color=draw::color::white, int32_t size=32);
ewol::Widget* GetSubWidget(bool fromToggle=false);
/**
* @brief Set the currentValue of the Button (pressed or not)
* @note Work only in toggle mode
@ -108,31 +84,23 @@ namespace widget {
* @param[in] togg New toggle mode
*/
void SetToggleMode(bool togg);
/**
* @brief Set the new image Size (default 32).
* @param[in] size The new display size.
*/
void SetImageSize(int32_t size);
public:
// Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; };
// Derived function
virtual bool CalculateMinSize(void);
// Derived function
virtual void OnRegenerateDisplay(void);
// Derived function
virtual void OnDraw(ewol::DrawProperty& displayProp);
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
private:
/**
* @brief Internal system to Change the property of the current status
* @param[in] new state
*/
void ChangeStatusIn(int32_t newStatusId);
public:
// Derived function
virtual const char * const GetObjectType(void) { return "widget::Button"; };
virtual bool CalculateMinSize(void);
virtual bool CalculateSize(float availlableX, float availlableY);
virtual void OnRegenerateDisplay(void);
virtual void OnDraw(ewol::DrawProperty& displayProp);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
private:
// derived function
virtual void PeriodicCall(int64_t localTime);
};
};

View File

@ -0,0 +1,62 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/ewol.h>
#include <ewol/widget/XmlComposer.h>
/*
ewol::Widget* m_widget;
etk::UString composerString;
etk::Vector<ComposerWidgetListNamed> m_list;
*/
widget::XmlComposer::XmlComposer(const etk::UString& composerXmlString)
{
// TODO ...
}
widget::XmlComposer::~XmlComposer(void)
{
if (NULL != m_widget) {
delete(m_widget);
// might have been destroy first here :
if (m_widget!=NULL) {
EWOL_ERROR("Composer : An error Occured when removing main node");
}
}
// nothing else to do .. all node in the list might have been removed now ...
if (0!=m_list.Size()) {
EWOL_ERROR("the subName element in the list are incorect...");
}
}
ewol::Widget* widget::XmlComposer::GetMainWidget(void)
{
// nothing else to do ...
return m_widget;
}
ewol::Widget* widget::XmlComposer::GetWidgetNamed(const etk::UString& widgetName)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (m_list[iii].widgetName == widgetName) {
return m_list[iii].widget;
}
}
return NULL;
}
virtual void widget::XmlComposer::OnObjectRemove(ewol::EObject* removeObject)
{
for (int32_t iii=0; iii<m_list.Size(); iii++) {
if (m_list[iii].widgetName == widgetName) {
m_list.Erase(iii);
}
}
}

View File

@ -0,0 +1,57 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_XML_COMPOSER_H__
#define __EWOL_XML_COMPOSER_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
namespace widget
{
class XmlComposer : public ewol::EObject
{
private:
class ComposerWidgetListNamed {
public:
ewol::Widget* widget;
etk::UString widgetName;
}
ewol::Widget* m_widget;
etk::UString composerString;
etk::Vector<ComposerWidgetListNamed> m_list;
public:
/**
* @brief Constructor
*/
XmlComposer(const etk::UString& composerXmlString);
/**
* @brief Destructor
*/
~XmlComposer(void);
public:
/**
* @brief Get the main node widget
* @return the requested pointer on the node
*/
ewol::Widget* GetMainWidget(void);
/**
* @brief Get the main node widget
* @param[in] widgetName name of the widget
* @return the requested pointer on the node
*/
ewol::Widget* GetWidgetNamed(const etk::UString& widgetName);
public:
// herited function :
virtual void OnObjectRemove(ewol::EObject* removeObject);
};
};
#endif

View File

@ -81,6 +81,8 @@ int32_t widget::Menu::Add(int32_t parent, etk::UString label, etk::UString image
tmpObject->m_message = message;
m_listElement.PushBack(tmpObject);
if (-1 == tmpObject->m_parentId) {
// TODO : When button are back ...
/*
widget::Button * myButton = NULL;
myButton = new widget::Button(label);
if (NULL == myButton) {
@ -94,6 +96,7 @@ int32_t widget::Menu::Add(int32_t parent, etk::UString label, etk::UString image
// keep the specific event ...
myButton->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventButtonPressed);
tmpObject->m_widgetPointer = myButton;
*/
}
return tmpObject->m_localId;
}
@ -168,6 +171,8 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
for(int32_t jjj=m_listElement.Size()-1; jjj>=0; jjj--) {
if (m_listElement[iii]!=NULL) {
if (m_listElement[iii]->m_localId == m_listElement[jjj]->m_parentId) {
// TODO : When button are back ...
/*
myButton = new widget::Button(m_listElement[jjj]->m_label);
if (NULL == myButton) {
EWOL_ERROR("Allocation Error");
@ -181,6 +186,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
mySizer->SubWidgetAdd(myButton);
m_listElement[jjj]->m_widgetPointer = myButton;
}
*/
}
}
}

View File

@ -300,6 +300,16 @@ bool ewol::Widget::CanExpentY(void)
return false;
}
bvec2 ewol::Widget::CanExpent(void)
{
if (false==IsHide()) {
return m_userExpend;
}
return bvec2(false,false);
}
void ewol::Widget::SetFillX(bool newFill)
{
m_userFill.setX(newFill);

View File

@ -81,8 +81,6 @@ namespace ewol {
// user configuaration
vec2 m_userMinSize; //!< user define the minimum size of the widget
vec2 m_userMaxSize; //!< user define the maximum size of the widget
bvec2 m_userExpend;
bvec2 m_userFill;
public:
/**
* @brief Set the zoom property of the widget
@ -158,6 +156,9 @@ namespace ewol {
* @return Requested size
*/
vec2 GetSize(void);
protected:
bvec2 m_userExpend;
public:
/**
* @brief Set the horizontal expend capacity
* @param[in] newExpend new Expend state
@ -178,6 +179,14 @@ namespace ewol {
* @return boolean repensent the capacity to expend
*/
virtual bool CanExpentY(void);
/**
* @brief Get the expend capabilities (x&y)
* @return 2D boolean repensent the capacity to expend
*/
virtual bvec2 CanExpent(void);
protected:
bvec2 m_userFill;
public:
/**
* @brief Set the horizontal filling capacity
* @param[in] newFill new fill state

View File

@ -1,27 +1,12 @@
/**
*******************************************************************************
* @file ewol/widget/meta/FileChooser.cpp
* @brief ewol File chooser meta widget system (Sources)
* @author Edouard DUPIN
* @date 29/12/2011
* @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.
*
*******************************************************************************
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <ewol/widget/meta/FileChooser.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/List.h>
@ -120,6 +105,8 @@ widget::FileChooser::FileChooser(void)
mySpacer->SetExpendX(true);
mySizerHori->SubWidgetAdd(mySpacer);
}
// TODO : set if back :
/*
m_widgetValidate = new widget::Button("Validate");
if (NULL == m_widgetValidate) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
@ -136,6 +123,7 @@ widget::FileChooser::FileChooser(void)
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventFileChooserCancel);
mySizerHori->SubWidgetAdd(m_widgetCancel);
}
*/
}
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);
if (NULL == mySizerHori) {
@ -280,7 +268,10 @@ void widget::FileChooser::SetValidateLabel(etk::UString label)
if (NULL == m_widgetValidate) {
return;
}
// TODO : set if back :
/*
m_widgetValidate->SetLabel(label);
*/
}
void widget::FileChooser::SetCancelLabel(etk::UString label)
@ -288,7 +279,10 @@ void widget::FileChooser::SetCancelLabel(etk::UString label)
if (NULL == m_widgetCancel) {
return;
}
// TODO : set if back :
/*
m_widgetCancel->SetLabel(label);
*/
}
void widget::FileChooser::SetFolder(etk::UString folder)

View File

@ -66,6 +66,8 @@ widget::Parameter::Parameter(void) :
mySizerHori->SubWidgetAdd(mySpacer);
}
// TODO : set if back :
/*
m_widgetCancel = new widget::Button("Close");
if (NULL == m_widgetCancel) {
EWOL_ERROR("Can not allocate widget ==> display might be in error");
@ -74,6 +76,7 @@ widget::Parameter::Parameter(void) :
m_widgetCancel->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventParameterClose);
mySizerHori->SubWidgetAdd(m_widgetCancel);
}
*/
}
mySizerHori = new widget::Sizer(widget::Sizer::modeHori);