[DEV] set the entry box working with the shaper system
This commit is contained in:
parent
fb3973915f
commit
6727919ee9
8
data/theme/default/widgetEntry.conf
Normal file
8
data/theme/default/widgetEntry.conf
Normal file
@ -0,0 +1,8 @@
|
||||
# padding for the GUI
|
||||
PaddingX=8
|
||||
PaddingY=8
|
||||
# change status in ms
|
||||
ChangeTime=356
|
||||
# the associated openGL ES-2 program :
|
||||
program=widgetEntry.prog
|
||||
|
@ -3,37 +3,56 @@ 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
|
||||
vec4 S_colorBg = vec4(0.0);
|
||||
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
|
||||
vec4 S_colorFg[3];
|
||||
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
|
||||
float S_sizePadding = 3.0;
|
||||
float S_sizeBorder = 1.0;
|
||||
|
||||
|
||||
void main(void) {
|
||||
float specialBorder = EW_sizeBorder+EW_sizePadding;
|
||||
vec2 endStart = EW_size - vec2(EW_sizePadding) - vec2(EW_sizeBorder);
|
||||
vec2 endStop = EW_size - vec2(EW_sizePadding);
|
||||
if( v_position.x> EW_sizePadding
|
||||
&& v_position.y> EW_sizePadding
|
||||
S_colorFg[0] = vec4(1.0,1.0,1.0,0.8);
|
||||
S_colorFg[1] = vec4(1.0,1.0,1.0,0.4);
|
||||
S_colorFg[2] = vec4(0.0,0.0,1.0,0.1);
|
||||
|
||||
float specialBorder = S_sizeBorder+S_sizePadding;
|
||||
vec2 endStart = EW_widgetProperty.size - vec2(S_sizePadding) - vec2(S_sizeBorder);
|
||||
vec2 endStop = EW_widgetProperty.size - vec2(S_sizePadding);
|
||||
if( v_position.x> S_sizePadding
|
||||
&& v_position.y> S_sizePadding
|
||||
&& v_position.x<= endStop.x
|
||||
&& v_position.y<= endStop.y
|
||||
) {
|
||||
// inside element
|
||||
if( v_position.x<= specialBorder
|
||||
|| v_position.y<= specialBorder
|
||||
|| v_position.x> endStart.x
|
||||
|| v_position.y> endStart.y
|
||||
) {
|
||||
// border ...
|
||||
gl_FragColor = S_colorBorder;
|
||||
} else {
|
||||
gl_FragColor = S_colorFg;
|
||||
gl_FragColor = S_colorFg[EW_status.stateOld]*(1.0-EW_status.transition)
|
||||
+ S_colorFg[EW_status.stateNew]*EW_status.transition;
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = S_colorBg;
|
||||
|
12
data/theme/rounded/widgetEntry.conf
Normal file
12
data/theme/rounded/widgetEntry.conf
Normal file
@ -0,0 +1,12 @@
|
||||
# padding for the GUI
|
||||
PaddingX=13
|
||||
PaddingY=7
|
||||
# change status in ms
|
||||
ChangeTime=356
|
||||
# the associated openGL ES-2 program :
|
||||
program=widgetEntry.prog
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ ewol::Text::Text(void) :
|
||||
m_clippingEnable(false),
|
||||
m_color(draw::color::black),
|
||||
m_colorBg(draw::color::none),
|
||||
m_colorCursor(draw::color::black),
|
||||
m_colorSelection(draw::color::olive),
|
||||
m_mode(ewol::font::Regular),
|
||||
m_kerning(true),
|
||||
m_distanceField(false),
|
||||
@ -32,6 +34,8 @@ ewol::Text::Text(void) :
|
||||
m_GLColor(-1),
|
||||
m_GLtexture(-1),
|
||||
m_GLtexID(-1),
|
||||
m_selectionStartPos(-100),
|
||||
m_cursorPos(-100),
|
||||
m_font(NULL)
|
||||
{
|
||||
SetFont("", -1);
|
||||
@ -46,6 +50,8 @@ ewol::Text::Text(etk::UString fontName, int32_t fontSize) :
|
||||
m_clippingEnable(false),
|
||||
m_color(draw::color::black),
|
||||
m_colorBg(draw::color::none),
|
||||
m_colorCursor(draw::color::black),
|
||||
m_colorSelection(draw::color::olive),
|
||||
m_mode(ewol::font::Regular),
|
||||
m_kerning(true),
|
||||
m_distanceField(false),
|
||||
@ -59,6 +65,8 @@ ewol::Text::Text(etk::UString fontName, int32_t fontSize) :
|
||||
m_GLColor(-1),
|
||||
m_GLtexture(-1),
|
||||
m_GLtexID(-1),
|
||||
m_selectionStartPos(-100),
|
||||
m_cursorPos(-100),
|
||||
m_font(NULL)
|
||||
{
|
||||
SetFont(fontName, fontSize);
|
||||
@ -92,6 +100,9 @@ void ewol::Text::LoadProgram(void)
|
||||
|
||||
void ewol::Text::Draw(void)
|
||||
{
|
||||
// draw BG in any case:
|
||||
m_vectorialDraw.Draw();
|
||||
|
||||
if (m_coord.Size()<=0 || NULL == m_font) {
|
||||
// TODO : a remètre ...
|
||||
//EWOL_WARNING("Nothink to draw...");
|
||||
@ -105,7 +116,6 @@ void ewol::Text::Draw(void)
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
m_vectorialDraw.Draw();
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix()*m_matrixApply;
|
||||
m_GLprogram->Use();
|
||||
@ -168,6 +178,8 @@ void ewol::Text::Clear(void)
|
||||
m_stopTextPos = 0;
|
||||
m_alignement = ewol::Text::alignDisable;
|
||||
m_htmlCurrrentLine = "";
|
||||
m_selectionStartPos = -100;
|
||||
m_cursorPos = -100;
|
||||
m_htmlDecoration.Clear();
|
||||
}
|
||||
|
||||
@ -480,14 +492,32 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
EWOL_ERROR("Font Id is not corectly defined");
|
||||
return;
|
||||
}
|
||||
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);
|
||||
PrintCursor(false);
|
||||
}
|
||||
// note this is faster when nothing is requested ...
|
||||
for(int32_t iii=0; iii<text.Size(); iii++) {
|
||||
if (iii<decoration.Size()) {
|
||||
SetColor(decoration[iii].m_colorFg);
|
||||
SetColorBg(decoration[iii].m_colorBg);
|
||||
tmpFg = decoration[iii].m_colorFg;
|
||||
tmpBg = decoration[iii].m_colorBg;
|
||||
SetFontMode(decoration[iii].m_mode);
|
||||
}
|
||||
if( ( m_selectionStartPos-1<iii
|
||||
&& iii <=m_cursorPos-1)
|
||||
|| ( m_selectionStartPos-1>=iii
|
||||
&& iii > m_cursorPos-1) ) {
|
||||
SetColor( 0x000000FF);
|
||||
SetColorBg(m_colorSelection);
|
||||
} else {
|
||||
SetColor( tmpFg);
|
||||
SetColorBg(tmpBg);
|
||||
}
|
||||
if (m_colorBg.a != 0) {
|
||||
etk::Vector3D<float> pos = m_position;
|
||||
m_vectorialDraw.SetPos(pos);
|
||||
@ -497,6 +527,11 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
} else {
|
||||
Print(text[iii]);
|
||||
}
|
||||
if (iii==m_cursorPos-1) {
|
||||
m_vectorialDraw.SetPos(m_position);
|
||||
SetColorBg(m_colorCursor);
|
||||
PrintCursor(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// special start case at the right of the endpoint :
|
||||
@ -537,14 +572,29 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
break;
|
||||
}
|
||||
// display all the elements
|
||||
if (0==m_cursorPos) {
|
||||
m_vectorialDraw.SetPos(m_position);
|
||||
SetColorBg(m_colorCursor);
|
||||
PrintCursor(false);
|
||||
}
|
||||
for(int32_t iii=currentId; iii<stop && iii<text.Size(); iii++) {
|
||||
float fontHeigh = m_font->GetHeight(m_mode);
|
||||
// Get specific decoration if provided
|
||||
if (iii<decoration.Size()) {
|
||||
SetColor(decoration[iii].m_colorFg);
|
||||
SetColorBg(decoration[iii].m_colorBg);
|
||||
tmpFg = decoration[iii].m_colorFg;
|
||||
tmpBg = decoration[iii].m_colorBg;
|
||||
SetFontMode(decoration[iii].m_mode);
|
||||
}
|
||||
if( ( m_selectionStartPos-1<iii
|
||||
&& iii <=m_cursorPos-1)
|
||||
|| ( m_selectionStartPos-1>=iii
|
||||
&& iii > m_cursorPos-1) ) {
|
||||
SetColor( 0x000000FF);
|
||||
SetColorBg(m_colorSelection);
|
||||
} else {
|
||||
SetColor( tmpFg);
|
||||
SetColorBg(tmpBg);
|
||||
}
|
||||
// special for the justify mode
|
||||
if (text[iii] == (uniChar_t)' ') {
|
||||
if (m_colorBg.a != 0) {
|
||||
@ -567,6 +617,11 @@ void ewol::Text::Print(const etk::UString& text, const etk::Vector<TextDecoratio
|
||||
Print(text[iii]);
|
||||
}
|
||||
}
|
||||
if (iii==m_cursorPos-1) {
|
||||
m_vectorialDraw.SetPos(m_position);
|
||||
SetColorBg(m_colorCursor);
|
||||
PrintCursor(false);
|
||||
}
|
||||
}
|
||||
if (currentId == stop) {
|
||||
currentId++;
|
||||
@ -930,3 +985,32 @@ void ewol::Text::HtmlFlush(void)
|
||||
m_htmlCurrrentLine = "";
|
||||
m_htmlDecoration.Clear();
|
||||
}
|
||||
|
||||
|
||||
void ewol::Text::DisableCursor(void)
|
||||
{
|
||||
m_selectionStartPos = -100;
|
||||
m_cursorPos = -100;
|
||||
}
|
||||
|
||||
void ewol::Text::SetCursorPos(int32_t cursorPos)
|
||||
{
|
||||
m_selectionStartPos = cursorPos;
|
||||
m_cursorPos = cursorPos;
|
||||
}
|
||||
|
||||
void ewol::Text::SetCursorSelection(int32_t cursorPos, int32_t selectionStartPos)
|
||||
{
|
||||
m_selectionStartPos = selectionStartPos;
|
||||
m_cursorPos = cursorPos;
|
||||
}
|
||||
|
||||
void ewol::Text::SetSelectionColor(draw::Color color)
|
||||
{
|
||||
m_colorSelection = color;
|
||||
}
|
||||
|
||||
void ewol::Text::SetCursorColor(draw::Color color)
|
||||
{
|
||||
m_colorCursor = color;
|
||||
}
|
||||
|
@ -56,6 +56,8 @@ namespace ewol
|
||||
private:
|
||||
draw::Color m_color; //!< The text foreground color
|
||||
draw::Color m_colorBg; //!< The text background color
|
||||
draw::Color m_colorCursor; //!< The text cursor color
|
||||
draw::Color m_colorSelection; //!< The text Selection color
|
||||
private:
|
||||
ewol::font::mode_te m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic
|
||||
bool m_kerning; //!< Kerning enable or disable on the next elements displayed
|
||||
@ -72,6 +74,9 @@ namespace ewol
|
||||
int32_t m_GLColor; //!< openGL id on the element (color buffer)
|
||||
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
|
||||
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
|
||||
private:
|
||||
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection)
|
||||
int32_t m_cursorPos; //!< Cursor position (default no cursor ==> -100)
|
||||
private:
|
||||
ewol::TexturedFont* m_font; //!< Font resources
|
||||
private: // Text
|
||||
@ -321,6 +326,32 @@ namespace ewol
|
||||
* @brief Draw the current line
|
||||
*/
|
||||
void HtmlFlush(void);
|
||||
public:
|
||||
/**
|
||||
* @brief Remove the cursor display
|
||||
*/
|
||||
void DisableCursor(void);
|
||||
/**
|
||||
* @brief Set a cursor at a specific position:
|
||||
* @param[in] cursorPos id of the cursor position
|
||||
*/
|
||||
void SetCursorPos(int32_t cursorPos);
|
||||
/**
|
||||
* @brief Set a cursor at a specific position with his associated selection:
|
||||
* @param[in] cursorPos id of the cursor position
|
||||
* @param[in] selectionStartPos id of the starting of the selection
|
||||
*/
|
||||
void SetCursorSelection(int32_t cursorPos, int32_t selectionStartPos);
|
||||
/**
|
||||
* @brief Change the selection color
|
||||
* @param[in] color New color for the Selection
|
||||
*/
|
||||
void SetSelectionColor(draw::Color color);
|
||||
/**
|
||||
* @brief Change the cursor color
|
||||
* @param[in] color New color for the Selection
|
||||
*/
|
||||
void SetCursorColor(draw::Color color);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,12 @@ extern const char * const ewolEventButtonLeave = "ewol-button-leave";
|
||||
#undef __class__
|
||||
#define __class__ "Button"
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
#define STATUS_NORMAL (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")
|
||||
@ -35,6 +41,8 @@ widget::Button::Button(etk::UString newLabel) :
|
||||
|
||||
m_textColorFg = draw::color::black;
|
||||
|
||||
m_shaper.ChangeStatusIn(STATUS_NORMAL);
|
||||
|
||||
SetCanHaveFocus(true);
|
||||
// Limit event at 1:
|
||||
SetMouseLimit(1);
|
||||
@ -190,19 +198,19 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput,
|
||||
{
|
||||
//EWOL_DEBUG("Event on BT ...");
|
||||
if(ewol::keyEvent::statusEnter == typeEvent) {
|
||||
ChangeStatusIn(2);
|
||||
ChangeStatusIn(STATUS_HOVER);
|
||||
}else if(ewol::keyEvent::statusLeave == typeEvent) {
|
||||
ChangeStatusIn(0);
|
||||
ChangeStatusIn(STATUS_NORMAL);
|
||||
}
|
||||
if (1 == IdInput) {
|
||||
if(ewol::keyEvent::statusDown == typeEvent) {
|
||||
GenerateEventId(ewolEventButtonDown);
|
||||
ChangeStatusIn(1);
|
||||
ChangeStatusIn(STATUS_PRESSED);
|
||||
MarkToRedraw();
|
||||
}
|
||||
if(ewol::keyEvent::statusUp == typeEvent) {
|
||||
GenerateEventId(ewolEventButtonUp);
|
||||
ChangeStatusIn(0);
|
||||
ChangeStatusIn(STATUS_NORMAL);
|
||||
MarkToRedraw();
|
||||
}
|
||||
if(ewol::keyEvent::statusSingle == typeEvent) {
|
||||
|
@ -26,8 +26,14 @@ const char * const ewolEventEntrySelect = "ewol-Entry-Select";
|
||||
#undef __class__
|
||||
#define __class__ "Entry"
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
#define STATUS_NORMAL (0)
|
||||
#define STATUS_HOVER (1)
|
||||
#define STATUS_SELECTED (2)
|
||||
|
||||
void widget::Entry::Init(void)
|
||||
|
||||
widget::Entry::Entry(etk::UString newData) :
|
||||
m_shaper("THEME:GUI:widgetEntry.conf")
|
||||
{
|
||||
AddEventId(ewolEventEntryClick);
|
||||
AddEventId(ewolEventEntryEnter);
|
||||
@ -36,8 +42,6 @@ void widget::Entry::Init(void)
|
||||
m_displayCursorPos = 0;
|
||||
m_displayCursorPosSelection = 0;
|
||||
m_userSize = 50;
|
||||
m_borderSize = 2;
|
||||
m_paddingSize = 3;
|
||||
m_displayCursor = false;
|
||||
m_textColorFg = draw::color::black;
|
||||
|
||||
@ -50,31 +54,6 @@ void widget::Entry::Init(void)
|
||||
ShortCutAdd("ctrl+v", ewolEventEntryPaste);
|
||||
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
||||
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
||||
etk::UString tmpString("THEME:GUI:widgetEntry.prog");
|
||||
// get the shader resource :
|
||||
m_GLPosition = 0;
|
||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||
m_GLsizeBorder = m_GLprogram->GetUniform("EW_sizeBorder");
|
||||
m_GLsizePadding = m_GLprogram->GetUniform("EW_sizePadding");
|
||||
m_GLsize = m_GLprogram->GetUniform("EW_size");
|
||||
m_GLposText = m_GLprogram->GetUniform("EW_posText");
|
||||
m_GLstate = m_GLprogram->GetUniform("EW_state");
|
||||
}
|
||||
}
|
||||
|
||||
widget::Entry::Entry(void)
|
||||
{
|
||||
Init();
|
||||
m_data = "";
|
||||
UpdateTextPosition();
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
widget::Entry::Entry(etk::UString newData)
|
||||
{
|
||||
Init();
|
||||
SetValue(newData);
|
||||
UpdateTextPosition();
|
||||
MarkToRedraw();
|
||||
@ -89,9 +68,11 @@ widget::Entry::~Entry(void)
|
||||
|
||||
bool widget::Entry::CalculateMinSize(void)
|
||||
{
|
||||
etk::Vector2D<float> padding = m_shaper.GetPadding();
|
||||
|
||||
int32_t minHeight = m_oObjectText.CalculateSize('A').y;
|
||||
m_minSize.x = m_userSize;
|
||||
m_minSize.y = minHeight + 2*(m_borderSize + 2*m_paddingSize);
|
||||
m_minSize.x = m_userSize + 2*padding.x;
|
||||
m_minSize.y = minHeight + 2*padding.y;
|
||||
UpdateTextPosition();
|
||||
MarkToRedraw();
|
||||
return true;
|
||||
@ -113,59 +94,9 @@ etk::UString widget::Entry::GetValue(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void widget::Entry::SetPoint(float x, float y)
|
||||
{
|
||||
etk::Vector2D<float> triangle(x, y);
|
||||
m_coord.PushBack(triangle);
|
||||
}
|
||||
|
||||
void widget::Entry::Rectangle(float x, float y, float w, float h)
|
||||
{
|
||||
m_coord.Clear();
|
||||
/* Bitmap position
|
||||
* xA xB
|
||||
* yC *------*
|
||||
* | |
|
||||
* | |
|
||||
* yD *------*
|
||||
*/
|
||||
float dxA = x;
|
||||
float dxB = x + w;
|
||||
float dyC = y;
|
||||
float dyD = y + h;
|
||||
SetPoint(dxA, dyD);
|
||||
SetPoint(dxA, dyC);
|
||||
SetPoint(dxB, dyC);
|
||||
|
||||
SetPoint(dxB, dyC);
|
||||
SetPoint(dxB, dyD);
|
||||
SetPoint(dxA, dyD);
|
||||
}
|
||||
|
||||
|
||||
void widget::Entry::OnDraw(ewol::DrawProperty& displayProp)
|
||||
{
|
||||
if (m_GLprogram==NULL) {
|
||||
EWOL_ERROR("No shader ...");
|
||||
return;
|
||||
}
|
||||
//glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||
m_GLprogram->Use();
|
||||
// set Matrix : translation/positionMatrix
|
||||
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||
// position :
|
||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||
// all entry parameters :
|
||||
m_GLprogram->Uniform1f(m_GLsizeBorder, m_borderSize);
|
||||
m_GLprogram->Uniform1f(m_GLsizePadding, m_paddingSize);
|
||||
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
|
||||
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
|
||||
m_GLprogram->Uniform1i(m_GLstate, 0);
|
||||
// Request the draw of the elements :
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||
m_GLprogram->UnUse();
|
||||
m_shaper.Draw();
|
||||
m_oObjectDecoration.Draw();
|
||||
m_oObjectText.Draw();
|
||||
}
|
||||
@ -174,17 +105,19 @@ void widget::Entry::OnDraw(ewol::DrawProperty& displayProp)
|
||||
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();
|
||||
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
int32_t tmpSizeY = m_minSize.y;
|
||||
int32_t tmpOriginX = 0;
|
||||
int32_t tmpOriginY = (m_size.y - tmpSizeY) / 2;
|
||||
// no change for the text orogin :
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
int32_t tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
|
||||
int32_t tmpTextOriginX = padding.x;
|
||||
int32_t tmpTextOriginY = tmpOriginY + padding.y;
|
||||
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
@ -192,33 +125,39 @@ void widget::Entry::OnRegenerateDisplay(void)
|
||||
if (true==m_userFill.y) {
|
||||
//tmpSizeY = m_size.y;
|
||||
tmpOriginY = 0;
|
||||
tmpTextOriginY = tmpOriginY + m_borderSize + 2*m_paddingSize;
|
||||
tmpTextOriginY = tmpOriginY + padding.y;
|
||||
}
|
||||
tmpOriginX += m_paddingSize;
|
||||
tmpOriginY += m_paddingSize;
|
||||
tmpSizeX -= 2*m_paddingSize;
|
||||
tmpSizeY -= 2*m_paddingSize;
|
||||
tmpOriginX += padding.x;
|
||||
tmpOriginY += padding.y;
|
||||
tmpSizeX -= 2*padding.x;
|
||||
tmpSizeY -= 2*padding.y;
|
||||
|
||||
|
||||
etk::Vector3D<float> textPos( tmpTextOriginX + m_displayStartPosition,
|
||||
tmpTextOriginY,
|
||||
0 );
|
||||
etk::Vector3D<float> drawClippingPos( 2*m_paddingSize + m_borderSize,
|
||||
2*m_paddingSize + m_borderSize,
|
||||
etk::Vector3D<float> drawClippingPos( padding.x,
|
||||
padding.y,
|
||||
-1 );
|
||||
etk::Vector3D<float> drawClippingSize( m_size.x - 2*drawClippingPos.x,
|
||||
m_size.y - 2*drawClippingPos.y,
|
||||
1 );
|
||||
m_oObjectText.SetClippingWidth(drawClippingPos, drawClippingSize);
|
||||
m_oObjectText.SetPos(textPos);
|
||||
if (m_displayCursorPosSelection != m_displayCursorPos) {
|
||||
m_oObjectText.SetCursorSelection(m_displayCursorPos, m_displayCursorPosSelection);
|
||||
} else {
|
||||
m_oObjectText.SetCursorPos(m_displayCursorPos);
|
||||
}
|
||||
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);
|
||||
Rectangle(0, 0, m_size.x, m_size.y);
|
||||
*/
|
||||
m_shaper.SetSize(m_size);
|
||||
|
||||
/*
|
||||
Must be rework corectly ==> selection and Cursor are integrated at the system ...
|
||||
@ -260,14 +199,16 @@ void widget::Entry::OnRegenerateDisplay(void)
|
||||
|
||||
void widget::Entry::UpdateCursorPosition(etk::Vector2D<float>& pos, bool selection)
|
||||
{
|
||||
etk::Vector2D<float> padding = m_shaper.GetPadding();
|
||||
|
||||
etk::Vector2D<float> relPos = RelativePosition(pos);
|
||||
relPos.x += -m_displayStartPosition - 2*m_paddingSize - m_borderSize;
|
||||
relPos.x += -m_displayStartPosition - padding.x;
|
||||
// try to find the new cursor position :
|
||||
etk::UString tmpDisplay = m_data.Extract(0, m_displayStartPosition);
|
||||
int32_t displayHidenSize = m_oObjectText.CalculateSize(tmpDisplay).x;
|
||||
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
|
||||
int32_t newCursorPosition = -1;
|
||||
int32_t tmpTextOriginX = m_borderSize + 2*m_paddingSize;
|
||||
int32_t tmpTextOriginX = padding.x;
|
||||
for (int32_t iii=0; iii<m_data.Size(); iii++) {
|
||||
tmpDisplay = m_data.Extract(0, iii);
|
||||
int32_t tmpWidth = m_oObjectText.CalculateSize(tmpDisplay).x - displayHidenSize;
|
||||
@ -546,11 +487,13 @@ void widget::Entry::OnReceiveMessage(ewol::EObject * CallerObject, const char *
|
||||
|
||||
void widget::Entry::UpdateTextPosition(void)
|
||||
{
|
||||
etk::Vector2D<float> padding = m_shaper.GetPadding();
|
||||
|
||||
int32_t tmpSizeX = m_minSize.x;
|
||||
if (true==m_userFill.x) {
|
||||
tmpSizeX = m_size.x;
|
||||
}
|
||||
int32_t tmpUserSize = tmpSizeX - 2*(m_borderSize + 2*m_paddingSize);
|
||||
int32_t tmpUserSize = tmpSizeX - 2*(padding.x);
|
||||
int32_t totalWidth = m_oObjectText.CalculateSize(m_data).x;
|
||||
// Check if the data inside the display can be contain in the entry box
|
||||
if (totalWidth < tmpUserSize) {
|
||||
@ -579,6 +522,7 @@ void widget::Entry::UpdateTextPosition(void)
|
||||
void widget::Entry::OnGetFocus(void)
|
||||
{
|
||||
m_displayCursor = true;
|
||||
ChangeStatusIn(STATUS_SELECTED);
|
||||
ewol::Keyboard(true);
|
||||
MarkToRedraw();
|
||||
}
|
||||
@ -587,6 +531,25 @@ void widget::Entry::OnGetFocus(void)
|
||||
void widget::Entry::OnLostFocus(void)
|
||||
{
|
||||
m_displayCursor = false;
|
||||
ChangeStatusIn(STATUS_NORMAL);
|
||||
ewol::Keyboard(false);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
|
||||
void widget::Entry::ChangeStatusIn(int32_t newStatusId)
|
||||
{
|
||||
if (true == m_shaper.ChangeStatusIn(newStatusId) ) {
|
||||
PeriodicCallSet(true);
|
||||
MarkToRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void widget::Entry::PeriodicCall(int64_t localTime)
|
||||
{
|
||||
if (false == m_shaper.PeriodicCall(localTime) ) {
|
||||
PeriodicCallSet(false);
|
||||
}
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/compositing/Text.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Shaper.h>
|
||||
#include <ewol/widget/Widget.h>
|
||||
#include <draw/Color.h>
|
||||
|
||||
@ -33,49 +34,34 @@ namespace widget {
|
||||
class Entry : public ewol::Widget
|
||||
{
|
||||
private:
|
||||
ewol::Program* m_GLprogram;
|
||||
int32_t m_GLPosition;
|
||||
int32_t m_GLMatrix;
|
||||
int32_t m_GLsizeBorder;
|
||||
int32_t m_GLsizePadding;
|
||||
int32_t m_GLsize;
|
||||
float m_pos[4];
|
||||
int32_t m_GLposText;
|
||||
int32_t m_GLstate;
|
||||
etk::Vector<etk::Vector2D<float> > m_coord; //!< internal coord of the object
|
||||
draw::Colorf m_color[3];
|
||||
void SetPoint(float x, float y);
|
||||
void Rectangle(float x, float y, float w, float h);
|
||||
private:
|
||||
ewol::Text m_oObjectText; //!< text display
|
||||
ewol::Drawing m_oObjectDecoration; //!< background display
|
||||
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
|
||||
int32_t m_userSize; //!< Display size requested by the user
|
||||
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
|
||||
int32_t m_borderSize; //!< Border size
|
||||
int32_t m_paddingSize; //!< space between border and the text and the border base and the border widget
|
||||
bool m_displayCursor; //!< Cursor mus be display only when the widget has the focus
|
||||
int32_t m_displayCursorPos; //!< Cursor position in number of Char
|
||||
int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable
|
||||
public:
|
||||
/**
|
||||
* @brief Contuctor
|
||||
*/
|
||||
Entry(void);
|
||||
/**
|
||||
* @brief Contuctor
|
||||
* @param[in] newData The USting that might be set in the Entry box (no event generation!!)
|
||||
*/
|
||||
Entry(etk::UString newData);
|
||||
Entry(etk::UString newData = "");
|
||||
/**
|
||||
* @brief Destuctor
|
||||
*/
|
||||
virtual ~Entry(void);
|
||||
// Derived function
|
||||
virtual const char * const GetObjectType(void) { return "EwolEntry"; };
|
||||
void Init(void);
|
||||
// Derived function
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetValue(etk::UString newData);
|
||||
@ -130,6 +116,10 @@ namespace widget {
|
||||
virtual void OnGetFocus(void);
|
||||
// Derived function
|
||||
virtual void OnLostFocus(void);
|
||||
// change the current shaper display :
|
||||
void ChangeStatusIn(int32_t newStatusId);
|
||||
// Derived function
|
||||
virtual void PeriodicCall(int64_t localTime);
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -100,23 +100,10 @@ LOCAL_COPY_FILES := ../data/textured3D.prog:textured3D.prog \
|
||||
\
|
||||
../data/text.prog:text.prog \
|
||||
../data/text.frag:text.frag \
|
||||
../data/text.vert:text.vert \
|
||||
\
|
||||
../data/theme/default/widgetEntry.prog:theme/default/widgetEntry.prog \
|
||||
../data/theme/default/widgetEntry.frag:theme/default/widgetEntry.frag \
|
||||
../data/theme/default/widgetEntry.vert:theme/default/widgetEntry.vert \
|
||||
\
|
||||
../data/theme/rounded/widgetEntry.prog:theme/rounded/widgetEntry.prog \
|
||||
../data/theme/rounded/widgetEntry.frag:theme/rounded/widgetEntry.frag \
|
||||
../data/theme/rounded/widgetEntry.vert:theme/rounded/widgetEntry.vert \
|
||||
\
|
||||
../data/theme/default/widgetButton.conf:theme/default/widgetButton.conf \
|
||||
../data/theme/default/widgetButton.prog:theme/default/widgetButton.prog \
|
||||
../data/theme/default/widgetButton.frag:theme/default/widgetButton.frag \
|
||||
../data/theme/default/widgetButton.vert:theme/default/widgetButton.vert \
|
||||
\
|
||||
../data/theme/rounded/widgetButton.conf:theme/rounded/widgetButton.conf \
|
||||
../data/theme/rounded/widgetButton.prog:theme/rounded/widgetButton.prog \
|
||||
../data/theme/rounded/widgetButton.frag:theme/rounded/widgetButton.frag \
|
||||
../data/theme/rounded/widgetButton.vert:theme/rounded/widgetButton.vert
|
||||
../data/text.vert:text.vert
|
||||
|
||||
LOCAL_COPY_FOLDERS := ../data/theme/default/widgetEntry.*:theme/default \
|
||||
../data/theme/rounded/widgetEntry.*:theme/rounded \
|
||||
../data/theme/default/widgetButton.*:theme/default \
|
||||
../data/theme/rounded/widgetButton.*:theme/rounded \
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user