[DEV] correct checkbox, pop-up and fileChooser
This commit is contained in:
parent
5606728ae4
commit
f9a5796a0a
@ -4,7 +4,7 @@
|
||||
{ name:"EW_border", color:"#FFF" },
|
||||
{ name:"EW_foreground", color:"#000A" },
|
||||
{ name:"EW_foregroundHover", color:"#0066" },
|
||||
{ name:"EW_foregroundSelected", color:"#060A" },
|
||||
{ name:"EW_foregroundSelected", color:"#FFFA" },
|
||||
{ name:"EW_foregroundPressed", color:"#6006" },
|
||||
]
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{ name:"EW_border", color:"#000" },
|
||||
{ name:"EW_foreground", color:"#8884" },
|
||||
{ name:"EW_foregroundHover", color:"#00A6" },
|
||||
{ name:"EW_foregroundSelected", color:"#0A0A" },
|
||||
{ name:"EW_foregroundSelected", color:"#000A" },
|
||||
{ name:"EW_foregroundPressed", color:"#A006" },
|
||||
]
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ struct displayProperty {
|
||||
};
|
||||
|
||||
struct widgetStateProperty {
|
||||
int activate;
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
@ -25,6 +26,7 @@ varying vec2 v_position; // interpolated position ...
|
||||
varying vec4 v_colorTansition;
|
||||
varying vec4 v_colorBorder;
|
||||
varying vec4 v_colorBackground;
|
||||
varying vec4 v_colorInside;
|
||||
|
||||
// internal static define
|
||||
float S_sizePadding = 3.0; // must not be NULL
|
||||
@ -64,5 +66,13 @@ void main(void) {
|
||||
float tmpVal2 = abs(tmpVal-0.5)*2.0;
|
||||
gl_FragColor = gl_FragColor*tmpVal2 + v_colorBorder*(1.0-tmpVal2);
|
||||
|
||||
// prevent origin moving ...
|
||||
position = v_position - EW_widgetProperty.insidePos - EW_widgetProperty.insideSize*0.5;
|
||||
position = position / EW_widgetProperty.insideSize;
|
||||
|
||||
if (sqrt(dot(position, position)) <= 1.0) {
|
||||
gl_FragColor = v_colorInside;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
{
|
||||
padding-left:13,
|
||||
padding-right:13,
|
||||
padding-top:7,
|
||||
padding-buttom:7,
|
||||
|
||||
box-size:20,
|
||||
box-inside:12,
|
||||
padding-left:10,
|
||||
padding-right:10,
|
||||
padding-top:10,
|
||||
padding-buttom:10,
|
||||
change-time:356,
|
||||
program:"THEME:GUI:CheckBox.prog",
|
||||
color:"THEME:COLOR:CheckBox.json"
|
||||
|
@ -4,6 +4,7 @@ precision mediump int;
|
||||
#endif
|
||||
|
||||
struct widgetStateProperty {
|
||||
int activate;
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
@ -26,6 +27,7 @@ varying vec2 v_position; // This will be passed into the fragment shader.
|
||||
varying vec4 v_colorTansition;
|
||||
varying vec4 v_colorBorder;
|
||||
varying vec4 v_colorBackground;
|
||||
varying vec4 v_colorInside;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
@ -37,16 +39,17 @@ void main(void) {
|
||||
colorOld = EW_foregroundPressed;
|
||||
} else if(EW_status.stateOld == 2) {
|
||||
colorOld = EW_foregroundHover;
|
||||
} else if(EW_status.stateOld == 3) {
|
||||
colorOld = EW_foregroundSelected;
|
||||
}
|
||||
vec4 colorNew = EW_foreground;
|
||||
if(EW_status.stateNew == 1) {
|
||||
colorNew = EW_foregroundPressed;
|
||||
} else if(EW_status.stateNew == 2) {
|
||||
colorNew = EW_foregroundHover;
|
||||
} else if(EW_status.stateNew == 3) {
|
||||
colorNew = EW_foregroundSelected;
|
||||
}
|
||||
|
||||
v_colorInside = EW_foreground;
|
||||
if (EW_status.activate == 1) {
|
||||
v_colorInside = EW_foregroundSelected;
|
||||
}
|
||||
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
|
@ -18,6 +18,7 @@ varying vec2 v_position; // interpolated position ...
|
||||
varying vec4 v_colorTansition;
|
||||
varying vec4 v_colorBorder;
|
||||
varying vec4 v_colorBackground;
|
||||
varying vec4 v_colorInside;
|
||||
|
||||
// internal static define
|
||||
float S_sizePadding = 3.0;
|
||||
@ -47,5 +48,13 @@ void main(void) {
|
||||
} else {
|
||||
gl_FragColor = v_colorBackground;
|
||||
}
|
||||
position = v_position - EW_widgetProperty.insidePos;
|
||||
if( position.x> 0.0
|
||||
&& position.y> 0.0
|
||||
&& position.x<= EW_widgetProperty.insideSize.x
|
||||
&& position.y<= EW_widgetProperty.insideSize.y
|
||||
) {
|
||||
gl_FragColor = v_colorInside;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
element-size:50,
|
||||
element-border:10,
|
||||
padding-left:80,
|
||||
box-size:20,
|
||||
box-inside:12,
|
||||
padding-left:8,
|
||||
padding-right:8,
|
||||
padding-top:8,
|
||||
padding-buttom:8,
|
||||
|
@ -4,6 +4,7 @@ precision mediump int;
|
||||
#endif
|
||||
|
||||
struct widgetStateProperty {
|
||||
int activate;
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
@ -26,6 +27,7 @@ varying vec2 v_position; // This will be passed into the fragment shader.
|
||||
varying vec4 v_colorTansition;
|
||||
varying vec4 v_colorBorder;
|
||||
varying vec4 v_colorBackground;
|
||||
varying vec4 v_colorInside;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
@ -37,16 +39,17 @@ void main(void) {
|
||||
colorOld = EW_foregroundPressed;
|
||||
} else if(EW_status.stateOld == 2) {
|
||||
colorOld = EW_foregroundHover;
|
||||
} else if(EW_status.stateOld == 3) {
|
||||
colorOld = EW_foregroundSelected;
|
||||
}
|
||||
vec4 colorNew = EW_foreground;
|
||||
if(EW_status.stateNew == 1) {
|
||||
colorNew = EW_foregroundPressed;
|
||||
} else if(EW_status.stateNew == 2) {
|
||||
colorNew = EW_foregroundHover;
|
||||
} else if(EW_status.stateNew == 3) {
|
||||
colorNew = EW_foregroundSelected;
|
||||
}
|
||||
|
||||
v_colorInside = EW_foreground;
|
||||
if (EW_status.activate == 1) {
|
||||
v_colorInside = EW_foregroundSelected;
|
||||
}
|
||||
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
|
@ -30,6 +30,7 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
|
||||
m_GLPropertySize(-1),
|
||||
m_GLPropertyInsidePos(-1),
|
||||
m_GLPropertyInsideSize(-1),
|
||||
m_GLStateActivate(-1),
|
||||
m_GLStateOld(-1),
|
||||
m_GLStateNew(-1),
|
||||
m_GLStateTransition(-1),
|
||||
@ -39,6 +40,7 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
|
||||
m_propertySize(0,0),
|
||||
m_propertyInsidePosition(0,0),
|
||||
m_propertyInsideSize(0,0),
|
||||
m_stateActivate(0),
|
||||
m_stateOld(0),
|
||||
m_stateNew(0),
|
||||
m_stateTransition(1.0) {
|
||||
@ -104,6 +106,7 @@ void ewol::compositing::Shaper::loadProgram(void) {
|
||||
m_GLPropertyInsidePos = m_GLprogram->getUniform("EW_widgetProperty.insidePos");
|
||||
m_GLPropertyInsideSize = m_GLprogram->getUniform("EW_widgetProperty.insideSize");
|
||||
// status property == > for the fragment shader
|
||||
m_GLStateActivate = m_GLprogram->getUniform("EW_status.activate");
|
||||
m_GLStateOld = m_GLprogram->getUniform("EW_status.stateOld");
|
||||
m_GLStateNew = m_GLprogram->getUniform("EW_status.stateNew");
|
||||
m_GLStateTransition = m_GLprogram->getUniform("EW_status.transition");
|
||||
@ -170,6 +173,7 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
|
||||
m_GLprogram->uniform2(m_GLPropertyOrigin, m_propertyOrigin);
|
||||
m_GLprogram->uniform2(m_GLPropertyInsidePos, m_propertyInsidePosition);
|
||||
m_GLprogram->uniform2(m_GLPropertyInsideSize, m_propertyInsideSize);
|
||||
m_GLprogram->uniform1i(m_GLStateActivate, m_stateActivate);
|
||||
m_GLprogram->uniform1i(m_GLStateOld, m_stateOld);
|
||||
m_GLprogram->uniform1i(m_GLStateNew, m_stateNew);
|
||||
m_GLprogram->uniform1f(m_GLStateTransition, m_stateTransition);
|
||||
|
@ -46,6 +46,7 @@ namespace ewol {
|
||||
int32_t m_GLPropertyOrigin; //!< openGL id on the element (widget origin)
|
||||
int32_t m_GLPropertyInsidePos; //!< openGL id on the element (widget internal element position)
|
||||
int32_t m_GLPropertyInsideSize; //!< openGL id on the element (widget internal element size)
|
||||
int32_t m_GLStateActivate; //!< openGL id on the element (activate state displayed)
|
||||
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] )
|
||||
@ -58,6 +59,7 @@ namespace ewol {
|
||||
vec2 m_propertySize; //!< widget size
|
||||
vec2 m_propertyInsidePosition; //!< internal subwidget position
|
||||
vec2 m_propertyInsideSize; //!< internal subwidget size
|
||||
int32_t m_stateActivate; //!< Activate state of the element
|
||||
int32_t m_stateOld; //!< previous state
|
||||
int32_t m_stateNew; //!< destination state
|
||||
float m_stateTransition; //!< working state between 2 states
|
||||
@ -193,6 +195,38 @@ namespace ewol {
|
||||
* @return the reference on the color
|
||||
*/
|
||||
const etk::Color<float>& getColor(int32_t _id);
|
||||
public:
|
||||
/**
|
||||
* @brief Get an ID on the configuration instance element
|
||||
* @param[in] _name Name of the element requested
|
||||
* @return The Id of the element
|
||||
*/
|
||||
int32_t requestConfig(const std::string& _name) {
|
||||
if (m_config == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return m_config->request(_name);
|
||||
}
|
||||
/**
|
||||
* @brief Get The number associated at an ID.
|
||||
* @param[in] _id Id of the parameter
|
||||
* @return the requested number.
|
||||
*/
|
||||
double getConfigNumber(int32_t _id) {
|
||||
if ( _id == -1
|
||||
|| m_config == NULL) {
|
||||
return 0.0;
|
||||
}
|
||||
return m_config->getNumber(_id);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Set activate state of the element
|
||||
* @param[in] _status New activate status
|
||||
*/
|
||||
void setActivateState(int32_t _status) {
|
||||
m_stateActivate = _status;
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -106,14 +106,15 @@ void ewol::widget::Button::onDraw(void) {
|
||||
|
||||
void ewol::widget::Button::onRegenerateDisplay(void) {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (true == needRedraw()) {
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
m_shaper.clear();
|
||||
m_shaper.setOrigin(vec2ClipInt32(m_selectableAreaPos));
|
||||
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize));
|
||||
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ));
|
||||
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ));
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
m_shaper.clear();
|
||||
m_shaper.setOrigin(vec2ClipInt32(m_selectableAreaPos));
|
||||
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize));
|
||||
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ));
|
||||
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ));
|
||||
}
|
||||
|
||||
void ewol::widget::Button::setLock(enum buttonLock _lock) {
|
||||
|
@ -23,7 +23,6 @@ const char* const ewol::widget::CheckBox::configShaper = "shaper";
|
||||
#define STATUS_UP (0)
|
||||
#define STATUS_HOVER (2)
|
||||
#define STATUS_PRESSED (1)
|
||||
#define STATUS_DOWN (3)
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "CheckBox"
|
||||
@ -42,6 +41,8 @@ ewol::widget::CheckBox::CheckBox(const std::string& _shaperName) :
|
||||
m_buttonPressed(false),
|
||||
m_selectableAreaPos(0,0),
|
||||
m_selectableAreaSize(0,0),
|
||||
m_shaperIdSize(-1),
|
||||
m_shaperIdSizeInsize(-1),
|
||||
m_value(false) {
|
||||
addObjectType("ewol::widget::CheckBox");
|
||||
// add basic Event generated :
|
||||
@ -54,6 +55,9 @@ ewol::widget::CheckBox::CheckBox(const std::string& _shaperName) :
|
||||
registerConfig(configValue, "bool", NULL, "Basic value of the widget");
|
||||
registerConfig(configShaper, "string", NULL, "the display name for config file");
|
||||
|
||||
m_shaperIdSize = m_shaper.requestConfig("box-size");
|
||||
m_shaperIdSizeInsize = m_shaper.requestConfig("box-inside");
|
||||
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
// This widget can have the focus ...
|
||||
@ -75,15 +79,22 @@ void ewol::widget::CheckBox::setShaperName(const std::string& _shaperName) {
|
||||
|
||||
void ewol::widget::CheckBox::calculateSize(const vec2& _availlable) {
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
ewol::Padding ret = calculateSizePadded(_availlable, padding);
|
||||
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
|
||||
m_selectableAreaPos = vec2(ret.xLeft(), ret.yButtom());
|
||||
m_selectableAreaPos = vec2(ret.xLeft()/*-boxSize*/, ret.yButtom());
|
||||
m_selectableAreaSize = m_size - (m_selectableAreaPos + vec2(ret.xRight(), ret.yTop()));
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::calculateMinMaxSize(void) {
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize);
|
||||
padding.setXLeft(padding.xLeft()*2.0f + boxSize);
|
||||
calculateMinMaxSizePadded(padding);
|
||||
if (m_size.y() < padding.y()+boxSize) {
|
||||
m_size.setY(padding.y()+boxSize);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::onDraw(void) {
|
||||
@ -93,14 +104,23 @@ void ewol::widget::CheckBox::onDraw(void) {
|
||||
|
||||
void ewol::widget::CheckBox::onRegenerateDisplay(void) {
|
||||
ewol::widget::Container2::onRegenerateDisplay();
|
||||
if (true == needRedraw()) {
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
m_shaper.clear();
|
||||
m_shaper.setOrigin(vec2ClipInt32(m_selectableAreaPos));
|
||||
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize - vec2(m_selectableAreaSize.x(), 0) + vec2(padding.xLeft(), 0)));
|
||||
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(), padding.yButtom())));
|
||||
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x()+ m_selectableAreaSize.x(), padding.y())));
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
ewol::Padding padding = m_shaper.getPadding();
|
||||
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize);
|
||||
float boxInside = m_shaper.getConfigNumber(m_shaperIdSizeInsize);
|
||||
m_shaper.clear();
|
||||
|
||||
vec2 origin(m_selectableAreaPos + vec2(0, (m_selectableAreaSize.y() - (boxSize+padding.y()))*0.5f));
|
||||
vec2 size = vec2(boxSize+padding.x(), boxSize+padding.y());
|
||||
|
||||
m_shaper.setOrigin(vec2ClipInt32(origin));
|
||||
m_shaper.setSize(vec2ClipInt32(size));
|
||||
origin = m_selectableAreaPos + vec2((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f);
|
||||
size = vec2(boxInside+padding.x(), boxInside+padding.y());
|
||||
m_shaper.setInsidePos(vec2ClipInt32(origin+vec2(padding.xLeft(),padding.yButtom()) ));
|
||||
m_shaper.setInsideSize(vec2ClipInt32(size-vec2(padding.x(),padding.y()) ));
|
||||
}
|
||||
|
||||
void ewol::widget::CheckBox::setValue(bool _val) {
|
||||
@ -114,6 +134,7 @@ void ewol::widget::CheckBox::setValue(bool _val) {
|
||||
CheckStatus();
|
||||
markToRedraw();
|
||||
}
|
||||
m_shaper.setActivateState(m_value==true?1:0);
|
||||
}
|
||||
|
||||
bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) {
|
||||
@ -190,11 +211,7 @@ void ewol::widget::CheckBox::CheckStatus(void) {
|
||||
if (true == m_mouseHover) {
|
||||
changeStatusIn(STATUS_HOVER);
|
||||
} else {
|
||||
if (true == m_value) {
|
||||
changeStatusIn(STATUS_DOWN);
|
||||
} else {
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
changeStatusIn(STATUS_UP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ namespace ewol {
|
||||
// hover area :
|
||||
vec2 m_selectableAreaPos; //!< Start position of the events
|
||||
vec2 m_selectableAreaSize; //!< size of the event positions
|
||||
// shaper ids:
|
||||
int32_t m_shaperIdSize;
|
||||
int32_t m_shaperIdSizeInsize;
|
||||
public:
|
||||
/**
|
||||
* @brief Main checkbox constructor
|
||||
|
@ -138,7 +138,7 @@ void ewol::widget::PopUp::onRegenerateDisplay(void) {
|
||||
|
||||
m_shaper.setOrigin(vec2(0,0));
|
||||
m_shaper.setSize(vec2ClipInt32(m_size));
|
||||
m_shaper.setInsidePos(vec2ClipInt32(tmpOrigin-vec2(padding.x(), padding.y())));
|
||||
m_shaper.setInsidePos(vec2ClipInt32(tmpOrigin-vec2(padding.xLeft(), padding.yButtom())));
|
||||
m_shaper.setInsideSize(vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y())));
|
||||
}
|
||||
// SUBwIDGET GENERATION ...
|
||||
|
@ -69,8 +69,9 @@ ewol::widget::FileChooser::FileChooser(void) {
|
||||
+ "<popup >\n"
|
||||
+ " <sizer mode='vert' lock='true' fill='true' expand='true'>\n"
|
||||
+ " <sizer mode='hori'>\n"
|
||||
+ " <checkbox name='[" + std::to_string(getId()) + "]file-shooser:show-hiden-file'/>\n"
|
||||
+ " <label>Show hiden files</label>\n"
|
||||
+ " <checkbox name='[" + std::to_string(getId()) + "]file-shooser:show-hiden-file'>\n"
|
||||
+ " <label>Show hiden files</label>\n"
|
||||
+ " </checkbox>\n"
|
||||
+ " <spacer expand='true,false'/>\n"
|
||||
+ " <button name='[" + std::to_string(getId()) + "]file-shooser:button-validate'>\n"
|
||||
+ " <sizer mode='hori'>\n"
|
||||
@ -116,7 +117,7 @@ ewol::widget::FileChooser::FileChooser(void) {
|
||||
+ " </sizer>\n"
|
||||
+ "</popup>";
|
||||
loadFromString(myDescription);
|
||||
registerOnEventNameWidget("[" + std::to_string(getId()) + "]file-shooser:show-hiden-file", "clicked", ewolEventFileChooserHidenFileChange);
|
||||
registerOnEventNameWidget("[" + std::to_string(getId()) + "]file-shooser:show-hiden-file", "value", ewolEventFileChooserHidenFileChange);
|
||||
registerOnEventNameWidget("[" + std::to_string(getId()) + "]file-shooser:button-validate", "pressed", eventValidate);
|
||||
registerOnEventNameWidget("[" + std::to_string(getId()) + "]file-shooser:button-cancel", "pressed", eventCancel);
|
||||
registerOnEventNameWidget("[" + std::to_string(getId()) + "]file-shooser:list-folder", "folder-validate", ewolEventFileChooserListFolder);
|
||||
|
Loading…
x
Reference in New Issue
Block a user