[DEV] better context menu display and some small corection
This commit is contained in:
parent
485aca72bc
commit
a6b7e7b132
8
data/theme/default/widgetContextMenu.conf
Normal file
8
data/theme/default/widgetContextMenu.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=widgetContextMenu.prog
|
||||
|
51
data/theme/default/widgetContextMenu.frag
Normal file
51
data/theme/default/widgetContextMenu.frag
Normal file
@ -0,0 +1,51 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
struct displayProperty {
|
||||
vec2 size;
|
||||
vec2 origin;
|
||||
vec2 insidePos;
|
||||
vec2 insideSize;
|
||||
};
|
||||
|
||||
|
||||
uniform displayProperty EW_widgetProperty;
|
||||
|
||||
|
||||
// transmit from the vertex shader
|
||||
varying vec2 v_position; // interpolated position ...
|
||||
varying vec4 v_colorTansition;
|
||||
|
||||
// internal static define
|
||||
vec4 S_colorBg = vec4(0.0);
|
||||
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
|
||||
float S_sizePadding = 1.0;
|
||||
float S_sizeBorder = 3.0;
|
||||
|
||||
void main(void) {
|
||||
// prevent origin moving ...
|
||||
vec2 position = v_position - EW_widgetProperty.origin;
|
||||
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( position.x> S_sizePadding
|
||||
&& position.y> S_sizePadding
|
||||
&& position.x<= endStop.x
|
||||
&& position.y<= endStop.y
|
||||
) {
|
||||
if( position.x<= specialBorder
|
||||
|| position.y<= specialBorder
|
||||
|| position.x> endStart.x
|
||||
|| position.y> endStart.y
|
||||
) {
|
||||
gl_FragColor = S_colorBorder;
|
||||
} else {
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
gl_FragColor = v_colorTansition;
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = S_colorBg;
|
||||
}
|
||||
}
|
||||
|
55
data/theme/default/widgetContextMenu.vert
Normal file
55
data/theme/default/widgetContextMenu.vert
Normal file
@ -0,0 +1,55 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
struct widgetStateProperty {
|
||||
int stateOld;
|
||||
int stateNew;
|
||||
float transition;
|
||||
};
|
||||
|
||||
uniform widgetStateProperty EW_status;
|
||||
|
||||
// Input :
|
||||
attribute vec2 EW_coord2d;
|
||||
uniform mat4 EW_MatrixTransformation;
|
||||
|
||||
// output :
|
||||
varying vec2 v_position; // This will be passed into the fragment shader.
|
||||
varying vec4 v_colorTansition;
|
||||
|
||||
// internal :
|
||||
vec4 S_colorFg[4];
|
||||
|
||||
void main(void) {
|
||||
S_colorFg[0] = vec4(1.0,1.0,1.0,0.8);
|
||||
S_colorFg[1] = vec4(0.7,0.0,0.0,0.4);
|
||||
S_colorFg[2] = vec4(0.0,0.0,0.7,0.4);
|
||||
S_colorFg[3] = vec4(0.0,0.7,0.0,0.4);
|
||||
|
||||
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
|
||||
// transmit position of the curent element (intermolated ...)
|
||||
v_position = EW_coord2d;
|
||||
|
||||
vec4 colorOld = S_colorFg[0];
|
||||
if(EW_status.stateOld==1) {
|
||||
colorOld = S_colorFg[1];
|
||||
} else if(EW_status.stateOld==2) {
|
||||
colorOld = S_colorFg[2];
|
||||
} else if(EW_status.stateOld==3) {
|
||||
colorOld = S_colorFg[3];
|
||||
}
|
||||
vec4 colorNew = S_colorFg[0];
|
||||
if(EW_status.stateNew==1) {
|
||||
colorNew = S_colorFg[1];
|
||||
} else if(EW_status.stateNew==2) {
|
||||
colorNew = S_colorFg[2];
|
||||
} else if(EW_status.stateNew==3) {
|
||||
colorNew = S_colorFg[3];
|
||||
}
|
||||
|
||||
// note : int() is needed for the OpenGL ES platform
|
||||
v_colorTansition = colorOld*(1.0-EW_status.transition)
|
||||
+ colorNew*EW_status.transition;
|
||||
}
|
@ -16,8 +16,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "ewol::Shaper"
|
||||
|
||||
ewol::Shaper::Shaper(const etk::UString& shaperName) :
|
||||
m_name(shaperName),
|
||||
ewol::Shaper::Shaper(const etk::UString& _shaperName) :
|
||||
m_name(_shaperName),
|
||||
m_config(NULL),
|
||||
m_confIdPaddingX(-1),
|
||||
m_confIdPaddingY(-1),
|
||||
@ -156,9 +156,9 @@ void ewol::Shaper::Clear(void)
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
bool ewol::Shaper::ChangeStatusIn(int32_t newStatusId)
|
||||
bool ewol::Shaper::ChangeStatusIn(int32_t _newStatusId)
|
||||
{
|
||||
m_nextStatusRequested = newStatusId;
|
||||
m_nextStatusRequested = _newStatusId;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -172,23 +172,23 @@ int32_t ewol::Shaper::GetNextDisplayedStatus(void)
|
||||
return m_nextStatusRequested;
|
||||
}
|
||||
|
||||
bool ewol::Shaper::PeriodicCall(int64_t localTime)
|
||||
bool ewol::Shaper::PeriodicCall(int64_t _localTime)
|
||||
{
|
||||
// start :
|
||||
if (m_time == -1) {
|
||||
m_time = localTime;
|
||||
m_time = _localTime;
|
||||
m_stateOld = m_stateNew;
|
||||
m_stateNew = m_nextStatusRequested;
|
||||
m_nextStatusRequested = -1;
|
||||
m_stateTransition = 0.0;
|
||||
EWOL_VERBOSE(" ##### START ##### ");
|
||||
}
|
||||
int64_t offset = localTime - m_time;
|
||||
int64_t offset = _localTime - m_time;
|
||||
float timeRelativity = m_config->GetFloat(m_confIdChangeTime)*1000.0;
|
||||
if (offset > timeRelativity) {
|
||||
// check if no new state requested:
|
||||
if (m_nextStatusRequested != -1) {
|
||||
m_time = localTime;
|
||||
m_time = _localTime;
|
||||
m_stateOld = m_stateNew;
|
||||
m_stateNew = m_nextStatusRequested;
|
||||
m_nextStatusRequested = -1;
|
||||
@ -224,31 +224,31 @@ void ewol::Shaper::UpdateVectex(void)
|
||||
m_propertyOrigin.y()+m_propertySize.y());
|
||||
}
|
||||
|
||||
void ewol::Shaper::SetOrigin(const vec2& newOri)
|
||||
void ewol::Shaper::SetOrigin(const vec2& _newOri)
|
||||
{
|
||||
if (m_propertyOrigin != newOri) {
|
||||
m_propertyOrigin = newOri;
|
||||
if (m_propertyOrigin != _newOri) {
|
||||
m_propertyOrigin = _newOri;
|
||||
UpdateVectex();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ewol::Shaper::SetSize(const vec2& newSize)
|
||||
void ewol::Shaper::SetSize(const vec2& _newSize)
|
||||
{
|
||||
if (m_propertySize != newSize) {
|
||||
m_propertySize = newSize;
|
||||
if (m_propertySize != _newSize) {
|
||||
m_propertySize = _newSize;
|
||||
UpdateVectex();
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::Shaper::SetInsideSize(const vec2& newInsideSize)
|
||||
void ewol::Shaper::SetInsideSize(const vec2& _newInsideSize)
|
||||
{
|
||||
m_propertyInsideSize = newInsideSize;
|
||||
m_propertyInsideSize = _newInsideSize;
|
||||
}
|
||||
|
||||
void ewol::Shaper::SetInsidePos(const vec2& newInsidePos)
|
||||
void ewol::Shaper::SetInsidePos(const vec2& _newInsidePos)
|
||||
{
|
||||
m_propertyInsidePosition = newInsidePos;
|
||||
m_propertyInsidePosition = _newInsidePos;
|
||||
}
|
||||
|
||||
|
||||
@ -263,11 +263,11 @@ vec2 ewol::Shaper::GetPadding(void)
|
||||
}
|
||||
|
||||
|
||||
void ewol::Shaper::SetSource(const etk::UString& newFile)
|
||||
void ewol::Shaper::SetSource(const etk::UString& _newFile)
|
||||
{
|
||||
Clear();
|
||||
UnLoadProgram();
|
||||
m_name = newFile;
|
||||
m_name = _newFile;
|
||||
LoadProgram();
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ namespace ewol
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
* @param[in] imageName Name of the file that might be loaded
|
||||
* @param[in] _shaperName Name of the file that might be loaded
|
||||
*/
|
||||
Shaper(const etk::UString& shaperName="");
|
||||
Shaper(const etk::UString& _shaperName="");
|
||||
/**
|
||||
* @brief generic destructor
|
||||
*/
|
||||
@ -86,11 +86,11 @@ namespace ewol
|
||||
void Clear(void);
|
||||
/**
|
||||
* @brief change the current status in an other
|
||||
* @param[in] the next new status requested
|
||||
* @param[in] _newStatusId the next new status requested
|
||||
* @return true The widget must call this fuction periodicly (and redraw itself)
|
||||
* @return false No need to request the periodic call.
|
||||
*/
|
||||
bool ChangeStatusIn(int32_t newStatusId);
|
||||
bool ChangeStatusIn(int32_t _newStatusId);
|
||||
/**
|
||||
* @brief Get the current displayed status of the shaper
|
||||
* @return The Status Id
|
||||
@ -103,41 +103,46 @@ namespace ewol
|
||||
int32_t GetNextDisplayedStatus(void);
|
||||
/**
|
||||
* @brief Same as the widfget periodic call (this is for change display)
|
||||
* @param[in] localTime The current time of the call.
|
||||
* @param[in] _localTime The current time of the call.
|
||||
* @return true The widget must call this fuction periodicly (and redraw itself)
|
||||
* @return false No need to request the periodic call.
|
||||
*/
|
||||
bool PeriodicCall(int64_t localTime);
|
||||
bool PeriodicCall(int64_t _localTime);
|
||||
/**
|
||||
* @brief Set the widget origin (needed fot the display)
|
||||
* @param[in] newOri : the new widget origin
|
||||
* @param[in] _newOri : the new widget origin
|
||||
*/
|
||||
void SetOrigin(const vec2& newOri);
|
||||
void SetOrigin(const vec2& _newOri);
|
||||
/**
|
||||
* @brief Set the widget size (needed fot the display)
|
||||
* @param[in] newSize : the new widget size
|
||||
* @param[in] _newSize : the new widget size
|
||||
*/
|
||||
void SetSize(const vec2& newSize);
|
||||
void SetSize(const vec2& _newSize);
|
||||
/**
|
||||
* @brief Set the internal widget size
|
||||
* @param[in] newInsidePos : the subelement size.
|
||||
* @param[in] _newInsidePos : the subelement size.
|
||||
*/
|
||||
void SetInsideSize(const vec2& newInsideSize);
|
||||
void SetInsideSize(const vec2& _newInsideSize);
|
||||
/**
|
||||
* @brief Set the internal widget position
|
||||
* @param[in] newInsidePos : the subelement position
|
||||
* @param[in] _newInsidePos : the subelement position
|
||||
*/
|
||||
void SetInsidePos(const vec2& newInsidePos);
|
||||
void SetInsidePos(const vec2& _newInsidePos);
|
||||
/**
|
||||
* @brief Get the padding declared by the user in the config file
|
||||
* @return the padding property
|
||||
*/
|
||||
vec2 GetPadding(void);
|
||||
/**
|
||||
* @brief Change the image Source ==> can not be done to display 2 images at the same time ...
|
||||
* @param[in] newFile New file of the Image
|
||||
* @brief Change the shaper Source
|
||||
* @param[in] _newFile New file of the shaper
|
||||
*/
|
||||
void SetSource(const etk::UString& newFile);
|
||||
void SetSource(const etk::UString& _newFile);
|
||||
/**
|
||||
* @brief Get the shaper file Source
|
||||
* @return the shapper file name
|
||||
*/
|
||||
const etk::UString& GetSource(void) const { return m_name; };
|
||||
/**
|
||||
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
|
||||
* @return the validity od the resources.
|
||||
|
@ -45,26 +45,6 @@ void ewol::eSystemInput::SetDpi(int32_t newDPI)
|
||||
CalculateLimit();
|
||||
}
|
||||
|
||||
void ewol::eSystemInput::CleanElement(InputPoperty_ts *eventTable, int32_t idInput)
|
||||
{
|
||||
if (NULL==eventTable) {
|
||||
return;
|
||||
}
|
||||
//EWOL_INFO("CleanElement[" << idInput << "] = @" << (int64_t)eventTable);
|
||||
eventTable[idInput].isUsed = false;
|
||||
eventTable[idInput].destinationInputId = 0;
|
||||
eventTable[idInput].lastTimeEvent = 0;
|
||||
eventTable[idInput].curentWidgetEvent = NULL;
|
||||
eventTable[idInput].origin.setValue(0,0);
|
||||
eventTable[idInput].size.setValue(99999999,99999999);
|
||||
eventTable[idInput].downStart.setValue(0,0);
|
||||
eventTable[idInput].isDown = false;
|
||||
eventTable[idInput].isInside = false;
|
||||
eventTable[idInput].nbClickEvent = 0;
|
||||
eventTable[idInput].posEvent.setValue(0,0);
|
||||
}
|
||||
|
||||
|
||||
bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te _type,
|
||||
ewol::Widget* _destWidget,
|
||||
int32_t _IdInput,
|
||||
@ -84,6 +64,40 @@ bool ewol::eSystemInput::localEventInput(ewol::keyEvent::type_te _type,
|
||||
return false;
|
||||
}
|
||||
|
||||
void ewol::eSystemInput::AbortElement(InputPoperty_ts *_eventTable, int32_t _idInput, ewol::keyEvent::type_te _type)
|
||||
{
|
||||
if (NULL==_eventTable) {
|
||||
return;
|
||||
}
|
||||
if (_eventTable[_idInput].isUsed==true) {
|
||||
localEventInput(_type,
|
||||
_eventTable[_idInput].curentWidgetEvent,
|
||||
_eventTable[_idInput].destinationInputId,
|
||||
ewol::keyEvent::statusAbort,
|
||||
_eventTable[_idInput].posEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::eSystemInput::CleanElement(InputPoperty_ts *_eventTable, int32_t _idInput)
|
||||
{
|
||||
if (NULL==_eventTable) {
|
||||
return;
|
||||
}
|
||||
//EWOL_INFO("CleanElement[" << idInput << "] = @" << (int64_t)eventTable);
|
||||
_eventTable[_idInput].isUsed = false;
|
||||
_eventTable[_idInput].destinationInputId = 0;
|
||||
_eventTable[_idInput].lastTimeEvent = 0;
|
||||
_eventTable[_idInput].curentWidgetEvent = NULL;
|
||||
_eventTable[_idInput].origin.setValue(0,0);
|
||||
_eventTable[_idInput].size.setValue(99999999,99999999);
|
||||
_eventTable[_idInput].downStart.setValue(0,0);
|
||||
_eventTable[_idInput].isDown = false;
|
||||
_eventTable[_idInput].isInside = false;
|
||||
_eventTable[_idInput].nbClickEvent = 0;
|
||||
_eventTable[_idInput].posEvent.setValue(0,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ewol::eSystemInput::TransfertEvent(ewol::Widget* source, ewol::Widget* destination)
|
||||
{
|
||||
@ -149,7 +163,9 @@ void ewol::eSystemInput::NewLayerSet(void)
|
||||
{
|
||||
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
// remove the property of this input ...
|
||||
AbortElement(m_eventInputSaved, iii, ewol::keyEvent::typeFinger);
|
||||
CleanElement(m_eventInputSaved, iii);
|
||||
AbortElement(m_eventMouseSaved, iii, ewol::keyEvent::typeMouse);
|
||||
CleanElement(m_eventMouseSaved, iii);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ namespace ewol
|
||||
#define MAX_MANAGE_INPUT (10)
|
||||
InputPoperty_ts m_eventInputSaved[MAX_MANAGE_INPUT];
|
||||
InputPoperty_ts m_eventMouseSaved[MAX_MANAGE_INPUT];
|
||||
void AbortElement(InputPoperty_ts *eventTable, int32_t idInput, ewol::keyEvent::type_te _type);
|
||||
void CleanElement(InputPoperty_ts *eventTable, int32_t idInput);
|
||||
/**
|
||||
* @brief generate the event on the destinated widget.
|
||||
|
@ -25,6 +25,7 @@ const char* const widget::Button::eventValue = "ewol-widget-button-event-va
|
||||
const char* const widget::Button::configToggle = "toggle";
|
||||
const char* const widget::Button::configLock = "lock";
|
||||
const char* const widget::Button::configValue = "value";
|
||||
const char* const widget::Button::configShaper = "shaper";
|
||||
|
||||
|
||||
// DEFINE for the shader display system :
|
||||
@ -73,6 +74,7 @@ widget::Button::Button(const etk::UString& _shaperName) :
|
||||
RegisterConfig(configToggle, "bool", NULL, "The Button can toogle");
|
||||
RegisterConfig(configValue, "bool", NULL, "Basic value of the widget");
|
||||
RegisterConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder");
|
||||
RegisterConfig(configShaper, "string", NULL, "the display name for config file");
|
||||
|
||||
// shaper satatus update:
|
||||
CheckStatus();
|
||||
@ -92,6 +94,7 @@ widget::Button::~Button(void)
|
||||
void widget::Button::SetShaperName(const etk::UString& _shaperName)
|
||||
{
|
||||
m_shaper.SetSource(_shaperName);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
void widget::Button::SetSubWidget(ewol::Widget* _subWidget)
|
||||
@ -508,6 +511,10 @@ bool widget::Button::OnSetConfig(const ewol::EConfig& _conf)
|
||||
SetValue(_conf.GetData().ToBool());
|
||||
return true;
|
||||
}
|
||||
if (_conf.GetConfig() == configShaper) {
|
||||
SetShaperName(_conf.GetData());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -550,6 +557,10 @@ bool widget::Button::OnGetConfig(const char* _config, etk::UString& _result) con
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_config == configShaper) {
|
||||
_result = m_shaper.GetSource();;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace widget {
|
||||
static const char* const configToggle;
|
||||
static const char* const configLock;
|
||||
static const char* const configValue;
|
||||
static const char* const configShaper;
|
||||
typedef enum {
|
||||
lockNone, //!< normal status of the button
|
||||
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
|
||||
|
@ -16,8 +16,9 @@
|
||||
#define __class__ "ContextMenu"
|
||||
|
||||
|
||||
const char* const widget::ContextMenu::configArrowPosition = "ewol-widget-context-menu-config-arrow-position";
|
||||
const char* const widget::ContextMenu::configArrowMode = "ewol-widget-context-menu-config-arrow-mode";
|
||||
const char* const widget::ContextMenu::configArrowPosition = "arrow-position";
|
||||
const char* const widget::ContextMenu::configArrowMode = "arrow-mode";
|
||||
const char* const widget::ContextMenu::configShaper = "shaper";
|
||||
|
||||
static ewol::Widget* Create(void)
|
||||
{
|
||||
@ -36,14 +37,16 @@ void widget::ContextMenu::UnInit(void)
|
||||
|
||||
|
||||
|
||||
widget::ContextMenu::ContextMenu(void)
|
||||
widget::ContextMenu::ContextMenu(const etk::UString& _shaperName) :
|
||||
m_shaper(_shaperName)
|
||||
{
|
||||
// add basic configurations :
|
||||
RegisterConfig(configArrowPosition, "vec2", NULL, "position of the arrow");
|
||||
RegisterConfig(configArrowMode, "list", "none;left;buttom;right;top", "Position of the arrow in the pop-up");
|
||||
RegisterConfig(configShaper, "string", NULL, "the display name for config file");
|
||||
|
||||
m_userExpand.setValue(false,false);
|
||||
|
||||
m_padding.setValue(4,4);
|
||||
m_offset = 20;
|
||||
|
||||
m_colorBackGroung = draw::color::white;
|
||||
@ -61,13 +64,20 @@ widget::ContextMenu::~ContextMenu(void)
|
||||
|
||||
}
|
||||
|
||||
void widget::ContextMenu::SetShaperName(const etk::UString& _shaperName)
|
||||
{
|
||||
m_shaper.SetSource(_shaperName);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
void widget::ContextMenu::CalculateSize(const vec2& availlable)
|
||||
|
||||
void widget::ContextMenu::CalculateSize(const vec2& _availlable)
|
||||
{
|
||||
//EWOL_DEBUG("CalculateSize=" << availlable);
|
||||
// pop-up fill all the display :
|
||||
m_size = availlable;
|
||||
|
||||
m_size = _availlable;
|
||||
vec2 padding = m_shaper.GetPadding();
|
||||
EWOL_DEBUG("our origin=" << m_origin << " size=" << m_size);
|
||||
if (NULL != m_subWidget) {
|
||||
vec2 subWidgetSize;
|
||||
vec2 subWidgetOrigin;
|
||||
@ -85,8 +95,7 @@ void widget::ContextMenu::CalculateSize(const vec2& availlable)
|
||||
subWidgetSize.setY((int32_t)subWidgetSize.y());
|
||||
|
||||
// set config to the Sub-widget
|
||||
switch (m_arrawBorder)
|
||||
{
|
||||
switch (m_arrawBorder) {
|
||||
case widget::CONTEXT_MENU_MARK_TOP:
|
||||
subWidgetOrigin.setX((int32_t)(m_arrowPos.x() - subWidgetSize.x()/2));
|
||||
subWidgetOrigin.setY((int32_t)(m_arrowPos.y() - m_offset - subWidgetSize.y()));
|
||||
@ -103,26 +112,27 @@ void widget::ContextMenu::CalculateSize(const vec2& availlable)
|
||||
break;
|
||||
}
|
||||
// set the widget position at the border of the screen
|
||||
subWidgetOrigin.setX( (int32_t)( etk_max(0, (subWidgetOrigin.x()-m_padding.x()*2))
|
||||
+ m_padding.x()*2) );
|
||||
subWidgetOrigin.setY( (int32_t)( etk_max(0, (subWidgetOrigin.y()-m_padding.y()*2))
|
||||
+ m_padding.y()*2) );
|
||||
subWidgetOrigin.setX( (int32_t)( etk_max(0, (subWidgetOrigin.x()-padding.x()*2))
|
||||
+ padding.x()*2) );
|
||||
subWidgetOrigin.setY( (int32_t)( etk_max(0, (subWidgetOrigin.y()-padding.y()*2))
|
||||
+ padding.y()*2) );
|
||||
switch (m_arrawBorder)
|
||||
{
|
||||
default:
|
||||
case widget::CONTEXT_MENU_MARK_TOP:
|
||||
case widget::CONTEXT_MENU_MARK_BOTTOM:
|
||||
if (m_arrowPos.x() <= m_offset ) {
|
||||
subWidgetOrigin.setX(m_arrowPos.x()+m_padding.x());
|
||||
subWidgetOrigin.setX(m_arrowPos.x()+padding.x());
|
||||
}
|
||||
break;
|
||||
case widget::CONTEXT_MENU_MARK_RIGHT:
|
||||
case widget::CONTEXT_MENU_MARK_LEFT:
|
||||
if (m_arrowPos.y() <= m_offset ) {
|
||||
subWidgetOrigin.setY(m_arrowPos.y()+m_padding.y());
|
||||
subWidgetOrigin.setY(m_arrowPos.y()+padding.y());
|
||||
}
|
||||
break;
|
||||
}
|
||||
EWOL_DEBUG(" ==> sub origin=" << subWidgetOrigin << " size=" << subWidgetSize);
|
||||
m_subWidget->SetOrigin(subWidgetOrigin);
|
||||
m_subWidget->CalculateSize(subWidgetSize);
|
||||
}
|
||||
@ -132,36 +142,31 @@ void widget::ContextMenu::CalculateSize(const vec2& availlable)
|
||||
|
||||
void widget::ContextMenu::CalculateMinMaxSize(void)
|
||||
{
|
||||
//EWOL_DEBUG("CalculateMinSize");
|
||||
m_userExpand.setValue(false,false);
|
||||
m_minSize.setValue(50,50);
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->CalculateMinMaxSize();
|
||||
m_minSize = m_subWidget->GetCalculateMinSize();
|
||||
}
|
||||
// call main class to calculate the min size...
|
||||
widget::Container::CalculateMinMaxSize();
|
||||
// add padding of the display
|
||||
m_minSize += m_shaper.GetPadding();
|
||||
//EWOL_DEBUG("CalculateMinSize=>>" << m_minSize);
|
||||
MarkToRedraw();
|
||||
}
|
||||
|
||||
void widget::ContextMenu::SystemDraw(const ewol::DrawProperty& _displayProp)
|
||||
{
|
||||
ewol::Widget::SystemDraw(_displayProp);
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->SystemDraw(_displayProp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void widget::ContextMenu::OnDraw(void)
|
||||
{
|
||||
m_compositing.Draw();
|
||||
m_shaper.Draw();
|
||||
}
|
||||
|
||||
|
||||
void widget::ContextMenu::OnRegenerateDisplay(void)
|
||||
{
|
||||
// call upper class :
|
||||
widget::Container::OnRegenerateDisplay();
|
||||
if (true == NeedRedraw()) {
|
||||
m_compositing.Clear();
|
||||
m_shaper.Clear();
|
||||
vec2 padding = m_shaper.GetPadding();
|
||||
|
||||
if (NULL != m_subWidget) {
|
||||
vec2 tmpSize = m_subWidget->GetSize();
|
||||
vec2 tmpOrigin = m_subWidget->GetOrigin();
|
||||
@ -174,13 +179,13 @@ void widget::ContextMenu::OnRegenerateDisplay(void)
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
if (m_arrowPos.x() <= tmpOrigin.x() ) {
|
||||
float laking = m_offset - m_padding.y();
|
||||
float laking = m_offset - padding.y();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()-laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
} else {
|
||||
float laking = m_offset - m_padding.y();
|
||||
float laking = m_offset - padding.y();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()-laking, 0.0f) );
|
||||
@ -191,13 +196,13 @@ void widget::ContextMenu::OnRegenerateDisplay(void)
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0) );
|
||||
m_compositing.AddVertex();
|
||||
if (m_arrowPos.x() <= tmpOrigin.x() ) {
|
||||
int32_t laking = m_offset - m_padding.y();
|
||||
int32_t laking = m_offset - padding.y();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x(), m_arrowPos.y()+laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
} else {
|
||||
int32_t laking = m_offset - m_padding.y();
|
||||
int32_t laking = m_offset - padding.y();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
|
||||
m_compositing.AddVertex();
|
||||
m_compositing.SetPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()+laking, 0.0f) );
|
||||
@ -210,17 +215,15 @@ void widget::ContextMenu::OnRegenerateDisplay(void)
|
||||
EWOL_TODO("later");
|
||||
break;
|
||||
}
|
||||
m_compositing.SetPos(vec3(tmpOrigin.x()-m_padding.x(), tmpOrigin.y() - m_padding.y(), 0.0f) );
|
||||
m_compositing.RectangleWidth(vec3(tmpSize.x() + m_padding.x()*2, tmpSize.y() + m_padding.y()*2, 0.0f) );
|
||||
// set the area in white ...
|
||||
m_compositing.SetColor(m_colorBackGroung);
|
||||
m_compositing.SetPos(vec3(tmpOrigin.x(), tmpOrigin.y(), 0.0f) );
|
||||
m_compositing.RectangleWidth(vec3(tmpSize.x(), tmpSize.y(), 0.0f) );
|
||||
|
||||
vec2 shaperOrigin = tmpOrigin-padding;
|
||||
vec2 shaperSize = tmpSize+padding*2.0f;
|
||||
m_shaper.SetOrigin(vec2ClipInt32(shaperOrigin));
|
||||
m_shaper.SetSize(vec2ClipInt32(shaperSize));
|
||||
m_shaper.SetInsidePos(vec2ClipInt32(shaperOrigin+padding));
|
||||
m_shaper.SetInsideSize(vec2ClipInt32(shaperSize-padding*2.0f));
|
||||
}
|
||||
}
|
||||
if (NULL != m_subWidget) {
|
||||
m_subWidget->OnRegenerateDisplay();
|
||||
}
|
||||
}
|
||||
bool widget::ContextMenu::OnEventInput(const ewol::EventInput& _event)
|
||||
{
|
||||
@ -261,10 +264,7 @@ ewol::Widget* widget::ContextMenu::GetWidgetAtPos(const vec2& pos)
|
||||
}
|
||||
|
||||
|
||||
const char* const widget::ContextMenu::configArrowPosition = "ewol-widget-context-menu-config-arrow-position";
|
||||
const char* const widget::ContextMenu::configArrowMode = "ewol-widget-context-menu-config-arrow-mode";
|
||||
|
||||
bool widget::Button::OnSetConfig(const ewol::EConfig& _conf)
|
||||
bool widget::ContextMenu::OnSetConfig(const ewol::EConfig& _conf)
|
||||
{
|
||||
if (true == widget::Container::OnSetConfig(_conf)) {
|
||||
return true;
|
||||
@ -287,10 +287,14 @@ bool widget::Button::OnSetConfig(const ewol::EConfig& _conf)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_conf.GetConfig() == configShaper) {
|
||||
SetShaperName(_conf.GetData());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool widget::Button::OnGetConfig(const char* _config, etk::UString& _result) const
|
||||
bool widget::ContextMenu::OnGetConfig(const char* _config, etk::UString& _result) const
|
||||
{
|
||||
if (true == widget::Container::OnGetConfig(_config, _result)) {
|
||||
return true;
|
||||
@ -320,6 +324,10 @@ bool widget::Button::OnGetConfig(const char* _config, etk::UString& _result) con
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (_config == configShaper) {
|
||||
_result = m_shaper.GetSource();;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/widget/Container.h>
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/compositing/Shaper.h>
|
||||
|
||||
namespace widget {
|
||||
typedef enum {
|
||||
@ -31,18 +32,27 @@ namespace widget {
|
||||
// Config list of properties
|
||||
static const char* const configArrowPosition;
|
||||
static const char* const configArrowMode;
|
||||
static const char* const configShaper;
|
||||
public:
|
||||
ContextMenu(void);
|
||||
ContextMenu(const etk::UString& _shaperName="THEME:GUI:widgetContextMenu.conf");
|
||||
virtual ~ContextMenu(void);
|
||||
private:
|
||||
ewol::Shaper m_shaper; //!< Compositing theme.
|
||||
public:
|
||||
/**
|
||||
* @brief Set the shaper name (use the contructer one this permit to not noad unused shaper)
|
||||
* @param[in] _shaperName The new shaper filename
|
||||
*/
|
||||
void SetShaperName(const etk::UString& _shaperName);
|
||||
private:
|
||||
// TODO : Rework the displayer ....
|
||||
ewol::Drawing m_compositing;
|
||||
draw::Color m_colorBackGroung;
|
||||
draw::Color m_colorBorder;
|
||||
|
||||
vec2 m_padding;
|
||||
vec2 m_arrowPos;
|
||||
float m_offset;
|
||||
private:
|
||||
vec2 m_arrowPos;
|
||||
markPosition_te m_arrawBorder;
|
||||
public:
|
||||
void SetPositionMark(markPosition_te position, vec2 arrowPos);
|
||||
@ -51,7 +61,6 @@ namespace widget {
|
||||
virtual bool OnSetConfig(const ewol::EConfig& _conf);
|
||||
virtual bool OnGetConfig(const char* _config, etk::UString& _result) const;
|
||||
public: // Derived function
|
||||
virtual void SystemDraw(const ewol::DrawProperty& displayProp);
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
virtual bool OnEventInput(const ewol::EventInput& _event);
|
||||
virtual void CalculateSize(const vec2& availlable);
|
||||
|
@ -119,6 +119,7 @@ def Create(target):
|
||||
|
||||
myModule.CopyFolder('../data/theme/default/widgetEntry.*','theme/default')
|
||||
myModule.CopyFolder('../data/theme/rounded/widgetEntry.*','theme/rounded')
|
||||
myModule.CopyFolder('../data/theme/default/widgetContextMenu.*','theme/default')
|
||||
myModule.CopyFolder('../data/theme/default/widgetButton.*','theme/default')
|
||||
myModule.CopyFolder('../data/theme/rounded/widgetButton.*','theme/rounded')
|
||||
myModule.CopyFolder('../data/textured.*','')
|
||||
|
Loading…
x
Reference in New Issue
Block a user