[DEV] add test software to show wat is possible and test every mode of the widget system
This commit is contained in:
parent
acd70a322c
commit
67e4d5363c
@ -3,33 +3,44 @@ precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform float EW_sizeBorder;
|
||||
uniform float EW_sizePadding;
|
||||
uniform vec2 EW_size;
|
||||
uniform vec4 EW_posText;
|
||||
uniform int EW_state;
|
||||
struct displayProperty {
|
||||
vec2 size;
|
||||
vec2 insidePos;
|
||||
vec2 insideSize;
|
||||
};
|
||||
|
||||
struct widgetStateProperty {
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
};
|
||||
|
||||
uniform displayProperty EW_widgetProperty;
|
||||
|
||||
uniform widgetStateProperty EW_status;
|
||||
|
||||
// transmit from the vertex shader
|
||||
varying vec2 v_position; // interpolated position ...
|
||||
|
||||
// internal static define
|
||||
float S_roundedRatio = 10.0;
|
||||
vec4 S_colorBg = vec4(0.0);
|
||||
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
|
||||
vec4 S_colorFg = vec4(0.5,0.5,0.5,0.3);
|
||||
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
float S_sizePadding = 3.0; // must not be NULL
|
||||
float S_sizeBorder = 1.0; //==> this id for 1 px border
|
||||
float S_roundedRatio = 10.0;
|
||||
|
||||
void main(void) {
|
||||
// position form center :
|
||||
vec2 ratio = EW_size / 2.0;
|
||||
vec2 ratio = EW_widgetProperty.size / 2.0;
|
||||
vec2 positionCenter = abs(v_position-ratio);
|
||||
vec2 ratioHight = ratio - EW_sizePadding;
|
||||
vec2 ratioLow = ratioHight - (EW_sizeBorder+S_roundedRatio);
|
||||
vec2 ratioHight = ratio - S_sizePadding;
|
||||
vec2 ratioLow = ratioHight - (S_sizeBorder+S_roundedRatio);
|
||||
vec2 circleMode = smoothstep(ratioLow, ratioHight, positionCenter);
|
||||
float tmpDist = sqrt(dot(circleMode,circleMode));
|
||||
|
||||
//float distanceInternal = (S_roundedRatio-EW_sizeBorder/2.0)/(S_roundedRatio-EW_sizeBorder);
|
||||
//float distanceExternal = (S_roundedRatio+EW_sizeBorder/2.0)/(S_roundedRatio-EW_sizeBorder);;
|
||||
//float distanceInternal = (S_roundedRatio-S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder);
|
||||
//float distanceExternal = (S_roundedRatio+S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder);;
|
||||
if(tmpDist <= 0.7 ) {
|
||||
gl_FragColor = S_colorFg;
|
||||
} else if(tmpDist <= 0.9) {
|
||||
|
@ -32,6 +32,7 @@ ewol::Shaper::Shaper(etk::UString shaperName) :
|
||||
m_GLStateOld(-1),
|
||||
m_GLStateNew(-1),
|
||||
m_GLStateTransition(-1),
|
||||
m_resourceTexture(NULL),
|
||||
m_nextStatusRequested(-1),
|
||||
m_time(-1),
|
||||
m_stateOld(0),
|
||||
@ -65,6 +66,10 @@ ewol::Shaper::~Shaper(void)
|
||||
ewol::resource::Release(m_GLprogram);
|
||||
m_GLprogram = NULL;
|
||||
}
|
||||
if (NULL != m_resourceTexture) {
|
||||
ewol::resource::Release(m_resourceTexture);
|
||||
m_resourceTexture = NULL;
|
||||
}
|
||||
if (NULL != m_config) {
|
||||
ewol::resource::Release(m_config);
|
||||
m_config = NULL;
|
||||
@ -82,6 +87,7 @@ void ewol::Shaper::LoadProgram(void)
|
||||
m_confIdPaddingY = m_config->Request("PaddingY");
|
||||
m_confIdChangeTime = m_config->Request("ChangeTime");
|
||||
m_confProgramFile = m_config->Request("program");
|
||||
m_confImageFile = m_config->Request("image");
|
||||
}
|
||||
etk::UString basicShaderFile = m_config->GetString(m_confProgramFile);
|
||||
// Get the relative position of the current file ...
|
||||
@ -101,6 +107,15 @@ void ewol::Shaper::LoadProgram(void)
|
||||
m_GLStateOld = m_GLprogram->GetUniform("EW_status.stateOld");
|
||||
m_GLStateNew = m_GLprogram->GetUniform("EW_status.stateNew");
|
||||
m_GLStateTransition = m_GLprogram->GetUniform("EW_status.transition");
|
||||
// for the texture ID :
|
||||
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
|
||||
}
|
||||
|
||||
etk::UString basicImageFile = m_config->GetString(m_confImageFile);
|
||||
tmpFilename = file.GetRelativeFolder() + basicImageFile;
|
||||
etk::Vector2D<int32_t> size(64,64);
|
||||
if (true == ewol::resource::Keep(tmpFilename, m_resourceTexture, size) ) {
|
||||
// nothing else to do ...
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +136,6 @@ void ewol::Shaper::Draw(void)
|
||||
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// position :
|
||||
// Note : Must be all the time a [-1..1] square ...
|
||||
// TODO : plop ...
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, m_coord);
|
||||
// all entry parameters :
|
||||
m_GLprogram->Uniform2fv(m_GLPropertySize, 1, &m_propertySize.x);
|
||||
@ -132,6 +145,10 @@ void ewol::Shaper::Draw(void)
|
||||
m_GLprogram->Uniform1i(m_GLStateNew, m_stateNew);
|
||||
m_GLprogram->Uniform1f(m_GLStateTransition, m_stateTransition);
|
||||
|
||||
if (NULL!=m_resourceTexture) {
|
||||
// TextureID
|
||||
m_GLprogram->SetTexture0(m_GLtexID, m_resourceTexture->GetId());
|
||||
}
|
||||
// Request the draw of the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
m_GLprogram->UnUse();
|
||||
@ -186,24 +203,47 @@ bool ewol::Shaper::PeriodicCall(int64_t localTime)
|
||||
}
|
||||
|
||||
|
||||
void ewol::Shaper::SetOrigin(etk::Vector2D<float> newOri)
|
||||
{
|
||||
if (m_propertyOrigin != newOri) {
|
||||
m_propertyOrigin = newOri;
|
||||
EWOL_CRITICAL("Set ori : " << m_propertyOrigin);
|
||||
// set coord ==> must be a static VBO ...
|
||||
m_coord[0].x= m_propertyOrigin.x;
|
||||
m_coord[0].y= m_propertyOrigin.y+m_propertySize.y;
|
||||
m_coord[1].x= m_propertyOrigin.x;
|
||||
m_coord[1].y= m_propertyOrigin.y;
|
||||
m_coord[2].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[2].y= m_propertyOrigin.y;
|
||||
|
||||
m_coord[3].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[3].y= m_propertyOrigin.y;
|
||||
m_coord[4].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[4].y= m_propertyOrigin.y+m_propertySize.y;
|
||||
m_coord[5].x= m_propertyOrigin.x;
|
||||
m_coord[5].y= m_propertyOrigin.x+m_propertySize.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ewol::Shaper::SetSize(etk::Vector2D<float> newSize)
|
||||
{
|
||||
if (m_propertySize != newSize) {
|
||||
m_propertySize = newSize;
|
||||
// set coord ==> must be a static VBO ...
|
||||
m_coord[0].x= 0;
|
||||
m_coord[0].y= m_propertySize.y;
|
||||
m_coord[1].x= 0;
|
||||
m_coord[1].y= 0;
|
||||
m_coord[2].x= m_propertySize.x;
|
||||
m_coord[2].y= 0;
|
||||
m_coord[0].x= m_propertyOrigin.x;
|
||||
m_coord[0].y= m_propertyOrigin.y+m_propertySize.y;
|
||||
m_coord[1].x= m_propertyOrigin.x;
|
||||
m_coord[1].y= m_propertyOrigin.y;
|
||||
m_coord[2].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[2].y= m_propertyOrigin.y;
|
||||
|
||||
m_coord[3].x= m_propertySize.x;
|
||||
m_coord[3].y= 0;
|
||||
m_coord[4].x= m_propertySize.x;
|
||||
m_coord[4].y= m_propertySize.y;
|
||||
m_coord[5].x= 0;
|
||||
m_coord[5].y= m_propertySize.y;
|
||||
m_coord[3].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[3].y= m_propertyOrigin.y;
|
||||
m_coord[4].x= m_propertyOrigin.x+m_propertySize.x;
|
||||
m_coord[4].y= m_propertyOrigin.y+m_propertySize.y;
|
||||
m_coord[5].x= m_propertyOrigin.x;
|
||||
m_coord[5].y= m_propertyOrigin.x+m_propertySize.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ namespace ewol
|
||||
int32_t m_confIdPaddingY; //!< ConfigFile padding property Y
|
||||
int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property
|
||||
int32_t m_confProgramFile; //!< ConfigFile OpengGl program Name
|
||||
int32_t m_confImageFile; //!< ConfigFile OpengGl program Name
|
||||
// OpenGL shaders programs:
|
||||
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
|
||||
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
|
||||
@ -40,9 +41,13 @@ namespace ewol
|
||||
int32_t m_GLStateOld; //!< openGL id on the element (old state displayed)
|
||||
int32_t m_GLStateNew; //!< openGL id on the element (new state displayed)
|
||||
int32_t m_GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] )
|
||||
int32_t m_GLtexID; //!< openGL id on the element (texture image)
|
||||
// For the Image :
|
||||
ewol::TextureFile* m_resourceTexture; //!< texture resources (for the image)
|
||||
// internal needed data :
|
||||
int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it
|
||||
int64_t m_time; //!< The last time of the dispaly (-1 if nothing progressing)
|
||||
etk::Vector2D<float> m_propertyOrigin; //!< widget origin
|
||||
etk::Vector2D<float> m_propertySize; //!< widget size
|
||||
etk::Vector2D<float> m_propertyInsidePosition; //!< internal subwidget position
|
||||
etk::Vector2D<float> m_propertyInsideSize; //!< internal subwidget size
|
||||
@ -88,6 +93,11 @@ namespace ewol
|
||||
* @return false No need to request the periodic call.
|
||||
*/
|
||||
bool PeriodicCall(int64_t localTime);
|
||||
/**
|
||||
* @brief Set the widget origin (needed fot the display)
|
||||
* @param[in] newOri : the new widget origin
|
||||
*/
|
||||
void SetOrigin(etk::Vector2D<float> newOri);
|
||||
/**
|
||||
* @brief Set the widget size (needed fot the display)
|
||||
* @param[in] newSize : the new widget size
|
||||
|
@ -459,6 +459,15 @@ void ewol::Text::ParseHtmlNode(void* element2)
|
||||
}
|
||||
|
||||
void ewol::Text::PrintDecorated(etk::UString& text)
|
||||
{
|
||||
etk::UString tmpData("<html><body>\n");
|
||||
tmpData+=text;
|
||||
tmpData+="\n</body></html>\n";
|
||||
//EWOL_DEBUG("plop : " << tmpData);
|
||||
PrintHTML(tmpData);
|
||||
}
|
||||
|
||||
void ewol::Text::PrintHTML(etk::UString& text)
|
||||
{
|
||||
TiXmlDocument XmlDocument;
|
||||
|
||||
@ -485,7 +494,6 @@ void ewol::Text::PrintDecorated(etk::UString& text)
|
||||
HtmlFlush();
|
||||
}
|
||||
|
||||
|
||||
void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoration>& decoration)
|
||||
{
|
||||
if (m_font == NULL) {
|
||||
@ -495,7 +503,6 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
draw::Color tmpFg(m_color);
|
||||
draw::Color tmpBg(m_colorBg);
|
||||
if (m_alignement == ewol::Text::alignDisable) {
|
||||
EWOL_DEBUG("kjhkjhkjhkjhkjh=" << m_cursorPos << " klj"<< m_selectionStartPos);
|
||||
if (0==m_cursorPos) {
|
||||
m_vectorialDraw.SetPos(m_position);
|
||||
SetColorBg(m_colorCursor);
|
||||
|
@ -214,6 +214,34 @@ namespace ewol
|
||||
* @param[in] text The string to display.
|
||||
*/
|
||||
void Print(const etk::UString& text);
|
||||
/**
|
||||
* @brief Display a compleat string in the current element with the generic decoration specification. (basic html data)
|
||||
* <pre>
|
||||
* <br/>
|
||||
* <br/><br/><br/>
|
||||
* <center>
|
||||
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
|
||||
* <font color=\"#FF0000\">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
|
||||
* an an other thext
|
||||
* </center>
|
||||
* <br/><br/><br/>
|
||||
* <left>
|
||||
* plop 1
|
||||
* </left>
|
||||
* <br/><br/><br/>
|
||||
* <right>
|
||||
* plop 2
|
||||
* </right>
|
||||
* <br/><br/><br/>
|
||||
* <justify>
|
||||
* Un exemple de text
|
||||
* </justify>
|
||||
* </pre>
|
||||
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
|
||||
* @param[in] text The string to display.
|
||||
* @TODO : implementation not done ....
|
||||
*/
|
||||
void PrintDecorated(etk::UString& text);
|
||||
/**
|
||||
* @brief Display a compleat string in the current element with the generic decoration specification. (basic html data)
|
||||
* <pre>
|
||||
@ -245,7 +273,7 @@ namespace ewol
|
||||
* @param[in] text The string to display.
|
||||
* @TODO : implementation not done ....
|
||||
*/
|
||||
void PrintDecorated(etk::UString& text);
|
||||
void PrintHTML(etk::UString& text);
|
||||
/**
|
||||
* @brief Display a compleat string in the current element whith specific decorations (advence mode).
|
||||
* @param[in] text The string to display.
|
||||
@ -273,7 +301,7 @@ namespace ewol
|
||||
* @param[in] alignement mode of alignement for the Text.
|
||||
* @note The text align in center change of line every display done (even if it was just a char)
|
||||
*/
|
||||
void SetTextAlignement(float startTextpos, float stopTextPos, ewol::Text::aligneMode_te alignement);
|
||||
void SetTextAlignement(float startTextpos, float stopTextPos, ewol::Text::aligneMode_te alignement=ewol::Text::alignDisable);
|
||||
/**
|
||||
* @brief Disable the alignement system
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <ewol/renderer/os/gui.h>
|
||||
#include <ewol/commandLine.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol"
|
||||
@ -19,6 +20,7 @@
|
||||
|
||||
int32_t ewol::Run(int32_t argc, const char* argv[])
|
||||
{
|
||||
|
||||
EWOL_DEBUG("Store commangLine in the specific system");
|
||||
ewol::commandLine::Clean();
|
||||
for( int32_t i=1 ; i<argc; i++) {
|
||||
|
@ -16,32 +16,32 @@ extern const char * const ewolEventButtonDown = "ewol-button-down";
|
||||
extern const char * const ewolEventButtonUp = "ewol-button-up";
|
||||
extern const char * const ewolEventButtonEnter = "ewol-button-enter";
|
||||
extern const char * const ewolEventButtonLeave = "ewol-button-leave";
|
||||
extern const char * const ewolEventButtonValue = "ewol-button-value";
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Button"
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
#define STATUS_NORMAL (0)
|
||||
#define STATUS_UP (0)
|
||||
#define STATUS_HOVER (2)
|
||||
#define STATUS_PRESSED (1)
|
||||
#define STATUS_DOWN (3)
|
||||
|
||||
|
||||
widget::Button::Button(etk::UString newLabel) :
|
||||
m_shaper("THEME:GUI:widgetButton.conf")
|
||||
m_shaper("THEME:GUI:widgetButton.conf"),
|
||||
m_label(newLabel),
|
||||
m_toggleMode(false),
|
||||
m_value(false)
|
||||
{
|
||||
m_label = newLabel;
|
||||
|
||||
AddEventId(ewolEventButtonPressed);
|
||||
AddEventId(ewolEventButtonDown);
|
||||
AddEventId(ewolEventButtonUp);
|
||||
AddEventId(ewolEventButtonEnter);
|
||||
AddEventId(ewolEventButtonLeave);
|
||||
m_alignement = widget::TEXT_ALIGN_CENTER;
|
||||
AddEventId(ewolEventButtonValue);
|
||||
|
||||
m_textColorFg = draw::color::black;
|
||||
|
||||
m_shaper.ChangeStatusIn(STATUS_NORMAL);
|
||||
m_shaper.ChangeStatusIn(STATUS_UP);
|
||||
|
||||
SetCanHaveFocus(true);
|
||||
// Limit event at 1:
|
||||
@ -70,8 +70,14 @@ void widget::Button::SetImageToggle(etk::UString imageName)
|
||||
bool widget::Button::CalculateMinSize(void)
|
||||
{
|
||||
etk::Vector2D<float> padding = m_shaper.GetPadding();
|
||||
|
||||
etk::Vector3D<int32_t> minSize = m_displayText.CalculateSize(m_label);
|
||||
if( true == m_toggleMode
|
||||
&& m_labelToggle.Size()!=0) {
|
||||
etk::Vector3D<int32_t> minSizeToggle = m_displayText.CalculateSize(m_labelToggle);
|
||||
minSize.x = etk_max(minSize.x, minSizeToggle.x);
|
||||
minSize.y = etk_max(minSize.y, minSizeToggle.y);
|
||||
minSize.z = etk_max(minSize.z, minSizeToggle.z);
|
||||
}
|
||||
m_minSize.x = padding.x*2 + minSize.x;
|
||||
m_minSize.y = padding.y*2 + minSize.y;
|
||||
// Add the image element ...
|
||||
@ -79,7 +85,6 @@ bool widget::Button::CalculateMinSize(void)
|
||||
|| true == m_displayImageToggle.HasSources()) {
|
||||
m_minSize.x += padding.x + minSize.y;
|
||||
}
|
||||
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
@ -91,29 +96,53 @@ void widget::Button::SetLabel(etk::UString newLabel)
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
void widget::Button::SetValue(bool val)
|
||||
etk::UString widget::Button::GetLabel(void)
|
||||
{
|
||||
|
||||
return m_label;
|
||||
}
|
||||
|
||||
void widget::Button::SetAlignement(textAlignement_te typeAlign)
|
||||
void widget::Button::SetLabelToggle(etk::UString newLabel)
|
||||
{
|
||||
m_alignement = typeAlign;
|
||||
m_labelToggle = newLabel;
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
etk::UString widget::Button::GetLabelToggle(void)
|
||||
{
|
||||
return m_labelToggle;
|
||||
}
|
||||
|
||||
void widget::Button::SetValue(bool val)
|
||||
{
|
||||
if (m_value != val) {
|
||||
m_value = val;
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
bool widget::Button::GetValue(void)
|
||||
{
|
||||
return false;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void widget::Button::SetToggleMode(bool togg)
|
||||
{
|
||||
if (m_toggleMode != togg) {
|
||||
m_toggleMode = togg;
|
||||
if (m_value == true) {
|
||||
m_value = false;
|
||||
// TODO : Change display and send event ...
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
void widget::Button::OnDraw(ewol::DrawProperty& displayProp)
|
||||
{
|
||||
m_shaper.Draw();
|
||||
#warning generate the Toggle
|
||||
if (true) {
|
||||
if( false == m_toggleMode
|
||||
|| false == m_value) {
|
||||
m_displayImage.Draw();
|
||||
} else {
|
||||
m_displayImageToggle.Draw();
|
||||
@ -131,8 +160,8 @@ void widget::Button::OnRegenerateDisplay(void)
|
||||
m_displayImageToggle.Clear();
|
||||
m_shaper.Clear();
|
||||
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
int32_t tmpSizeY = m_minSize.y;
|
||||
etk::Vector2D<int32_t> localSize = m_minSize;
|
||||
|
||||
etk::Vector3D<float> tmpOrigin((float)((m_size.x - m_minSize.x) / 2.0),
|
||||
(float)((m_size.y - m_minSize.y) / 2.0),
|
||||
(float)(0.0));
|
||||
@ -142,20 +171,17 @@ void widget::Button::OnRegenerateDisplay(void)
|
||||
(float)(0.0));
|
||||
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
localSize.x = m_size.x;
|
||||
tmpOrigin.x = 0.0;
|
||||
if (m_alignement == widget::TEXT_ALIGN_LEFT) {
|
||||
tmpTextOrigin.x = padding.x;
|
||||
}
|
||||
}
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
localSize.y = m_size.y;
|
||||
tmpOrigin.y = 0.0;
|
||||
}
|
||||
tmpOrigin.x += padding.x;
|
||||
tmpOrigin.x += padding.y;
|
||||
tmpSizeX -= 2*padding.x;
|
||||
tmpSizeY -= 2*padding.y;
|
||||
tmpOrigin.y += padding.y;
|
||||
localSize.x -= 2*padding.x;
|
||||
localSize.y -= 2*padding.y;
|
||||
|
||||
etk::Vector2D<float> textPos(tmpTextOrigin.x, tmpTextOrigin.x);
|
||||
|
||||
@ -164,10 +190,14 @@ void widget::Button::OnRegenerateDisplay(void)
|
||||
etk::Vector3D<int32_t> minSize = m_displayText.CalculateSize(m_label);
|
||||
etk::Vector3D<int32_t> imagePos(tmpTextOrigin.x-padding.x/4, tmpTextOrigin.y-padding.x/4, 0);
|
||||
etk::Vector2D<int32_t> imageSize(minSize.y+padding.x/2, minSize.y+padding.x/2);
|
||||
m_displayImage.SetPos(imagePos);
|
||||
m_displayImage.Print(imageSize);
|
||||
m_displayImageToggle.SetPos(imagePos);
|
||||
m_displayImageToggle.Print(imageSize);
|
||||
if( false==m_toggleMode
|
||||
|| false==m_value) {
|
||||
m_displayImage.SetPos(imagePos);
|
||||
m_displayImage.Print(imageSize);
|
||||
} else {
|
||||
m_displayImageToggle.SetPos(imagePos);
|
||||
m_displayImageToggle.Print(imageSize);
|
||||
}
|
||||
// update the text position ...
|
||||
tmpTextOrigin.x += padding.x/2 + minSize.y;
|
||||
}
|
||||
@ -179,13 +209,21 @@ void widget::Button::OnRegenerateDisplay(void)
|
||||
|
||||
// clean the element
|
||||
m_displayText.Clear();
|
||||
m_displayText.SetTextAlignement(0, localSize.x + 2*padding.x);
|
||||
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
|
||||
m_displayText.Print(m_label);
|
||||
m_displayText.Translate(tmpTextOrigin);
|
||||
if( false == m_toggleMode
|
||||
|| false == m_value) {
|
||||
m_displayText.PrintDecorated(m_label);
|
||||
} else {
|
||||
m_displayText.PrintDecorated(m_labelToggle);
|
||||
}
|
||||
m_displayText.Translate(tmpOrigin);
|
||||
|
||||
|
||||
m_shaper.SetSize(m_size);
|
||||
m_shaper.SetInsidePos(textPos);
|
||||
//m_shaper.SetOrigin(etk::Vector2D<float>(tmpTextOrigin.x-padding.x, tmpTextOrigin.y-padding.y) );
|
||||
localSize.x += 2*padding.x;
|
||||
localSize.y += 2*padding.y;
|
||||
m_shaper.SetSize(localSize);
|
||||
m_shaper.SetInsidePos(etk::Vector2D<float>(tmpTextOrigin.x, tmpTextOrigin.y) );
|
||||
etk::Vector3D<float> tmpp = m_displayText.CalculateSize(m_label);
|
||||
etk::Vector2D<float> tmpp2(tmpp.x, tmpp.y);
|
||||
m_shaper.SetInsideSize(tmpp2);
|
||||
@ -200,7 +238,7 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
||||
if(ewol::keyEvent::statusEnter == typeEvent) {
|
||||
ChangeStatusIn(STATUS_HOVER);
|
||||
}else if(ewol::keyEvent::statusLeave == typeEvent) {
|
||||
ChangeStatusIn(STATUS_NORMAL);
|
||||
ChangeStatusIn(STATUS_UP);
|
||||
}
|
||||
if (1 == IdInput) {
|
||||
if(ewol::keyEvent::statusDown == typeEvent) {
|
||||
@ -210,11 +248,19 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
||||
}
|
||||
if(ewol::keyEvent::statusUp == typeEvent) {
|
||||
GenerateEventId(ewolEventButtonUp);
|
||||
ChangeStatusIn(STATUS_NORMAL);
|
||||
ChangeStatusIn(STATUS_UP);
|
||||
MarkToRedraw();
|
||||
}
|
||||
if(ewol::keyEvent::statusSingle == typeEvent) {
|
||||
// inverse value :
|
||||
m_value = (m_value)?false:true;
|
||||
GenerateEventId(ewolEventButtonPressed);
|
||||
GenerateEventId(ewolEventButtonValue, m_value);
|
||||
if( false == m_toggleMode
|
||||
&& true == m_value) {
|
||||
m_value = false;
|
||||
GenerateEventId(ewolEventButtonValue, m_value);
|
||||
}
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
|
@ -22,38 +22,82 @@ extern const char * const ewolEventButtonDown;
|
||||
extern const char * const ewolEventButtonUp;
|
||||
extern const char * const ewolEventButtonEnter;
|
||||
extern const char * const ewolEventButtonLeave;
|
||||
extern const char * const ewolEventButtonValue;
|
||||
|
||||
namespace widget {
|
||||
typedef enum {
|
||||
TEXT_ALIGN_LEFT,
|
||||
TEXT_ALIGN_CENTER,
|
||||
} textAlignement_te;
|
||||
class Button : public ewol::Widget
|
||||
{
|
||||
private:
|
||||
ewol::Shaper m_shaper;
|
||||
ewol::Text m_displayText;
|
||||
ewol::Image m_displayImage;
|
||||
ewol::Image m_displayImageToggle;
|
||||
textAlignement_te m_alignement;
|
||||
etk::UString m_label;
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
ewol::Shaper m_shaper; //!< Compositing theme.
|
||||
ewol::Text m_displayText; //!< compositing Text.
|
||||
ewol::Image m_displayImage; //!< Image to display in normal mode.
|
||||
ewol::Image m_displayImageToggle; //!< Image to display in toggle mode.
|
||||
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.
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param[in] newLabel Button Label to display
|
||||
*/
|
||||
Button(etk::UString newLabel="No Label");
|
||||
// Derived function
|
||||
virtual const char * const GetObjectType(void) { return "EwolButton"; };
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
virtual ~Button(void);
|
||||
/**
|
||||
* @brief Specify the current label of the Button
|
||||
* @param[in] newLabel The string that might be displayed
|
||||
*/
|
||||
void SetLabel(etk::UString newLabel);
|
||||
/**
|
||||
* @brief Get the current displayed text
|
||||
* @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.
|
||||
*/
|
||||
void SetImage(etk::UString imageName);
|
||||
/**
|
||||
* @brief Set the image when button is pressed.
|
||||
* @param[in] imageName Filename of the image.
|
||||
*/
|
||||
void SetImageToggle(etk::UString imageName);
|
||||
/**
|
||||
* @brief Set the currentValue of the Button (pressed or not)
|
||||
* @note Work only in toggle mode
|
||||
* @param[in] val New value of the button
|
||||
*/
|
||||
void SetValue(bool val);
|
||||
/**
|
||||
* @brief Get the current button value.
|
||||
* @return True : The button is pressed.
|
||||
* @return false : The button is released.
|
||||
*/
|
||||
bool GetValue(void);
|
||||
/**
|
||||
* @brief Change the Toggle mode.
|
||||
* @param[in] togg New toggle mode
|
||||
*/
|
||||
void SetToggleMode(bool togg);
|
||||
public:
|
||||
// Derived function
|
||||
virtual const char * const GetObjectType(void) { return "widget::Button"; };
|
||||
// Derived function
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetLabel(etk::UString newLabel);
|
||||
etk::UString GetLabel(void) {return m_label;};
|
||||
void SetImage(etk::UString imageName);
|
||||
void SetImageToggle(etk::UString imageName);
|
||||
void SetValue(bool val);
|
||||
bool GetValue(void);
|
||||
void SetAlignement(textAlignement_te typeAlign);
|
||||
void SetColorFg(draw::Color newColor) { m_textColorFg = newColor; };
|
||||
public:
|
||||
// Derived function
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
// Derived function
|
||||
|
@ -26,8 +26,6 @@ void widget::ButtonColor::Init(void)
|
||||
{
|
||||
AddEventId(ewolEventButtonColorChange);
|
||||
|
||||
m_alignement = widget::TEXT_ALIGN_CENTER;
|
||||
|
||||
#ifdef __TARGET_OS__Android
|
||||
m_padding.y = 12;
|
||||
m_padding.x = 12;
|
||||
@ -90,12 +88,6 @@ void widget::ButtonColor::SetValue(bool val)
|
||||
|
||||
}
|
||||
|
||||
void widget::ButtonColor::SetAlignement(textAlignement_te typeAlign)
|
||||
{
|
||||
m_alignement = typeAlign;
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
||||
bool widget::ButtonColor::GetValue(void)
|
||||
{
|
||||
@ -125,9 +117,6 @@ void widget::ButtonColor::OnRegenerateDisplay(void)
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
tmpOriginX = 0;
|
||||
if (m_alignement == widget::TEXT_ALIGN_LEFT) {
|
||||
tmpTextOriginX = m_padding.x;
|
||||
}
|
||||
}
|
||||
if (true==m_userFill.y) {
|
||||
tmpSizeY = m_size.y;
|
||||
|
@ -34,12 +34,10 @@ namespace widget {
|
||||
etk::UString GetLabel(void) {return m_label;};
|
||||
void SetValue(bool val);
|
||||
bool GetValue(void);
|
||||
void SetAlignement(textAlignement_te typeAlign);
|
||||
void SetPadding(etk::Vector2D<float> newPadding);
|
||||
private:
|
||||
ewol::Text m_oObjectText;
|
||||
ewol::Drawing m_oObjectDecoration;
|
||||
textAlignement_te m_alignement;
|
||||
etk::Vector2D<float> m_padding;
|
||||
etk::UString m_label;
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
|
@ -97,7 +97,6 @@ etk::UString widget::Entry::GetValue(void)
|
||||
void widget::Entry::OnDraw(ewol::DrawProperty& displayProp)
|
||||
{
|
||||
m_shaper.Draw();
|
||||
m_oObjectDecoration.Draw();
|
||||
m_oObjectText.Draw();
|
||||
}
|
||||
|
||||
@ -106,7 +105,6 @@ void widget::Entry::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
m_shaper.Clear();
|
||||
m_oObjectDecoration.Clear();
|
||||
m_oObjectText.Clear();
|
||||
UpdateTextPosition();
|
||||
etk::Vector2D<float> padding = m_shaper.GetPadding();
|
||||
@ -151,48 +149,7 @@ void widget::Entry::OnRegenerateDisplay(void)
|
||||
}
|
||||
m_oObjectText.Print(m_data);
|
||||
m_oObjectText.SetClippingMode(false);
|
||||
/*
|
||||
m_pos[0] = m_borderSize+2*drawClippingPos.x;
|
||||
m_pos[1] = m_borderSize+2*drawClippingPos.y;
|
||||
m_pos[2] = m_size.x - 2*(m_borderSize+2*drawClippingPos.x);
|
||||
m_pos[3] = m_size.y - 2*(m_borderSize+2*drawClippingPos.y);
|
||||
*/
|
||||
m_shaper.SetSize(m_size);
|
||||
|
||||
/*
|
||||
Must be rework corectly ==> selection and Cursor are integrated at the system ...
|
||||
int32_t pos1 = m_displayCursorPosSelection;
|
||||
int32_t pos2 = m_displayCursorPos;
|
||||
if(m_displayCursorPosSelection>m_displayCursorPos) {
|
||||
pos2 = m_displayCursorPosSelection;
|
||||
pos1 = m_displayCursorPos;
|
||||
}
|
||||
if(pos1!=pos2) {
|
||||
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||
m_oObjectDecoration.clippingSet(drawClipping);
|
||||
etk::UString tmpDisplay = m_data.Extract(0, pos1);
|
||||
etk::Vector2D<int32_t> minSize = m_oObjectText.GetSize(tmpDisplay);
|
||||
tmpDisplay = m_data.Extract(0, pos2);
|
||||
etk::Vector2D<int32_t> maxSize = m_oObjectText.GetSize(tmpDisplay);
|
||||
|
||||
int32_t XPos = minSize.x + m_borderSize + 2*m_paddingSize + m_displayStartPosition;
|
||||
int32_t XPosEnd = maxSize.x + m_borderSize + 2*m_paddingSize + m_displayStartPosition;
|
||||
XPos = etk_avg(m_borderSize + 2*m_paddingSize, XPos, m_size.x - 2*m_paddingSize );
|
||||
XPosEnd = etk_avg(m_borderSize + 2*m_paddingSize, XPosEnd, m_size.x - 2*m_paddingSize );
|
||||
m_oObjectDecoration.SetColor(0x4444FFAA);
|
||||
m_oObjectDecoration.Rectangle( XPos, tmpTextOriginY, XPosEnd-XPos, maxSize.y);
|
||||
m_oObjectDecoration.clippingDisable();
|
||||
}
|
||||
if (true == m_displayCursor) {
|
||||
m_oObjectDecoration.SetColor(m_textColorFg);
|
||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayCursorPos);
|
||||
etk::Vector2D<int32_t> minSize = m_oObjectText.GetSize(tmpDisplay);
|
||||
int32_t XCursorPos = minSize.x + m_borderSize + 2*m_paddingSize + m_displayStartPosition;
|
||||
if (XCursorPos >= m_borderSize + 2*m_paddingSize) {
|
||||
m_oObjectDecoration.Line(XCursorPos, tmpTextOriginY, XCursorPos, tmpTextOriginY + minSize.y, 1);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,6 @@ namespace widget {
|
||||
private:
|
||||
ewol::Shaper m_shaper;
|
||||
ewol::Text m_oObjectText; //!< text display
|
||||
// TODO : remove this one : ...
|
||||
ewol::Drawing m_oObjectDecoration; //!< background display
|
||||
etk::UString m_data; //!< sting that must be displayed
|
||||
draw::Color m_textColorFg; //!< Text color
|
||||
draw::Color m_textColorBg; //!< Background color
|
||||
|
@ -178,7 +178,6 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonPressed, ewolEventButtonPressed);
|
||||
myButton->SetExpendX(true);
|
||||
myButton->SetFillX(true);
|
||||
myButton->SetAlignement(widget::TEXT_ALIGN_LEFT);
|
||||
// add it in the widget list
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
m_listElement[jjj]->m_widgetPointer = myButton;
|
||||
|
@ -183,9 +183,119 @@ void ewol::Widget::MarkToRedraw(void)
|
||||
{
|
||||
m_needRegenerateDisplay = true;
|
||||
ewol::widgetManager::MarkDrawingIsNeeded();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
void ewol::Widget::SetZoom(float newVal)
|
||||
{
|
||||
m_zoom = newVal;
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
float ewol::Widget::GetZoom(void)
|
||||
{
|
||||
return m_zoom;
|
||||
}
|
||||
|
||||
void ewol::Widget::SetOrigin(float x, float y)
|
||||
{
|
||||
m_origin.x=x;
|
||||
m_origin.y=y;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> ewol::Widget::GetOrigin(void)
|
||||
{
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> ewol::Widget::RelativePosition(etk::Vector2D<float> pos)
|
||||
{
|
||||
pos.x -= m_origin.x;
|
||||
pos.y -= m_origin.y;
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool ewol::Widget::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = m_userMinSize.x;
|
||||
m_minSize.y = m_userMinSize.y;
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::Widget::SetMinSize(float x, float y)
|
||||
{
|
||||
m_userMinSize.x = x;
|
||||
m_userMinSize.y = y;
|
||||
}
|
||||
|
||||
etk::Vector2D<float> ewol::Widget::GetMinSize(void)
|
||||
{
|
||||
if (false==IsHide()) {
|
||||
return m_minSize;
|
||||
}
|
||||
return etk::Vector2D<float>(0,0);
|
||||
}
|
||||
|
||||
etk::Vector2D<float> ewol::Widget::GetSize(void)
|
||||
{
|
||||
if (false==IsHide()) {
|
||||
return m_size;
|
||||
}
|
||||
return etk::Vector2D<float>(0,0);
|
||||
}
|
||||
|
||||
void ewol::Widget::SetExpendX(bool newExpend)
|
||||
{
|
||||
m_userExpend.x = newExpend;
|
||||
ewol::RequestUpdateSize();
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::Widget::CanExpentX(void)
|
||||
{
|
||||
if (false==IsHide()) {
|
||||
return m_userExpend.x;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::Widget::SetExpendY(bool newExpend)
|
||||
{
|
||||
m_userExpend.y = newExpend;
|
||||
ewol::RequestUpdateSize();
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::Widget::CanExpentY(void)
|
||||
{
|
||||
if (false==IsHide()) {
|
||||
return m_userExpend.y;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::Widget::SetFillX(bool newFill)
|
||||
{
|
||||
m_userFill.x = newFill;
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::Widget::CanFillX(void)
|
||||
{
|
||||
return m_userFill.x;
|
||||
}
|
||||
|
||||
void ewol::Widget::SetFillY(bool newFill)
|
||||
{
|
||||
m_userFill.y = newFill;
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
bool ewol::Widget::CanFillY(void)
|
||||
{
|
||||
return m_userFill.y;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------------
|
||||
// -- Shortcut : management of the shortcut
|
||||
|
@ -97,13 +97,13 @@ namespace ewol {
|
||||
* @param[in] newVal newZoom value
|
||||
* @return ---
|
||||
*/
|
||||
void SetZoom(float newVal) { m_zoom = newVal; MarkToRedraw(); };
|
||||
void SetZoom(float newVal);
|
||||
/**
|
||||
* @brief Get the zoom property of the widget
|
||||
* @param ---
|
||||
* @return the current zoom value
|
||||
*/
|
||||
float GetZoom(void) { return m_zoom; };
|
||||
float GetZoom(void);
|
||||
/**
|
||||
* @brief Set origin at the widget (must be an parrent widget that set this parameter).
|
||||
* This represent the absolute origin in the program windows
|
||||
@ -111,19 +111,19 @@ namespace ewol {
|
||||
* @param[in] y Position ot hte vertical origin
|
||||
* @return ---
|
||||
*/
|
||||
void SetOrigin(float x, float y) { m_origin.x=x; m_origin.y=y;};
|
||||
void SetOrigin(float x, float y);
|
||||
/**
|
||||
* @brief Get the origin (obsolute position in the windows)
|
||||
* @param ---
|
||||
* @return coordonate of the origin requested
|
||||
*/
|
||||
etk::Vector2D<float> GetOrigin(void) { return m_origin; };
|
||||
etk::Vector2D<float> GetOrigin(void);
|
||||
/**
|
||||
* @brief Convert the absolute position in the local Position (Relative)
|
||||
* @param[in] pos Absolute position that you request convertion
|
||||
* @return the relative position
|
||||
*/
|
||||
virtual etk::Vector2D<float> RelativePosition(etk::Vector2D<float> pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; };
|
||||
virtual etk::Vector2D<float> RelativePosition(etk::Vector2D<float> pos);
|
||||
/**
|
||||
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
|
||||
* By default this save the widget availlable size in the widget size
|
||||
@ -141,74 +141,74 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
// TODO : Remove bool ==> deprecated ...
|
||||
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; MarkToRedraw(); return true; };
|
||||
virtual bool CalculateMinSize(void);
|
||||
/**
|
||||
* @brief User set the minimum size he want to set the display
|
||||
* @param[in] x Set minimum horizontal size (-1 : no requested)
|
||||
* @param[in] y Set minimum vertical size (-1 : no requested)
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetMinSize(float x=-1, float y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; };
|
||||
virtual void SetMinSize(float x=-1, float y=-1);
|
||||
/**
|
||||
* @brief Get the current calculated min size
|
||||
* @param ---
|
||||
* @return re size requested
|
||||
*/
|
||||
etk::Vector2D<float> GetMinSize(void) { if (false==IsHide()) { return m_minSize; } return etk::Vector2D<float>(0,0); };
|
||||
etk::Vector2D<float> GetMinSize(void);
|
||||
/**
|
||||
* @brief Get the widget size
|
||||
* @param ---
|
||||
* @return Requested size
|
||||
*/
|
||||
etk::Vector2D<float> GetSize(void) { if (false==IsHide()) { return m_size; } return etk::Vector2D<float>(0,0); };
|
||||
etk::Vector2D<float> GetSize(void);
|
||||
/**
|
||||
* @brief Set the horizontal expend capacity
|
||||
* @param[in] newExpend new Expend state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetExpendX(bool newExpend=false) { m_userExpend.x = newExpend; };
|
||||
virtual void SetExpendX(bool newExpend=false);
|
||||
/**
|
||||
* @brief Get the horizontal expend capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to expend
|
||||
*/
|
||||
virtual bool CanExpentX(void) { if (false==IsHide()) { return m_userExpend.x; } return false; };
|
||||
virtual bool CanExpentX(void);
|
||||
/**
|
||||
* @brief Set the vertical expend capacity
|
||||
* @param[in] newExpend new Expend state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetExpendY(bool newExpend=false) { m_userExpend.y = newExpend; };
|
||||
virtual void SetExpendY(bool newExpend=false);
|
||||
/**
|
||||
* @brief Get the vertical expend capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to expend
|
||||
*/
|
||||
virtual bool CanExpentY(void) { if (false==IsHide()) { return m_userExpend.y; } return false; };
|
||||
virtual bool CanExpentY(void);
|
||||
/**
|
||||
* @brief Set the horizontal filling capacity
|
||||
* @param[in] newFill new fill state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetFillX(bool newFill=false) { m_userFill.x = newFill; };
|
||||
virtual void SetFillX(bool newFill=false);
|
||||
/**
|
||||
* @brief Get the horizontal filling capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to horizontal filling
|
||||
*/
|
||||
bool CanFillX(void) { return m_userFill.x; };
|
||||
bool CanFillX(void);
|
||||
/**
|
||||
* @brief Set the vertical filling capacity
|
||||
* @param[in] newFill new fill state
|
||||
* @return ---
|
||||
*/
|
||||
virtual void SetFillY(bool newFill=false) { m_userFill.y = newFill; };
|
||||
virtual void SetFillY(bool newFill=false);
|
||||
/**
|
||||
* @brief Get the vertical filling capabilities
|
||||
* @param ---
|
||||
* @return boolean repensent the capacity to vertical filling
|
||||
*/
|
||||
bool CanFillY(void) { return m_userFill.y; };
|
||||
bool CanFillY(void);
|
||||
/**
|
||||
* @brief Set the widget hidden
|
||||
* @param ---
|
||||
|
3
test/Makefile
Normal file
3
test/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
all:
|
||||
cd human ; make
|
26
test/human/Linux.mk
Normal file
26
test/human/Linux.mk
Normal file
@ -0,0 +1,26 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# load the common sources file of the platform
|
||||
include $(LOCAL_PATH)/file.mk
|
||||
|
||||
LOCAL_CONFIG_FILES := Config.in
|
||||
|
||||
# name of the librairy
|
||||
LOCAL_MODULE := human
|
||||
|
||||
# name of the dependency
|
||||
LOCAL_STATIC_LIBRARIES := ewol
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_SRC_FILES := $(FILE_LIST)
|
||||
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
|
||||
LOCAL_CFLAGS := -DPROJECT_NAME="\"$(LOCAL_MODULE)\""
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
57
test/human/Makefile
Normal file
57
test/human/Makefile
Normal file
@ -0,0 +1,57 @@
|
||||
#############################################################################"
|
||||
# main makefile for a basic application
|
||||
# this is minimal application main makefile
|
||||
#############################################################################"
|
||||
|
||||
# Project name ==> generate the application name [a-z] <== make attention at the case this generate error on Android compilation
|
||||
PROJECT_NAME=human
|
||||
|
||||
#Can be manny things, but limit whith no space no special char and no Maj ... [a-z]
|
||||
# com : Commercial
|
||||
# net : Network??
|
||||
# org : Organisation
|
||||
# gov : Governement
|
||||
# mil : Military
|
||||
# edu : Education
|
||||
# pri : Private
|
||||
# museum : ...
|
||||
PROJECT_COMPAGNY_TYPE=org
|
||||
|
||||
# Compagny name of the project [a-zA-Z0-9 \-]
|
||||
PROJECT_COMPAGNY_NAME=Edouard DUPIN
|
||||
|
||||
# List of mainainer that might be contact in problem case : "Mr NAME Surname<mail@host.com>" "second ..."
|
||||
PROJECT_MAINTAINER="Mr DUPIN Edouard <yui.heero@gmail.com>"
|
||||
|
||||
# the icon of the project is all time needed ... if it is not present the ewol icon might be set (must be a .png file) (and no space in the fileName and filePath)
|
||||
PROJECT_ICON=$(shell pwd)/data/icon.png
|
||||
|
||||
# project section : (must be separate by coma
|
||||
# refer to : http://packages.debian.org/sid/
|
||||
# admin cli-mono comm database debian-installer
|
||||
# debug doc editors electronics devel embedded
|
||||
# fonts games gnome gnu-r gnustep graphics
|
||||
# hamradio haskell httpd interpreters java
|
||||
# kde kernel libdevel libs lisp localization
|
||||
# mail math misc net news ocaml oldlibs otherosfs
|
||||
# perl php python ruby science shells sound tex
|
||||
# text utils vcs video virtual web x11 xfce zope ...
|
||||
PROJECT_SECTION=test
|
||||
|
||||
# project prority
|
||||
# required : Packages which are necessary for the proper functioning of the system (usually, this means that dpkg functionality depends on these packages). Removing a required package may cause your system to become totally broken and you may not even be able to use dpkg to put things back, so only do so if you know what you are doing. Systems with only the required packages are probably unusable, but they do have enough functionality to allow the sysadmin to boot and install more software.
|
||||
# important : Important programs, including those which one would expect to find on any Unix-like system. If the expectation is that an experienced Unix person who found it missing would say "What on earth is going on, where is foo?", it must be an important package.[6] Other packages without which the system will not run well or be usable must also have priority important. This does not include Emacs, the X Window System, TeX or any other large applications. The important packages are just a bare minimum of commonly-expected and necessary tools.
|
||||
# standard : These packages provide a reasonably small but not too limited character-mode system. This is what will be installed by default if the user doesn't select anything else. It doesn't include many large applications.
|
||||
# optional : (In a sense everything that isn't required is optional, but that's not what is meant here.) This is all the software that you might reasonably want to install if you didn't know what it was and don't have specialized requirements. This is a much larger system and includes the X Window System, a full TeX distribution, and many applications. Note that optional packages should not conflict with each other.
|
||||
# extra : This contains all packages that conflict with others with required, important, standard or optional priorities, or are only likely to be useful if you already know what they are or have specialized requirements (such as packages containing only detached debugging symbols).
|
||||
PROJECT_PRIORITY=extra
|
||||
|
||||
# description of the current project inside quote and no \n
|
||||
PROJECT_DESCRIPTION="Test software"
|
||||
|
||||
# Add package needed :
|
||||
# current user packages
|
||||
USER_PACKAGES =$(shell pwd)/
|
||||
|
||||
# include the basic makefile of ewol :
|
||||
include $(shell pwd)/../../Makefile.mk
|
10
test/human/appl/Debug.cpp
Normal file
10
test/human/appl/Debug.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
// *********** << needed to have a goo display (do not exeed)
|
||||
const char * applLog = "human ";
|
27
test/human/appl/Debug.h
Normal file
27
test/human/appl/Debug.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/Debug.h>
|
||||
|
||||
extern const char * applLog;
|
||||
|
||||
#define APPL_CRITICAL(data) ETK_CRITICAL(applLog, data)
|
||||
#define APPL_WARNING(data) ETK_WARNING(applLog, data)
|
||||
#define APPL_ERROR(data) ETK_ERROR(applLog, data)
|
||||
#define APPL_INFO(data) ETK_INFO(applLog, data)
|
||||
#define APPL_DEBUG(data) ETK_DEBUG(applLog, data)
|
||||
#define APPL_VERBOSE(data) ETK_VERBOSE(applLog, data)
|
||||
#define APPL_ASSERT(cond, data) ETK_ASSERT(applLog, cond, data)
|
||||
#define APPL_CHECK_INOUT(cond) ETK_CHECK_INOUT(applLog, cond)
|
||||
#define APPL_TODO(cond) ETK_TODO(applLog, cond)
|
||||
|
||||
#endif
|
162
test/human/appl/MainWindows.cpp
Normal file
162
test/human/appl/MainWindows.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/MainWindows.h>
|
||||
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/CheckBox.h>
|
||||
#include <ewol/widget/SizerHori.h>
|
||||
#include <ewol/widget/SizerVert.h>
|
||||
#include <ewol/widget/Label.h>
|
||||
#include <ewol/widget/Entry.h>
|
||||
#include <ewol/widget/List.h>
|
||||
#include <ewol/widget/ContextMenu.h>
|
||||
#include <ewol/widget/PopUp.h>
|
||||
#include <ewol/widget/Spacer.h>
|
||||
#include <ewol/widget/Slider.h>
|
||||
#include <ewol/widget/Menu.h>
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <ewol/widget/meta/Parameter.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
|
||||
|
||||
const char * l_eventChangeExpendX = "event-change-expend-X";
|
||||
const char * l_eventChangeExpendY = "event-change-expend-Y";
|
||||
const char * l_eventChangeFillX = "event-change-fill-X";
|
||||
const char * l_eventChangeFillY = "event-change-fill-Y";
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "MainWindows"
|
||||
|
||||
MainWindows::MainWindows(void)
|
||||
{
|
||||
APPL_DEBUG("CREATE WINDOWS ... ");
|
||||
widget::SizerVert* mySizerVert = NULL;
|
||||
widget::SizerVert* mySizerVert2 = NULL;
|
||||
widget::SizerHori* mySizerHori = NULL;
|
||||
widget::Button* myButton = NULL;
|
||||
|
||||
mySizerVert = new widget::SizerVert();
|
||||
if (NULL == mySizerVert) {
|
||||
APPL_DEBUG("Allocation error mySizerVert");
|
||||
return;
|
||||
}
|
||||
SetSubWidget(mySizerVert);
|
||||
|
||||
mySizerHori = new widget::SizerHori();
|
||||
if (NULL == mySizerHori) {
|
||||
APPL_DEBUG("Allocation error mySizerHori");
|
||||
return;
|
||||
}
|
||||
mySizerVert->SubWidgetAdd(mySizerHori);
|
||||
myButton = new widget::Button("<center>Expend X (false)</center>");
|
||||
if (NULL != myButton) {
|
||||
myButton->SetToggleMode(true);
|
||||
myButton->SetLabelToggle("<center>Expend X (true)</center>");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonValue, l_eventChangeExpendX);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
}
|
||||
myButton = new widget::Button("<center>Expend Y (false)</center>");
|
||||
if (NULL != myButton) {
|
||||
myButton->SetToggleMode(true);
|
||||
myButton->SetLabelToggle("<center>Expend Y (true)</center>");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonValue, l_eventChangeExpendY);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
}
|
||||
myButton = new widget::Button("<center>Fill X (false)</center>");
|
||||
if (NULL != myButton) {
|
||||
myButton->SetToggleMode(true);
|
||||
myButton->SetLabelToggle("<center>Fill X (true)</center>");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonValue, l_eventChangeFillX);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
}
|
||||
myButton = new widget::Button("<center>Fill Y (false)</center>");
|
||||
if (NULL != myButton) {
|
||||
myButton->SetToggleMode(true);
|
||||
myButton->SetLabelToggle("<center>Fill Y (true)</center>");
|
||||
myButton->RegisterOnEvent(this, ewolEventButtonValue, l_eventChangeFillY);
|
||||
mySizerHori->SubWidgetAdd(myButton);
|
||||
}
|
||||
|
||||
m_button = new widget::Button("My Button");
|
||||
if (NULL != m_button) {
|
||||
m_button->SetExpendX(false);
|
||||
m_button->SetExpendY(false);
|
||||
m_button->SetFillX(false);
|
||||
m_button->SetFillY(false);
|
||||
mySizerVert->SubWidgetAdd(m_button);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
|
||||
{
|
||||
ewol::Windows::OnReceiveMessage(CallerObject, eventId, data);
|
||||
|
||||
APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" );
|
||||
|
||||
if (eventId == l_eventChangeExpendX) {
|
||||
if (NULL!=m_button) {
|
||||
if (data=="1") {
|
||||
m_button->SetExpendX(true);
|
||||
} else {
|
||||
m_button->SetExpendX(false);
|
||||
}
|
||||
}
|
||||
} else if (eventId == l_eventChangeExpendY) {
|
||||
if (NULL!=m_button) {
|
||||
if (data=="1") {
|
||||
m_button->SetExpendY(true);
|
||||
} else {
|
||||
m_button->SetExpendY(false);
|
||||
}
|
||||
}
|
||||
} else if (eventId == l_eventChangeFillX) {
|
||||
if (NULL!=m_button) {
|
||||
if (data=="1") {
|
||||
m_button->SetFillX(true);
|
||||
} else {
|
||||
m_button->SetFillX(false);
|
||||
}
|
||||
}
|
||||
} else if (eventId == l_eventChangeFillY) {
|
||||
if (NULL!=m_button) {
|
||||
if (data=="1") {
|
||||
m_button->SetFillY(true);
|
||||
} else {
|
||||
m_button->SetFillY(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inform object that an other object is removed ...
|
||||
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
|
||||
* @note : Sub classes must call this class
|
||||
* @return ---
|
||||
*/
|
||||
void MainWindows::OnObjectRemove(ewol::EObject * removeObject)
|
||||
{
|
||||
ewol::Windows::OnObjectRemove(removeObject);
|
||||
if (m_button == removeObject) {
|
||||
m_button = NULL;
|
||||
}
|
||||
}
|
35
test/human/appl/MainWindows.h
Normal file
35
test/human/appl/MainWindows.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __MAIN_WINDOWS_H__
|
||||
#define __MAIN_WINDOWS_H__
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <ewol/widget/Windows.h>
|
||||
#include <ewol/widget/Button.h>
|
||||
|
||||
class MainWindows : public ewol::Windows
|
||||
{
|
||||
private:
|
||||
widget::Button* m_button;
|
||||
public:
|
||||
// Constructeur
|
||||
MainWindows(void);
|
||||
~MainWindows(void);
|
||||
// Derived function
|
||||
const char * const GetObjectType(void) { return "MainWindows"; };
|
||||
// Derived function
|
||||
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
|
||||
// Derived function
|
||||
virtual void OnObjectRemove(ewol::EObject * removeObject);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
107
test/human/appl/init.cpp
Normal file
107
test/human/appl/init.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UString.h>
|
||||
#include <etk/os/FSNode.h>
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/config.h>
|
||||
#include <ewol/commandLine.h>
|
||||
#include <ewol/eObject/EObject.h>
|
||||
#include <ewol/widget/WidgetManager.h>
|
||||
|
||||
#include <appl/Debug.h>
|
||||
#include <appl/MainWindows.h>
|
||||
|
||||
MainWindows * basicWindows = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
// only one things to do :
|
||||
return ewol::Run(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief main application function Initialisation
|
||||
*/
|
||||
void APP_Init(void)
|
||||
{
|
||||
#ifdef __TARGET_OS__Linux
|
||||
#ifdef MODE_RELEASE
|
||||
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Release)");
|
||||
#else
|
||||
APPL_INFO("==> Init "PROJECT_NAME" (START) (Linux) (Debug)");
|
||||
#endif
|
||||
#else
|
||||
#ifdef MODE_RELEASE
|
||||
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Release)");
|
||||
#else
|
||||
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Debug)");
|
||||
#endif
|
||||
#endif
|
||||
etk::InitDefaultFolder(PROJECT_NAME);
|
||||
ewol::ChangeSize(etk::Vector2D<int32_t>(800, 600));
|
||||
#ifdef __TARGET_OS__Android
|
||||
ewol::config::FontSetDefault("FreeSerif", 19);
|
||||
#else
|
||||
ewol::config::FontSetDefault("FreeSerif", 14);
|
||||
#endif
|
||||
|
||||
basicWindows = new MainWindows();
|
||||
|
||||
if (NULL == basicWindows) {
|
||||
APPL_ERROR("Can not allocate the basic windows");
|
||||
ewol::Stop();
|
||||
return;
|
||||
}
|
||||
// create the specific windows
|
||||
ewol::WindowsSet(basicWindows);
|
||||
|
||||
|
||||
// add files
|
||||
APPL_INFO("show list of command line input : ");
|
||||
for( int32_t iii=0 ; iii<ewol::commandLine::Size(); iii++) {
|
||||
APPL_INFO("parameter [" << iii << "] is \"" << ewol::commandLine::Get(iii) << "\"");
|
||||
}
|
||||
|
||||
APPL_INFO("==> Init "PROJECT_NAME" (END)");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief the system request the icon file name :
|
||||
*/
|
||||
etk::UString APP_Icon(void)
|
||||
{
|
||||
etk::UString bitmapFile("DATA:iconHuman.bmp");
|
||||
return bitmapFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief main application function Un-Initialisation
|
||||
*/
|
||||
void APP_UnInit(void)
|
||||
{
|
||||
APPL_INFO("==> Un-Init "PROJECT_NAME" (START)");
|
||||
// Remove windows :
|
||||
ewol::WindowsSet(NULL);
|
||||
|
||||
if (NULL != basicWindows) {
|
||||
delete(basicWindows);
|
||||
basicWindows = NULL;
|
||||
}
|
||||
APPL_INFO("==> Un-Init "PROJECT_NAME" (END)");
|
||||
}
|
||||
|
41
test/human/config/Linux.config
Normal file
41
test/human/config/Linux.config
Normal file
@ -0,0 +1,41 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Linux kernel version:
|
||||
#
|
||||
|
||||
#
|
||||
# Modules
|
||||
#
|
||||
BUILD_HUMAN=y
|
||||
# BUILD_AGG is not set
|
||||
# BUILD_ETK is not set
|
||||
# BUILD_EWOL is not set
|
||||
# BUILD_FREETYPE is not set
|
||||
# BUILD_LUA is not set
|
||||
# BUILD_OGG is not set
|
||||
# BUILD_PARSERSVG is not set
|
||||
# BUILD_LIBPNG is not set
|
||||
# BUILD_PORTAUDIO is not set
|
||||
# BUILD_TINYXML is not set
|
||||
# BUILD_ZLIB is not set
|
||||
# BUILD_LIBZIP is not set
|
||||
|
||||
#
|
||||
# edn
|
||||
#
|
||||
|
||||
#
|
||||
# General
|
||||
#
|
||||
APPL_BUFFER_FONT_NORMAL=y
|
||||
# APPL_BUFFER_FONT_DISTANCE_FIELD is not set
|
||||
|
||||
#
|
||||
# ewol
|
||||
#
|
||||
|
||||
#
|
||||
# General
|
||||
#
|
||||
# __EWOL_INTEGRATED_FONT__ is not set
|
||||
__EWOL_APPL_BASIC_TITLE__="Edn : Sources Code Editor"
|
11
test/human/file.mk
Normal file
11
test/human/file.mk
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
###############################################################################
|
||||
### Files Listes ###
|
||||
###############################################################################
|
||||
|
||||
# Globals debug tool:
|
||||
FILE_LIST:= appl/Debug.cpp \
|
||||
appl/init.cpp \
|
||||
appl/MainWindows.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user