Focus: added it at the widget manager, but no change ewpected with the windows for now

This commit is contained in:
Edouard Dupin 2011-11-22 14:02:58 +01:00
parent 5a5b358a46
commit 80f4796eec
7 changed files with 121 additions and 8 deletions

View File

@ -70,7 +70,13 @@ void ewol::UnInit(void)
void ewol::DisplayWindows(ewol::Windows * windows)
{
// Remove current Focus :
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
// set display of the windows :
guiAbstraction::SetDisplayOnWindows(windows);
// Set the new default Focus :
ewol::widgetManager::FocusSetDefault(windows);
}

View File

@ -52,6 +52,12 @@ extern const char * ewolLibName;
# define EWOL_DEBUG(data) do {}while(0)
#endif
#if EWOL_DEBUG_LEVEL > 3
# define EWOL_VERBOSE(data) ETK_VERBOSE(ewolLibName, data)
#else
# define EWOL_VERBOSE(data) do {}while(0)
#endif
#define EWOL_TODO(data) EWOL_WARNING("TODO : " << data)
#define EWOL_ASSERT(cond, data) ETK_ASSERT(ewolLibName, cond, data)

View File

@ -46,6 +46,8 @@ ewol::Widget::Widget(void)
m_genericDraw = true;
m_specificDraw = false;
ewol::widgetManager::Add(this);
m_canFocus = false;
m_hasFocus = false;
}
ewol::Widget::~Widget(void)

View File

@ -30,16 +30,28 @@
// internal element of the widget manager :
static etk::VectorType<ewol::Widget*> m_widgetList; // all widget allocated ==> all time increment ... never removed ...
// For the focus Management
static ewol::Widget * m_focusWidgetDefault = NULL;
static ewol::Widget * m_focusWidgetCurrent = NULL;
void ewol::widgetManager::Init(void)
{
EWOL_INFO("user widget manager");
}
void ewol::widgetManager::UnInit(void)
{
EWOL_INFO("Realease all FOCUS");
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
EWOL_INFO(" Remove missing user widget");
for(int32_t iii=0; iii<m_widgetList.Size(); iii++) {
ewol::widgetManager::Rm(iii);
if (m_widgetList[iii]!=NULL) {
EWOL_WARNING("Un-Removed widget ... id=" << iii);
delete(m_widgetList[iii]);
m_widgetList[iii]=NULL;
}
}
m_widgetList.Clear();
}
@ -50,6 +62,8 @@ void ewol::widgetManager::Add(ewol::Widget * newWidget)
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
if (-1 == tmpID) {
m_widgetList.PushBack(newWidget);
} else {
EWOL_WARNING("Widget Already added to the widget manager, id=" << tmpID);
}
}
@ -57,7 +71,7 @@ void ewol::widgetManager::Rm(ewol::Widget * newWidget)
{
// check existance
int32_t tmpID = ewol::widgetManager::GetId(newWidget);
if (-1 == tmpID) {
if (-1 != tmpID) {
ewol::widgetManager::Rm(tmpID);
} else {
EWOL_ERROR("Widget already removed ...");
@ -68,7 +82,12 @@ void ewol::widgetManager::Rm(int32_t widgetId)
{
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
if (m_widgetList[widgetId]!=NULL) {
delete(m_widgetList[widgetId]);
if (m_focusWidgetCurrent==m_widgetList[widgetId]) {
ewol::widgetManager::FocusRelease();
}
if (m_focusWidgetDefault==m_widgetList[widgetId]) {
ewol::widgetManager::FocusSetDefault(NULL);
}
m_widgetList[widgetId]=NULL;
}
}
@ -87,10 +106,84 @@ int32_t ewol::widgetManager::GetId(ewol::Widget * newWidget)
return -1;
}
ewol::Widget * Get(int32_t widgetId)
ewol::Widget * ewol::widgetManager::Get(int32_t widgetId)
{
if (0 <= widgetId && widgetId < m_widgetList.Size()) {
return m_widgetList[widgetId];
}
return NULL;
}
/* *************************************************************************
* Focus Area :
* *************************************************************************/
void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
{
if (NULL == newWidget) {
// nothing to do ...
return;
}
if (false == newWidget->CanHaveFocus()) {
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget));
return;
}
if (newWidget == m_focusWidgetCurrent) {
// nothing to do ...
return;
}
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = newWidget;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->SetFocus();
}
}
void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget)
{
if (NULL != newWidget && false == newWidget->CanHaveFocus()) {
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget));
return;
}
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = newWidget;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->SetFocus();
}
}
m_focusWidgetDefault = newWidget;
}
void ewol::widgetManager::FocusRelease(void)
{
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
// nothink to do ...
return;
}
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = m_focusWidgetDefault;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent));
m_focusWidgetCurrent->SetFocus();
}
}
ewol::Widget * ewol::widgetManager::FocusGet(void)
{
return m_focusWidgetCurrent;
}

View File

@ -40,6 +40,11 @@ namespace ewol {
void Rm( int32_t widgetId);
int32_t GetId( ewol::Widget * newWidget);
ewol::Widget * Get( int32_t widgetId);
void FocusKeep( ewol::Widget * newWidget); // set the focus at the specific widget
void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter
void FocusRelease( void); // Release focus from the current widget to the default
ewol::Widget * FocusGet( void);
};
};

View File

@ -46,6 +46,7 @@ const char * ewolEventWindowsExpend = "ewol Windows expend/unExpend";
ewol::Windows::Windows(void)
{
SetCanHaveFocus(true);
m_subWidget = NULL;
// enable specific drawing system ...
SpecificDrawEnable();

View File

@ -28,9 +28,9 @@
const char * ewolEventButtonPressed = "ewol Button Pressed";
const char * ewolEventButtonEnter = "ewol Button Enter";
const char * ewolEventButtonLeave = "ewol Button Leave";
const char * const ewolEventButtonPressed = "ewol Button Pressed";
const char * const ewolEventButtonEnter = "ewol Button Enter";
const char * const ewolEventButtonLeave = "ewol Button Leave";