change capacities of the button image && simplify java

This commit is contained in:
Edouard Dupin 2012-07-02 17:41:51 +02:00
parent 8fcd8369cd
commit 67c039f8d6
5 changed files with 72 additions and 22 deletions

View File

@ -148,7 +148,7 @@ public class __PROJECT_NAME__ extends Activity {
super.onResume(); super.onResume();
mGLView.onResume(); mGLView.onResume();
mAudioThread = new Thread(mStreams); mAudioThread = new Thread(mStreams);
if (mAudioThread ~= NULL) { if (mAudioThread != null) {
mAudioThread.start(); mAudioThread.start();
} }
// call C // call C
@ -159,11 +159,13 @@ public class __PROJECT_NAME__ extends Activity {
{ {
super.onPause(); super.onPause();
mGLView.onPause(); mGLView.onPause();
if (mAudioThread ~= NULL) { if (mAudioThread != null) {
// request audio stop // request audio stop
mAudioThread.AutoStop(); mStreams.AutoStop();
// wait the thread ended ... // wait the thread ended ...
mAudioThread.join(); try {
mAudioThread.join();
} catch(InterruptedException e) { }
} }
// call C // call C
interfaceJNI.ActivityOnPause(); interfaceJNI.ActivityOnPause();

View File

@ -50,12 +50,12 @@ public class interfaceJNI {
// Audio section ... // Audio section ...
public static native void IOAudioPlayback(short[] bufferData, int frames, int nbChannels); public static native void IOAudioPlayback(short[] bufferData, int frames, int nbChannels);
public static int EWOL_SYSTEM_KEY__VOLUME_UP = 1; public static final int EWOL_SYSTEM_KEY__VOLUME_UP = 1;
public static int EWOL_SYSTEM_KEY__VOLUME_DOWN = 2; public static final int EWOL_SYSTEM_KEY__VOLUME_DOWN = 2;
public static int EWOL_SYSTEM_KEY__MENU = 3; public static final int EWOL_SYSTEM_KEY__MENU = 3;
public static int EWOL_SYSTEM_KEY__CAMERA = 4; public static final int EWOL_SYSTEM_KEY__CAMERA = 4;
public static int EWOL_SYSTEM_KEY__HOME = 5; public static final int EWOL_SYSTEM_KEY__HOME = 5;
public static int EWOL_SYSTEM_KEY__POWER = 6; public static final int EWOL_SYSTEM_KEY__POWER = 6;
public static native void IOKeyboardEventKeySystem(int keyVal, boolean isDown); public static native void IOKeyboardEventKeySystem(int keyVal, boolean isDown);
// renderer Event : // renderer Event :
public static native void RenderInit(); public static native void RenderInit();

View File

@ -73,7 +73,11 @@ void TOOLS_DisplayTime(void)
} }
#ifdef __PLATFORM__Android
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_VERBOSE; etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_VERBOSE;
#else
etk::logLevel_te g_requestedLevel = etk::LOG_LEVEL_ERROR;
#endif
void GeneralDebugSetLevel(etk::logLevel_te ccc) { void GeneralDebugSetLevel(etk::logLevel_te ccc) {
g_requestedLevel = etk::LOG_LEVEL_VERBOSE; g_requestedLevel = ccc;
} }

View File

@ -41,7 +41,7 @@ void ewol::WIDGET_ButtonImageInit(void)
#undef __class__ #undef __class__
#define __class__ "ButtonImage" #define __class__ "ButtonImage"
ewol::ButtonImage::ButtonImage(etk::UString newLabel) ewol::ButtonImage::ButtonImage(etk::UString imageName)
{ {
AddEventId(ewolEventButtonPressed); AddEventId(ewolEventButtonPressed);
AddEventId(ewolEventButtonDown); AddEventId(ewolEventButtonDown);
@ -53,12 +53,14 @@ ewol::ButtonImage::ButtonImage(etk::UString newLabel)
m_over = false; m_over = false;
m_down = false; m_down = false;
m_value = false; m_value = false;
m_image = imageName;
for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) { for (int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
m_OOImage[iii] = NULL; m_OOImage[iii] = NULL;
m_OOImageBg1[iii] = NULL; m_OOImageBg1[iii] = NULL;
m_OOImageBG2[iii] = NULL; m_OOImageBG2[iii] = NULL;
m_resetNeeded[iii] = false; m_resetNeeded[iii] = false;
} }
m_toggleMode = false;
} }
@ -134,12 +136,29 @@ const char * const ewol::ButtonImage::GetObjectType(void)
void ewol::ButtonImage::SetValue(bool val) void ewol::ButtonImage::SetValue(bool val)
{ {
if (true == m_toggleMode) {
m_value = val;
MarkToReedraw();
}
} }
bool ewol::ButtonImage::GetValue(void) bool ewol::ButtonImage::GetValue(void)
{ {
return false; return m_value;
}
void ewol::ButtonImage::SetToggleMode(bool val)
{
m_toggleMode = val;
if (m_toggleMode == false) {
m_value = false;
}
MarkToReedraw();
}
bool ewol::ButtonImage::GetToggleMode(void)
{
return m_toggleMode;
} }
@ -222,21 +241,29 @@ bool ewol::ButtonImage::OnEventInput(ewol::inputType_te type, int32_t IdInput, e
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) { if (1 == IdInput) {
if(ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) { if(ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
GenerateEventId(ewolEventButtonDown);
m_down = true; m_down = true;
m_value = true; if (false == m_toggleMode) {
m_value = true;
}
GenerateEventId(ewolEventButtonDown, (m_value)?"true":"false");
MarkToReedraw(); MarkToReedraw();
} }
if(ewol::EVENT_INPUT_TYPE_UP == typeEvent) { if(ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
GenerateEventId(ewolEventButtonUp);
m_down = false; m_down = false;
m_value = false; if (false == m_toggleMode) {
m_value = false;
}
GenerateEventId(ewolEventButtonUp, (m_value)?"true":"false");
MarkToReedraw(); MarkToReedraw();
} }
if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent || ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { || ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
GenerateEventId(ewolEventButtonPressed); if (true == m_toggleMode) {
m_value = (true==m_value) ? false : true;
}
GenerateEventId(ewolEventButtonPressed, (m_value)?"true":"false");
MarkToReedraw(); MarkToReedraw();
return true; return true;
} }
@ -281,9 +308,23 @@ bool ewol::ButtonImage::OnEventInput(ewol::inputType_te type, int32_t IdInput, e
bool ewol::ButtonImage::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData) bool ewol::ButtonImage::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData)
{ {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( typeEvent == ewol::EVENT_KB_TYPE_DOWN if (unicodeData == '\r') {
&& unicodeData == '\r') { if(typeEvent == ewol::EVENT_KB_TYPE_DOWN) {
GenerateEventId(ewolEventButtonEnter); m_down = true;
if (false == m_toggleMode) {
m_value = true;
GenerateEventId(ewolEventButtonEnter, (m_value)?"true":"false");
}
} else if(typeEvent == ewol::EVENT_KB_TYPE_UP) {
m_down = false;
if (false == m_toggleMode) {
m_value = false;
GenerateEventId(ewolEventButtonEnter, (m_value)?"true":"false");
} else {
m_value = (true==m_value) ? false : true;
GenerateEventId(ewolEventButtonEnter, (m_value)?"true":"false");
}
}
} }
return false; return false;
} }

View File

@ -57,6 +57,8 @@ namespace ewol {
void SetImageSelected(etk::UString imageName); void SetImageSelected(etk::UString imageName);
void SetValue(bool val); void SetValue(bool val);
bool GetValue(void); bool GetValue(void);
void SetToggleMode(bool val);
bool GetToggleMode(void);
private: private:
etk::UString m_image; etk::UString m_image;
bool m_resetNeeded[NB_BOUBLE_BUFFER]; bool m_resetNeeded[NB_BOUBLE_BUFFER];
@ -68,6 +70,7 @@ namespace ewol {
bool m_over; bool m_over;
bool m_down; bool m_down;
bool m_value; bool m_value;
bool m_toggleMode;
public: public:
virtual void OnRegenerateDisplay(void); virtual void OnRegenerateDisplay(void);
public: public: